tidy up Route, add argument to sh/ver
authorDirk Koopman <djk@tobit.co.uk>
Fri, 8 May 2020 15:06:53 +0000 (16:06 +0100)
committerDirk Koopman <djk@tobit.co.uk>
Fri, 8 May 2020 15:06:53 +0000 (16:06 +0100)
Changes
cmd/show/version.pl
cmd/stat/route.pl [new file with mode: 0644]
cmd/stat/route_node.pl
perl/DXProtHandle.pm
perl/DXUtil.pm
perl/Route.pm
perl/Route/Node.pm
perl/Route/User.pm
perl/cluster.pl

diff --git a/Changes b/Changes
index b4e9da25e84dca7d2c7458008d5375add1f300a7..207ce7c8b5cfa344f80f15a0ada6ac237f92a307 100644 (file)
--- 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=======================================================================
index b57dd36c258d52a916fbf12748dc2e48055af736..31acc5caddcd10a5d425003d4a9857d316cde9a0 100644 (file)
@@ -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 (file)
index 0000000..57012eb
--- /dev/null
@@ -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);
index 05560e70762d5c4e5c230d986122efb658c8139a..0c7f222471f6de74a7b4a116ed10fe4651d4834b 100644 (file)
@@ -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();
index 5193a227043bb3d1a4a28430560ebf2a415f81c0..40271df7965877b6c4217b5ef5e1c36a1fef5006 100644 (file)
@@ -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;
index 8bb9b956c59d306b8aab36b6cab0807bca10c5bd..551a61921213ec00b90ab8a29738929bb0d647ce 100644 (file)
@@ -182,7 +182,7 @@ sub ptimelist
        my $ref = shift;
        my $out;
        for (sort keys %$ref) {
-               $out .= "$_=$ref->{$_}, ";
+               $out .= "$_=" . atime($ref->{$_}) . ", ";
        }
        chop $out;
        chop $out;
index 6c8c44a858653adc507374f7dea9099c6c2ff39f..9e5926442b4f40e0e409bb4224cdc6927f44d498 100644 (file)
@@ -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 ([
index 89e84d4072b1910b83b6b41d05c2d50431df2b4e..193fb8de3d29ae55c2a4cf21fa67e879319d690c 100644 (file)
@@ -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;
index 0cd170299f482243af45b801d767376d48d6bdda..e99def158bcedfa087028790ae74882160c4ed44 100644 (file)
@@ -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;
index 78f2f594b02706bcf7e44b1ffeaa4fbb9ad0c672..18460f14298a942753c7abba3025e892427ec4d6 100755 (executable)
@@ -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]";