procmail
[Top] [All Lists]

Re: How to match IP's

2001-09-08 13:49:10
Martin tackled the problem:

|  # the range of IP addresses that we want to check for
|  # in this case 61.134.3.0 - 61.134.20.95
|  rangemin=`echo $(( 61*$m1 + 134*$m2 + 3*$m3 + 0 ))`
|  rangemax=`echo $(( 61*$m1 + 134*$m2 + 20*$m3 + 95 ))`

Just be sure that asterisk is still in $SHELLMETAS (or put a trailing
semicolon inside the second backtick).

|  # note that really you would say
|  # rangemin=1032192768
|  # rangemax=1032197215
|  # to avoid having to do those calculations for every mail

And therein lies the problem.  If the first octet of the higher range
boundary or of the IP to be tested is 128 or greater, procmail's scoring
can't handle the expanded value.

| Personally I'd just pass it all out to Perl to do the range check.

Maybe the best thing is to pass all four octets to a program that can handle
arithmetic up to 2^32 (possibly perl), then, rather than trying the
expansion within procmail.

Alternatively, we could test the octets one at a time: it can get
complicated, though, when the range's endpoints are in the middles of octet
ranges.



_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>