get the basic QX01 handling working in the out direction
[spider.git] / perl / DXProt.pm
index e07e3ba04f179a13e7431ceb799cc5a4a556de4c..0bd23a7ea16e9c80ed95500d092d113e95caec6b 100644 (file)
@@ -185,19 +185,8 @@ sub check
 
 sub init
 {
-       my $user = DXUser->get($main::mycall);
-       $DXProt::myprot_version += $main::version*100;
-       $main::me = DXProt->new($main::mycall, 0, $user); 
-       $main::me->{here} = 1;
-       $main::me->{state} = "indifferent";
        do "$main::data/hop_table.pl" if -e "$main::data/hop_table.pl";
        confess $@ if $@;
-       $main::me->{sort} = 'S';    # S for spider
-       $main::me->{priv} = 9;
-       $main::me->{metric} = 0;
-       $main::me->{pingave} = 0;
-       
-#      $Route::Node::me->adddxchan($main::me);
 }
 
 #
@@ -276,7 +265,7 @@ sub start
 
        # send initialisation string
        unless ($self->{outbound}) {
-               $self->send(pc18());
+               $self->sendinit;
        }
        
        $self->state('init');
@@ -290,6 +279,16 @@ sub start
        $script->run($self) if $script;
 }
 
+#
+# send outgoing 'challenge'
+#
+
+sub sendinit
+{
+       my $self = shift;
+       $self->send(pc18());
+}
+
 #
 # This is the normal pcxx despatcher
 #
@@ -349,6 +348,20 @@ sub normal
                                $to = $field[2];
                        }
 
+                       # if this is a 'nodx' node then ignore it
+                       if ($badnode->in($field[6]) || ($via && $badnode->in($via))) {
+                               dbg("PCPROT: Bad Node, dropped") if isdbg('chanerr');
+                               return;
+                       }
+
+                       # if this is a 'bad spotter' user then ignore it
+                       my $nossid = $from;
+                       $nossid =~ s/-\d+$//;
+                       if ($badspotter->in($nossid)) {
+                               dbg("PCPROT: Bad Spotter, dropped") if isdbg('chanerr');
+                               return;
+                       }
+
                        # if we are converting announces to talk is it a dup?
                        if ($ann_to_talk) {
                                if (AnnTalk::is_talk_candidate($from, $field[3]) && AnnTalk::dup($from, $to, $field[3])) {
@@ -408,7 +421,9 @@ sub normal
                        }
                        
                        # if this is a 'bad spotter' user then ignore it
-                       if ($badspotter->in($field[6])) {
+                       my $nossid = $field[6];
+                       $nossid =~ s/-\d+$//;
+                       if ($badspotter->in($nossid)) {
                                dbg("PCPROT: Bad Spotter, dropped") if isdbg('chanerr');
                                return;
                        }
@@ -549,6 +564,20 @@ sub normal
                                }
                        }
 
+                       # if this is a 'nodx' node then ignore it
+                       if ($badnode->in($field[5])) {
+                               dbg("PCPROT: Bad Node, dropped") if isdbg('chanerr');
+                               return;
+                       }
+
+                       # if this is a 'bad spotter' user then ignore it
+                       my $nossid = $field[1];
+                       $nossid =~ s/-\d+$//;
+                       if ($badspotter->in($nossid)) {
+                               dbg("PCPROT: Bad Spotter, dropped") if isdbg('chanerr');
+                               return;
+                       }
+
                        if ($field[2] eq '*' || $field[2] eq $main::mycall) {
 
 
@@ -709,6 +738,23 @@ sub normal
                if ($pcno == 18) {              # link request
                        $self->state('init');   
 
+                       # record the type and version offered
+                       if ($field[1] =~ /DXSpider Version: (\d+\.\d+) Build: (\d+\.\d+)/) {
+                               $self->version(53 + $1);
+                               $self->user->version(53 + $1);
+                               $self->build(0 + $2);
+                               $self->user->build(0 + $2);
+                               unless ($self->is_spider) {
+                                       $self->user->sort('S');
+                                       $self->user->put;
+                                       $self->sort('S');
+                               }
+                       } else {
+                               $self->version(50.0);
+                               $self->version($field[2] / 100) if $field[2] && $field[2] =~ /^\d+$/;
+                               $self->user->version($self->version);
+                       }
+
                        # first clear out any nodes on this dxchannel
                        my $parent = Route::Node::get($self->{call});
                        my @rout = $parent->del_nodes;
@@ -756,7 +802,7 @@ sub normal
                                my $dxchan = DXChannel->get($call);
                                if ($dxchan && $dxchan != $self) {
                                        dbg("PCPROT: PC19 from $self->{call} trying to alter wrong locally connected $call, ignored!") if isdbg('chanerr');
-                                       return;
+                                       next;
                                }
 
                                # update it if required
@@ -1138,11 +1184,6 @@ sub normal
                                                                        } else {
                                                                                $tochan->{pingave} = $tochan->{pingave} + (($t - $tochan->{pingave}) / 6);
                                                                        }
-#                                                                      my $st;
-#                                                                      for (@{$tochan->{pingtime}}) {
-#                                                                              $st += $_;
-#                                                                      }
-#                                                                      $tochan->{pingave} = $st / @{$tochan->{pingtime}};
                                                                        $tochan->{nopings} = $nopings; # pump up the timer
                                                                }
                                                        } 
@@ -1207,6 +1248,9 @@ sub normal
                        
                        return;
                }
+               if ($pcno == 90) {              # new style PC16,17,19,21
+                       return;
+               }
        }
         
        # if get here then rebroadcast the thing with its Hop count decremented (if
@@ -1248,7 +1292,7 @@ sub process
                next unless $dxchan->is_node();
                next if $dxchan == $main::me;
 
-               # send the pc50
+               # send the pc50 or PC90
                $dxchan->send($pc50s) if $pc50s;
                
                # send a ping out on this channel
@@ -1285,6 +1329,7 @@ sub process
 # some active measures
 #
 
+
 sub send_dx_spot
 {
        my $self = shift;
@@ -1539,6 +1584,7 @@ sub send_local_config
                unshift @localnodes, $main::routeroot;
        }
        
+
        send_route($self, \&pc19, scalar(@localnodes)+scalar(@remotenodes), @localnodes, @remotenodes);
        
        # get all the users connected on the above nodes and send them out
@@ -1868,6 +1914,8 @@ sub broadcast_route
                foreach $dxchan (@dxchan) {
                        next if $dxchan == $self;
                        next if $dxchan == $main::me;
+                       next if $dxchan->user->wantnp;
+                       
                        $dxchan->send_route($generate, @_);
                }
        }
@@ -1915,6 +1963,12 @@ sub route_pc50
        broadcast_route($self, \&pc50, 1, @_);
 }
 
+sub route_pc90
+{
+       my $self = shift;
+       broadcast_route($self, \&pc90, 1, @_);
+}
+
 sub in_filter_route
 {
        my $self = shift;