#!/usr/bin/perl $debug = 0; BEGIN {push @INC, '/www/cgi-bin'}; use perlfunc; # collect some variables $node = nvram_get("node"); $node = "NOCALL" if $node eq ""; $tactical = nvram_get("tactical"); $config = nvram_get("config"); $config = "not set" if $config eq "" or not -d "/etc/config.$config"; read_postdata(); # set up the day/night style sheet system "mkdir -p /tmp/web; cp -f /www/day.css /tmp/web/style.css" unless -f "/tmp/web/style.css"; if($parms{night}) { system "touch /tmp/.night; cp -f /www/night.css /tmp/web/style.css" } elsif(not $parms{reload}) { $parms{night} = 1 if -f "/tmp/.night" } else { system "rm -f /tmp/.night; cp -f /www/day.css /tmp/web/style.css" } #system "rm -rf /tmp/web"; # generate the page http_header(); html_header("Broadband-Hamnet Node $node", 1); print "
\n"; print "
\n"; alert_banner(); # page header print "

$node"; print " / $tactical" if $tactical; print "

"; print "
\n"; # nav buttons print "\n"; #print qq(\n); print "Help\n"; print "   "; print "\n"; if($config eq "mesh") { print "   "; print "\n"; print "   "; print "\n"; } if($config eq "mesh" or $config eq "client") { print "   "; print "\n"; } print "   "; print "\n"; print "   "; print "Night Mode\n"; print "\n"; if($config eq "not set") { print "

This node is not yet configured.
"; print "Go to the setup page and set your node name and password.
\n"; print "Click Save Changes, even if you didn't make any changes, then the node will reboot.
\n"; } # status display @col1 = @col2 = (); $hide_local = 0; $browser_ip = ""; # left column - network interface info if(system "ifconfig br-lan >/dev/null 2>&1") # lan not bridged { # show the wifi address ($ip, $mask, $bcast, $net, $cidr) = get_ip4_network("wlan0"); $cidr = "/ $cidr" if $cidr; $str = "WiFi address$ip $cidr
"; $str .= "" . get_ip6_addr("wlan0") . ""; push @col1, $str; # find out if the browser is on this node's lan # if not, hide the local network details ($ip, $mask, $bcast, $net, $cidr) = get_ip4_network("eth0"); if($ENV{REMOTE_ADDR} =~ /::ffff:([\d\.]+)/) { $browser_ip = $1; $hide_local = 1 unless validate_same_subnet($browser_ip, $ip, $mask); } if($ip =~ /^10\./ or not $hide_local) { $cidr = "/ $cidr" if $cidr; $str = "LAN address$ip $cidr
"; $str .= "" . get_ip6_addr("eth0") . ""; push @col1, $str; } } else # lan is bridged { # show the wifi/lan bridge address unless the browser is on a different network ($ip, $mask, $bcast, $net, $cidr) = get_ip4_network("br-lan"); if($ENV{REMOTE_ADDR} =~ /::ffff:([\d\.]+)/) { $browser_ip = $1; $hide_local = 1 unless validate_same_subnet($browser_ip, $ip, $mask); } unless($hide_local) { $cidr = "/ $cidr" if $cidr; $str = "WiFi/LAN address$ip $cidr
"; $str .= "" . get_ip6_addr("br-lan") . ""; push @col1, $str; } } if(not $hide_local and not system "ifconfig eth0.1 >/dev/null 2>&1") { ($ip, $mask, $bcast, $net, $cidr) = get_ip4_network("eth0.1"); $cidr = "/ $cidr" if $cidr; $cidr = "" unless $cidr; $str = "WAN address$ip $cidr
"; $str .= "" . get_ip6_addr("eth0.1") . ""; push @col1, $str; } $ip = get_default_gw(); if($ip =~ /^10\./ or not $hide_local) { $str = "default gateway$ip"; $str .= "
" . mesh_ip2hostname($ip) . "" if $ip =~ /^10\./; push @col1, $str . ""; } if($browser_ip) { $str = "your address$browser_ip"; $str .= "
" . mesh_ip2hostname($browser_ip) . "";# if $ip =~ /^10\./; push @col1, $str . ""; } if(-f "/tmp/olsrd.log") { chomp($lines = `wc -l /tmp/olsrd.log | awk '{print \$1}'`); chomp($start = `tail -n1 /tmp/olsrd.log | awk '{print \$1}'`); chomp($uptime = `cat /proc/uptime | cut -f1 -d.`); $uptime -= $start; $up_d = int($uptime/86400); $uptime -= $up_d*86400; $up_h = int($uptime/3600); $uptime -= $up_h*3600; $up_m = int($uptime/60); $up_s = $uptime - $up_m*60; $str = "OLSR restarts
runtime"; $str .= sprintf "%d
%d - %02d:%02d:%02d", $lines, $up_d, $up_h, $up_m, $up_s; push @col1, " "; push @col1, $str; } # right column - system info if($config eq "mesh" or $config eq "client") { $str = "Signal/Noise/Ratio"; ($s, $n) = get_wifi_signal("wlan0"); if($s eq "N/A") { $str .= "N/A" } else { $str .= sprintf "%d / %d / %d dB", $s, $n, $s - $n } $str .= "   "; $str .= "\n"; $str .= ""; push @col2, $str; } push @col2, "firmware version
configuration" . `cat /etc/mesh-release` . "
$config"; push @col2, "system time" . `date +'%a %b %e %Y
%T %Z'` . ""; $uptime = `uptime`; $uptime =~ s/^ ..:..:.. up //; ($uptime, $load) = $uptime =~ /(.*), load average: (.*)/; push @col2, "uptime
load average$uptime
$load"; $str = "free spaceflash = "; $space = get_free_space("/overlay"); $str .= $space < 100 ? "$space KB" : "$space KB"; $str .= "
/tmp = "; $space = get_free_space("/tmp"); $str .= $space < 3000 ? "$space KB" : "$space KB"; $str .= "
memory = "; $space = get_free_mem(); $str .= $space < 500 ? "$space KB" : "$space KB"; $str .= ""; push @col2, $str; # now print the tables print "

\n"; print "
\n"; foreach(@col1) { print "$_\n" } print "
\n"; foreach(@col2) { print "$_\n" } print "
\n"; # end print "
\n"; print "
\n"; show_debug_info(); show_parse_errors(); print "\n"; print "\n";