attempt to fix myalias/mycall external usurpation
[spider.git] / perl / DXProtHandle.pm
index 600bfd8f61db19163be7fdae8cb3da3de426d5fc..73f139193a4279febaba885c4ba5d7965fe90d00 100644 (file)
@@ -49,7 +49,7 @@ use vars qw($pc11_max_age $pc23_max_age $last_pc50 $eph_restime $eph_info_restim
                        $eph_pc15_restime $pc9x_past_age $pc9x_dupe_age
                        $pc10_dupe_age $pc92_slug_changes $last_pc92_slug
                        $pc92Ain $pc92Cin $pc92Din $pc92Kin $pc9x_time_tolerance
-                       $pc92filterdef $senderverify $pc11_dwell_time $pc11_extract_route $pc92_ad_enabled $pc92c_ipaddr_enable
+                       $pc92filterdef $senderverify $pc11_dwell_time $pc11_extract_route $pc92_ad_enabled $pc92c_ipaddr_enabled
                   );
 
 $pc9x_dupe_age = 60;                   # catch loops of circular (usually) D records
@@ -863,9 +863,11 @@ sub handle_18
        $self->state('init');
 
        my $parent = Route::Node::get($self->{call});
-       
+
+       my ($software, $version, $build) = (undef, 0, 0);
+        
        # record the type and version offered
-       if (my ($software, $version) = $pc->[1] =~ /(DXSpider|CC\s*Cluster)\s+Version: (\d+(?:\.\d+)?)/i) {
+       if (($software, $version) = $pc->[1] =~ /(DXSpider|CC\s*Cluster)\s+Version: (\d+(?:\.\d+)?)/i) {
                $version += 0;
                $version += 53 if $version < 6;
                $self->{version} = $version;
@@ -885,7 +887,7 @@ sub handle_18
                        $self->sort('S');
                }
 #              $self->{handle_xml}++ if DXXml::available() && $pc->[1] =~ /\bxml/;
-       } elsif (my ($software, $version, $build) = $pc->[1] =~ /(AR-Cluster)\s+Version:\s+(\d+\.\d+).?(\d+\.\d+)?/) {
+       } elsif (($software, $version, $build) = $pc->[1] =~ /(AR-Cluster)\s+Version:\s+(\d+\.\d+).?(\d+\.\d+)?/) {
                dbg("$self->{call} = $software version $version build $build");
                $self->{version} = $version;
                $self->user->version($version);
@@ -943,7 +945,7 @@ sub check_add_user
                        $user->node($homenode);
                        $user->priv(0);
                }
-               $user->lastin($main::systime); # this make it last longer than just this invocation
+               $user->lastin($main::systime); # this makes it last longer than just this invocation
                $user->put;                             # just to make sure it gets written away!!!
                dbg("DXProt: PC92 new user record for $call created");
        }
@@ -1030,6 +1032,12 @@ sub handle_19
                        next;
                }
 
+               if ($call eq $main::myalias) {
+                       LogDbg('err', "ROUTE: $call eq \$myalias from $self->{call}, ignored!!!");
+                       dbgprintring(3) if isdbg('nologchan');
+                       next;
+               }
+               
                my $user = check_add_user($call, 'A');
 
 #              if (eph_dup($genline)) {
@@ -1805,7 +1813,12 @@ sub _add_thingy
                                $user->del if $user;
                            $call = $normcall; # this is safe because a route add will ignore duplicates
                        }
-                       
+
+                       if ($call eq $main::myalias && $is_node) {
+                               LogDbg('err', "ROUTE: $call eq \$myalias from $ncall - downgraded to user!!!");
+                               dbgprintring(3) if isdbg('nologchan');
+                               $is_node = 0;
+                       }
                        if ($is_node) {
                                dbg("ROUTE: added node $call to $ncall") if isdbg('routelow');
                                $user = check_add_user($call, 'A');
@@ -2247,7 +2260,9 @@ sub handle_92
                                dbg("PCPROT: $self->{call} : type $sort $_->[0] refers to me, ignored") if isdbg('route');
                                next;
                        }
-                       if ($_->[0] eq $main::myalias && $_->[1] || $_->[0] eq $main::mycall && $_->[1] == 0) {
+
+                       my $isnode = ($_->[1] | $_->[2]);
+                       if (($_->[0] eq $main::myalias && $isnode) || ($_->[0] eq $main::mycall && !$isnode)) {
                                LogDbg('err',"PCPROT: $self->{call} : type $sort $_->[0] trying to change type to " . $_->[1]?"Node":"User" . ", ignored");
                                next;
                        }
@@ -2321,8 +2336,11 @@ sub handle_92
                $self->route_pc16($pcall, undef, $parent, @pc16) if @pc16;
        }
 
-       # broadcast it if we get here
-       $self->broadcast_route_pc9x($pcall, undef, $line, 0) unless !$pc92_ad_enabled && ($sort eq 'A' || $sort eq 'D');
+       # broadcast it if we get here (but not if it's an A or D record and pc92_ad_enabled isn't set;
+       if ($sort eq 'A' || $sort eq 'D') {
+               return unless $pc92_ad_enabled;
+       }
+       $self->broadcast_route_pc9x($pcall, undef, $line, 0);
 }
 
 # get all the routes for a thing, bearing in mind that the thing (e.g. a user)
@@ -2390,8 +2408,10 @@ sub handle_93
        my $text = $pc->[6];
        my $onode = uc $pc->[7];
        my $ipaddr = $pc->[8];
-       
+
+       $onode = undef unless $onode && is_callsign($onode);
        $onode //= $pcall;
+       $ipaddr = undef unless $ipaddr && is_ipaddr($ipaddr);
 
        # this is catch loops caused by bad software ...
        if (eph_dup("PC93|$from|$text|$onode", $pc10_dupe_age)) {
@@ -2510,10 +2530,11 @@ sub handle_default
        }
 }
 
+# does what it says on the tin..
 sub populate_routing_table
 {
        my ($self, $node, $user, $ip) = @_;
-
+       
        my $rn = Route::Node::get($node);
        unless ($rn) {
                $rn = Route::Node->new($node);