try fix node type changes from outside
[spider.git] / perl / cluster.pl
index 55841c2f826e1c737c32838ed1ab5510f59ca54a..fc530e21c1db11b12f554ab43514f33a8e1f01fa 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 #
 # This is the DX cluster 'daemon'. It sits in the middle of its little
 # web of client routines sucking and blowing data where it may.
@@ -11,6 +11,7 @@
 #
 
 require 5.10.1;
+use warnings;
 
 # make sure that modules are searched in the order local then perl
 BEGIN {
@@ -125,6 +126,7 @@ use vars qw(@inqueue $systime $starttime $lockfn @outstanding_connects
                        $clusterport $mycall $decease $is_win $routeroot $me $reqreg $bumpexisting
                        $allowdxby $dbh $dsn $dbuser $dbpass $do_xml $systime_days $systime_daystart
                        $can_encode $maxconnect_user $maxconnect_node $idle_interval $log_flush_interval
+                       $broadcast_debug
                   );
 
 @inqueue = ();                                 # the main input queue, an array of hashes
@@ -142,7 +144,9 @@ $maxconnect_node = 0;                       # Ditto but for nodes. In either case if a new incoming
 $idle_interval = 0.500;                # the wait between invocations of the main idle loop processing.
 $log_flush_interval = 2;               # interval to wait between log flushes
 
-our $ending;                                                              # signal that we are ending;
+our $ending;                                   # signal that we are ending;
+our $broadcast_debug;                  # allow broadcasting of debug info down "enhanced" user connections
+
 
 
 # send a message to call on conn and disconnect
@@ -429,7 +433,7 @@ sub setup_start
        }
 
        # open the debug file, set various FHs to be unbuffered
-       dbginit(\&DXCommandmode::broadcast_debug);
+       dbginit($broadcast_debug ? \&DXCommandmode::broadcast_debug : undef);
        foreach (@debug) {
                dbgadd($_);
        }
@@ -498,8 +502,18 @@ sub setup_start
                die "\$myalias \& \$mycall are the same ($mycall)!, they must be different (hint: make \$mycall = '${mycall}-2';). Oh and don't forget to rerun create_sysop.pl!" if $mycall eq $myalias;
                my $ref = DXUser::get($mycall);
                die "$mycall missing, run the create_sysop.pl script and please RTFM" unless $ref && $ref->priv == 9;
+               my $oldsort = $ref->sort;
+               if ($oldsort ne 'S') {
+                       $ref->sort('S');
+                       dbg "Resetting node type from $oldsort -> DXSpider ('S')";
+               }
                $ref = DXUser::get($myalias);
                die "$myalias missing, run the create_sysop.pl script and please RTFM" unless $ref && $ref->priv == 9;
+               $oldsort = $ref->sort;
+               if ($oldsort ne 'U') {
+                       $ref->sort('U');
+                       dbg "Resetting sysop user type from $oldsort -> User ('U')";
+               }
        }
 
        # start listening for incoming messages/connects