attempt to fix myalias/mycall external usurpation
authorDirk Koopman <djk@tobit.co.uk>
Fri, 17 Mar 2023 20:21:10 +0000 (20:21 +0000)
committerDirk Koopman <djk@tobit.co.uk>
Fri, 17 Mar 2023 20:21:10 +0000 (20:21 +0000)
Do some housekeeping on startup and ending.

Suppress useless warnings caused by uninititalised object handles that
are correctly uninitialised caused by error conditions failing
prematurely.

Fix logdbg to show the type of message in debug.

Changes
perl/DXDebug.pm
perl/DXLog.pm
perl/DXProtHandle.pm
perl/QSL.pm
perl/RBN.pm
perl/cluster.pl

diff --git a/Changes b/Changes
index 74c07256e21aea98e4bddc26e751945a2f90df65..840bcdc0f4a432658888aef6b5dd3014a0ff508f 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,9 @@
+17Mar23=======================================================================
+1. Try to nail down incoming PC92s that attempt to change the type of $myalias
+   or $mycall. 
+2. Do some housekeeping with the startup and finish debugging to make the 
+   order of messaging more logical. Also disable some messaging caused by 
+   other errors/circumstances causing various object handles disappearing.  
 10Mar23=======================================================================
 1. I am aware that there are windows nodes out there on mojo (brave, impetuous 
    that you are) and wget is not an easy option to download badip files. So, 
index f249282e5b57e5d69399de8ece3cde3d5e1763f6..83e49259863e0f7259cfcae0fa4702e536d7a2a6 100644 (file)
@@ -28,7 +28,7 @@ use 5.10.1;
 
 require Exporter;
 @ISA = qw(Exporter);
-@EXPORT = qw(dbginit dbg dbgadd dbgsub dbglist dbgdump isdbg dbgclose dbgtrace dbgprintring confess croak cluck carp);
+@EXPORT = qw(dbginit dbg dbgadd dbgsub dbglist dbgdump isdbg dbgclose dbgtrace dbgprintring dbgsetcat confess croak cluck carp);
 
 use strict;
 use vars qw(%dbglevel $fp $callback $cleandays $keepdays $dbgringlth);
@@ -297,6 +297,12 @@ sub dbgclean
        }
 }
 
+# force a category for the next (unconditional) dbg message (replace (*) with (<something>))
+sub dbgsetcat
+{
+       $_isdbg = shift;
+}
+
 1;
 __END__
 
index 439518c26ff08c588c00243dac0e533130f75775..a332d39208336c26c5c9c012bc4a3a7b6ac6959a 100644 (file)
@@ -220,8 +220,11 @@ sub Log
 sub LogDbg
 {
        my $cat = shift;
-       DXDebug::dbg($_) for @_;
-       Log($cat, @_);
+       foreach my $m (@_) {
+               DXDebug::dbgsetcat($cat);
+               DXDebug::dbg($m);
+               Log($cat, $m);
+       }
 }
 
 sub Logclose
index c4f31232ea0ce2537d6b0bc8ee0f395f74b8399f..73f139193a4279febaba885c4ba5d7965fe90d00 100644 (file)
@@ -945,7 +945,7 @@ sub check_add_user
                        $user->node($homenode);
                        $user->priv(0);
                }
-               $user->lastin($main::systime); # this make it last longer than just this invocation
+               $user->lastin($main::systime); # this makes it last longer than just this invocation
                $user->put;                             # just to make sure it gets written away!!!
                dbg("DXProt: PC92 new user record for $call created");
        }
@@ -1032,6 +1032,12 @@ sub handle_19
                        next;
                }
 
+               if ($call eq $main::myalias) {
+                       LogDbg('err', "ROUTE: $call eq \$myalias from $self->{call}, ignored!!!");
+                       dbgprintring(3) if isdbg('nologchan');
+                       next;
+               }
+               
                my $user = check_add_user($call, 'A');
 
 #              if (eph_dup($genline)) {
@@ -1807,7 +1813,12 @@ sub _add_thingy
                                $user->del if $user;
                            $call = $normcall; # this is safe because a route add will ignore duplicates
                        }
