X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FAranea.pm;h=08d97ce99cc605ed78323a1ec6a0107e35b7d3d3;hb=bab2cc5b932a1b57a8a81e7e815c692169da0d6c;hp=726a068d896a1180b76900ab44bd7605ca3e8f43;hpb=27b6e9691f9985830388bbb8fc0a04357fa4f11f;p=spider.git diff --git a/perl/Aranea.pm b/perl/Aranea.pm index 726a068d..08d97ce9 100644 --- a/perl/Aranea.pm +++ b/perl/Aranea.pm @@ -36,12 +36,14 @@ use vars qw($VERSION $BRANCH); main::mkver($VERSION = q$Revision$); -use vars qw(@ISA $ntpflag $dupeage); +use vars qw(@ISA $ntpflag $dupeage $cf_interval $hello_interval); @ISA = qw(DXChannel); $ntpflag = 0; # should be set in startup if NTP in use $dupeage = 12*60*60; # duplicates stored half a day +$cf_interval = 30*60; # interval between config broadcasts +$hello_interval = 3*60*60; # interval between hello broadcasts for me and local users my $seqno = 0; my $dayno = 0; @@ -124,6 +126,7 @@ sub start unless ($self->{outbound}) { my $thing = Thingy::Rt->new_cf; $thing->broadcast; + $main::me->lastcf($main::systime); } # run a script send the output to the debug file @@ -142,9 +145,11 @@ sub normal } # -# periodic processing +# periodic processing (every second) # +my $lastmin = time; + sub process { @@ -154,6 +159,56 @@ sub process $dayno = $d; $daystart = $main::systime - ($main::systime % 86400); } + if ($main::systime >= $lastmin + 60) { + per_minute(); + $lastmin = $main::systime; + } +} + +sub per_minute +{ + # send hello and cf packages periodically + foreach my $dxchan (DXChannel::get_all()) { + next if $dxchan->is_aranea; + if ($main::systime >= $dxchan->lasthello + $hello_interval) { + my $thing = Thingy::Hello->new(h => $dxchan->here); + $thing->{user} = $dxchan->{call} unless $dxchan == $main::me; + if (my $v = $dxchan->{version}) { + if ($dxchan->is_spider) { + $thing->{sw} = 'DXSp'; + } + $thing->{v} = $v; + } + $thing->{b} = $dxchan->{build} if $dxchan->{build}; + $thing->broadcast($dxchan); + $dxchan->lasthello($main::systime); + } + if ($dxchan->is_node) { + if ($main::systime >= $dxchan->lastcf + $cf_interval) { + my $call = $dxchan->call; + if ($dxchan == $main::me) { + + # i am special but, currently, still a node + my $thing = Thingy::Rt->new_cf; + $thing->broadcast; + $dxchan->lastcf($main::systime); + } else { + + # i am a pc protocol node connected directly + my $thing = Thingy::Rt->new(); + $thing->{user} = $call unless $dxchan == $main::me; + if (my $nref = Route::Node::get($call)) { + $thing->copy_pc16_data($nref); + $thing->broadcast($dxchan); + $dxchan->lastcf($main::systime); + } else { + dbg("Aranea::per_minute: Route::Node for $call disappeared"); + $dxchan->disconnect; + } + } + } + } + } } sub disconnect @@ -192,7 +247,7 @@ sub disconnect DXProt::route_pc21($self, $main::mycall, undef, @rout) if @rout; # remove outstanding pings -# delete $pings{$call}; + Thingy::Ping::forget($call); # I was the last node visited $self->user->node($main::mycall); @@ -247,7 +302,7 @@ sub genheader sub decode_dts { my $dts = shift; - my ($dt, $seqno) = map {hex} unpack "H6H4", $dts; + my ($dt, $seqno) = map {hex} unpack "A6 A4", $dts; my $secs = $dt & 0x3FFFF; $dt >>= 18; my $day = $dt >> 1; @@ -268,7 +323,7 @@ sub tencode { my $s = shift; $s =~ s/([\%=|,\'\x00-\x1f\x7f-\xff])/sprintf("%%%02X", ord($1))/eg; - $s = "'$s'" if $s =~ / /; +# $s = "'$s'" if $s =~ / /; return $s; } @@ -277,7 +332,7 @@ sub tdecode my $s = shift; $s =~ s/^'(.*)'$/$1/; $s =~ s/\%([0-9A-F][0-9A-F])/chr(hex($1))/eg; - return $s; + return length $s ? $s : ''; } sub genmsg @@ -328,13 +383,14 @@ sub input my ($gp, $tus) = split /:/, $group, 2 if $group; $err .= "from me," if $origin eq $main::mycall; - $err .= "invalid group ($gp)," if $gp && $gp !~ /^[A-Z0-9]{2,}$/; + $err .= "invalid group ($gp)," if $gp && $gp !~ /^[-A-Z0-9]{2,}$/; $err .= "invalid tocall ($tus)," if $tus && !is_callsign($tus); $err .= "invalid fromcall ($user)," if $user && !is_callsign($user); my $class = 'Thingy::' . ucfirst(lc $cmd); my $thing; my ($t, $seqno, $ntp) = decode_dts($dts) unless $err; + dbg("dts: $dts = $ntp $t($main::systime) $seqno") if isdbg('dts'); $err .= "invalid date/seq," unless $t; if ($err) {