fix DXChannel::get
[spider.git] / perl / Thingy / Ping.pm
index a1ab4599fa4cebe310fb60774c5369a6851c61e7..ec9ce73d1b5b6b208abaea184b2fe3925aecd04c 100644 (file)
@@ -55,14 +55,20 @@ sub gen_DXProt
                # {user} as well as a true user and also it may not
                # have originated here.
 
-               my $from = $thing->{o} if $thing->{out};
-           $from ||= $thing->{user} if Route::Node::get($thing->{user});
-               $from ||= $thing->{origin};
-               my $to = $thing->{o} unless $thing->{out};
-               $to ||= $thing->{touser} if Route::Node::get($thing->{touser});
-               $to ||= $thing->{group};
-
-               
+               my ($from, $to);
+               if ($thing->{out}) {
+                       $from = $thing->{o};
+                       $from ||= $thing->{user} unless Route::User::get($thing->{user});
+                       $from ||= $thing->{origin};
+                       $to = $thing->{touser} unless Route::User::get($thing->{touser});
+                       $to ||= $thing->{group};
+               } else {
+                       $from ||= $thing->{user} unless Route::User::get($thing->{user});
+                       $from ||= $thing->{origin};
+                       $to = $thing->{o};
+                       $to ||= $thing->{touser} unless Route::User::get($thing->{touser});
+                       $to ||= $thing->{group};
+               }
                $thing->{DXProt} = DXProt::pc51($to, $from, $thing->{out});
        }
        return $thing->{DXProt};
@@ -112,7 +118,7 @@ sub handle
 
                        # it's a reply, look in the ping list for this one
                        my $ref = $ping{$thing->{id}} if exists $thing->{id};
-                       $ref ||= find(($thing->{user}||$thing->{origin}), ($thing->{touser}||$thing->{group}));
+                       $ref = find(($thing->{user}||$thing->{origin}), ($thing->{touser}||$thing->{group})) unless $ref;
                        if ($ref) {
                                my $t = tv_interval($ref->{t}, [ gettimeofday ]);
                                my $tochan = DXChannel::get($ref->{touser} || $ref->{group});