+sub handle
+{
+ my $thing = shift;
+ my $dxchan = shift;
+
+ # verify authenticity
+ if ($dxchan->{call} eq $thing->{origin}) {
+
+ # for directly connected calls
+ if ($verify_on_login) {
+ my $pp = $dxchan->user->passphrase;
+ unless ($pp) {
+ dbglog('err', "Thingy::Hello::handle: verify on and $thing->{origin} has no passphrase");
+ $dxchan->disconnect;
+ return;
+ }
+ my $auth = Verify->new("DXSp,$thing->{origin},$thing->{s},$thing->{v},$thing->{b}");
+ unless ($auth->verify($thing->{auth}, $dxchan->user->passphrase)) {
+ dbglog('err', "Thingy::Hello::handle: verify on and $thing->{origin} failed auth check");
+ $dxchan->disconnect;
+ return;
+ }
+ }
+ if ($dxchan->{state} ne 'normal') {
+ $dxchan->start($dxchan->{conn}->{csort}, $dxchan->{conn}->{outbound} ? 'O' : 'A');
+ if ($dxchan->{outbound}) {
+ my $thing = Thingy::Hello->new();
+ $thing->send($dxchan);
+ }
+ }
+ } 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});
+ unless ($nref) {
+ my $v = $thing->{user} ? undef : $thing->{v};
+ $nref = Route::Node->new($thing->{origin}, $v, 1);
+ }
+ 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);
+ }
+ }
+ }
+ }
+ RouteDB::update($thing->{origin}, $dxchan->{call}, $thing->{hopsaway});
+ RouteDB::update($thing->{user}, $dxchan->{call}, $thing->{hopsaway}) if $thing->{user};
+
+ $thing->broadcast($dxchan);
+}
+
+sub new