From cfa6a715412c7c4972ec85034bd2d945751317cb Mon Sep 17 00:00:00 2001 From: Dirk Koopman Date: Fri, 8 May 2020 16:06:53 +0100 Subject: [PATCH] tidy up Route, add argument to sh/ver --- Changes | 4 ++++ cmd/show/version.pl | 24 ++++++++++++++++++++---- cmd/stat/route.pl | 28 ++++++++++++++++++++++++++++ cmd/stat/route_node.pl | 2 +- perl/DXProtHandle.pm | 2 +- perl/DXUtil.pm | 2 +- perl/Route.pm | 2 ++ perl/Route/Node.pm | 6 ++---- perl/Route/User.pm | 5 ----- perl/cluster.pl | 3 +++ 10 files changed, 62 insertions(+), 16 deletions(-) create mode 100644 cmd/stat/route.pl diff --git a/Changes b/Changes index b4e9da25..207ce7c8 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,7 @@ +08May20======================================================================= +1. Tidy up routing table +2. Add new argument to show/version (ALL or list of regexes) that allow you + to see the version and build nos of all nodes on the system. 07May20======================================================================= 1. Revert changes made since 25Apr concerning IP address reconciliation. 25Apr20======================================================================= diff --git a/cmd/show/version.pl b/cmd/show/version.pl index b57dd36c..31acc5ca 100644 --- a/cmd/show/version.pl +++ b/cmd/show/version.pl @@ -6,10 +6,26 @@ # # +my ($self, $line) = @_; my @out; -my ($year) = (gmtime($main::systime))[5]; -$year += 1900; -push @out, "DX Spider Cluster version $main::version (build $main::build git: $main::gitversion) on \u$^O"; -push @out, "Copyright (c) 1998-$year Dirk Koopman G1TLH"; +my @in = map {uc} split /\s+/, $line; + +if ($self->priv > 5 && @in) { +# $DB::single=1; + + my $q = $in[0] eq 'ALL' ? '.*' : join('|', @in); + my @n = sort {$a->call cmp $b->call} grep {$_->call =~ /^(?:$q)/} Route::Node::get_all(); + push @out, " Node Version Build PC9X via PC92"; + foreach my $n (@n) { + push @out, sprintf " %-10s %5d %5s %3s %3s", $n->call, $n->version, $n->build, yesno($n->do_pc9x), yesno($n->via_pc92); + } + push @out, ' ' . scalar @n . " Nodes found"; +} else { + my ($year) = (gmtime($main::systime))[5]; + $year += 1900; + push @out, "DX Spider Cluster version $main::version (build $main::build git: $main::gitversion) on \u$^O"; + push @out, "Copyright (c) 1998-$year Dirk Koopman G1TLH"; +} + return (1, @out); diff --git a/cmd/stat/route.pl b/cmd/stat/route.pl new file mode 100644 index 00000000..57012eb8 --- /dev/null +++ b/cmd/stat/route.pl @@ -0,0 +1,28 @@ +# +# show a Route thingy +# +# Copyright (c) 2020 Dirk Koopman G1TLH +# +# A general purpose Route get thingy, use stat/route_user or _node if +# you want a list of all that particular type of thingy otherwise this +# is likely to be less typing and will dwym. +# + +my ($self, $line) = @_; +my @out; +my @list = split /\s+/, $line; # generate a list of callsigns + +push @list, $self->call unless @list; + +foreach my $call (@list) { + $call = uc $call; + my $ref = Route::get($call); + if ($ref) { + push @out, print_all_fields($self, $ref, "Route::User Information $call"); + } else { + push @out, "Route: $call not found"; + } + push @out, "" if @list > 1; +} + +return (1, @out); diff --git a/cmd/stat/route_node.pl b/cmd/stat/route_node.pl index 05560e70..0c7f2224 100644 --- a/cmd/stat/route_node.pl +++ b/cmd/stat/route_node.pl @@ -9,7 +9,7 @@ my ($self, $line) = @_; my @out; my @list = split /\s+/, $line; # generate a list of callsigns -@list = ($self->call) if !@list; # my channel if no callsigns +@list = ($self->call) unless @list; # my channel if no callsigns if ($self->priv > 5 && @list && uc $list[0] eq 'ALL') { push @out, "Node Callsigns in Routing Table"; @list = sort map {$_->call} Route::Node::get_all(); diff --git a/perl/DXProtHandle.pm b/perl/DXProtHandle.pm index 5193a227..40271df7 100644 --- a/perl/DXProtHandle.pm +++ b/perl/DXProtHandle.pm @@ -1480,7 +1480,7 @@ sub _add_thingy my @rout; # remove spurious IPV6 prefix on IPV4 addresses - $ip =~ s/^::ffff://; + $ip =~ s/^::ffff:// if $ip; if ($call) { my $ncall = $parent->call; diff --git a/perl/DXUtil.pm b/perl/DXUtil.pm index 8bb9b956..551a6192 100644 --- a/perl/DXUtil.pm +++ b/perl/DXUtil.pm @@ -182,7 +182,7 @@ sub ptimelist my $ref = shift; my $out; for (sort keys %$ref) { - $out .= "$_=$ref->{$_}, "; + $out .= "$_=" . atime($ref->{$_}) . ", "; } chop $out; chop $out; diff --git a/perl/Route.pm b/perl/Route.pm index 6c8c44a8..9e592644 100644 --- a/perl/Route.pm +++ b/perl/Route.pm @@ -25,6 +25,7 @@ use strict; use vars qw(%list %valid $filterdef $maxlevel); %valid = ( + parent => '0,Parent Calls,parray', call => "0,Callsign", flags => "0,Flags,phex", dxcc => '0,Country Code', @@ -32,6 +33,7 @@ use vars qw(%list %valid $filterdef $maxlevel); cq => '0,CQ Zone', state => '0,State', city => '0,City', + ip => '0,IP Address', ); $filterdef = bless ([ diff --git a/perl/Route/Node.pm b/perl/Route/Node.pm index 89e84d40..193fb8de 100644 --- a/perl/Route/Node.pm +++ b/perl/Route/Node.pm @@ -19,7 +19,6 @@ use vars qw(%list %valid @ISA $max $filterdef $obscount); @ISA = qw(Route); %valid = ( - parent => '0,Parent Calls,parray', nodes => '0,Nodes,parray', users => '0,Users,parray', usercount => '0,User Count', @@ -29,11 +28,10 @@ use vars qw(%list %valid @ISA $max $filterdef $obscount); lastmsg => '0,Last Route Msg,atime', lastid => '0,Last Route MsgID', do_pc9x => '0,Uses pc9x,yesno', - via_pc92 => '0,Came in via pc92,yesno', + via_pc92 => '0,In via pc92?,yesno', obscount => '0,Obscount', last_PC92C => '9,Last PC92C', - PC92C_dxchan => '9,Channel of PC92C,phash', - ip => '0,IP Address', + PC92C_dxchan => '9,PC92C hops,phash', ); $filterdef = $Route::filterdef; diff --git a/perl/Route/User.pm b/perl/Route/User.pm index 0cd17029..e99def15 100644 --- a/perl/Route/User.pm +++ b/perl/Route/User.pm @@ -17,11 +17,6 @@ use strict; use vars qw(%list %valid @ISA $max $filterdef); @ISA = qw(Route); -%valid = ( - parent => '0,Parent Calls,parray', - ip => '0,IP Address', -); - $filterdef = $Route::filterdef; %list = (); $max = 0; diff --git a/perl/cluster.pl b/perl/cluster.pl index 78f2f594..18460f14 100755 --- a/perl/cluster.pl +++ b/perl/cluster.pl @@ -460,6 +460,9 @@ sub setup_start my $desc = $repo->command_oneline(['describe', '--long'], STDERR => 0); if ($desc) { my ($v, $s, $b, $g) = $desc =~ /^([\d.]+)(?:\.(\d+))?-(\d+)-g([0-9a-f]+)/; + $s ||= ''; + dbg("Git: $desc"); + dbg("Git: V=$v S=$s B=$b g=$g"); $version = $v; $build = $b || 0; $gitversion = "$g\[r]"; -- 2.43.0