#!/usr/bin/perl =for comment Part of AREDN -- Used for creating Amateur Radio Emergency Data Networks Copyright (C) 2015 Conrad Lara See Contributors file for additional contributors Copyright (c) 2013 David Rivenburg et al. BroadBand-HamNet This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation version 3 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Additional Terms: Additional use restrictions exist on the AREDN(TM) trademark and logo. See AREDNLicense.txt for more info. Attributions to the AREDN Project must be retained in the source code. If importing this code into a new or existing project attribution to the AREDN project must be added to the source code. You must not misrepresent the origin of the material contained within. Modified versions must be modified to attribute to the original source and be marked in reasonable ways as differentiate it from the original version. =cut $debug = 0; BEGIN {push @INC, '/www/cgi-bin'}; use perlfunc; use ucifunc; # 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.mesh"; $wifi_iface = get_interface("wifi"); $wifi_iface =~ /wlan(\d+)/; $radio = ( defined $1 )? "radio$1" : "radio0"; $wifi_disable = ( $wifi_iface =~ /eth.*$/ )? 1 : 0; if ( ! $wifi_disable ) { ($junk, $wifi_channel) = &uci_get_named_option("wireless", "$radio", "channel"); if ($wifi_channel >= 76 and $wifi_channel <= 99) { $wifi_channel = ($wifi_channel*5+3000); } ($junk, $wifi_chanbw) = &uci_get_named_option("wireless", "$radio", "chanbw"); $wifi_ssid = "N/A"; @wisections = &uci_get_all_indexed_by_sectiontype("wireless", "wifi-iface"); foreach(@wisections) { if ($_->{network} eq "wifi") { $wifi_ssid = $_->{ssid}; } } } $node_desc = `/sbin/uci -q get system.\@system[0].description`; #pull the node description from uci #get location info if available $lat_lon = "Location Not Available"; $lat=&uci_get_indexed_option("aredn","location",0,"lat"); $lon=&uci_get_indexed_option("aredn","location",0,"lon"); if($lat ne "" and $lon ne "") { $lat_lon = "
Location: $lat $lon
"; } $olsrTotal = `/sbin/ip route list table 30 | wc -l`; #num hosts olsr is keeping track of $olsrNodes = `/sbin/ip route list table 30 | egrep "/" | wc -l`; #num *nodes* on the network (minus other hosts) read_postdata(); if($parms{css} and -f "/www/$parms{css}" and $parms{css} =~ /\.css$/i) { unlink "/tmp/web/style.css"; symlink "/www/$parms{css}","/tmp/web/style.css"; } # generate the page http_header(); html_header("$node status", 1); print "
\n"; print "
\n"; alert_banner(); # page header print "

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

"; print "
$lat_lon
"; #display location info print "
$node_desc
" if $node_desc; print "
\n"; # nav buttons print "\n"; #print qq(\n); print "Help\n"; print "   "; print "\n"; if($config eq "mesh") { print "   "; print "\n"; if ( ! $wifi_disable ) { print "   "; print "\n"; } } print "   "; print "\n"; print "   "; print ""; print ""; 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"; print "

\n"; print "
\n"; print "

This device can be configured to either permit or prohibit known encrypted traffic on its RF link. It is up to the user to decide which is appropriate based on how it will be used and the license under which it will be operated. These rules vary by country, frequency, and intended use. You are encouraged to read and understand these rules before going further.

"; print "

This device is pre-configured with no restrictions as to the type of data being passed.

\n"; print "

Follow these steps if you wish to prohibit known encrypted traffic on the RF link. These instructions will disappear, so copy them for your reference:

"; print "

    \n"; print "
  1. Setup your node name and password as instructed at the top of this page
  2. "; print "
  3. After you Save Changes allow your node to reboot
  4. "; print "
  5. Return to the Node Status page and navigate to Setup > Administration
  6. "; print "
  7. Obtain the blockknownencryption package from the AREDN™ website OR refresh the Package list (node must be connected to the internet)
  8. "; print "
  9. Install the blockknownencryption package by uploading it or choosing it from the package drop-down list
  10. "; print "
  11. Wait until the package installs and then reboot your node
  12. "; print "

\n"; print "
"; } # status display @col1 = @col2 = (); $hide_local = 0; $browser_ip = ""; # left column - network interface info # show the Primary/Wifi address ($ip, $mask, $bcast, $net, $cidr) = get_ip4_network($wifi_iface); $cidr = "/ $cidr" if $cidr; if (! $wifi_disable ) { $str = "Wifi address$ip $cidr
"; } else { $str = "Primary address$ip $cidr
"; } # $str .= "" . get_ip6_addr($wifi_iface) . ""; 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(get_interface("lan")); 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(get_interface("lan")) . ""; push @col1, $str; } { my $wanintf = get_interface("wan"); if(not $hide_local and not system "ifconfig $wanintf >/dev/null 2>&1") { ($ip, $mask, $bcast, $net, $cidr) = get_ip4_network("$wanintf"); $cidr = "/ $cidr" if $cidr; $cidr = "" unless $cidr; $str = "WAN address$ip $cidr
"; # $str .= "" . get_ip6_addr("$wanintf") . ""; 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 ( ! $wifi_disable ) { $str = "SSID$wifi_ssid"; push @col1, $str . ""; $str = "Channel$wifi_channel"; push @col1, $str . ""; $str = "Bandwidth$wifi_chanbw MHz"; push @col1, $str . ""; } # right column - system info if($config eq "mesh" and ! $wifi_disable ) { $str = "Signal/Noise/Ratio"; ($s, $n) = get_wifi_signal($wifi_iface); 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" . `cat /etc/mesh-release`. ""; 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; push @col2, "OLSR EntriesTotal = $olsrTotal
Nodes = $olsrNodes"; #display OLSR numbers # 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(); page_footer(); print "\n"; print "\n";