X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXProtHandle.pm;h=a6668a36db0daeef1752d86b796d4dcaf7d82e18;hb=61a666ccf108505f0cec2e5c682fde019fc3a051;hp=6f4fbd08d92c3bca3513e7189111ede1aa982e8d;hpb=7e3729a9039462c460dae4804f40c0bd506f3423;p=spider.git diff --git a/perl/DXProtHandle.pm b/perl/DXProtHandle.pm index 6f4fbd08..a6668a36 100644 --- a/perl/DXProtHandle.pm +++ b/perl/DXProtHandle.pm @@ -93,7 +93,9 @@ sub handle_10 if ($censorpc) { my @bad; if (@bad = BadWords::check($pc->[3])) { - dbg("PCPROT: Bad words: @bad, dropped") if isdbg('chanerr'); + my $bw = join ', ', @bad; + dbg($line) if isdbg('nologchan'); + dbg("PCPROT: Badwords: '$bw', dropped"); return; } } @@ -110,7 +112,8 @@ sub handle_10 # if this is a 'nodx' node then ignore it if ($badnode->in($pc->[6]) || ($via && $badnode->in($via))) { - dbg("PCPROT: Bad Node, dropped") if isdbg('chanerr'); + dbg($line) if isdbg('nologchan'); + dbg("PCPROT: Bad Node, dropped"); return; } @@ -118,7 +121,8 @@ sub handle_10 my $nossid = $from; $nossid =~ s/-\d+$//; if ($badspotter->in($nossid)) { - dbg("PCPROT: Bad Spotter, dropped") if isdbg('chanerr'); + dbg($line) if isdbg('nologchan'); + dbg("PCPROT: Bad Spotter, dropped"); return; } @@ -163,18 +167,21 @@ sub handle_11 # is the spotted callsign blank? This should really be trapped earlier but it # could break other protocol sentences. Also check for lower case characters. if ($pc->[2] =~ /^\s*$/) { - dbg("PCPROT: blank callsign, dropped") if isdbg('chanerr'); + dbg($line) if isdbg('nologchan'); + dbg("PCPROT: blank callsign, dropped"); return; } if ($pc->[2] =~ /[a-z]/) { - dbg("PCPROT: lowercase characters, dropped") if isdbg('chanerr'); + dbg($line) if isdbg('nologchan'); + dbg("PCPROT: lowercase characters, dropped"); return; } # if this is a 'nodx' node then ignore it if ($badnode->in($pc->[7])) { - dbg("PCPROT: Bad Node $pc->[7], dropped") if isdbg('chanerr'); + dbg($line) if isdbg('nologchan'); + dbg("PCPROT: Bad Node $pc->[7], dropped"); return; } @@ -182,7 +189,8 @@ sub handle_11 my $nossid = $pc->[6]; $nossid =~ s/-\d+$//; if ($badspotter->in($nossid)) { - dbg("PCPROT: Bad Spotter $pc->[6], dropped") if isdbg('chanerr'); + dbg($line) if isdbg('nologchan'); + dbg("PCPROT: Bad Spotter $pc->[6], dropped"); return; } @@ -200,13 +208,15 @@ sub handle_11 my $d = cltounix($pc->[3], $pc->[4]); # bang out (and don't pass on) if date is invalid or the spot is too old (or too young) if (!$d || (($pcno == 11 || $pcno == 61) && ($d < $main::systime - $pc11_max_age || $d > $main::systime + 900))) { - dbg("PCPROT: Spot ignored, invalid date or out of range ($pc->[3] $pc->[4])\n") if isdbg('chanerr'); + dbg("PCPROT: Spot ignored, invalid date or out of range ($pc->[3] $pc->[4])\n"); return; } # is it 'baddx' - if ($baddx->in($pc->[2]) || BadWords::check($pc->[2])) { - dbg("PCPROT: Bad DX spot, ignored") if isdbg('chanerr'); + if ($baddx->in($pc->[2]) || (my @bad = BadWords::check($pc->[2]))) { + my $bw = join ', ', @bad; + $bw = qq{ '$bw'} if $bw; + dbg("PCPROT: Bad DX spot$bw, ignored"); return; } @@ -220,7 +230,9 @@ sub handle_11 if ($censorpc) { my @bad; if (@bad = BadWords::check($pc->[5])) { - dbg("PCPROT: Bad words: @bad, dropped") if isdbg('chanerr'); + my $bw = join ', ', @bad; + dbg($line) if isdbg('nologchan'); + dbg("PCPROT: Badwords: '$bw', dropped"); return; } } @@ -439,14 +451,17 @@ sub handle_12 if ($censorpc) { my @bad; if (@bad = BadWords::check($pc->[3])) { - dbg("PCPROT: Bad words: @bad, dropped") if isdbg('chanerr'); + my $bw = join ', ', @bad; + dbg($line) if isdbg('nologchan'); + dbg("PCPROT: Badwords: '$bw', dropped"); return; } } # if this is a 'nodx' node then ignore it if ($badnode->in($pc->[5])) { - dbg("PCPROT: Bad Node, dropped") if isdbg('chanerr'); + dbg($line) if isdbg('nologchan'); + dbg("PCPROT: Bad Node, dropped"); return; } @@ -454,7 +469,8 @@ sub handle_12 my $nossid = $pc->[1]; $nossid =~ s/-\d+$//; if ($badspotter->in($nossid)) { - dbg("PCPROT: Bad Spotter, dropped") if isdbg('chanerr'); + dbg($line) if isdbg('nologchan'); + dbg("PCPROT: Bad Spotter, dropped"); return; } @@ -1571,19 +1587,23 @@ sub _decode_pc92_call my $version = $part[1] || 0; my $build = $part[2] || 0; my $ip = $part[3] || ''; - - if (is_ipaddr($version)) { + + # remember that, at this stage, IPV6 addresses have : replaced by , + if (length $version > 4 && $version =~ /[,\.][\da-f]{1,4}/i) { $ip = $version; $version = 0; } $version =~ s/\D//g; + $version = 0 unless $version && $version =~ /^[0-9]+$/; $build =~ s/^0\.//; $build =~ s/\D//g; + $build = 0 unless $build && $build =~ /^[0-9]+$/; if ($ip) { $ip =~ s/,/:/g; $ip =~ s/^::ffff://i; + $ip = '' unless is_ipaddr($ip); } - dbg("$icall = '" . join("', '", $call, $is_node, $is_extnode, $here, $version, $build, $ip) . "'") if isdbg('pc92'); + dbg("'$icall' = '" . join("', '", $call, $is_node, $is_extnode, $here, $version, $build, $ip) . "'") if isdbg('pc92'); return ($call, $is_node, $is_extnode, $here, $version+0, $build+0, $ip); } @@ -1665,9 +1685,9 @@ sub _add_thingy $user->sort('S'); dbg("PCProt::_add_thingy node $call v: $version b: $build sort ($old) updated to " . $user->sort); } elsif ($user->is_spider && ($version < 3000 || ($version > 4000 && $version < 5455))) { - unless ($version == 5000 && $build == 0) { + unless ($version > 0 && $build == 0) { $user->sort('A'); - $build //= 0; + $build ||= 0; dbg("PCProt::_add_thingy node $call v: $version b: $build sort ($old) downgraded to " . $user->sort); } } @@ -2253,7 +2273,9 @@ sub handle_93 if ($censorpc) { my @bad; if (@bad = BadWords::check($text)) { - dbg("PCPROT: Bad words: @bad, dropped") if isdbg('chanerr'); + my $bw = join ', ', @bad; + dbg($line) if isdbg('nologchan'); + dbg("PCPROT: Badwords: '$bw', dropped"); return; } } @@ -2262,7 +2284,8 @@ sub handle_93 my $nossid = $from; $nossid =~ s/-\d+$//; if ($badspotter->in($nossid)) { - dbg("PCPROT: Bad Spotter, dropped") if isdbg('chanerr'); + dbg($line) if isdbg('nologchan'); + dbg("PCPROT: Bad Spotter, dropped"); return; }