X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXProt.pm;h=2bfb9e5e61fa7ac44a7ae669fd18b21f230c78ff;hb=8178d787d7cc8040fa8958197582bba5c80e6f59;hp=e07e3ba04f179a13e7431ceb799cc5a4a556de4c;hpb=6462efdcfd799f0b0c032565f19eea085ca0dba9;p=spider.git diff --git a/perl/DXProt.pm b/perl/DXProt.pm index e07e3ba0..2bfb9e5e 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 # @@ -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 @@ -1032,7 +1078,7 @@ sub normal # add this station to the user database, if required my $user = DXUser->get_current($call); - $user = DXUser->new($call) if !$user; + $user = DXUser->new($call) unless $user; if ($field[2] == 1) { $user->name($field[3]); @@ -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; @@ -1453,24 +1498,27 @@ sub send_announce # obtain country codes etc my ($ann_dxcc, $ann_itu, $ann_cq, $org_dxcc, $org_itu, $org_cq) = (0..0); + my ($ann_state, $org_state) = ("", ""); my @dxcc = Prefix::extract($_[0]); if (@dxcc > 0) { $ann_dxcc = $dxcc[1]->dxcc; $ann_itu = $dxcc[1]->itu; $ann_cq = $dxcc[1]->cq; + $ann_state = $dxcc[1]->state; } @dxcc = Prefix::extract($_[4]); if (@dxcc > 0) { $org_dxcc = $dxcc[1]->dxcc; $org_itu = $dxcc[1]->itu; $org_cq = $dxcc[1]->cq; + $org_state = $dxcc[1]->state; } if ($self->{inannfilter}) { my ($filter, $hops) = $self->{inannfilter}->it(@_, $self->{call}, $ann_dxcc, $ann_itu, $ann_cq, - $org_dxcc, $org_itu, $org_cq); + $org_dxcc, $org_itu, $org_cq, $ann_state, $org_state); unless ($filter) { dbg("PCPROT: Rejected by input announce filter") if isdbg('chanerr'); return; @@ -1539,6 +1587,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 @@ -1829,7 +1878,7 @@ sub send_route if (!$self->{isolate} && $self->{routefilter}) { $filter = undef; if ($r) { - ($filter, $hops) = $self->{routefilter}->it($self->{call}, $self->{dxcc}, $self->{itu}, $self->{cq}, $r->call, $r->dxcc, $r->itu, $r->cq); + ($filter, $hops) = $self->{routefilter}->it($self->{call}, $self->{dxcc}, $self->{itu}, $self->{cq}, $r->call, $r->dxcc, $r->itu, $r->cq, $self->{state}, $r->{state}); if ($filter) { push @rin, $r; } else { @@ -1868,6 +1917,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 +1966,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; @@ -1922,7 +1979,7 @@ sub in_filter_route my ($filter, $hops) = (1, 1); if ($self->{inroutefilter}) { - ($filter, $hops) = $self->{inroutefilter}->it($self->{call}, $self->{dxcc}, $self->{itu}, $self->{cq}, $r->call, $r->dxcc, $r->itu, $r->cq); + ($filter, $hops) = $self->{inroutefilter}->it($self->{call}, $self->{dxcc}, $self->{itu}, $self->{cq}, $r->call, $r->dxcc, $r->itu, $r->cq, $self->state, $r->state); dbg("PCPROT: $self->{call}/" . $r->call . ' rejected by in_filter_route') if !$filter && isdbg('chanerr'); } return $filter;