I like to watch my Freenet logs from time to time to make sure they are working properly. I also like to go find those IP addresses that keep showing up as being unmatched. The following perl script works in most Unix-based operating systems. I run it in the same directory as Freenet. It will log unmatched IP addresses it finds to a database and will filter out the "Unmatchable packet" messages.
I would recommend setting your "Minimum priority to log messages at" in your configuration page to "ERROR" or you'll get a lot of debugging log entries.
#!/usr/bin/env perl
use strict;
use DB_File;
open(LOGS,
"tail -F logs/freenet-latest.log|")
or die "Couldn't open logs: $!\n";
my %h;
tie(%h,
"DB_File",
"unmatched_ips")
or die "Could not open file: $!\n";
my $done =
0;
local $SIG{INT
} =
sub { $done =
1;
};
while(<LOGS>)
{
if (/Unmatchable packet from
(\d+\.\d+\.\d+\.\d+
)/
)
{
if ( !
exists $h{$
1} )
{
print "Unmatched IP: $1\n";
$h{$
1} =
1;
}
}
else
{
print;
}
last if ( $done );
}
close(LOGS
);
untie %h;
print "Exited cleanly\n";
I use the following script to output the list of unmatched IP addresses. Sometimes I'll search for the IP addresses in Frost and get lucky and find the ref so I can complete the connection. Something else this might be useful for is to generate firewall rules so these packets get blocked before they reach your host.
#!/usr/bin/env perl
use strict;
use DB_File;
my %h;
tie(%h,
"DB_File",
"unmatched_ips")
or die "Could not open unmatched_ips: $!\n";
for my $ip ( keys %h )
{
print "$ip\n";
}
untie %h;