remove any leading ::ffff: on ipv4 addresses
[spider.git] / cmd / links.pl
index cfae3b365f6bc9488c743cb02cd9e18cc25e728a..e53917b4f0e282f6a5541b5cd2f34ba0360e162b 100644 (file)
@@ -7,7 +7,7 @@
 # and subsequently plagerized by K1XX.
 #
 # 16-Jun-2000
-# $Id$
+#
 #
 
 my $self = shift;
@@ -16,7 +16,7 @@ my @out;
 my $nowt = time;
 
 push @out, "                                      Ave  Obs  Ping  Next      Filters";
-push @out, "  Callsign Type Started               RTT Count Int.  Ping Iso? In  Out PC92?";
+push @out, "  Callsign Type Started               RTT Count Int.  Ping Iso? In  Out PC92? Address";
 
 foreach $dxchan ( sort {$a->call cmp $b->call} DXChannel::get_all_nodes ) {
        my $call = $dxchan->call();
@@ -25,12 +25,14 @@ foreach $dxchan ( sort {$a->call cmp $b->call} DXChannel::get_all_nodes ) {
        my $sort;
        my $name = $dxchan->user->name || " ";
        my $obscount = $dxchan->nopings;
-       my $lastt = $dxchan->pingint - ($nowt - $dxchan->lastping);
        my $pingint = $dxchan->pingint;
+       my $lastt = $dxchan->lastping ? ($dxchan->pingint - ($nowt - $dxchan->lastping)) : $pingint;
        my $ping = $dxchan->is_node && $dxchan != $main::me ? sprintf("%8.2f",$dxchan->pingave) : "";
        my $iso = $dxchan->isolate ? 'Y' :' ';
-       my ($fin, $fout) = (' ', ' ');
-       unless ($dxchan->do_pc92) {
+       my ($fin, $fout, $pc92) = (' ', ' ', ' ');
+       if ($dxchan->do_pc9x) {
+               $pc92 = 'Y';
+       } else {
                my $f;
                if ($f = $dxchan->inroutefilter) {
                        $fin = $dxchan->inroutefilter =~ /node_default/ ? 'D' : 'Y';
@@ -39,14 +41,26 @@ foreach $dxchan ( sort {$a->call cmp $b->call} DXChannel::get_all_nodes ) {
                        $fout = $dxchan->routefilter =~ /node_default/ ? 'D' : 'Y';
                }
        }
-       $sort = 'ANEA' if $dxchan->is_aranea;
+       unless ($pingint) {
+               $lastt = 0;
+               $ping = "        ";
+       }
+
        $sort = "DXSP" if $dxchan->is_spider;
        $sort = "CLX " if $dxchan->is_clx;
        $sort = "DXNT" if $dxchan->is_dxnet;
        $sort = "AR-C" if $dxchan->is_arcluster;
        $sort = "AK1A" if $dxchan->is_ak1a;
-       my $pc92 = $dxchan->do_pc9x ? 'Y' : '';
-       push @out, sprintf "%10s $sort $t$ping   $obscount  %5d %5d  $iso    $fin   $fout   $pc92", $call, $pingint, $lastt;
+       my $ipaddr;
+
+       my $addr = $dxchan->hostname;
+       if ($addr) {
+           $ipaddr = $addr if is_ipaddr($addr);
+               $ipaddr = 'local' if $addr =~ /^127\./ || $addr =~ /^::[0-9a-f]+$/;
+       }
+       $ipaddr = 'ax25' if $dxchan->conn->ax25;
+
+       push @out, sprintf "%10s $sort $t$ping   $obscount  %5d %5d  $iso    $fin   $fout   $pc92    $ipaddr", $call, $pingint, $lastt;
 }
 
 return (1, @out)