9 my $gi = Geo::IP->open("GeoLiteCity.dat", GEOIP_STANDARD);
11 my $server = IO::Socket::INET->new(
16 or die "can't setup server";
18 my $num_of_client = -1;
23 $client = $server->accept;
24 } until ( defined($client) );
25 my $peerhost = $client->peerhost();
26 print "Accepted a client $client, $peerhost, id = ", ++$num_of_client, "\n";
27 $client->autoflush(1);
28 open (SYSLOG, "/tmp/perl.pipe");
30 my @messages = split(",", $_);
32 my $host = substr($messages[0],1);
33 my $facility = substr($messages[1],1);
34 my $priority = substr($messages[2],1);
35 my $level = substr($messages[3],1);
36 my $tag = substr($messages[4],1);
37 my $YMD = substr($messages[5],1);
38 my $HMS = substr($messages[6],1);
39 my $program = substr($messages[7],1);
40 my $msg = substr($messages[8],1);
41 if($msg =~/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/ ){
43 if (unpack('N',inet_aton($ip)) > 0) {
44 my $record = $gi->record_by_addr($ip);
46 print "Sending $ip ".$record->latitude.":".$record->longitude."\n";
47 print $client $record->latitude.":".$record->longitude."\n";
50 print "$msg $ip Hrrm no country for old men.\n";
53 print "No ip in $msg";