From b2982f5b324ee910847e28d76652c74576b8ed8e Mon Sep 17 00:00:00 2001 From: Dirk Koopman Date: Fri, 3 Mar 2023 14:22:54 +0000 Subject: [PATCH] add user level ping as link check command --- Changes | 4 ++++ cmd/Commands_en.hlp | 21 +++++++++++++++++++++ cmd/ping.pl | 46 ++++++++++++++++++++++++++++++--------------- 3 files changed, 56 insertions(+), 15 deletions(-) diff --git a/Changes b/Changes index 9d9e2466..8ee7916f 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,10 @@ 1. Fix DXDebug::DXDebug not found errors in rarely used functions. This is also an interaction with differing versions of Mojolicious. Clearly this has never happened to me (sigh). +2. Allow non-privileged users to use ping (no arguments) and get 'PONG nn' + where nn is an incrementing counter or if there is an argument it will + return 'PONG ' - all in UPPER CASE. See help ping for more + details. 02Mar23======================================================================= 1. Fix sh/dx/30 problem. I.e. allow old style version of sh/dx 30. 01Mar23======================================================================= diff --git a/cmd/Commands_en.hlp b/cmd/Commands_en.hlp index 909c3b7d..63cef603 100644 --- a/cmd/Commands_en.hlp +++ b/cmd/Commands_en.hlp @@ -1128,6 +1128,27 @@ PC protocol to connected nodes either for testing or to unstick things. You can also use in the same way as a talk command to a connected user but without any processing, added of "from to ^Check the link quality between nodes This command allows you to send a frame to another cluster node on the network and get a return frame. The time it takes to do this diff --git a/cmd/ping.pl b/cmd/ping.pl index 32efda31..89f43a0b 100644 --- a/cmd/ping.pl +++ b/cmd/ping.pl @@ -6,27 +6,43 @@ # # -my $self = shift; -my $line = uc shift; # only one callsign allowed -my ($call) = $line =~ /^\s*(\S+)/; +my $counter; -# are we permitted? -return (1, $self->msg('e5')) if $self->priv < 1; +sub init +{ + $counter = 0; +} -# is there a call? -return (1, $self->msg('e6')) if !$call; +sub handle +{ + my $self = shift; + my $line = uc shift; # only one callsign allowed + my ($call) = $line =~ /^\s*(\S+)/; -# is it me? -return (1, $self->msg('pinge1')) if $call eq $main::mycall; +# $DB::single = 1; -# can we see it? Is it a node? -my $noderef = Route::Node::get($call); + if ($self->{priv} < 1) { + if ($call) { + return (1, "PONG $call"); + } + ++$counter, return (1, "PONG $counter") + } -return (1, $self->msg('e7', $call)) unless $noderef; + # is there a call? + return (1, $self->msg('e6')) if !$call; -# ping it -DXXml::Ping::add($self, $call); + # is it me? + return (1, $self->msg('pinge1')) if $call eq $main::mycall; -return (1, $self->msg('pingo', $call)); + # can we see it? Is it a node? + my $noderef = Route::Node::get($call); + + return (1, $self->msg('e7', $call)) unless $noderef; + + # ping it + DXXml::Ping::add($self, $call); + + return (1, $self->msg('pingo', $call)); +} -- 2.34.1