-                       
+
+                       if ($call eq $main::myalias && $is_node) {
+                               LogDbg('err', "ROUTE: $call eq \$myalias from $ncall - downgraded to user!!!");
+                               dbgprintring(3) if isdbg('nologchan');
+                               $is_node = 0;
+                       }
                        if ($is_node) {
                                dbg("ROUTE: added node $call to $ncall") if isdbg('routelow');
                                $user = check_add_user($call, 'A');
@@ -2249,7 +2260,9 @@ sub handle_92
                                dbg("PCPROT: $self->{call} : type $sort $_->[0] refers to me, ignored") if isdbg('route');
                                next;
                        }
-                       if ($_->[0] eq $main::myalias && $_->[1] || $_->[0] eq $main::mycall && $_->[1] == 0) {
+
+                       my $isnode = ($_->[1] | $_->[2]);
+                       if (($_->[0] eq $main::myalias && $isnode) || ($_->[0] eq $main::mycall && !$isnode)) {
                                LogDbg('err',"PCPROT: $self->{call} : type $sort $_->[0] trying to change type to " . $_->[1]?"Node":"User" . ", ignored");
                                next;
                        }
index ec5512216f563ffe9929bad57253d9d87851799f..b9f4ee85ace6df724cab7ba30200f46c6778896d 100644 (file)
@@ -48,7 +48,7 @@ sub init
 sub finish
 {
        dbg("DXQSL finished");
-       $dbm->sync;
+       $dbm->sync if $dbm;
        undef $dbm;
        untie %u;
 }
index e844b6d6bcba0c5597a948b2c5fc765520cd45d2..820f39cbb620d73cab33efaa54da2245edef0876 100644 (file)
@@ -194,7 +194,7 @@ sub start
        $self->{width} = 80 unless $self->{width} && $self->{width} > 80;
        $self->{consort} = $line;       # save the connection type
 
-       LogDbg('DXCommand', "$call connected from $self->{hostname}");
+       LogDbg('err', "$call connected from $self->{hostname}");
 
        # set some necessary flags on the user if they are connecting
        $self->{registered} = 1;
@@ -369,7 +369,7 @@ sub normal
                                                dbg("seeme: result '$buf'") if isdbg('seeme');
                                                $uchan->local_send('S', $buf);
                                        } else {
-                                               LogDbg("RBN Someone is playing silly persons $rcall is not a user and cannot do 'seeme', ignored and reset");
+                                               LogDbg('err',"RBN Someone is playing silly persons $rcall is not a user and cannot do 'seeme', ignored and reset");
                                                del_seeme($rcall);
                                        }
                                }
@@ -852,7 +852,7 @@ sub per_minute
                next unless $dxchan->is_rbn;
                dbg "RBN:STATS minute $dxchan->{call} raw: $dxchan->{noraw} retrieved spots: $dxchan->{norbn} delivered: $dxchan->{nospot} after filtering to users: " . scalar keys %{$dxchan->{nousers}} if isdbg('rbnstats');
                if ($dxchan->{noraw} == 0 && $dxchan->{lasttime} > 60) {
-                       LogDbg('RBN', "RBN: no input from $dxchan->{call}, disconnecting");
+                       LogDbg('err', "RBN: no input from $dxchan->{call}, disconnecting");
                        $dxchan->disconnect;
                }
                $dxchan->{noraw} = $dxchan->{norbn} = $dxchan->{nospot} = 0; $dxchan->{nousers} = {};
