Re: PM/IRX filter tools (Perl?)?

David Carmean (dave@west.net)
Sun, 24 Sep 1995 12:40:22 -0700 (PDT)

On Sun, 24 Sep 1995, Hugh Messenger wrote:

> did you ever find any ... ?
>
> -- hugh
>

[Note to portmaster-users: This is *really* basic but a
big timesaver for me, so I thought I'd cc it to the list.]

No, so I started my own. First thing I did was just to
make a script to automatically number filter entries (which I upload
using the pmcommand program) of the form:

set filter s1_wan.out NNN deny tcp 0.0.0.0/0 xxx.xxx.xxx.x/19 log
set filter s1_wan.out NNN deny udp 0.0.0.0/0 xxx.xxx.xxx.x/19 log

It just uses stdin and stdout like such:

pmfilter < un-numbered > numbered

Here it is...

--------8<--------8<--------8<-- CUT HERE --8<--------8<--------8<-------

#!/usr/bin/perl
#

foreach $line (<>)
{
chop ($line);
if (!($line =~ /^set/))
{
print STDOUT "$line\n";
}
else
{
@line = split (/ +/,$line);
$filter = $line[2];
$filters{$filter}++;
$line[3] = $filters{$filter};
foreach $thingin (@line)
{
print STDOUT "$thingin ";
}
print STDOUT "\n";
}
}

--------8<--------8<--------8<-- CUT HERE --8<--------8<--------8<-------

------------------------------------------------------------------------
David Carmean WB6YZM DC574 dave@west.net
WestNet Communications, Inc. (805)892-2133 (805)289-1000
PGP Key Fingerprint: CD 1C C1 15 3E E3 1D 41 ED C2 3E A8 D6 29 BD C4
------------------------------------------------------------------------