X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FAranea.pm;h=087eefc3d2f16c639f01384a77107648d95f5771;hb=4d22d5fd3874e8292d82f84a777b99ff7d10402a;hp=fc77cc13122fe6f1a7f330c11992e5aedb1ac59f;hpb=dcbafa96df9fbad90df86076b6ee9fa6a673a61c;p=spider.git diff --git a/perl/Aranea.pm b/perl/Aranea.pm index fc77cc13..087eefc3 100644 --- a/perl/Aranea.pm +++ b/perl/Aranea.pm @@ -25,13 +25,16 @@ use Script; use Verify; use DXDupe; use Thingy; +use Thingy::Rt; +use Thingy::Hello; +use Thingy::Bye; use RouteDB; +use DXProt; +use DXCommandmode; 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); @@ -118,6 +121,12 @@ sub start # send info to all logged in thingies $self->tell_login('loginn'); + # broadcast our configuration to the world + unless ($self->{outbound}) { + my $thing = Thingy::Rt->new_lcf; + $thing->broadcast; + } + # run a script send the output to the debug file my $script = new Script(lc $call) || new Script('node_default'); $script->run($self) if $script; @@ -154,9 +163,12 @@ sub disconnect my $call = $self->call; return if $self->{disconnecting}++; - + + my $thing = Thingy::Bye->new(origin=>$main::mycall, user=>$call); + $thing->broadcast($self); + # get rid of any PC16/17/19 -# eph_del_regex("^PC1[679]*$call"); + DXProt::eph_del_regex("^PC1[679]*$call"); # do routing stuff, remove me from routing table my $node = Route::Node::get($call); @@ -167,7 +179,7 @@ sub disconnect # and all my ephemera as well for (@rout) { my $c = $_->call; -# eph_del_regex("^PC1[679].*$c"); + DXProt::eph_del_regex("^PC1[679].*$c"); } } @@ -178,7 +190,7 @@ sub disconnect $mref->stop_msg($call) if $mref; # broadcast to all other nodes that all the nodes connected to via me are gone -# $self->route_pc21($main::mycall, undef, @rout) if @rout; + DXProt::route_pc21($self, $main::mycall, undef, @rout) if @rout; # remove outstanding pings # delete $pings{$call}; @@ -199,6 +211,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; @@ -206,9 +235,7 @@ sub genheader my $from = shift; my $date = ((($dayno << 1) | $ntpflag) << 18) | ($main::systime % 86400); - my $r = "$mycall," . sprintf('%6X%04X,0', $date, $seqno); - $r .= ",$to" if $to; - $r .= ",$from" if $from; + my $r = formathead($mycall, sprintf('%6X%04X', $date, $seqno), 0, $from, $to); $seqno++; $seqno = 0 if $seqno > 0x0ffff; return $r; @@ -257,16 +284,20 @@ sub tdecode sub genmsg { my $thing = shift; - my $name = shift; + my $list = ref $_[0] ? shift : \@_; + my ($name) = uc ref $thing; + $name =~ /::(\w+)$/; + $name = $1; my $head = genheader($thing->{origin}, ($thing->{group} || $thing->{touser} || $thing->{tonode}), ($thing->{user} || $thing->{fromuser} || $thing->{fromnode}) ); - my $data = "$name,"; - while (@_) { - my $k = lc shift; - my $v = tencode(shift); - $data .= "$k=$v,"; + + my $data = uc $name . ','; + while (@$list) { + my $k = lc shift @$list; + my $v = $thing->{$k}; + $data .= "$k=" . tencode($v) . ',' if defined $v; } chop $data; return "$head|$data"; @@ -286,7 +317,7 @@ sub input my ($head, $data) = split /\|/, $line, 2; return unless $head && $data; - my ($origin, $dts, $hop, $group, $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 && $dts && defined $hop; @@ -296,7 +327,8 @@ sub input $err .= "missing cmd or data," unless $cmd && $data; $err .= "invalid command ($cmd)," unless $cmd =~ /^[A-Z][A-Z0-9]*$/; 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 tocall ($tus)," if $tus && !is_callsign($tus); $err .= "invalid fromcall ($user)," if $user && !is_callsign($user); @@ -314,9 +346,7 @@ sub input $thing = $class->new(); # reconstitute the header but wth hop increased by one - $head = join(',', $origin, $dts, ++$hop); - $head .= ",$group" if $group; - $head .= ",$user" if $user; + $head = formathead($origin, $dts, ++$hop, $user, $group); $thing->{Aranea} = "$head|$data"; # store useful data @@ -327,15 +357,17 @@ sub input $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