2 # Hello Thingy handling
6 # Copyright (c) 2005 Dirk Koopman G1TLH
11 package Thingy::Hello;
13 use vars qw($VERSION $BRANCH);
14 $VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
15 $BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /^\d+\.\d+(?:\.(\d+)\.(\d+))?$/ || (0,0));
16 $main::build += $VERSION;
17 $main::branch += $BRANCH;
24 use vars qw(@ISA $verify_on_login);
27 $verify_on_login = 1; # make sure that a HELLO coming from
28 # the dxchan call is authentic
33 unless ($thing->{Aranea}) {
34 my $s = sprintf "%X", int(rand() * 100000000);
35 my $auth = Verify->new("DXSp,$main::mycall,$s,$main::version,$main::build");
36 $thing->{Aranea} = Aranea::genmsg($thing, 'HELLO', sw=>'DXSp',
40 auth=>$auth->challenge($main::me->user->passphrase)
43 return $thing->{Aranea};
52 if ($dxchan->call eq $thing->{origin}) {
53 if ($verify_on_login) {
54 my $pp = $dxchan->user->passphrase;
56 dbglog('err', "Thingy::Hello::handle: verify on and $thing->{origin} has no passphrase");
60 my $auth = Verify->new("DXSp,$thing->{origin},$thing->{s},$thing->{v},$thing->{b}");
61 unless ($auth->verify($thing->{auth}, $dxchan->user->passphrase)) {
62 dbglog('err', "Thingy::Hello::handle: verify on and $thing->{origin} failed auth check");
67 if ($dxchan->{state} ne 'normal') {
68 $dxchan->start($dxchan->{conn}->{csort}, $dxchan->{conn}->{outbound} ? 'O' : 'A');
69 if ($dxchan->{outbound}) {
70 my $thing = Thingy::Hello->new();
71 $thing->send($dxchan);
75 $thing->broadcast($dxchan);
81 my $thing = $pkg->SUPER::new(origin=>$main::mycall);