On Tuesday November 2 2010 16:40:49 Rob McMahon wrote:
The fix to NetAddr::IP seems to be as simple as
--- NetAddr/IP/Lite.pm.bak Fri Oct 29 00:33:06 2010
+++ NetAddr/IP/Lite.pm Tue Nov 2 15:18:05 2010
@@ -740,7 +740,7 @@
if ($mval == 128) { # cidr 128
$mask = Ones;
}
- elsif ($ip =~ /^\d+\.\d+\.\d+\.\d+$/) { # corner case of ipV4
with new6
+ elsif ($ip =~ /^\d+(\.\d+(\.\d+(\.\d+)?)?)?$/) { # corner
case of ipV4 with new6
$mask = shiftleft(Ones,32 -$mval);
}
elsif ($mask < 128) { # small cidr
Having made that change SpamAssassin runs `make test' cleanly. Before
it failed on four tests in cidrs.t, including
ok !tryone "128.0.0.1", "127/8";
ok !tryone "128.0.0.1", "127.0/16";
ok !tryone "128.0.0.1", "127.0.0/24";
and one in recreate.t (complaining about the "netset: cannot include"
warnings).
Thanks. The bug has been reopened now:
https://rt.cpan.org/Public/Bug/Display.html?id=62521
you may want to attach your solution there.
Philip Prindeville wrote:
You might be able to get better results with: Net-Patricia-1.18
which I released earlier this week.
Thank you for bringing it to our attention. Now that you have added
the AF_INET6 support is became useful. I toyed with it for a while,
looks good and fast (and a bit memory fat compared to NetAddr::IP).
Lookups are more than 16 times faster for a set of 30 networks (our
real setup) using 750.000 real SMTP client's addresses collected from
our mailer log (using AF_INET6 database variant to store both inet
and inet6 addresses) - compared to the current SpamAssassin solution.
It does allow storing data with each network, which we need to
implement includes/excludes. One thing that we need to figure out
is how to test if one network (not a single IP address) is in
the trie - this is needed to check validity of config files,
but is not used later for mail checking, so it need not be
very fast.
One suggestion: currently it is not possible to store 0 and 1
as a data item associated with each net, because a 0 is treated
the same as undef and replaced by the key.
And the AF_NET6 argument to new() needs to be documented in a POD.
Thanks for your efforts!
Mark