@@ -908,7 +908,10 @@ sub finish
 
 sub write_cache
 {
+       return unless $json;
+
        my $ta = [ gettimeofday ];
+       
        $json->indent(1)->canonical(1) if isdbg 'rbncache';
        my $s = eval {$json->encode($spots)};
        if ($s) {
index b45213a71ba4a5dd4f2b18bb43b24c08a2db989d..7188ed6f426189e65460842c58170ddfdc353d3e 100755 (executable)
@@ -552,12 +552,6 @@ sub setup_start
        # log our path
        dbg "Perl path: " . join(':', @INC);
        
-       # try to load the database
-       if (DXSql::init($dsn)) {
-               $dbh = DXSql->new($dsn);
-               $dbh = $dbh->connect($dsn, $dbuser, $dbpass) if $dbh;
-       }
-
        # try to load Encode and Git
        {
                local $^W = 0;
@@ -600,6 +594,36 @@ sub setup_start
                $SIG{__DIE__} = $w;
        }
 
+       unless ($is_win) {
+               $SIG{HUP} = 'IGNORE';
+               $SIG{CHLD} = sub { $zombies++ };
+
+               $SIG{PIPE} = sub {      dbg("Broken PIPE signal received"); };
+               $SIG{IO} = sub {        dbg("SIGIO received"); };
+               $SIG{WINCH} = $SIG{STOP} = $SIG{CONT} = 'IGNORE';
+               $SIG{KILL} = 'DEFAULT'; # as if it matters....
+
+               # catch the rest with a hopeful message
+               for (keys %SIG) {
+                       if (!$SIG{$_}) {
+                               #               dbg("Catching SIG $_") if isdbg('chan');
+                               $SIG{$_} = sub { my $sig = shift;       DXDebug::confess("Caught signal $sig");  };
+                       }
+               }
+       }
+
+
+       # banner
+       my ($year) = (gmtime)[5];
+       $year += 1900;
+       LogDbg('cluster', "DXSpider v$version build $build (git: $gitbranch/$gitversion) using perl $^V on $^O started");
+       LogDbg('cluster', "Copyright (c) 1998-$year Dirk Koopman G1TLH");
+       LogDbg('cluster', "Capabilities: ve7cc rbn");
+
+       # prime some signals
+       unless ($DB::VERSION) {
+               $SIG{INT} = $SIG{TERM} = sub { $ending = 10; };
+       }
 
        # setup location of motd & issue
        localdata_mv($motd);
@@ -610,12 +634,6 @@ sub setup_start
        # try to load XML::Simple
        DXXml::init();
 
-       # banner
-       my ($year) = (gmtime)[5];
-       $year += 1900;
-       LogDbg('cluster', "DXSpider v$version build $build (git: $gitbranch/$gitversion) using perl $^V on $^O started");
-       LogDbg('cluster', "Copyright (c) 1998-$year Dirk Koopman G1TLH");
-       LogDbg('cluster', "Capabilities: ve7cc rbn");
 
        # load Prefixes
        dbg("loading prefixes ...");
@@ -683,35 +701,6 @@ sub setup_start
        dbg("UDP Listener") if $UDPMsg::enable;
        UDPMsg::init(\&new_channel);
 
-       # load bad words
-       BadWords::load();
-
-       # prime some signals
-       unless ($DB::VERSION) {
-               $SIG{INT} = $SIG{TERM} = sub { $ending = 10; };
-       }
-
-       # get any bad IPs 
-       DXCIDR::init();
-
-       unless ($is_win) {
-               $SIG{HUP} = 'IGNORE';
-               $SIG{CHLD} = sub { $zombies++ };
-
-               $SIG{PIPE} = sub {      dbg("Broken PIPE signal received"); };
-               $SIG{IO} = sub {        dbg("SIGIO received"); };
-               $SIG{WINCH} = $SIG{STOP} = $SIG{CONT} = 'IGNORE';
-               $SIG{KILL} = 'DEFAULT'; # as if it matters....
-
-               # catch the rest with a hopeful message
-               for (keys %SIG) {
-                       if (!$SIG{$_}) {
-                               #               dbg("Catching SIG $_") if isdbg('chan');
-                               $SIG{$_} = sub { my $sig = shift;       DXDebug::confess("Caught signal $sig");  };
-                       }
-               }
-       }
-
        # start dupe system
        dbg("Starting Dupe system");
        DXDupe::init();
@@ -757,6 +746,13 @@ sub setup_start
        dbg("Starting DX Spot system");
        Spot->init();
 
+       # try to load the spot database if present
+       if (DXSql::init($dsn)) {
+               $dbh = DXSql->new($dsn);
+               $dbh = $dbh->connect($dsn, $dbuser, $dbpass) if $dbh;
+       }
+
+
        # read in any existing message headers and clean out old crap
        dbg("Reading existing Message/Bulletine headers ...");
        DXMsg->init();
@@ -777,6 +773,13 @@ sub setup_start
        dbg("Starting DXQsl system");
        QSL::init(1);
 
+       # load bad words
+       BadWords::load();
+
+       # get any bad IPs 
+       DXCIDR::init();
+
+
        dbg("Ooing local initialisations ...");
        if (defined &Local::init) {
                eval {