1. make spot dups look back 5 mins.
[spider.git] / perl / DXCommandmode.pm
index 2f3d85f23b95492424846bb05acbe4381106deca..96ccc0a494aa872575064fee0a22cee274ad30c9 100644 (file)
@@ -41,6 +41,12 @@ $errstr = ();                                        # error string from eval
 $scriptbase = "$main::root/scripts"; # the place where all users start scripts go
 $maxerrors = 20;                               # the maximum number of concurrent errors allowed before disconnection
 
+use vars qw($VERSION $BRANCH);
+$VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
+$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ ) || 0;
+$main::build += $VERSION;
+$main::branch += $BRANCH;
+
 #
 # obtain a new connection this is derived from dxchannel
 #
@@ -125,6 +131,13 @@ sub start
        
        $self->tell_login('loginu');
        
+       # do we need to send a forward/opernam?
+       my $lastoper = $user->lastoper || 0;
+       my $homenode = $user->homenode || ""; 
+       if ($homenode eq $main::mycall && $lastoper + $DXUser::lastoperinterval < $main::systime) {
+               run_cmd($DXProt::me, "forward/opernam $call");
+               $user->lastoper($main::systime);
+       }
 }
 
 #
@@ -412,8 +425,14 @@ sub disconnect
        my $call = $self->call;
        delete $self->{senddbg};
 
-       my @rout = $main::routeroot->del_user($call);
-       dbg("B/C PC17 on $main::mycall for: $call") if isdbg('route');
+       my $uref = Route::User::get($call);
+       my @rout;
+       if ($uref) {
+               @rout = $main::routeroot->del_user($uref);
+               dbg("B/C PC17 on $main::mycall for: $call") if isdbg('route');
+       } else {
+               confess "trying to disconnect a non existant user $call";
+       }
 
        # issue a pc17 to everybody interested
        DXProt::route_pc17($DXProt::me, $main::routeroot, @rout) if @rout;