X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXProt.pm;h=dae885e4d0c889a5bce92f96fddf69a25bb305a9;hb=c1e8434f73e0b575c3b2d28cd3c257c3b15ffbe6;hp=ba958cfad0418bad5deac0c279c5ea9f5c620527;hpb=98b0984d0ab735a1ae2d96e36728c7e334cf5fd7;p=spider.git diff --git a/perl/DXProt.pm b/perl/DXProt.pm index ba958cfa..dae885e4 100644 --- a/perl/DXProt.pm +++ b/perl/DXProt.pm @@ -33,6 +33,7 @@ use DXHash; use Route; use Route::Node; use Script; +use Investigate; use strict; @@ -44,7 +45,7 @@ $main::branch += $BRANCH; use vars qw($pc11_max_age $pc23_max_age $last_pc50 $eph_restime $eph_info_restime $eph_pc34_restime $last_hour $last10 %eph %pings %rcmds $ann_to_talk - $pingint $obscount %pc19list $chatdupeage + $pingint $obscount %pc19list $chatdupeage $investigation_int %nodehops $baddx $badspotter $badnode $censorpc $rspfcheck $allowzero $decode_dk0wcy $send_opernam @checklist); @@ -71,6 +72,7 @@ $eph_pc34_restime = 30; $pingint = 5*60; $obscount = 2; $chatdupeage = 20 * 60 * 60; +$investigation_int = 7*86400; # time between checks to see if we can see this node @checklist = ( @@ -708,6 +710,9 @@ sub handle_16 # do we believe this call? unless ($ncall eq $self->{call} || $self->is_believed($ncall)) { + if (my $ivp = Investigate::get($ncall, $self->{call})) { + $ivp->store_pcxx($pcno,$line,$origin,@_); + } dbg("PCPROT: We don't believe $ncall on $self->{call}"); return; } @@ -788,6 +793,9 @@ sub handle_17 # do we believe this call? unless ($ncall eq $self->{call} || $self->is_believed($ncall)) { + if (my $ivp = Investigate::get($ncall, $self->{call})) { + $ivp->store_pcxx($pcno,$line,$origin,@_); + } dbg("PCPROT: We don't believe $ncall on $self->{call}"); return; } @@ -909,14 +917,6 @@ sub handle_19 next if length $call < 3; # min 3 letter callsigns next if $call eq $main::mycall; - # do we believe this call? - unless ($call eq $self->{call} || $self->is_believed($call)) { - dbg("PCPROT: We don't believe $call on $self->{call}"); - next; - } - - eph_del_regex("^PC(?:21\\^$call|17\\^[^\\^]+\\^$call)"); - # add this station to the user database, if required (don't remove SSID from nodes) my $user = DXUser->get_current($call); if (!$user) { @@ -928,7 +928,24 @@ sub handle_19 $user->node($call); } $user->wantroutepc19(1) unless defined $user->wantroutepc19; + $user->lastin($main::systime) unless DXChannel->get($call); + $user->put; + + # do we believe this call? + unless ($call eq $self->{call} || $self->is_believed($call)) { + my $pt = $user->lastping || 0; + if ($pt+$investigation_int < $main::systime && !Investigate::get($call, $self->{call})) { + my $ivp = Investigate->new($call, $self->{call}); + $ivp->version($ver); + $ivp->here($here); + $ivp->store_pcxx($pcno,$line,$origin,'PC19',$here,$call,$conf,$ver,$_[-1]); + } + dbg("PCPROT: We don't believe $call on $self->{call}"); + next; + } + eph_del_regex("^PC(?:21\\^$call|17\\^[^\\^]+\\^$call)"); + my $r = Route::Node::get($call) || Route::Node->new($call); $r->here($here); $r->conf($conf); @@ -943,9 +960,6 @@ sub handle_19 # unbusy and stop and outgoing mail (ie if somehow we receive another PC19 without a disconnect) my $mref = DXMsg::get_busy($call); $mref->stop_msg($call) if $mref; - - $user->lastin($main::systime) unless DXChannel->get($call); - $user->put; } # route out new nodes to legacy nodes @@ -978,6 +992,9 @@ sub handle_21 return if $call eq $main::mycall; # don't allow malicious buggers to disconnect me (or ignore loops)! unless ($call eq $self->{call} || $self->is_believed($call)) { + if (my $ivp = Investigate::get($call, $self->{call})) { + $ivp->store_pcxx($pcno,$line,$origin,@_); + } dbg("PCPROT: We don't believe $call on $self->{call}"); return; } @@ -1403,7 +1420,21 @@ sub handle_51 } else { $tochan->{pingave} = $tochan->{pingave} + (($t - $tochan->{pingave}) / 6); } + my $rref = Route::Node::get($tochan->{call}); + $rref->pingtime($tochan->{pingave}) if $rref; $tochan->{nopings} = $nopings; # pump up the timer + if (my $ivp = Investigate::get($from, $self->{call})) { + $ivp->handle_ping; + } + } elsif (my $rref = Route::Node::get($r->{call})) { + if (defined $rref->pingtime) { + $rref->pingtime($rref->pingtime + (($t - $rref->pingtime) / 6)); + } else { + $rref->pingtime($t); + } + if (my $ivp = Investigate::get($from, $self->{call})) { + $ivp->handle_ping; + } } } } @@ -1677,6 +1708,8 @@ sub handle_default # This is called from inside the main cluster processing loop and is used # for despatching commands that are doing some long processing job # +# It is called once per second +# sub process { my $t = time; @@ -1710,6 +1743,8 @@ sub process } } + Investigate::process(); + # every ten seconds if ($t - $last10 >= 10) { # clean out ephemera @@ -2150,14 +2185,23 @@ sub load_hops # add a ping request to the ping queues sub addping { - my ($from, $to) = @_; + my ($from, $to, $via) = @_; my $ref = $pings{$to} || []; my $r = {}; $r->{call} = $from; $r->{t} = [ gettimeofday ]; - route(undef, $to, pc51($to, $main::mycall, 1)); + if ($via && (my $dxchan = DXChannel->get($via))) { + $dxchan->send(pc51($to, $main::mycall, 1)); + } else { + route(undef, $to, pc51($to, $main::mycall, 1)); + } push @$ref, $r; $pings{$to} = $ref; + my $u = DXUser->get_current($to); + if ($u) { + $u->lastping($main::systime); + $u->put; + } } sub process_rcmd