fix ping problem
authorDirk Koopman <djk@tobit.co.uk>
Sat, 4 Mar 2023 00:18:41 +0000 (00:18 +0000)
committerDirk Koopman <djk@tobit.co.uk>
Sat, 4 Mar 2023 00:18:41 +0000 (00:18 +0000)
Please look at the Changes for an explanation.

I have do the prep work for allowing users to alter the prompt
idle timer (currently fixed to 11 minutes). The cmd has yet to be
written.

Changes
perl/DXChannel.pm
perl/DXCommandmode.pm
perl/DXUser.pm

diff --git a/Changes b/Changes
index 8ee7916f07b997da5588c3a870284b43d9ecc4af..65575f39b20526151405229e1cef51fb242b4c6d 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,18 @@
+04Mar23=======================================================================
+1. Fixed regression caused by too many command errors in (startup) script
+   files. This is caused by much stricter checking of commands entered both 
+   by users AND scripts. If there more concurrent errors ie. greater than
+   $DXChannel::maxerrors (default 10) then that user will be disconnected.
+
+   Unfortunately this could include the $mycall (node) channel if there were
+   too many command users in the startup script. The example I looked at had
+   a load of HTML pasted into it.  
+   
+   For various reasons the only manifestation of this problem was that pings
+   no longer worked. 
+
+   This has been fixed. I am grateful to Fulvio HB9DHG for letting me break
+   his node for an hour or so until I worked out what was going on.  
 03Mar23=======================================================================
 1. Fix DXDebug::DXDebug not found errors in rarely used functions. This is 
    also an interaction with differing versions of Mojolicious. Clearly this 
index 240142c65107a80e6979fa417935f247fd4f1866..e60ce6c6be307e382420bb74a9828d9427780312 100644 (file)
@@ -33,6 +33,8 @@ use DXDebug;
 use Filter;
 use Prefix;
 use Route;
+use DXLog;
+
 
 use strict;
 use vars qw(%channels %valid @ISA $count $maxerrors);
@@ -124,6 +126,7 @@ $count = 0;
                  talk => '0,Want Talk,yesno',
                  talklist => '0,Talk List,parray',
                  user => '9,DXUser ref',
+                 user_interval => '0,Prompt Idle Time',
                  ve7cc => '0,VE7CC program special,yesno',
                  verified => '9,Verified?,yesno',
                  version => '1,Node Version',
@@ -135,7 +138,7 @@ $count = 0;
                  wx => '0,Want WX,yesno',                
                 );
 
-$maxerrors = 5;                                # the maximum number of concurrent errors allowed before disconnection
+$maxerrors = 10;                               # the maximum number of concurrent errors allowed before disconnection
 
 # object destruction
 sub DESTROY
@@ -204,12 +207,13 @@ sub _error_out
 {
        my $self = shift;
        my $e = shift;
-       if (++$self->{errors} > $maxerrors) {
+       if ($self != $main::me && ++$self->{errors} > $maxerrors) {
                $self->send($self->msg('e26'));
+               LogDbg('err', "DXChannel $self->{call}: too many errors ($self->{errors} > $maxerrors), disconnecting");
                $self->disconnect;
                return ();
        } else {
-               return ($self->msg($e));
+               return ($e ? $self->msg($e) : '');
        }
 }
 
index d2f4a4ff97c549b3b596ce62edf5530cb66d7d11..8720e940ac016e4ec5e8da04346f106d80722787 100644 (file)
@@ -252,6 +252,7 @@ sub start
        }
 
        $self->lastmsgpoll($main::systime);
+       $self->{user_interval} = $self->user->user_interval || $main::user_interval; # allow user to change idle time between prompts
        $self->prompt;
 }
 
@@ -543,7 +544,7 @@ sub run_cmd
                # check for length of whole command line and any invalid characters
                if (length $cmdline > $maxcmdlth || $cmd =~ m|\.| || $cmd !~ m|^\w+(?:/\w+){0,1}(?:/\d+)?$|) {
                        LogDbg('DXCommand', "cmd: $self->{call} - invalid characters in '$cmd'");
-                       return $self->_error_out('e40');        
+                       return $self->_error_out('e40');
                }
 
                my ($path, $fcmd);
@@ -588,7 +589,7 @@ sub run_cmd
                                return $self->_error_out('e1');
                        }
                } else {
-                       dbg("cmd: $cmd not found") if isdbg('command');
+                       LogDbg('DXCommand', "$self->{call} cmd: '$cmd' not found");
                        return $self->_error_out('e1');
                }
        }
@@ -597,11 +598,7 @@ sub run_cmd
        if ($ok) {
                delete $self->{errors};
        } else {
-               if (++$self->{errors} > $DXChannel::maxerrors) {
-                       $self->send($self->msg('e26'));
-                       $self->disconnect;
-                       return ();
-               }
+               return $self->_error_out('e26');
        }
        return map {s/([^\s])\s+$/$1/; $_} @ans;
 }
@@ -627,7 +624,7 @@ sub process
                }
                
                # send a prompt if no activity out on this channel
-               if ($t >= $dxchan->t + $main::user_interval) {
+               if ($t >= $dxchan->t + $dxchan->{user_interval}) {
                        $dxchan->prompt() if $dxchan->{state} =~ /^prompt/o;
                        $dxchan->t($t);
                }
index a4e52a26abb1e97a21cc8d657a81c5653c0852e1..7481ed8456c423a84ada12dba8ad585315ae3f83 100644 (file)
@@ -85,6 +85,7 @@ my $json;
                  rbnseeme => '0,RBN See Me,yesno',
                  registered => '9,Registered?,yesno',
                  startt => '0,Start Time,cldatetime',
+                 user_interval => '0,Prompt IdleTime',
                  version => '1,Version',
                  wantann => '0,Req Announce,yesno',
                  wantann_talk => '0,Talklike Anns,yesno',