+ my $thing = shift;
+ my $dxchan = shift;
+
+ my $origin = $thing->{origin};
+ my $node = $dxchan->{call};
+
+ my $nref;
+
+ $thing->{pc19n} ||= [];
+
+ # verify authenticity
+ if ($node eq $origin) {
+
+ # for directly connected calls
+ if ($verify_on_login) {
+ my $pp = $dxchan->user->passphrase;
+ unless ($pp) {
+ dbglog('err', "Thingy::Hello::handle: verify on and $origin has no passphrase");
+ $dxchan->disconnect;
+ return;
+ }
+ my $auth = Verify->new("DXSp,$origin,$thing->{s},$thing->{v},$thing->{b}");
+ unless ($auth->verify($thing->{auth}, $dxchan->user->passphrase)) {
+ dbglog('err', "Thingy::Hello::handle: verify on and $origin failed auth check");
+ $dxchan->disconnect;
+ return;
+ }
+ }
+ if ($dxchan->{state} ne 'normal') {
+ $nref = $main::routeroot->add($origin, $thing->{v}, 1);
+ push @{$thing->{pc19n}}, $nref if $nref;
+ $dxchan->start($dxchan->{conn}->{csort}, $dxchan->{conn}->{outbound} ? 'O' : 'A');
+ if ($dxchan->{outbound}) {
+ my $thing = Thingy::Hello->new();
+ $thing->send($dxchan);
+
+ # broadcast our configuration to the world
+ $thing = Thingy::Rt->new_lcf;
+ $thing->broadcast;
+ }
+ }
+ $nref = Route::Node::get($origin);
+ } else {
+
+ # for otherwise connected calls, that come in relayed from other nodes
+ # note that we cannot do any connections at this point
+ $nref = Route::Node::get($origin);
+ unless ($nref) {
+ my $v = $thing->{user} ? undef : $thing->{v};
+ $nref = Route::Node->new($origin, $v, 1);
+ push @{$thing->{pc19n}}, $nref;
+ }
+ }
+
+ # 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($origin, $node, $thing->{hopsaway});
+ RouteDB::update($thing->{user}, $node, $thing->{hopsaway}) if $thing->{user};
+
+ delete $thing->{pc19n} unless @{$thing->{pc19n}};
+
+ $thing->broadcast($dxchan);