mirror of https://github.com/aredn/aredn.git
bugfix: correctly show primary wifi hostname for all references, etx sort, denote dtd & tun* iface
This commit is contained in:
parent
77a5ad96c3
commit
b314c4539f
|
@ -87,6 +87,8 @@ foreach(`echo /all | nc 127.0.0.1 2006 2>$tmperr`)
|
|||
}
|
||||
elsif($table eq "MID")
|
||||
{
|
||||
($ip, $junk) = split /\s+/, $_;
|
||||
foreach $aip ( split /;/, $junk ) { $ipalias{$aip} = $ip }
|
||||
}
|
||||
elsif($table eq "Routes")
|
||||
{
|
||||
|
@ -111,20 +113,14 @@ foreach(`cat /etc/hosts`)
|
|||
chomp;
|
||||
($ip, $name, $tactical) = split /\s+/, $_;
|
||||
next if $name =~ /^(localhost|localnode|localap|dtdlink\..*)$/;
|
||||
if ( $name !~ /\.local\.mesh$/ ) { $name="${name}.local.mesh"; }
|
||||
if($ip eq $my_ip)
|
||||
{
|
||||
$tactical = "" unless $tactical;
|
||||
$localhosts{$ip}{tactical} = $tactical;
|
||||
$localhosts{$ip}{name} = $name;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $name !~ /\./ )
|
||||
{
|
||||
$name="${name}.local.mesh";
|
||||
}
|
||||
push @{$localhosts{$my_ip}{hosts}}, $name;
|
||||
}
|
||||
else { push @{$localhosts{$my_ip}{hosts}}, $name; }
|
||||
}
|
||||
|
||||
# load the olsr hosts file
|
||||
|
@ -135,36 +131,38 @@ foreach(`cat /var/run/hosts_olsr 2>/dev/null`)
|
|||
($ip, $name, $junk, $originator, $mid, $midnum) = split /\s+/, $_;
|
||||
next unless $originator;
|
||||
next if $originator eq "myself";
|
||||
if ( $name =~ /^dtdlink\..*$/ )
|
||||
{
|
||||
$hosts{$ip}{name} = $name;
|
||||
$hosts{$ip}{hide} = 1;
|
||||
next;
|
||||
}
|
||||
|
||||
if(defined $mid and $midnum =~ /^\#(\d+)/)
|
||||
{
|
||||
if ( !exists $hosts{$ip}{name} )
|
||||
{
|
||||
$hosts{$ip}{name} = $name;
|
||||
}
|
||||
$hosts{$ip}{hide} = 1;
|
||||
$hosts{$originator}{mid} = $1;
|
||||
}
|
||||
elsif($ip eq $originator)
|
||||
if ( $name !~ /\.local\.mesh$/ ) { $name="${name}.local.mesh"; }
|
||||
|
||||
if ( $ip eq $originator )
|
||||
{
|
||||
if($hosts{$ip}{name}) { $hosts{$ip}{tactical} = $name }
|
||||
else { $hosts{$ip}{name} = $name }
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $name !~ /\./ )
|
||||
$hosts{$ip}{name} = $name;
|
||||
if ( $routes{$ip} ) { $hosts{$ip}{etx} = $routes{$ip}{etx} ; }
|
||||
else { $hosts{$ip}{etx} = "99.000"; }
|
||||
}
|
||||
}
|
||||
elsif ( $name =~ /^dtdlink\..*$/ )
|
||||
{
|
||||
$name="${name}.local.mesh";
|
||||
$hosts{$ip}{name} = $name;
|
||||
if ( $routes{$ip} ) { $hosts{$ip}{etx} = $routes{$ip}{etx} ; }
|
||||
else { $hosts{$ip}{etx} = "99.000"; }
|
||||
$dtd{$originator} = 1 ;
|
||||
}
|
||||
push @{$hosts{$originator}{hosts}}, $name;
|
||||
elsif ( $name =~ /^mid\d+\..*$/ )
|
||||
{
|
||||
$midcount{$originator} = $midcount{$originator} ? $midcount{$originator}+1: 1 ;
|
||||
if (! $hosts{$ip}{name} )
|
||||
{
|
||||
if ( $routes{$ip} ) { $hosts{$ip}{etx} = $routes{$ip}{etx} ; }
|
||||
else { $hosts{$ip}{etx} = "99.000"; }
|
||||
$hosts{$ip}{name} = $name;
|
||||
}
|
||||
}
|
||||
else { push @{$hosts{$originator}{hosts}}, $name; }
|
||||
}
|
||||
|
||||
# load the olsr services file
|
||||
foreach(`cat /var/run/services_olsr 2>/dev/null`)
|
||||
|
@ -178,10 +176,7 @@ foreach(`cat /var/run/services_olsr 2>/dev/null`)
|
|||
($name, $originator) = split /\#/, $name;
|
||||
$name =~ s/\s+$//;
|
||||
|
||||
if ( $host !~ /\./ )
|
||||
{
|
||||
$host="${host}.local.mesh";
|
||||
}
|
||||
if ( $host !~ /\./ ) { $host="${host}.local.mesh"; }
|
||||
|
||||
#$host = $originator eq " my own service" ? $node : $hosts{$originator}{name};
|
||||
|
||||
|
@ -279,7 +274,7 @@ if(keys %localhosts)
|
|||
|
||||
foreach $ip (keys %localhosts)
|
||||
{
|
||||
$host = $localhosts{$ip}{name} . ".local.mesh";
|
||||
$host = $localhosts{$ip}{name};
|
||||
$tactical = $localhosts{$ip}{tactical} ? " / " . $localhosts{$ip}{tactical} : "";
|
||||
$rows{$host} = sprintf "<tr><td valign=top><nobr>%s</nobr></td><td colspan=3> </td><td>\n", $host . $tactical;
|
||||
foreach(sort keys %{$services{$host}})
|
||||
|
@ -316,40 +311,35 @@ print "<tr><th align=left><nobr>Remote Nodes</nobr></th><th> </th><th
|
|||
print "<tr><td colspan=5><hr></td></tr>\n";
|
||||
|
||||
%rows = ();
|
||||
%sortrows = ();
|
||||
foreach $ip (keys %hosts)
|
||||
{
|
||||
next if $links{$ip};
|
||||
next if exists $hosts{$ip}{hide};
|
||||
next if $ipalias{$ip};
|
||||
|
||||
$isNeig=0;
|
||||
foreach $aip (keys %ipalias)
|
||||
{
|
||||
if ($ipalias{$aip} eq $ip ) { if ($links{$aip} ) { $isNeig=1; last;} }
|
||||
}
|
||||
next if $isNeig;
|
||||
|
||||
$host = $hosts{$ip}{name};
|
||||
$tactical = $hosts{$ip}{tactical} ? " / " . $hosts{$ip}{tactical} : "";
|
||||
$etx = "unknown";
|
||||
$etx = sprintf "%.2f", $hosts{$ip}{etx};
|
||||
next if ($etx > 50 );
|
||||
|
||||
if ( $host !~ /\./ )
|
||||
{
|
||||
$host="${host}.local.mesh";
|
||||
}
|
||||
|
||||
if($routes{$ip}) # get the etx directly
|
||||
{
|
||||
$etx = sprintf "%.2f", $routes{$ip}{etx};
|
||||
}
|
||||
else # find the subnet it belongs to
|
||||
{
|
||||
foreach $net (keys %routes)
|
||||
{
|
||||
next unless (ip2decimal($ip) & $routes{$net}{mask}) == $routes{$net}{value};
|
||||
$etx = sprintf "%.2f", $routes{$net}{etx};
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
next if $etx eq "unknown";
|
||||
$rows{$host} = sprintf "<tr><td valign=top><nobr><a href='http://%s:8080/'>%s</a>", $host, $host . $tactical;
|
||||
if($midnum = $hosts{$ip}{mid}) # show mid interfaces
|
||||
|
||||
undef $nodeiface;
|
||||
if ( $dtd{$ip} )
|
||||
{
|
||||
$midnum = ($midnum > 1) ? "*$midnum" : "";
|
||||
$rows{$host} .= " <small>(mid$midnum)</small>";
|
||||
$nodeiface = "dtd";
|
||||
if ( $midcount{$ip} ) { $midcount{$ip} -= 1; } # extra mid entry matching and with dtdlink in hosts_olsrd
|
||||
}
|
||||
if ( $midcount{$ip} ) { $nodeiface = $nodeiface ? "dtd," . "tun*$midcount{$ip}" : "tun*$midcount{$ip}" ; }
|
||||
if ( $nodeiface ) { $rows{$host} .= " <small>($nodeiface)</small>"; }
|
||||
|
||||
$rows{$host} .= sprintf "</nobr></td><td></td><td align=right valign=top>%s</td><td></td><td>\n", $etx;
|
||||
foreach(sort keys %{$services{$host}})
|
||||
{
|
||||
|
@ -368,11 +358,12 @@ foreach $ip (keys %hosts)
|
|||
}
|
||||
$rows{$host} .= "</td></tr>\n";
|
||||
}
|
||||
$sortrows{$ip}=$host;
|
||||
}
|
||||
|
||||
if(keys %rows)
|
||||
{
|
||||
foreach(sort keys %rows) { print $rows{$_} }
|
||||
foreach(sort { $hosts{$a}{etx} <=> $hosts{$b}{etx} } keys %sortrows) { print $rows{$sortrows{$_}} }
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -382,7 +373,6 @@ else
|
|||
|
||||
print "</table></td><td width=20> </td><td valign=top><table>\n";
|
||||
|
||||
|
||||
# show current neighbors
|
||||
|
||||
print "<tr><th align=left><nobr>Current Neighbors</nobr></th><th> </th><th>LQ</th><th>NLQ</th><th> </th><th align=left>Services</th></tr>\n";
|
||||
|
@ -394,33 +384,38 @@ if(keys %links)
|
|||
|
||||
foreach $ip (keys %links)
|
||||
{
|
||||
$host = $hosts{$ip}{name} ? $hosts{$ip}{name} : $ip;
|
||||
$tactical = $hosts{$ip}{tactical} ? " / " . $hosts{$ip}{tactical} : "";
|
||||
|
||||
if ( $host !~ /\./ )
|
||||
{
|
||||
$host="${host}.local.mesh";
|
||||
}
|
||||
$ipmain = exists $ipalias{$ip} ? $ipalias{$ip} : $ip ;
|
||||
$host = $hosts{$ipmain}{name} ? $hosts{$ipmain}{name} : $ipmain;
|
||||
$tactical = $hosts{$ipmain}{tactical} ? " / " . $hosts{$ipmain}{tactical} : "";
|
||||
|
||||
$rows{$host} = sprintf "<tr><td valign=top><nobr><a href='http://%s:8080/'>%s</a>", $host, $host . $tactical;
|
||||
|
||||
if($midnum = $hosts{$ip}{mid}) # show mid interfaces
|
||||
if ( $ipmain ne $ip ) # indicate if dtd or tunnel interface to neighbor
|
||||
{
|
||||
$midnum = ($midnum > 1) ? "*$midnum" : "";
|
||||
$rows{$host} .= " <small>(mid$midnum)</small>";
|
||||
if ( $hosts{$ip}{name} =~ /^dtdlink\..*$/ ){ $linktype="dtd" ; }
|
||||
elsif ( $hosts{$ip}{name} =~ /^mid\d+\..*$/ ) { $linktype="tun" ; }
|
||||
else { $linktype="?" ; }
|
||||
|
||||
$rows{$host} .= " <small>($linktype)</small>";
|
||||
}
|
||||
|
||||
$rows{$host} .= sprintf ("</nobr></td><td></td><td align=right valign=top>%.0f%%</td><td align=right valign=top>%.0f%%</td><td></td><td>\n", 100*$links{$ip}{lq}, 100*$links{$ip}{nlq});
|
||||
|
||||
if ( ! exists $neighservices{$host} )
|
||||
{
|
||||
foreach(sort keys %{$services{$host}}) { $rows{$host} .= "<nobr>" . $services{$host}{$_} . "</nobr><br>\n" }
|
||||
|
||||
$rows{$host} .= "</td></tr>\n";
|
||||
|
||||
# add advertised dmz hosts
|
||||
foreach $dmzhost (@{$hosts{$ip}{hosts}})
|
||||
foreach $dmzhost (@{$hosts{$ipmain}{hosts}})
|
||||
{
|
||||
$rows{$host} .= "<tr><td valign=top><nobr> <img src='/dot.png'>$dmzhost</nobr></td><td colspan=3></td><td>\n";
|
||||
foreach(sort keys %{$services{$dmzhost}}) { $rows{$host} .= $services{$dmzhost}{$_} . "<br>\n" }
|
||||
$rows{$host} .= "</td></tr>\n";
|
||||
}
|
||||
$neighservices{$host}=1;
|
||||
}
|
||||
}
|
||||
|
||||
foreach(sort keys %rows) { print $rows{$_} }
|
||||
|
@ -490,7 +485,8 @@ if($debug)
|
|||
}
|
||||
|
||||
print "\nhosts\n";
|
||||
foreach $ip (sort keys %hosts)
|
||||
#foreach $ip (sort keys %hosts)
|
||||
foreach $ip (sort { $hosts{$a}{etx} <=> $hosts{$b}{etx} } keys %hosts)
|
||||
{
|
||||
$hosts{$ip}{name} = "" unless $hosts{$ip}{name};
|
||||
printf "%s %s", $ip, $hosts{$ip}{name};
|
||||
|
@ -498,6 +494,7 @@ if($debug)
|
|||
foreach(@{$hosts{$ip}{hosts}}) { print ":$_" }
|
||||
printf(" %d", $hosts{$ip}{mid}) if $hosts{$ip}{mid};
|
||||
print "\n";
|
||||
print "ETX=$hosts{$ip}{etx}\n";
|
||||
}
|
||||
|
||||
print "\nlinks\n";
|
||||
|
|
Loading…
Reference in New Issue