X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXProt.pm;h=2168c7fc3cb5404842f01808abee2acc6b39b22d;hb=dbf7523a9b228dbdf1d03109afde351b8b194fab;hp=fc55f42d6ef869448373e2272eaadcbce2ef553d;hpb=9a61ef555083e7288a41de95d3709454c0a20625;p=spider.git diff --git a/perl/DXProt.pm b/perl/DXProt.pm index fc55f42d..2168c7fc 100644 --- a/perl/DXProt.pm +++ b/perl/DXProt.pm @@ -38,7 +38,7 @@ use strict; use vars qw($VERSION $BRANCH); $VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ ); -$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ ) || 0; +$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ || (0,0)); $main::build += $VERSION; $main::branch += $BRANCH; @@ -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 # @@ -739,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; @@ -1168,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 } } @@ -1238,24 +1249,6 @@ sub normal return; } if ($pcno == 90) { # new style PC16,17,19,21 - my $node = $field[1]; - - # mark this node as wanting PC90s - my $parent = Route::Node::get($node); - if ($parent) { - my $t = hex $field[2]; - my $last = $parent->lastpc90 || 0; - if ($last < $t) { - $parent->pc90(1); - $parent->lastpc90($t); - my ($updsort, $n) = unpack "AA*", $field[3]; - for (my $i = 4; $i < $#field; $i++) { - my ($sort, $flag, $node, $ping) = $field[$i] =~ m{(\w)(\d)([-\w+])(,\d+)?}; - $ping /= 10 if (defined $ping); - } - } - } - return; } } @@ -1300,11 +1293,7 @@ sub process next if $dxchan == $main::me; # send the pc50 or PC90 - if ($pc50s && $dxchan->user->wantpc90) { - $dxchan->send_route(\&pc90, 1, $main::me, 'T', @dxchan); - } else { - $dxchan->send($pc50s) if $pc50s; - } + $dxchan->send($pc50s) if $pc50s; # send a ping out on this channel if ($dxchan->{pingint} && $t >= $dxchan->{pingint} + $dxchan->{lastping}) { @@ -1585,7 +1574,7 @@ sub send_local_config # and are not themselves isolated, this to make sure that isolated nodes # don't appear outside of this node my @dxchan = grep { $_->call ne $main::mycall && $_ != $self && !$_->{isolate} } DXChannel::get_all_nodes(); - @localnodes = map { my $r = Route::Node::get($_->{call}); $r ? $r : () } @dxchan if @dxchan && !$self->user->wantpc90; + @localnodes = map { my $r = Route::Node::get($_->{call}); $r ? $r : () } @dxchan if @dxchan; my @intcalls = map { $_->nodes } @localnodes if @localnodes; my $ref = Route::Node::get($self->{call}); my @rnodes = $ref->nodes; @@ -1606,7 +1595,6 @@ sub send_local_config dbg("sent a null value") if isdbg('chanerr'); } } - $self->send_route(\&pc90, 1, $main::me, 'T', DXChannel::get_all()) if $self->user->wantpc90; } # @@ -1926,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, @_); } }