From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 22604 invoked from network); 29 Mar 2021 19:51:01 -0000 Received: from minnie.tuhs.org (45.79.103.53) by inbox.vuxu.org with ESMTPUTF8; 29 Mar 2021 19:51:01 -0000 Received: by minnie.tuhs.org (Postfix, from userid 112) id 6AAF79C892; Tue, 30 Mar 2021 05:50:58 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id DC5B49C82B; Tue, 30 Mar 2021 05:50:29 +1000 (AEST) Authentication-Results: minnie.tuhs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="VWJlr9Nw"; dkim-atps=neutral Received: by minnie.tuhs.org (Postfix, from userid 112) id E83F69C82B; Tue, 30 Mar 2021 05:50:24 +1000 (AEST) Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) by minnie.tuhs.org (Postfix) with ESMTPS id 882559C829 for ; Tue, 30 Mar 2021 05:50:23 +1000 (AEST) Received: by mail-lj1-f169.google.com with SMTP id u10so17290148lju.7 for ; Mon, 29 Mar 2021 12:50:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rnz/RujMMrFFr9rpm/CWB9toe58+zwPV4J8ao1l0Nzs=; b=VWJlr9NwWxOb4ysrEbqxttNmm96qb+4KkppOPm/hJ5O8gdyd1J1+8Q5TUpTOVcVe3t XX1CSL8XQZd0SztUZb4qmF057rXZVS/0m8xGIjh4NWjL83acuuPaJFb7YkdesIrHpc3q 3GegsC/h+SIpbnTzA25iTiC6g0ldIzA3AnuZpeYX7lODJwICYrx/uK9t3XGnxE//FAIc vIAyjluVCMRBBeX9RFsMgt55GRlZ3OHbJ2zJ2Igb7zdkT9uugA39cugeACiIxY+8n0/y DAi82lHovbDRn4H5OfWcnI1lE44CYTO+aD8LXwX0odnsqyGjOdb7o/rjruR4yn8lMzCG d2rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rnz/RujMMrFFr9rpm/CWB9toe58+zwPV4J8ao1l0Nzs=; b=sOIUdwBewo7YAyeQ0UqPfC8lJMIsRRDwxfkGTbGxSiCQcUn3w0BKfEtLpXZkJnRpX0 b3OqABcXfoHhwI6PzSCEJyhWSR+t8vgS3OU3cs/u8Gl8wHcZNK/KNKqYynvkIjnZGA1m 3wvEeXkxSpCcLdPBhvWT9pqFy0i87AZ3YK3pB4WNstZok2E7Q8/TZ69nD5SiB9u2XhgG 9rvic7S7AllfdSAFWzc1lAUXwnxEwjZBnnA57Yg422b/EB1/qYgaHix7VwYOVpnZDKgf BRT/pFtQasvP1/EReNP5sR802YiLHkv8jxkkpkli0nE3wlxkRrSUM7DNRjbjcUi6GBby krEg== X-Gm-Message-State: AOAM531/iQqpcp75KTDPqyEeSvkK9kI2NDfRxulvYSzgLiQmEQPXQvLF uM0ooRHciUH0jcuuzAUVJT1s3Gqd7WmsxNKbIjiiJshL X-Google-Smtp-Source: ABdhPJxu7sojKxYZSIpGA5gZXSqRf0kjl/3ONxT6sUDyfv8IQBkAu7/O4vppTmV4Gm5ptuYJO8L7NBSCaPN7yhHB0ck= X-Received: by 2002:a2e:b537:: with SMTP id z23mr18517488ljm.350.1617047421704; Mon, 29 Mar 2021 12:50:21 -0700 (PDT) MIME-Version: 1.0 References: <20210329143449.GA28080@mcvoy.com> In-Reply-To: <20210329143449.GA28080@mcvoy.com> From: Rob Pike Date: Tue, 30 Mar 2021 06:50:10 +1100 Message-ID: To: Larry McVoy Content-Type: multipart/alternative; boundary="00000000000027de0705beb23144" Subject: Re: [TUHS] Remember the ed thread? X-BeenThere: tuhs@minnie.tuhs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: The Unix Heritage Society mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: TUHS main list Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" --00000000000027de0705beb23144 Content-Type: text/plain; charset="UTF-8" Ed is the standard editor. -rob On Tue, Mar 30, 2021 at 1:36 AM Larry McVoy wrote: > I had *.clients.your-server.de crawling mcvoy.com in violation of my > robots.txt. For whatever reason, the tty settings (or something) > made vi not work, I dunno what the deal is, stty -tabs didn't help. > > So I had to resort to ed to write and debug the little program below. > It was surprisingly pleasant, it's probably the first time I've used ed > for anything real in at least a decade. My fingers still know it. > > +1 for ed. It's how many decades old and still useful? > > > #!/usr/libexec/bitkeeper/bk tclsh > > int > main(void) > { > FILE log = popen("/var/log/apache2/dns.l", "r"); > string buf, ip; > string dropped{string}; > > fconfigure(log, buffering: "line"); > while (buf = ) { > unless (buf =~ /([^ ]+\.your-server\.de\.) /) continue; > ip = $1; > if (defined(dropped{ip})) continue; > dropped{ip} = "yes"; > warn("DROP ${ip}\n"); > system("/sbin/iptables -I INPUT -s ${ip} -j DROP"); > } > } > --00000000000027de0705beb23144 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Ed is the standard editor.

-rob


On Tue, Mar 30, 2021 at 1:36 AM Larry McVoy <lm@mcvoy.com> wrote:
I had *.clients.your-server.de crawli= ng mcvoy.= com in violation of my
robots.txt.=C2=A0 For whatever reason, the tty settings (or something)
made vi not work, I dunno what the deal is, stty -tabs didn't help.

So I had to resort to ed to write and debug the little program below.
It was surprisingly pleasant, it's probably the first time I've use= d ed
for anything real in at least a decade.=C2=A0 My fingers still know it.

+1 for ed.=C2=A0 It's how many decades old and still useful?


#!/usr/libexec/bitkeeper/bk tclsh

int
main(void)
{
=C2=A0 =C2=A0 =C2=A0 =C2=A0 FILE=C2=A0 =C2=A0 log =3D popen("/var/log/= apache2/dns.l", "r");
=C2=A0 =C2=A0 =C2=A0 =C2=A0 string=C2=A0 buf, ip;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 string=C2=A0 dropped{string};

=C2=A0 =C2=A0 =C2=A0 =C2=A0 fconfigure(log, buffering: "line"); =C2=A0 =C2=A0 =C2=A0 =C2=A0 while (buf =3D <log>) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 unless (buf =3D~ /(= [^ ]+\.your-server\.de\.) /) continue;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ip =3D $1;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (defined(dropped= {ip})) continue;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 dropped{ip} =3D &qu= ot;yes";
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 warn("DROP ${i= p}\n");
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 system("/sbin/= iptables -I INPUT -s ${ip} -j DROP");
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
}
--00000000000027de0705beb23144--