X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FThingy%2FHello.pm;h=5b63900699b7ad05d40806f30e1af76d8df12ab6;hb=4d22d5fd3874e8292d82f84a777b99ff7d10402a;hp=c098ca944edfb97825184cf8ab6543107826dbf5;hpb=87b2f58b1b0df6c0cb5c5f0070db554ec2d2a961;p=spider.git diff --git a/perl/Thingy/Hello.pm b/perl/Thingy/Hello.pm index c098ca94..5b639006 100644 --- a/perl/Thingy/Hello.pm +++ b/perl/Thingy/Hello.pm @@ -1,6 +1,9 @@ # # Hello Thingy handling # +# Note that this is a generator of pc19n and pc16n/pc16u +# and a consumer of fpc19n and fpc16n +# # $Id$ # # Copyright (c) 2005 Dirk Koopman G1TLH @@ -11,18 +14,18 @@ use strict; package Thingy::Hello; 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 DXChannel; use DXDebug; use Verify; use Thingy; +use Thingy::RouteFilter; +use Thingy::Rt; use vars qw(@ISA $verify_on_login); -@ISA = qw(Thingy); +@ISA = qw(Thingy Thingy::RouteFilter); $verify_on_login = 1; # make sure that a HELLO coming from # the dxchan call is authentic @@ -31,14 +34,13 @@ sub gen_Aranea { my $thing = shift; unless ($thing->{Aranea}) { - my $s = sprintf "%X", int(rand() * 100000000); - my $auth = Verify->new("DXSp,$main::mycall,$s,$main::version,$main::build"); - $thing->{Aranea} = Aranea::genmsg($thing, 'HELLO', sw=>'DXSp', - v=>$main::version, - b=>$main::build, - 's'=>$s, - auth=>$auth->challenge($main::me->user->passphrase) - ); + $thing->add_auth; + + $thing->{sw} ||= 'DXSp'; + $thing->{v} ||= $main::version; + $thing->{b} ||= $main::build; + + $thing->{Aranea} = Aranea::genmsg($thing, [qw(sw v b s auth)]); } return $thing->{Aranea}; } @@ -48,6 +50,9 @@ sub handle my $thing = shift; my $dxchan = shift; + my $nref; + $thing->{pc19n} ||= []; + # verify authenticity if ($dxchan->{call} eq $thing->{origin}) { @@ -71,39 +76,47 @@ sub handle if ($dxchan->{outbound}) { my $thing = Thingy::Hello->new(); $thing->send($dxchan); + + # broadcast our configuration to the world + $thing = Thingy::Rt->new_lcf; + $thing->broadcast; } } + my $origin = $thing->{origin}; + $nref = $main::routeroot->add($origin, $thing->{v}, 1); + push @{$thing->{pc19n}}, $nref if $nref; } else { # for otherwise connected calls, that come in relayed from other nodes # note that we cannot do any connections at this point - my $nref = Route::Node::get($thing->{origin}); + $nref = Route::Node::get($thing->{origin}); unless ($nref) { my $v = $thing->{user} ? undef : $thing->{v}; $nref = Route::Node->new($thing->{origin}, $v, 1); + push @{$thing->{pc19n}}, $nref; } - if (my $user = $thing->{user}) { - my $ur = Route::get($user); - unless ($ur) { - my $uref = DXUser->get_current($user); - if ($uref->is_node || $uref->is_aranea) { - $nref->add($user, $thing->{v}, 1); - } else { - $nref->add_user($user, 1); - } + } + + # handle "User" + if (my $user = $thing->{user}) { + my $ur = Route::get($user); + unless ($ur) { + my $uref = DXUser->get_current($user); + if ($uref->is_node || $uref->is_aranea) { + my $u = $nref->add($user, $thing->{v}, 1); + push @{$thing->{pc19n}}, $u if $u; + } else { + $thing->{pc16n} = $nref; + $thing->{pc16u} = [$nref->add_user($user, 1)]; } } } RouteDB::update($thing->{origin}, $dxchan->{call}, $thing->{hopsaway}); RouteDB::update($thing->{user}, $dxchan->{call}, $thing->{hopsaway}) if $thing->{user}; - + + delete $thing->{pc19n} unless @{$thing->{pc19n}}; + $thing->broadcast($dxchan); } -sub new -{ - my $pkg = shift; - my $thing = $pkg->SUPER::new(origin=>$main::mycall); - return $thing; -} 1;