X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXProt.pm;h=201013a0c1bd034b9e7abcbac159756dd7a8031e;hb=8db1b590ed9b6b260fb4d437c120cccdd08bbb4d;hp=736cab4d41d1a58496cb0b7bfcb305dec26f557d;hpb=b51a81586ebf52195e587daf321eb7053a2de16e;p=spider.git diff --git a/perl/DXProt.pm b/perl/DXProt.pm index 736cab4d..201013a0 100644 --- a/perl/DXProt.pm +++ b/perl/DXProt.pm @@ -254,15 +254,14 @@ sub start $self->{pingint} = $ping; $self->{nopings} = $user->nopings || 2; $self->{pingtime} = [ ]; - $self->{pingave} = 0; + $self->{pingave} = 999; + $self->{lastping} = $main::systime; # send initialisation string unless ($self->{outbound}) { $self->send(pc18()); - $self->{lastping} = $main::systime; - } else { - $self->{lastping} = $main::systime + ($self->pingint / 2); } + $self->state('init'); $self->{pc50_t} = $main::systime; @@ -571,7 +570,15 @@ sub normal $conf = $conf eq '*'; - my $r = Route::User::get($call); + # reject this if we think it is a node already + my $r = Route::Node::get($call); + my $u = DXUser->get_current($call) unless $r; + if ($r || ($u && $u->is_node)) { + dbg("PCPROT: $call is a node") if isdbg('chanerr'); + next; + } + + $r = Route::User::get($call); my $flags = Route::here($here)|Route::conf($conf); if ($r) { @@ -622,17 +629,17 @@ sub normal dbg("PCPROT: PC17 from $self->{call} trying to alter locally connected $ncall, ignored!") if isdbg('chanerr'); return; } - my $parent = Route::Node::get($ncall); - unless ($parent) { - dbg("PCPROT: Route::Node $ncall not in config") if isdbg('chanerr'); - return; - } + my $uref = Route::User::get($ucall); unless ($uref) { dbg("PCPROT: Route::User $ucall not in config") if isdbg('chanerr'); return; } - + my $parent = Route::Node::get($ncall); + unless ($parent) { + dbg("PCPROT: Route::Node $ncall not in config") if isdbg('chanerr'); + return; + } # input filter if required return unless $self->in_filter_route($parent); @@ -753,6 +760,7 @@ sub normal $self->send_local_config(); $self->send(pc22()); $self->state('normal'); + $self->{lastping} = 0; return; } @@ -798,6 +806,7 @@ sub normal if ($pcno == 22) { $self->state('normal'); + $self->{lastping} = 0; return; } @@ -1030,14 +1039,27 @@ sub normal $dxchan->send($dxchan->msg('pingi', $from, $s, $ave)) } elsif ($dxchan->is_node) { if ($tochan) { - $tochan->{nopings} = $tochan->user->nopings || 2; # pump up the timer + my $nopings = $tochan->user->nopings || 2; push @{$tochan->{pingtime}}, $t; shift @{$tochan->{pingtime}} if @{$tochan->{pingtime}} > 6; - my $st; - for (@{$tochan->{pingtime}}) { - $st += $_; + + # cope with a missed ping, this means you must set the pingint large enough + if ($tochan->is_arcluster && $t > $tochan->{pingint} && $t < 2 * $tochan->{pingint} ) { + $t -= $tochan->{pingint}; } - $tochan->{pingave} = $st / @{$tochan->{pingtime}}; + + # calc smoothed RTT a la TCP + if (@{$tochan->{pingtime}} == 1) { + $tochan->{pingave} = $t; + } else { + $tochan->{pingave} = $tochan->{pingave} + (($t - $tochan->{pingave}) / 8); + } +# my $st; +# for (@{$tochan->{pingtime}}) { +# $st += $_; +# } +# $tochan->{pingave} = $st / @{$tochan->{pingtime}}; + $tochan->{nopings} = $nopings; # pump up the timer } } } @@ -1789,7 +1811,7 @@ sub send_route for (; @_ && $no; $no--) { my $r = shift; - if ($self->{routefilter}) { + 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); @@ -1802,7 +1824,7 @@ sub send_route dbg("was sent a null value") if isdbg('chanerr'); } } else { - push @rin, $r; + push @rin, $r unless $self->{isolate} && $r->call ne $main::mycall; } } if (@rin) { @@ -1827,13 +1849,11 @@ sub broadcast_route my $dxchan; my $line; - foreach $dxchan (@dxchan) { - next if $dxchan == $self; - next if $dxchan == $me; - if ($dxchan->{routefilter}) { + unless ($self->{isolate}) { + foreach $dxchan (@dxchan) { + next if $dxchan == $self; + next if $dxchan == $me; $dxchan->send_route($generate, @_); - } else { - $dxchan->send_route($generate, @_) unless $self->{isolate} || $dxchan->{isolate}; } } } @@ -1896,12 +1916,13 @@ sub in_filter_route sub eph_dup { my $s = shift; + my $r; # chop the end off $s =~ s/\^H\d\d?\^?\~?$//; - return 1 if exists $eph{$s}; + $r = 1 if exists $eph{$s}; # pump up the dup if it keeps circulating $eph{$s} = $main::systime; - return undef; + return $r; } sub eph_del_regex @@ -1920,7 +1941,7 @@ sub eph_clean my ($key, $val); while (($key, $val) = each %eph) { - if ($main::systime - $val > 90) { + if ($main::systime - $val > 180) { delete $eph{$key}; } }