allow debug to track cluster config
[spider.git] / perl / DXProtHandle.pm
index 8d766732777e31a90dc5c74f735ea3ca5136ae75..14e7766de48c8a675330d4c75007434b517eede3 100644 (file)
@@ -171,13 +171,13 @@ sub handle_11
        # convert the date to a unix date
        my $d = cltounix($_[3], $_[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 && ($d < $main::systime - $pc11_max_age || $d > $main::systime + 900))) {
+       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 ($_[3] $_[4])\n") if isdbg('chanerr');
                return;
        }
 
        # is it 'baddx'
-       if ($baddx->in($_[2]) || BadWords::check($_[2]) || $_[2] =~ /COCK/) {
+       if ($baddx->in($_[2]) || BadWords::check($_[2])) {
                dbg("PCPROT: Bad DX spot, ignored") if isdbg('chanerr');
                return;
        }
@@ -197,7 +197,7 @@ sub handle_11
                }
        }
 
-       my @spot = Spot::prepare($_[1], $_[2], $d, $_[5], $nossid, $_[7]);
+       my @spot = Spot::prepare($_[1], $_[2], $d, $_[5], $nossid, $_[7], $_[8]);
        # global spot filtering on INPUT
        if ($self->{inspotsfilter}) {
                my ($filter, $hops) = $self->{inspotsfilter}->it(@spot);
@@ -321,6 +321,12 @@ sub handle_12
                return;
        }
 
+       # ignore PC12s from origins that use PCxx protocol
+       my $oref = Route::get($origin);
+       if ($oref->do_pc9x) {
+               dbg("PCPROT: PC12 rxed from PC9x node, ignored") if isdbg('chanerr');
+               return;
+       }
 
        my $dxchan;
 
@@ -1353,7 +1359,10 @@ sub _decode_pc92_call
        my $is_node = $flag & 4;
        my $is_extnode = $flag & 2;
        my $here = $flag & 1;
-       return ($call, $is_node, $is_extnode, $here, $part[1], $part[2]);
+       my $ip  = $part[3];
+       $ip ||= $part[1] if $part[1] && ($part[1] =~ /^(?:\d+\.)+/ || $part[1] =~ /^(?:(?:[abcdef\d]+)?,)+/);
+       $ip =~ s/,/:/g if $ip;
+       return ($call, $is_node, $is_extnode, $here, $part[1], $part[2], $ip);
 }
 
 # decode a pc92 call: flag call : version : build
@@ -1364,7 +1373,7 @@ sub _encode_pc92_call
        # plain call or value
        return $ref unless ref $ref;
 
-       my $ext = shift;
+       my $ext = shift || 0;
        my $flag = 0;
        my $call = $ref->call;
        my $extra = '';
@@ -1373,14 +1382,17 @@ sub _encode_pc92_call
                $flag |= 4;
                my $dxchan = DXChannel::get($call);
                $flag |= 2 if $call ne $main::mycall && $dxchan && !$dxchan->{do_pc9x};
-               if ($ext) {
-                       if ($ref->version) {
-                               my $version = $ref->version || 1.0;
-                               $version =  $version * 100 + 5300 if $version < 50;
-                               $extra .= ":" . $version;
-                       }
+               if (($ext & 1) && $ref->version) {
+                       my $version = $ref->version || 1.0;
+                       $version =  $version * 100 + 5300 if $version < 50;
+                       $extra .= ":" . $version;
                }
        }
+       if (($ext & 2) && $ref->ip) {
+               my $ip = $ref->ip;
+               $ip =~ s/:/,/g;
+               $extra .= ':' . $ip;
+       }
        return "$flag$call$extra";
 }
 
@@ -1394,19 +1406,29 @@ sub _add_thingy
        my $dxchan = shift;
        my $hops = shift;
 
-       my ($call, $is_node, $is_extnode, $here, $version, $build) = @$s;
+       my ($call, $is_node, $is_extnode, $here, $version, $build, $ip) = @$s;
        my @rout;
 
        if ($call) {
+               my $ncall = $parent->call;
                if ($is_node) {
-                       dbg("ROUTE: added node $call to " . $parent->call) if isdbg('routelow');
-                       @rout = $parent->add($call, $version, Route::here($here));
+                       dbg("ROUTE: added node $call to $ncall") if isdbg('routelow');
+                       @rout = $parent->add($call, $version, Route::here($here), $ip);
                        my $r = Route::Node::get($call);
                        $r->PC92C_dxchan($dxchan->call, $hops) if $r;
+                       if ($ip) {
+                               $r->ip($ip);
+                               Log('DXProt', "PC92A $call -> $ip on $ncall");
+                       }
                } else {
-                       dbg("ROUTE: added user $call to " . $parent->call) if isdbg('routelow');
-                       @rout = $parent->add_user($call, Route::here($here));
-                       $dxchan->tell_buddies('loginb', $call, $parent->call) if $dxchan;
+                       dbg("ROUTE: added user $call to $ncall") if isdbg('routelow');
+                       @rout = $parent->add_user($call, Route::here($here), $ip);
+                       $dxchan->tell_buddies('loginb', $call, $ncall) if $dxchan;
+                       my $r = Route::User::get($call);
+                       if ($ip) {
+                               $r->ip($ip);
+                               Log('DXProt', "PC92A $call -> $ip on $ncall");
+                       }
                }
                if ($pc92_slug_changes && $parent == $main::routeroot) {
                        $things_add{$call} = Route::get($call);
@@ -1971,8 +1993,8 @@ sub handle_93
                $self->send_announce(1, pc12($from, $text, $local, $sysop, $wx, $pcall), $from, $local, $text, $sysop, $pcall, $wx, $via eq 'LOCAL' ? $via : undef);
                return if $via eq 'LOCAL';
        } elsif (!is_callsign($to) && $text =~ /^#\d+ /) {
-               # chat messages to non-pc9x nodes
-               $self->send_chat(1, pc12($from, $text, undef, $to, undef, $pcall), $from, '*', $text, $to, $pcall, '0');
+               # chat messages really only locally connected users
+               $self->send_chat(1, $line, $from, '*', $text, $to, $pcall, '0');
        }
 
        # broadcast this chat sentence everywhere unless it is targetted to 'LOCAL'