X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FAranea.pm;h=ed1c99cda1e429ce27928c5099e9a2e856206596;hb=6c06ed486e67b3e36e9af4794d2eb84f59f249c4;hp=3af3aee9432cd934f21f992cbd3006b3f36867a4;hpb=5b3c2c5e342c23fbab96b7573c5963344617878f;p=spider.git diff --git a/perl/Aranea.pm b/perl/Aranea.pm index 3af3aee9..ed1c99cd 100644 --- a/perl/Aranea.pm +++ b/perl/Aranea.pm @@ -25,12 +25,11 @@ use Script; use Verify; use DXDupe; use Thingy; +use RouteDB; use vars qw($VERSION $BRANCH); -$VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ ); -$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ || (0,0)); -$main::build += $VERSION; -$main::branch += $BRANCH; + +main::mkver($VERSION = q$Revision$); use vars qw(@ISA $ntpflag $dupeage); @@ -55,7 +54,7 @@ sub new # add this node to the table, the values get filled in later my $pkg = shift; my $call = shift; - $main::routeroot->add($call, '5000', Route::here(1)) if $call ne $main::mycall; + $main::routeroot->add($call, '5251', Route::here(1)) if $call ne $main::mycall; $self->{'sort'} = 'W'; return $self; } @@ -153,9 +152,12 @@ sub disconnect my $call = $self->call; return if $self->{disconnecting}++; - + + my $thing = Thingy::Bye->new(origin=>$main::mycall, user=>$call); + $thing->process($self); + # get rid of any PC16/17/19 -# eph_del_regex("^PC1[679]*$call"); + eph_del_regex("^PC1[679]*$call"); # do routing stuff, remove me from routing table my $node = Route::Node::get($call); @@ -166,7 +168,7 @@ sub disconnect # and all my ephemera as well for (@rout) { my $c = $_->call; -# eph_del_regex("^PC1[679].*$c"); + eph_del_regex("^PC1[679].*$c"); } } @@ -198,6 +200,23 @@ sub disconnect # because it has to be used before a channel is fully initialised). # +sub formathead +{ + my $mycall = shift; + my $dts = shift; + my $hop = shift; + my $user = shift; + my $group = shift; + + my $s = "$mycall,$dts,$hop"; + $s .= ",$user" if $user; + if ($group) { + $s .= "," unless $user; + $s .= ",$group" if $group; + } + return $s; +} + sub genheader { my $mycall = shift; @@ -205,8 +224,7 @@ sub genheader my $from = shift; my $date = ((($dayno << 1) | $ntpflag) << 18) | ($main::systime % 86400); - my $r = "$mycall,$to," . sprintf('%6X%04X,0', $date, $seqno); - $r .= ",$from" if $from; + my $r = formathead($mycall, sprintf('%6X%04X', $date, $seqno), 0, $from, $to); $seqno++; $seqno = 0 if $seqno > 0x0ffff; return $r; @@ -284,16 +302,20 @@ sub input my ($head, $data) = split /\|/, $line, 2; return unless $head && $data; - my ($origin, $group, $dts, $hop, $user) = split /,/, $head; + my ($origin, $dts, $hop, $user, $group) = split /,/, $head; return if DXDupe::check("Ara,$origin,$dts", $dupeage); my $err; - $err .= "incomplete header," unless $origin && defined $group && $dts && defined $hop; + $err .= "incomplete header," unless $origin && $dts && defined $hop; my ($cmd, $rdata) = split /,/, $data, 2; # validate it further $err .= "missing cmd or data," unless $cmd && $data; $err .= "invalid command ($cmd)," unless $cmd =~ /^[A-Z][A-Z0-9]*$/; - $err .= "invalid group ($group)," unless $group =~ /^[-A-Z0-9\/:]{2,}$/; + my ($gp, $tus) = split /:/, $group, 2 if $group; + + $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; @@ -308,26 +330,28 @@ sub input $thing = $class->new(); # reconstitute the header but wth hop increased by one - $head = join(',', $origin, $group, $dts, ++$hop); - $head .= ",$user" if $user; + $head = formathead($origin, $dts, ++$hop, $user, $group); $thing->{Aranea} = "$head|$data"; # store useful data $thing->{origin} = $origin; - ($thing->{group}, $thing->{touser}) = split /:/, $group, 2; $thing->{time} = $t; + $thing->{group} = $gp if $gp; + $thing->{touser} = $tus if $tus; $thing->{user} = $user if $user; $thing->{hopsaway} = $hop; - - for (split(/,/, $rdata)) { - if (/=/) { - my ($k,$v) = split /=/, $_, 2; - $thing->{$k} = tdecode($v); - } else { - $thing->{$_} = 1; + + if ($rdata) { + for (split(/,/, $rdata)) { + if (/=/) { + my ($k,$v) = split /=/, $_, 2; + $thing->{$k} = tdecode($v); + } else { + $thing->{$_} = 1; + } } } - + # post process the thing, this generally adds on semantic meaning # does parameter checking etc. It also adds / prepares the thingy so # this is compatible with older protocol and arranges data so