mirror of https://github.com/aredn/aredn.git
Fix library requires (#1147)
* Another attempt to stop the mesh page from being truncated sometimes * Fix originator * Fix the require(...) libraries
This commit is contained in:
parent
9b89db7a7f
commit
d8b85d5b4a
|
@ -35,7 +35,7 @@
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
require("uci")
|
require("uci")
|
||||||
local olsr = require("aredn.olsr")
|
require("aredn.olsr")
|
||||||
|
|
||||||
local dns_file = "/tmp/dnsmasq.d/supernode.conf"
|
local dns_file = "/tmp/dnsmasq.d/supernode.conf"
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ end
|
||||||
|
|
||||||
-- Find the first supernode to use as a nameserver
|
-- Find the first supernode to use as a nameserver
|
||||||
local dns = ""
|
local dns = ""
|
||||||
for _, hna in ipairs(olsr.getOLSRHNA())
|
for _, hna in ipairs(aredn.olsr.getOLSRHNA())
|
||||||
do
|
do
|
||||||
if hna.genmask == 8 and hna.destination == "10.0.0.0" then
|
if hna.genmask == 8 and hna.destination == "10.0.0.0" then
|
||||||
dns = "#" .. hna.gateway .. "\nserver=/local.mesh/" .. hna.gateway .. "\nrev-server=10.0.0.0/8," .. hna.gateway .. "\nrev-server=172.31.0.0/16," .. hna.gateway .. "\nrev-server=172.30.0.0/16," .. hna.gateway .. "\n"
|
dns = "#" .. hna.gateway .. "\nserver=/local.mesh/" .. hna.gateway .. "\nrev-server=10.0.0.0/8," .. hna.gateway .. "\nrev-server=172.31.0.0/16," .. hna.gateway .. "\nrev-server=172.30.0.0/16," .. hna.gateway .. "\n"
|
||||||
|
|
|
@ -11,7 +11,7 @@ no-negcache
|
||||||
resolv-file=/tmp/resolv.conf.auto
|
resolv-file=/tmp/resolv.conf.auto
|
||||||
|
|
||||||
# include olsr nameservice
|
# include olsr nameservice
|
||||||
addn-hosts=/var/run/hosts_olsr.stable
|
addn-hosts=/var/run/hosts_olsr
|
||||||
|
|
||||||
dhcp-authoritative
|
dhcp-authoritative
|
||||||
dhcp-leasefile=/tmp/dhcp.leases
|
dhcp-leasefile=/tmp/dhcp.leases
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
version.
|
version.
|
||||||
|
|
||||||
--]]
|
--]]
|
||||||
local aredn_info = require("aredn.info")
|
require("aredn.info")
|
||||||
require("aredn.utils")
|
require("aredn.utils")
|
||||||
|
|
||||||
-- -------------------------------------
|
-- -------------------------------------
|
||||||
|
@ -80,4 +80,4 @@ function module:POST()
|
||||||
return res
|
return res
|
||||||
end
|
end
|
||||||
|
|
||||||
return module
|
return module
|
||||||
|
|
|
@ -33,8 +33,8 @@
|
||||||
version.
|
version.
|
||||||
|
|
||||||
--]]
|
--]]
|
||||||
local aredn_info = require("aredn.info")
|
require("aredn.info")
|
||||||
local aredn_hardware = require("aredn.hardware")
|
require("aredn.hardware")
|
||||||
require("aredn.utils")
|
require("aredn.utils")
|
||||||
|
|
||||||
-- -------------------------------------
|
-- -------------------------------------
|
||||||
|
@ -68,31 +68,31 @@ function module:GET()
|
||||||
local res={}
|
local res={}
|
||||||
local data={}
|
local data={}
|
||||||
data.basic = {}
|
data.basic = {}
|
||||||
data.basic.nodename = aredn_info.getNodeName()
|
data.basic.nodename = aredn.info.getNodeName()
|
||||||
data.basic.description = aredn_info.getNodeDescription()
|
data.basic.description = aredn.info.getNodeDescription()
|
||||||
-- password :: "WE CANNOT RETRIEVE THE PASSWORD"
|
-- password :: "WE CANNOT RETRIEVE THE PASSWORD"
|
||||||
|
|
||||||
-- MESHRF
|
-- MESHRF
|
||||||
radio = aredn_info.getMeshRadioDevice()
|
radio = aredn.info.getMeshRadioDevice()
|
||||||
data.meshrf = {}
|
data.meshrf = {}
|
||||||
data.meshrf.ssid_full = aredn_info.getSSID()
|
data.meshrf.ssid_full = aredn.info.getSSID()
|
||||||
data.meshrf.ssid_prefix = data['meshrf']['ssid_full']:split("-")[1]
|
data.meshrf.ssid_prefix = data['meshrf']['ssid_full']:split("-")[1]
|
||||||
data.meshrf.enabled = aredn_info.isMeshRadioEnabled(radio)
|
data.meshrf.enabled = aredn.info.isMeshRadioEnabled(radio)
|
||||||
data.meshrf.ip = aredn_info.getInterfaceIPAddress("wifi")
|
data.meshrf.ip = aredn.info.getInterfaceIPAddress("wifi")
|
||||||
data.meshrf.netmask = aredn_info.getInterfaceNetmask("wifi")
|
data.meshrf.netmask = aredn.info.getInterfaceNetmask("wifi")
|
||||||
data.meshrf.distance = aredn_info.getMeshRadioDistance(radio)
|
data.meshrf.distance = aredn.info.getMeshRadioDistance(radio)
|
||||||
data.meshrf.bw = aredn_info.getChannelBW(radio)
|
data.meshrf.bw = aredn.info.getChannelBW(radio)
|
||||||
data.meshrf.channel = aredn_info.getChannel(radio)
|
data.meshrf.channel = aredn.info.getChannel(radio)
|
||||||
data.meshrf.power = aredn_info.getTXPower(radio)
|
data.meshrf.power = aredn.info.getTXPower(radio)
|
||||||
data.meshrf.maxpower = aredn_hardware.wifi_maxpower(radio, data['meshrf']['channel'])
|
data.meshrf.maxpower = aredn.hardware.wifi_maxpower(radio, data['meshrf']['channel'])
|
||||||
|
|
||||||
|
|
||||||
-- LAN
|
-- LAN
|
||||||
data.lan = {}
|
data.lan = {}
|
||||||
data.lan.mode = aredn_info.getLANMode()
|
data.lan.mode = aredn.info.getLANMode()
|
||||||
data.lan.dhcp = aredn_info.isLANDHCPEnabled()
|
data.lan.dhcp = aredn.info.isLANDHCPEnabled()
|
||||||
data.lan.ip = aredn_info.getInterfaceIPAddress("lan")
|
data.lan.ip = aredn.info.getInterfaceIPAddress("lan")
|
||||||
data.lan.netmask = aredn_info.getInterfaceNetmask("lan")
|
data.lan.netmask = aredn.info.getInterfaceNetmask("lan")
|
||||||
-- dhcp_start
|
-- dhcp_start
|
||||||
-- dhcp_end
|
-- dhcp_end
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ function module:GET()
|
||||||
|
|
||||||
-- WAN Advanced
|
-- WAN Advanced
|
||||||
data.wanadv = {}
|
data.wanadv = {}
|
||||||
data.wanadv.meshgw = aredn_info.isMeshGatewayEnabled()
|
data.wanadv.meshgw = aredn.info.isMeshGatewayEnabled()
|
||||||
|
|
||||||
-- WAN Wifi Client
|
-- WAN Wifi Client
|
||||||
data.wanclient = {}
|
data.wanclient = {}
|
||||||
|
|
|
@ -207,12 +207,12 @@ function html.wait_for_reboot(delay, countdown)
|
||||||
end
|
end
|
||||||
|
|
||||||
function html.reboot()
|
function html.reboot()
|
||||||
local aredn_info = require("aredn.info")
|
require("aredn.info")
|
||||||
require("aredn.hardware")
|
require("aredn.hardware")
|
||||||
require("aredn.http")
|
require("aredn.http")
|
||||||
require("uci")
|
require("uci")
|
||||||
|
|
||||||
local node = aredn_info.get_nvram("node")
|
local node = aredn.info.get_nvram("node")
|
||||||
if node == "" then
|
if node == "" then
|
||||||
node = "Node"
|
node = "Node"
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
require("uci")
|
require("uci")
|
||||||
local aredn_uci = require("aredn.uci")
|
local aredn_uci = require("aredn.uci")
|
||||||
require("aredn.utils")
|
require("aredn.utils")
|
||||||
|
|
||||||
local lip=require("luci.ip")
|
local lip=require("luci.ip")
|
||||||
require("nixio")
|
require("nixio")
|
||||||
require("ubus")
|
require("ubus")
|
||||||
|
@ -330,12 +329,10 @@ function model.all_services()
|
||||||
local services={}
|
local services={}
|
||||||
local lines={}
|
local lines={}
|
||||||
local pos, val
|
local pos, val
|
||||||
local hfile=io.open("/var/run/services_olsr","r")
|
for line in aredn.olsr.getServicesAsLines() do
|
||||||
if hfile~=nil then
|
table.insert(lines,line)
|
||||||
for line in hfile:lines() do
|
end
|
||||||
table.insert(lines,line)
|
if #lines > 0 then
|
||||||
end
|
|
||||||
hfile:close()
|
|
||||||
for pos,val in pairs(lines) do
|
for pos,val in pairs(lines) do
|
||||||
local service={}
|
local service={}
|
||||||
local link,protocol,name,ip = string.match(val,"^([^|]*)|(.+)|([^\t]*)\t#(.*)")
|
local link,protocol,name,ip = string.match(val,"^([^|]*)|(.+)|([^\t]*)\t#(.*)")
|
||||||
|
@ -366,15 +363,14 @@ end
|
||||||
-- Return *All* Hosts
|
-- Return *All* Hosts
|
||||||
-------------------------------------
|
-------------------------------------
|
||||||
function model.all_hosts()
|
function model.all_hosts()
|
||||||
|
require("aredn.olsr")
|
||||||
local hosts={}
|
local hosts={}
|
||||||
local lines={}
|
local lines={}
|
||||||
local pos, val
|
local pos, val
|
||||||
local hfile=io.open("/var/run/hosts_olsr.stable","r")
|
for line in aredn.olsr.getHostAsLines() do
|
||||||
if hfile~=nil then
|
table.insert(lines,line)
|
||||||
for line in hfile:lines() do
|
end
|
||||||
table.insert(lines,line)
|
if #lines > 0 then
|
||||||
end
|
|
||||||
hfile:close()
|
|
||||||
for pos,val in pairs(lines) do
|
for pos,val in pairs(lines) do
|
||||||
local host={}
|
local host={}
|
||||||
|
|
||||||
|
@ -585,7 +581,7 @@ end
|
||||||
-------------------------------------
|
-------------------------------------
|
||||||
function model.getLocalHosts()
|
function model.getLocalHosts()
|
||||||
local localhosts = {}
|
local localhosts = {}
|
||||||
myhosts=os.capture('/bin/grep "# myself" /var/run/hosts_olsr.stable|grep -v dtdlink')
|
myhosts=os.capture('/bin/grep "# myself" /var/run/hosts_olsr|grep -v dtdlink')
|
||||||
local lines = myhosts:splitNewLine()
|
local lines = myhosts:splitNewLine()
|
||||||
data = {}
|
data = {}
|
||||||
for k,v in pairs(lines) do
|
for k,v in pairs(lines) do
|
||||||
|
|
|
@ -35,17 +35,17 @@
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
require("aredn.utils")
|
require("aredn.utils")
|
||||||
local aredn_info = require("aredn.info")
|
require("aredn.info")
|
||||||
require("aredn.hardware")
|
require("aredn.hardware")
|
||||||
require("uci")
|
require("uci")
|
||||||
|
|
||||||
local needsrun = aredn_info.get_nvram("nodeupgraded")
|
local needsrun = aredn.info.get_nvram("nodeupgraded")
|
||||||
if needsrun == "" or needsrun == "0" then
|
if needsrun == "" or needsrun == "0" then
|
||||||
print "Node not upgraded, exiting"
|
print "Node not upgraded, exiting"
|
||||||
os.exit(0)
|
os.exit(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
local config = aredn_info.get_nvram("config")
|
local config = aredn.info.get_nvram("config")
|
||||||
if config ~= "mesh" then
|
if config ~= "mesh" then
|
||||||
print "This node was previously configured in non-mesh mode and is no longer implemented. Returning to 'firstboot'."
|
print "This node was previously configured in non-mesh mode and is no longer implemented. Returning to 'firstboot'."
|
||||||
local f = io.popen("firstboot -y && reboot")
|
local f = io.popen("firstboot -y && reboot")
|
||||||
|
@ -54,7 +54,7 @@ if config ~= "mesh" then
|
||||||
os.exit(1)
|
os.exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
local node = aredn_info.get_nvram("node")
|
local node = aredn.info.get_nvram("node")
|
||||||
local mac2 = mac_to_ip(aredn.hardware.get_interface_mac(aredn.hardware.get_iface_name("wifi")), 0)
|
local mac2 = mac_to_ip(aredn.hardware.get_interface_mac(aredn.hardware.get_iface_name("wifi")), 0)
|
||||||
local dtdmac = mac_to_ip(aredn.hardware.get_interface_mac(aredn.hardware.get_iface_name("lan")), 0)
|
local dtdmac = mac_to_ip(aredn.hardware.get_interface_mac(aredn.hardware.get_iface_name("lan")), 0)
|
||||||
|
|
||||||
|
@ -124,6 +124,6 @@ os.remove("/tmp/.mesh_setup")
|
||||||
|
|
||||||
os.execute("/usr/local/bin/node-setup")
|
os.execute("/usr/local/bin/node-setup")
|
||||||
|
|
||||||
aredn_info.set_nvram("nodeupgraded", "0")
|
aredn.info.set_nvram("nodeupgraded", "0")
|
||||||
print "Rebooting node"
|
print "Rebooting node"
|
||||||
os.execute("reboot >/dev/null 2>&1")
|
os.execute("reboot >/dev/null 2>&1")
|
||||||
|
|
|
@ -42,6 +42,7 @@ require("aredn.utils")
|
||||||
require("iwinfo")
|
require("iwinfo")
|
||||||
require("aredn.hardware")
|
require("aredn.hardware")
|
||||||
require("aredn.log")
|
require("aredn.log")
|
||||||
|
require("aredn.olsr")
|
||||||
require("luci.jsonc")
|
require("luci.jsonc")
|
||||||
require("ubus")
|
require("ubus")
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
local ip = require("luci.ip")
|
local ip = require("luci.ip")
|
||||||
local info = require("aredn.info")
|
require("aredn.info")
|
||||||
local socket = require("socket")
|
local socket = require("socket")
|
||||||
|
|
||||||
local refresh_timeout = 15 * 60 -- refresh high cost data every 15 minutes
|
local refresh_timeout = 15 * 60 -- refresh high cost data every 15 minutes
|
||||||
|
@ -204,7 +204,7 @@ function canonical_hostname(hostname)
|
||||||
return hostname
|
return hostname
|
||||||
end
|
end
|
||||||
|
|
||||||
local myhostname = canonical_hostname(info.get_nvram("node") or "localnode")
|
local myhostname = canonical_hostname(aredn.info.get_nvram("node") or "localnode")
|
||||||
local myip = uci.cursor():get("network", "wifi", "ipaddr")
|
local myip = uci.cursor():get("network", "wifi", "ipaddr")
|
||||||
|
|
||||||
-- Clear old data
|
-- Clear old data
|
||||||
|
|
|
@ -70,28 +70,26 @@ function do_namechange()
|
||||||
local subdomains = ""
|
local subdomains = ""
|
||||||
|
|
||||||
-- Load the hosts file
|
-- Load the hosts file
|
||||||
if nixio.fs.stat("/var/run/hosts_olsr.stable") then
|
for line in aredn.olsr.getHostAsLines()
|
||||||
for line in io.lines("/var/run/hosts_olsr.stable")
|
do
|
||||||
do
|
local v = line:splitWhiteSpace()
|
||||||
local v = line:splitWhiteSpace()
|
local ip = v[1]
|
||||||
local ip = v[1]
|
local name = v[2]
|
||||||
local name = v[2]
|
local originator = v[4]
|
||||||
local originator = v[4]
|
local mid = v[5]
|
||||||
local mid = v[5]
|
if ip then
|
||||||
if ip then
|
if ip:match("^%d") and originator and originator ~= "myself" and (ip == originator or mid == "(mid") then
|
||||||
if ip:match("^%d") and originator and originator ~= "myself" and (ip == originator or mid == "(mid") then
|
if hosts[ip] then
|
||||||
if hosts[ip] then
|
hosts[ip] = hosts[ip] .. "/" .. name
|
||||||
hosts[ip] = hosts[ip] .. "/" .. name
|
else
|
||||||
else
|
hosts[ip] = name
|
||||||
hosts[ip] = name
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if name and name:sub(1,2) == "*." then
|
end
|
||||||
if not name:match("%.local%.mesh$") then
|
if name and name:sub(1,2) == "*." then
|
||||||
name = name .. ".local.mesh"
|
if not name:match("%.local%.mesh$") then
|
||||||
end
|
name = name .. ".local.mesh"
|
||||||
subdomains = subdomains .. "address=/." .. name:sub(3) .. "/" .. ip .. "\n"
|
|
||||||
end
|
end
|
||||||
|
subdomains = subdomains .. "address=/." .. name:sub(3) .. "/" .. ip .. "\n"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -46,12 +46,12 @@
|
||||||
require("aredn.utils")
|
require("aredn.utils")
|
||||||
require("iwinfo")
|
require("iwinfo")
|
||||||
require("aredn.hardware")
|
require("aredn.hardware")
|
||||||
local aredn_info = require('aredn.info')
|
require('aredn.info')
|
||||||
|
|
||||||
local wifi_mac = aredn_info.get_nvram("wifimac")
|
local wifi_mac = aredn.info.get_nvram("wifimac")
|
||||||
local mac2 = aredn_info.get_nvram("mac2")
|
local mac2 = aredn.info.get_nvram("mac2")
|
||||||
local node = aredn_info.get_nvram("node")
|
local node = aredn.info.get_nvram("node")
|
||||||
local dtdmac = aredn_info.get_nvram("dtdmac")
|
local dtdmac = aredn.info.get_nvram("dtdmac")
|
||||||
|
|
||||||
local hardware_mac
|
local hardware_mac
|
||||||
if wifi_mac == "" or mac2 == "" then
|
if wifi_mac == "" or mac2 == "" then
|
||||||
|
@ -104,17 +104,17 @@ if wifi_mac == "" or mac2 == "" then
|
||||||
end
|
end
|
||||||
|
|
||||||
if wifi_mac == "" then
|
if wifi_mac == "" then
|
||||||
aredn_info.set_nvram("wifimac", hardware_mac)
|
aredn.info.set_nvram("wifimac", hardware_mac)
|
||||||
end
|
end
|
||||||
|
|
||||||
if mac2 == "" then
|
if mac2 == "" then
|
||||||
local a, b, c = hardware_mac:match("%w%w:%w%w:%w%w:(%w%w):(%w%w):(%w%w)")
|
local a, b, c = hardware_mac:match("%w%w:%w%w:%w%w:(%w%w):(%w%w):(%w%w)")
|
||||||
mac2 = string.format("%d.%d.%d", tonumber(a, 16), tonumber(b, 16), tonumber(c, 16))
|
mac2 = string.format("%d.%d.%d", tonumber(a, 16), tonumber(b, 16), tonumber(c, 16))
|
||||||
aredn_info.set_nvram("mac2", mac2)
|
aredn.info.set_nvram("mac2", mac2)
|
||||||
end
|
end
|
||||||
|
|
||||||
if node == "" then
|
if node == "" then
|
||||||
aredn_info.set_nvram("node", "NOCALL-" .. mac2:gsub("%.", "-"))
|
aredn.info.set_nvram("node", "NOCALL-" .. mac2:gsub("%.", "-"))
|
||||||
end
|
end
|
||||||
|
|
||||||
if dtdmac == "" then
|
if dtdmac == "" then
|
||||||
|
@ -127,5 +127,5 @@ if dtdmac == "" then
|
||||||
end
|
end
|
||||||
dtdmac = string.format("%d.%d.%d", a, tonumber(b, 16), tonumber(c, 16))
|
dtdmac = string.format("%d.%d.%d", a, tonumber(b, 16), tonumber(c, 16))
|
||||||
end
|
end
|
||||||
aredn_info.set_nvram("dtdmac", dtdmac)
|
aredn.info.set_nvram("dtdmac", dtdmac)
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,6 +33,4 @@
|
||||||
|
|
||||||
LICENSE
|
LICENSE
|
||||||
|
|
||||||
cp /var/run/hosts_olsr /var/run/hosts_olsr.snapshot
|
|
||||||
mv -f /var/run/hosts_olsr.snapshot /var/run/hosts_olsr.stable
|
|
||||||
touch /tmp/namechange
|
touch /tmp/namechange
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
require("nixio")
|
require("nixio")
|
||||||
require("aredn.utils")
|
require("aredn.utils")
|
||||||
require("aredn.hardware")
|
require("aredn.hardware")
|
||||||
aredn.info = require("aredn.info")
|
require("aredn.info")
|
||||||
|
|
||||||
function usage()
|
function usage()
|
||||||
print("usage: wscan [-1abnor] [-i iface]")
|
print("usage: wscan [-1abnor] [-i iface]")
|
||||||
|
|
|
@ -39,9 +39,9 @@ require("nixio")
|
||||||
require("aredn.hardware")
|
require("aredn.hardware")
|
||||||
require("aredn.http")
|
require("aredn.http")
|
||||||
require("aredn.utils")
|
require("aredn.utils")
|
||||||
aredn.html = require("aredn.html")
|
require("aredn.html")
|
||||||
require("uci")
|
require("uci")
|
||||||
aredn.info = require("aredn.info")
|
require("aredn.info")
|
||||||
require("ubus")
|
require("ubus")
|
||||||
require("luci.jsonc")
|
require("luci.jsonc")
|
||||||
|
|
||||||
|
|
|
@ -39,9 +39,9 @@ require("nixio")
|
||||||
require("aredn.hardware")
|
require("aredn.hardware")
|
||||||
require("aredn.http")
|
require("aredn.http")
|
||||||
require("aredn.utils")
|
require("aredn.utils")
|
||||||
aredn.html = require("aredn.html")
|
require("aredn.html")
|
||||||
require("uci")
|
require("uci")
|
||||||
aredn.info = require("aredn.info")
|
require("aredn.info")
|
||||||
|
|
||||||
local html = aredn.html
|
local html = aredn.html
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,6 @@ require("nixio")
|
||||||
require("aredn.hardware")
|
require("aredn.hardware")
|
||||||
require("aredn.http")
|
require("aredn.http")
|
||||||
local html = require("aredn.html")
|
local html = require("aredn.html")
|
||||||
local aredn_info = require("aredn.info")
|
|
||||||
|
|
||||||
math.randomseed(os.time())
|
math.randomseed(os.time())
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,8 @@ require("aredn.uci")
|
||||||
require("aredn.utils")
|
require("aredn.utils")
|
||||||
require("aredn.http")
|
require("aredn.http")
|
||||||
require("aredn.hardware")
|
require("aredn.hardware")
|
||||||
local aredn_olsr = require("aredn.olsr")
|
require("aredn.olsr")
|
||||||
local aredn_info = require("aredn.info")
|
require("aredn.info")
|
||||||
require("nixio")
|
require("nixio")
|
||||||
local json = require("luci.jsonc")
|
local json = require("luci.jsonc")
|
||||||
require("iwinfo")
|
require("iwinfo")
|
||||||
|
@ -55,56 +55,56 @@ os.capture = capture
|
||||||
function getSysinfo()
|
function getSysinfo()
|
||||||
local info={}
|
local info={}
|
||||||
info['api_version']=API_VERSION
|
info['api_version']=API_VERSION
|
||||||
info['node']=aredn_info.getNodeName()
|
info['node']=aredn.info.getNodeName()
|
||||||
info['tactical']=aredn_info.getTacticalName()
|
info['tactical']=aredn.info.getTacticalName()
|
||||||
info['description']=aredn_info.getNodeDescription()
|
info['description']=aredn.info.getNodeDescription()
|
||||||
info['firmware_version']=aredn_info.getFirmwareVersion()
|
info['firmware_version']=aredn.info.getFirmwareVersion()
|
||||||
info['model']=aredn_info.getModel()
|
info['model']=aredn.info.getModel()
|
||||||
--
|
--
|
||||||
info['date']=aredn_info.getDate()
|
info['date']=aredn.info.getDate()
|
||||||
info['time']=aredn_info.getTime()
|
info['time']=aredn.info.getTime()
|
||||||
--
|
--
|
||||||
info['uptime']=aredn_info.getUptime()
|
info['uptime']=aredn.info.getUptime()
|
||||||
info['loads']=aredn_info.getLoads()
|
info['loads']=aredn.info.getLoads()
|
||||||
info['first_boot']=aredn_info.getFirstBoot()
|
info['first_boot']=aredn.info.getFirstBoot()
|
||||||
info['target_type']=aredn_info.getTargetType()
|
info['target_type']=aredn.info.getTargetType()
|
||||||
return info
|
return info
|
||||||
end
|
end
|
||||||
|
|
||||||
function getAlerts()
|
function getAlerts()
|
||||||
local info={}
|
local info={}
|
||||||
info['aredn']=aredn_info.getArednAlert()
|
info['aredn']=aredn.info.getArednAlert()
|
||||||
info['local']=aredn_info.getLocalAlert()
|
info['local']=aredn.info.getLocalAlert()
|
||||||
return info
|
return info
|
||||||
end
|
end
|
||||||
|
|
||||||
function getStatusMeshRF()
|
function getStatusMeshRF()
|
||||||
local info={}
|
local info={}
|
||||||
local dev = aredn_info.getMeshRadioDevice()
|
local dev = aredn.info.getMeshRadioDevice()
|
||||||
if dev and dev ~= "" then
|
if dev and dev ~= "" then
|
||||||
info['device']= dev
|
info['device']= dev
|
||||||
info['ssid']=aredn_info.getSSID()
|
info['ssid']=aredn.info.getSSID()
|
||||||
info['channel']=aredn_info.getChannel(info['device'])
|
info['channel']=aredn.info.getChannel(info['device'])
|
||||||
info['chanbw']=aredn_info.getChannelBW(info['device'])
|
info['chanbw']=aredn.info.getChannelBW(info['device'])
|
||||||
info['band']=aredn_info.getBand(info['device'])
|
info['band']=aredn.info.getBand(info['device'])
|
||||||
info['frequency']=aredn_info.getFreq(info['device'])
|
info['frequency']=aredn.info.getFreq(info['device'])
|
||||||
end
|
end
|
||||||
return info
|
return info
|
||||||
end
|
end
|
||||||
|
|
||||||
function getStatusIp()
|
function getStatusIp()
|
||||||
local info={}
|
local info={}
|
||||||
info['gateway']=aredn_info.getDefaultGW()
|
info['gateway']=aredn.info.getDefaultGW()
|
||||||
info['wifi']=aredn_info.getInterfaceIPAddress('wifi')
|
info['wifi']=aredn.info.getInterfaceIPAddress('wifi')
|
||||||
info['lan']=aredn_info.getInterfaceIPAddress('lan')
|
info['lan']=aredn.info.getInterfaceIPAddress('lan')
|
||||||
info['wan']=aredn_info.getInterfaceIPAddress('wan')
|
info['wan']=aredn.info.getInterfaceIPAddress('wan')
|
||||||
return info
|
return info
|
||||||
end
|
end
|
||||||
|
|
||||||
function getLocationInfo()
|
function getLocationInfo()
|
||||||
local info={}
|
local info={}
|
||||||
local lat, lon= aredn_info.getLatLon()
|
local lat, lon= aredn.info.getLatLon()
|
||||||
local gs= aredn_info.getGridSquare()
|
local gs= aredn.info.getGridSquare()
|
||||||
info['lat']=lat
|
info['lat']=lat
|
||||||
info['lon']=lon
|
info['lon']=lon
|
||||||
info['gridsquare']=gs
|
info['gridsquare']=gs
|
||||||
|
@ -112,7 +112,7 @@ function getLocationInfo()
|
||||||
end
|
end
|
||||||
|
|
||||||
function getFreeMemory()
|
function getFreeMemory()
|
||||||
local info = aredn_info.getFreeMemory()
|
local info = aredn.info.getFreeMemory()
|
||||||
return info
|
return info
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ end
|
||||||
function getRemoteNodes()
|
function getRemoteNodes()
|
||||||
local info = {}
|
local info = {}
|
||||||
local neighbors = {}
|
local neighbors = {}
|
||||||
for _, v in ipairs(aredn_olsr.getOLSRLinks())
|
for _, v in ipairs(aredn.olsr.getOLSRLinks())
|
||||||
do
|
do
|
||||||
local remoteIP = v.remoteIP
|
local remoteIP = v.remoteIP
|
||||||
neighbors[remoteIP] = true
|
neighbors[remoteIP] = true
|
||||||
|
@ -143,11 +143,11 @@ function getRemoteNodes()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local routeetx = {}
|
local routeetx = {}
|
||||||
for _, v in ipairs(aredn_olsr.getOLSRRoutes())
|
for _, v in ipairs(aredn.olsr.getOLSRRoutes())
|
||||||
do
|
do
|
||||||
routeetx[v.destination] = string.format("%.2f", v.etx)
|
routeetx[v.destination] = string.format("%.2f", v.etx)
|
||||||
end
|
end
|
||||||
for line in io.lines("/var/run/hosts_olsr.stable")
|
for line in aredn.olsr.getHostAsLines()
|
||||||
do
|
do
|
||||||
local ip, hostname = line:match("^(%d+%.%d+%.%d+%.%d+)%s+(%S+)%s+#.*$")
|
local ip, hostname = line:match("^(%d+%.%d+%.%d+%.%d+)%s+(%S+)%s+#.*$")
|
||||||
if ip and not neighbors[ip] and not (hostname:match("^dtdlink%.") or hostname:match("^mid%d+%.")) then
|
if ip and not neighbors[ip] and not (hostname:match("^dtdlink%.") or hostname:match("^mid%d+%.")) then
|
||||||
|
@ -186,8 +186,8 @@ function getSignal(realtime)
|
||||||
local wifiiface=get_ifname("wifi")
|
local wifiiface=get_ifname("wifi")
|
||||||
|
|
||||||
-- get bandwidth
|
-- get bandwidth
|
||||||
local radio=aredn_info.getMeshRadioDevice()
|
local radio=aredn.info.getMeshRadioDevice()
|
||||||
local bandwidth=aredn_info.getChannelBW(radio)
|
local bandwidth=aredn.info.getChannelBW(radio)
|
||||||
|
|
||||||
local timestamp_s=os.time()
|
local timestamp_s=os.time()
|
||||||
local signal_dbm, noise_dbm, tx_rate_mbps, rx_rate_mbps, tx_rate_mcs_index, rx_rate_mcs_index
|
local signal_dbm, noise_dbm, tx_rate_mbps, rx_rate_mbps, tx_rate_mcs_index, rx_rate_mcs_index
|
||||||
|
@ -297,13 +297,13 @@ function getSignal(realtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
function getScanList()
|
function getScanList()
|
||||||
local device = aredn_info.getMeshRadioDevice()
|
local device = aredn.info.getMeshRadioDevice()
|
||||||
local scanlist = iwinfo["nl80211"].scanlist(device)
|
local scanlist = iwinfo["nl80211"].scanlist(device)
|
||||||
return scanlist
|
return scanlist
|
||||||
end
|
end
|
||||||
|
|
||||||
function getFreqList()
|
function getFreqList()
|
||||||
local device = aredn_info.getMeshRadioDevice()
|
local device = aredn.info.getMeshRadioDevice()
|
||||||
local freqlist = iwinfo["nl80211"].freqlist(device)
|
local freqlist = iwinfo["nl80211"].freqlist(device)
|
||||||
return freqlist
|
return freqlist
|
||||||
end
|
end
|
||||||
|
@ -361,9 +361,9 @@ for page, comps in pairs(qsset) do
|
||||||
elseif comp=="memory" then
|
elseif comp=="memory" then
|
||||||
info['pages'][page][comp]=getFreeMemory()
|
info['pages'][page][comp]=getFreeMemory()
|
||||||
elseif comp=="storage" then
|
elseif comp=="storage" then
|
||||||
info['pages'][page][comp]=aredn_info.getFSFree()
|
info['pages'][page][comp]=aredn.info.getFSFree()
|
||||||
elseif comp=="olsr" then
|
elseif comp=="olsr" then
|
||||||
info['pages'][page][comp]=aredn_info.getOLSRInfo()
|
info['pages'][page][comp]=aredn.info.getOLSRInfo()
|
||||||
elseif comp=="location" then
|
elseif comp=="location" then
|
||||||
info['pages'][page][comp]=getLocationInfo()
|
info['pages'][page][comp]=getLocationInfo()
|
||||||
elseif comp=="freqlist" then
|
elseif comp=="freqlist" then
|
||||||
|
@ -407,15 +407,15 @@ for page, comps in pairs(qsset) do
|
||||||
if comp=="sysinfo" then
|
if comp=="sysinfo" then
|
||||||
info['pages'][page][comp]=getSysinfo()
|
info['pages'][page][comp]=getSysinfo()
|
||||||
elseif comp=="allhosts" then
|
elseif comp=="allhosts" then
|
||||||
info['pages'][page][comp]=aredn_info.all_hosts()
|
info['pages'][page][comp]=aredn.info.all_hosts()
|
||||||
elseif comp=="localhosts" then
|
elseif comp=="localhosts" then
|
||||||
info['pages'][page][comp]=aredn_info.getLocalHosts()
|
info['pages'][page][comp]=aredn.info.getLocalHosts()
|
||||||
elseif comp=="remotenodes" then
|
elseif comp=="remotenodes" then
|
||||||
info['pages'][page][comp]=getRemoteNodes()
|
info['pages'][page][comp]=getRemoteNodes()
|
||||||
elseif comp=="currentneighbors" then
|
elseif comp=="currentneighbors" then
|
||||||
info['pages'][page][comp]=aredn_olsr.getCurrentNeighbors(true)
|
info['pages'][page][comp]=aredn.olsr.getCurrentNeighbors(true)
|
||||||
elseif comp=="services" then
|
elseif comp=="services" then
|
||||||
info['pages'][page][comp]=aredn_info.all_services()
|
info['pages'][page][comp]=aredn.info.all_services()
|
||||||
elseif comp=="previousneighbors" then
|
elseif comp=="previousneighbors" then
|
||||||
info['pages'][page][comp]={}
|
info['pages'][page][comp]={}
|
||||||
elseif comp=="topology" then
|
elseif comp=="topology" then
|
||||||
|
|
|
@ -38,8 +38,6 @@ require("uci")
|
||||||
require("aredn.uci")
|
require("aredn.uci")
|
||||||
require("aredn.utils")
|
require("aredn.utils")
|
||||||
require("aredn.http")
|
require("aredn.http")
|
||||||
local aredn_olsr = require("aredn.olsr")
|
|
||||||
local aredn_info = require("aredn.info")
|
|
||||||
require("nixio")
|
require("nixio")
|
||||||
local json = require("luci.jsonc")
|
local json = require("luci.jsonc")
|
||||||
require("iwinfo")
|
require("iwinfo")
|
||||||
|
@ -139,4 +137,4 @@ end
|
||||||
json_header()
|
json_header()
|
||||||
|
|
||||||
-- Output the info table as json
|
-- Output the info table as json
|
||||||
print(json.stringify(response,true))
|
print(json.stringify(response,true))
|
||||||
|
|
|
@ -37,9 +37,9 @@
|
||||||
require("uci")
|
require("uci")
|
||||||
require("nixio")
|
require("nixio")
|
||||||
require("aredn.utils")
|
require("aredn.utils")
|
||||||
local info = require("aredn.info")
|
require("aredn.info")
|
||||||
|
|
||||||
local node = info.get_nvram("node")
|
local node = aredn.info.get_nvram("node")
|
||||||
|
|
||||||
local q = os.getenv("QUERY_STRING") or ""
|
local q = os.getenv("QUERY_STRING") or ""
|
||||||
local server = q:match("server=([^&]*)")
|
local server = q:match("server=([^&]*)")
|
||||||
|
|
|
@ -37,7 +37,7 @@ require("uci")
|
||||||
require("aredn.http")
|
require("aredn.http")
|
||||||
require("aredn.hardware")
|
require("aredn.hardware")
|
||||||
local html = require("aredn.html")
|
local html = require("aredn.html")
|
||||||
local info = require("aredn.info")
|
require("aredn.info")
|
||||||
|
|
||||||
local cursor = uci.cursor()
|
local cursor = uci.cursor()
|
||||||
|
|
||||||
|
|
|
@ -39,9 +39,10 @@ require("nixio")
|
||||||
require("aredn.hardware")
|
require("aredn.hardware")
|
||||||
require("aredn.http")
|
require("aredn.http")
|
||||||
require("aredn.utils")
|
require("aredn.utils")
|
||||||
aredn.html = require("aredn.html")
|
require("aredn.html")
|
||||||
require("uci")
|
require("uci")
|
||||||
aredn.info = require("aredn.info")
|
require("aredn.info")
|
||||||
|
require("aredn.olsr")
|
||||||
|
|
||||||
local html = aredn.html
|
local html = aredn.html
|
||||||
|
|
||||||
|
@ -555,17 +556,15 @@ do
|
||||||
if val == "_add" then
|
if val == "_add" then
|
||||||
if host ~= "" then
|
if host ~= "" then
|
||||||
local pattern = "%s" .. host .. "%s"
|
local pattern = "%s" .. host .. "%s"
|
||||||
if nixio.fs.stat("/var/run/hosts_olsr.stable") then
|
for line in aredn.olsr.getHostAsLines()
|
||||||
for line in io.lines("/var/run/hosts_olsr.stable")
|
do
|
||||||
do
|
if line:lower():match(pattern) then
|
||||||
if line:lower():match(pattern) then
|
foundhost = true
|
||||||
foundhost = true
|
dhcperr(val .. [[ <font color='red'>Warning!</font> ']] .. host .. [[ is already in use!<br>
|
||||||
dhcperr(val .. [[ <font color='red'>Warning!</font> ']] .. host .. [[ is already in use!<br>
|
Please choose another hostname.<br>
|
||||||
Please choose another hostname.<br>
|
Prefixing the hostname with your callsign will help prevent duplicates on the network.
|
||||||
Prefixing the hostname with your callsign will help prevent duplicates on the network.
|
]])
|
||||||
]])
|
break
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -899,17 +898,15 @@ do
|
||||||
if val == "_add" then
|
if val == "_add" then
|
||||||
if host ~= "" then
|
if host ~= "" then
|
||||||
local pattern = "%s" .. host .. "%s"
|
local pattern = "%s" .. host .. "%s"
|
||||||
if nixio.fs.stat("/var/run/hosts_olsr.stable") then
|
for line in aredn.olsr.getHostAsLines()
|
||||||
for line in io.lines("/var/run/hosts_olsr.stable")
|
do
|
||||||
do
|
if line:lower():match(pattern) then
|
||||||
if line:lower():match(pattern) then
|
foundhost = true
|
||||||
foundhost = true
|
aliaserr(val .. [[ <font color='red'>Warning!</font> ']] .. host .. [[ is already in use!<br>
|
||||||
aliaserr(val .. [[ <font color='red'>Warning!</font> ']] .. host .. [[ is already in use!<br>
|
Please choose another hostname.<br>
|
||||||
Please choose another hostname.<br>
|
Prefixing the hostname with your callsign will help prevent duplicates on the network.
|
||||||
Prefixing the hostname with your callsign will help prevent duplicates on the network.
|
]])
|
||||||
]])
|
break
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not host:match("^%*%.") and (host:match("_") or not host:match("^[%w%-%.]+$")) then
|
if not host:match("^%*%.") and (host:match("_") or not host:match("^[%w%-%.]+$")) then
|
||||||
|
|
|
@ -40,15 +40,15 @@ require("aredn.http")
|
||||||
require("aredn.hardware")
|
require("aredn.hardware")
|
||||||
require("aredn.utils")
|
require("aredn.utils")
|
||||||
local html = require("aredn.html")
|
local html = require("aredn.html")
|
||||||
local aredn_info = require("aredn.info")
|
require("aredn.info")
|
||||||
|
|
||||||
local node = aredn_info.get_nvram("node")
|
local node = aredn.info.get_nvram("node")
|
||||||
if not node then
|
if not node then
|
||||||
node = "NOCALL"
|
node = "NOCALL"
|
||||||
end
|
end
|
||||||
local wifiiface = aredn.hardware.get_iface_name("wifi")
|
local wifiiface = aredn.hardware.get_iface_name("wifi")
|
||||||
local nf = iwinfo.nl80211.noise(wifiiface) or -95
|
local nf = iwinfo.nl80211.noise(wifiiface) or -95
|
||||||
local myfreq = tonumber(aredn_info.getFreq(aredn_info.getMeshRadioDevice()))
|
local myfreq = tonumber(aredn.info.getFreq(aredn.info.getMeshRadioDevice()))
|
||||||
|
|
||||||
local board_type = aredn.hardware.get_board_type()
|
local board_type = aredn.hardware.get_board_type()
|
||||||
if board_type:match("^ubnt,") and board_type:match("ac") then
|
if board_type:match("^ubnt,") and board_type:match("ac") then
|
||||||
|
@ -69,7 +69,7 @@ local scanned = {}
|
||||||
local f = io.popen("iw dev " .. wifiiface .. " station dump")
|
local f = io.popen("iw dev " .. wifiiface .. " station dump")
|
||||||
if f then
|
if f then
|
||||||
local scan = {}
|
local scan = {}
|
||||||
local myssid = aredn_info.getSSID()
|
local myssid = aredn.info.getSSID()
|
||||||
for line in f:lines()
|
for line in f:lines()
|
||||||
do
|
do
|
||||||
local m = line:match("^Station ([%da-fA-F:]+) %(on " .. wifiiface .. "%)")
|
local m = line:match("^Station ([%da-fA-F:]+) %(on " .. wifiiface .. "%)")
|
||||||
|
|
|
@ -43,7 +43,7 @@ require("aredn.hardware")
|
||||||
require("uci")
|
require("uci")
|
||||||
require('luci.http')
|
require('luci.http')
|
||||||
local html = require("aredn.html")
|
local html = require("aredn.html")
|
||||||
local aredn_info = require("aredn.info")
|
require("aredn.info")
|
||||||
|
|
||||||
local errors = {}
|
local errors = {}
|
||||||
local output = {}
|
local output = {}
|
||||||
|
@ -172,9 +172,9 @@ if parms.button_uploaddata then
|
||||||
end
|
end
|
||||||
|
|
||||||
if parms.button_default then
|
if parms.button_default then
|
||||||
local node = aredn_info.get_nvram("node")
|
local node = aredn.info.get_nvram("node")
|
||||||
local mac2 = aredn_info.get_nvram("mac2")
|
local mac2 = aredn.info.get_nvram("mac2")
|
||||||
local dtdmac = aredn_info.get_nvram("dtdmac")
|
local dtdmac = aredn.info.get_nvram("dtdmac")
|
||||||
for line in io.lines("/etc/config.mesh/_setup.default")
|
for line in io.lines("/etc/config.mesh/_setup.default")
|
||||||
do
|
do
|
||||||
if not (line:match("^%s*#") or line:match("^%s*$")) then
|
if not (line:match("^%s*#") or line:match("^%s*$")) then
|
||||||
|
@ -192,9 +192,9 @@ else
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if parms.button_reset or not has_parms then
|
if parms.button_reset or not has_parms then
|
||||||
local node = aredn_info.get_nvram("node")
|
local node = aredn.info.get_nvram("node")
|
||||||
local mac2 = aredn_info.get_nvram("mac2")
|
local mac2 = aredn.info.get_nvram("mac2")
|
||||||
local dtdmac = aredn_info.get_nvram("dtdmac")
|
local dtdmac = aredn.info.get_nvram("dtdmac")
|
||||||
for line in io.lines("/etc/config.mesh/_setup")
|
for line in io.lines("/etc/config.mesh/_setup")
|
||||||
do
|
do
|
||||||
if not (line:match("^%s*#") or line:match("^%s*$")) then
|
if not (line:match("^%s*#") or line:match("^%s*$")) then
|
||||||
|
@ -250,8 +250,8 @@ end
|
||||||
|
|
||||||
local nodetac
|
local nodetac
|
||||||
if parms.button_reset or parms.button_default or (not nodetac and not has_parms) then
|
if parms.button_reset or parms.button_default or (not nodetac and not has_parms) then
|
||||||
nodetac = aredn_info.get_nvram("node")
|
nodetac = aredn.info.get_nvram("node")
|
||||||
tactical = aredn_info.get_nvram("tactical")
|
tactical = aredn.info.get_nvram("tactical")
|
||||||
if tactical ~= "" then
|
if tactical ~= "" then
|
||||||
nodetac = nodetac .. " / " .. tactical
|
nodetac = nodetac .. " / " .. tactical
|
||||||
end
|
end
|
||||||
|
@ -769,9 +769,9 @@ if parms.button_save then
|
||||||
cm:commit("aredn")
|
cm:commit("aredn")
|
||||||
end
|
end
|
||||||
|
|
||||||
aredn_info.set_nvram("node", parms.node);
|
aredn.info.set_nvram("node", parms.node);
|
||||||
aredn_info.set_nvram("tactical", parms.tactical)
|
aredn.info.set_nvram("tactical", parms.tactical)
|
||||||
aredn_info.set_nvram("config", parms.config)
|
aredn.info.set_nvram("config", parms.config)
|
||||||
|
|
||||||
if not nixio.fs.stat("/tmp/web/save") then
|
if not nixio.fs.stat("/tmp/web/save") then
|
||||||
nixio.fs.mkdir("/tmp/web/save")
|
nixio.fs.mkdir("/tmp/web/save")
|
||||||
|
@ -823,7 +823,7 @@ end
|
||||||
-- generate page
|
-- generate page
|
||||||
|
|
||||||
http_header()
|
http_header()
|
||||||
html.header(aredn_info.get_nvram("node") .. " setup", false)
|
html.header(aredn.info.get_nvram("node") .. " setup", false)
|
||||||
|
|
||||||
html.print([[
|
html.print([[
|
||||||
<script>
|
<script>
|
||||||
|
|
|
@ -39,9 +39,9 @@ require("nixio")
|
||||||
require("aredn.http")
|
require("aredn.http")
|
||||||
require("aredn.utils")
|
require("aredn.utils")
|
||||||
local html = require("aredn.html")
|
local html = require("aredn.html")
|
||||||
local aredn_info = require("aredn.info")
|
require("aredn.info")
|
||||||
|
|
||||||
local node = aredn_info.get_nvram("node")
|
local node = aredn.info.get_nvram("node")
|
||||||
if not node then
|
if not node then
|
||||||
node = "NOCALL"
|
node = "NOCALL"
|
||||||
end
|
end
|
||||||
|
|
|
@ -39,9 +39,10 @@ require("nixio")
|
||||||
require("aredn.hardware")
|
require("aredn.hardware")
|
||||||
require("aredn.http")
|
require("aredn.http")
|
||||||
require("aredn.utils")
|
require("aredn.utils")
|
||||||
|
require("aredn.olsr")
|
||||||
local html = require("aredn.html")
|
local html = require("aredn.html")
|
||||||
require("uci")
|
require("uci")
|
||||||
local aredn_info = require("aredn.info")
|
require("aredn.info")
|
||||||
|
|
||||||
-- helpers start
|
-- helpers start
|
||||||
|
|
||||||
|
@ -58,16 +59,14 @@ function mesh_ip_to_hostnames(ip)
|
||||||
return host.gsub("%s+", " / ")
|
return host.gsub("%s+", " / ")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if nixio.fs.stat("/var/run/hosts_olsr.stable") then
|
for line in aredn.olsr.getHostAsLines()
|
||||||
for line in io.lines("/var/run/hosts_olsr.stable")
|
do
|
||||||
do
|
local host = line:match(pattern)
|
||||||
local host = line:match(pattern)
|
if host then
|
||||||
if host then
|
host = host:gsub("^dtdlink%.","")
|
||||||
host = host:gsub("^dtdlink%.","")
|
host = host:gsub("^mid[0-9]*%.","")
|
||||||
host = host:gsub("^mid[0-9]*%.","")
|
host = host:gsub("%.local.mesh$","")
|
||||||
host = host:gsub("%.local.mesh$","")
|
return host
|
||||||
return host
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return host
|
return host
|
||||||
|
@ -143,12 +142,12 @@ end
|
||||||
|
|
||||||
-- helpers end
|
-- helpers end
|
||||||
|
|
||||||
local node = aredn_info.get_nvram("node")
|
local node = aredn.info.get_nvram("node")
|
||||||
if node == "" then
|
if node == "" then
|
||||||
node = "NOCALL"
|
node = "NOCALL"
|
||||||
end
|
end
|
||||||
local tactical = aredn_info.get_nvram("tactical")
|
local tactical = aredn.info.get_nvram("tactical")
|
||||||
local config = aredn_info.get_nvram("config")
|
local config = aredn.info.get_nvram("config")
|
||||||
if config == "" or nixio.fs.stat("/etc/config.mesh", "type") ~= "dir" then
|
if config == "" or nixio.fs.stat("/etc/config.mesh", "type") ~= "dir" then
|
||||||
config = "not set"
|
config = "not set"
|
||||||
end
|
end
|
||||||
|
@ -211,15 +210,13 @@ end
|
||||||
|
|
||||||
local host_total = 0
|
local host_total = 0
|
||||||
local host_nodes = 0
|
local host_nodes = 0
|
||||||
if nixio.fs.stat("/var/run/hosts_olsr.stable") then
|
for line in aredn.olsr.getHostAsLines()
|
||||||
for line in io.lines("/var/run/hosts_olsr.stable")
|
do
|
||||||
do
|
if line:match("^10%.") and not line:match("%smid%d+%.") then
|
||||||
if line:match("^10%.") and not line:match("%smid%d+%.") then
|
host_total = host_total + 1
|
||||||
host_total = host_total + 1
|
local host = line:match("^10%..+%sdtdlink%.")
|
||||||
local host = line:match("^10%..+%sdtdlink%.")
|
if host then
|
||||||
if host then
|
host_nodes = host_nodes + 1
|
||||||
host_nodes = host_nodes + 1
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -54,7 +54,6 @@ local files = {
|
||||||
"/etc/os-release",
|
"/etc/os-release",
|
||||||
"/tmp/etc/",
|
"/tmp/etc/",
|
||||||
"/var/run/hosts_olsr",
|
"/var/run/hosts_olsr",
|
||||||
"/var/run/hosts_olsr.stable",
|
|
||||||
"/var/run/services_olsr",
|
"/var/run/services_olsr",
|
||||||
"/tmp/rssi.dat",
|
"/tmp/rssi.dat",
|
||||||
"/tmp/rssi.log",
|
"/tmp/rssi.log",
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
require("aredn.http")
|
require("aredn.http")
|
||||||
require("aredn.hardware")
|
require("aredn.hardware")
|
||||||
local html = require("aredn.html")
|
local html = require("aredn.html")
|
||||||
aredn.info = require("aredn.info")
|
require("aredn.info")
|
||||||
|
|
||||||
local node = aredn.info.get_nvram("node")
|
local node = aredn.info.get_nvram("node")
|
||||||
if not node then
|
if not node then
|
||||||
|
|
|
@ -36,8 +36,8 @@
|
||||||
|
|
||||||
require("uci")
|
require("uci")
|
||||||
require("aredn.utils")
|
require("aredn.utils")
|
||||||
local aredn_info = require("aredn.info")
|
require("aredn.info")
|
||||||
local aredn_olsr = require("aredn.olsr")
|
require("aredn.olsr")
|
||||||
require("aredn.hardware")
|
require("aredn.hardware")
|
||||||
require("aredn.http")
|
require("aredn.http")
|
||||||
require("nixio")
|
require("nixio")
|
||||||
|
@ -60,14 +60,14 @@ info['api_version']="1.13"
|
||||||
|
|
||||||
|
|
||||||
-- NODE name
|
-- NODE name
|
||||||
info['node']=aredn_info.getNodeName()
|
info['node']=aredn.info.getNodeName()
|
||||||
|
|
||||||
info['node_details']={}
|
info['node_details']={}
|
||||||
-- MODEL
|
-- MODEL
|
||||||
info['node_details']['model']=aredn_info.getModel()
|
info['node_details']['model']=aredn.info.getModel()
|
||||||
|
|
||||||
-- DESCRIPTION
|
-- DESCRIPTION
|
||||||
info['node_details']['description']=aredn_info.getNodeDescription()
|
info['node_details']['description']=aredn.info.getNodeDescription()
|
||||||
|
|
||||||
-- BOARD ID
|
-- BOARD ID
|
||||||
info['node_details']['board_id']=hardware_boardid()
|
info['node_details']['board_id']=hardware_boardid()
|
||||||
|
@ -80,10 +80,10 @@ end
|
||||||
info['node_details']['firmware_mfg']=fw_mfg
|
info['node_details']['firmware_mfg']=fw_mfg
|
||||||
|
|
||||||
-- Firmware version
|
-- Firmware version
|
||||||
info['node_details']['firmware_version']=aredn_info.getFirmwareVersion()
|
info['node_details']['firmware_version']=aredn.info.getFirmwareVersion()
|
||||||
|
|
||||||
-- Mesh Gatway
|
-- Mesh Gatway
|
||||||
info['node_details']['mesh_gateway']=aredn_info.getMeshGatewaySetting()
|
info['node_details']['mesh_gateway']=aredn.info.getMeshGatewaySetting()
|
||||||
|
|
||||||
-- Supernode
|
-- Supernode
|
||||||
if ctx:get("aredn", "@supernode[0]", "enable") == "1" then
|
if ctx:get("aredn", "@supernode[0]", "enable") == "1" then
|
||||||
|
@ -92,17 +92,17 @@ end
|
||||||
|
|
||||||
-- Mesh RF info
|
-- Mesh RF info
|
||||||
info['meshrf']={}
|
info['meshrf']={}
|
||||||
local radio=aredn_info.getMeshRadioDevice()
|
local radio=aredn.info.getMeshRadioDevice()
|
||||||
|
|
||||||
if ( radio ~= nil and radio ~= "" ) then
|
if ( radio ~= nil and radio ~= "" ) then
|
||||||
info['meshrf']['status']="on"
|
info['meshrf']['status']="on"
|
||||||
info['meshrf']['ssid']=aredn_info.getSSID()
|
info['meshrf']['ssid']=aredn.info.getSSID()
|
||||||
info['meshrf']['channel']=aredn_info.getChannel(radio)
|
info['meshrf']['channel']=aredn.info.getChannel(radio)
|
||||||
info['meshrf']['chanbw']=aredn_info.getChannelBW(radio)
|
info['meshrf']['chanbw']=aredn.info.getChannelBW(radio)
|
||||||
info['meshrf']['freq']=aredn_info.getFreq(radio)
|
info['meshrf']['freq']=aredn.info.getFreq(radio)
|
||||||
info['meshrf']['azimuth'] = aredn_info.getAzimuth()
|
info['meshrf']['azimuth'] = aredn.info.getAzimuth()
|
||||||
info['meshrf']['elevation'] = aredn_info.getElevation()
|
info['meshrf']['elevation'] = aredn.info.getElevation()
|
||||||
info['meshrf']['height'] = aredn_info.getHeight()
|
info['meshrf']['height'] = aredn.info.getHeight()
|
||||||
info['meshrf']['antenna'] = aredn.hardware.get_current_antenna(radio)
|
info['meshrf']['antenna'] = aredn.hardware.get_current_antenna(radio)
|
||||||
info['meshrf']['antenna_aux'] = aredn.hardware.get_current_antenna_aux(radio)
|
info['meshrf']['antenna_aux'] = aredn.hardware.get_current_antenna_aux(radio)
|
||||||
else
|
else
|
||||||
|
@ -118,12 +118,12 @@ info['tunnels']['active_tunnel_count']=atc:chomp()
|
||||||
|
|
||||||
-- Location info
|
-- Location info
|
||||||
-- LAT/LON
|
-- LAT/LON
|
||||||
local lat, lon = aredn_info.getLatLon()
|
local lat, lon = aredn.info.getLatLon()
|
||||||
info['lat']=lat
|
info['lat']=lat
|
||||||
info['lon']=lon
|
info['lon']=lon
|
||||||
|
|
||||||
-- GRID SQUARE
|
-- GRID SQUARE
|
||||||
info["grid_square"]=aredn_info.getGridSquare()
|
info["grid_square"]=aredn.info.getGridSquare()
|
||||||
|
|
||||||
-- UPTIME AND LOADAVGS
|
-- UPTIME AND LOADAVGS
|
||||||
mynix=nixio.sysinfo()
|
mynix=nixio.sysinfo()
|
||||||
|
@ -157,22 +157,22 @@ info['interfaces']=tif
|
||||||
|
|
||||||
-- HOSTS
|
-- HOSTS
|
||||||
if string.find(nixio.getenv("QUERY_STRING"):lower(),"hosts=1") then
|
if string.find(nixio.getenv("QUERY_STRING"):lower(),"hosts=1") then
|
||||||
info['hosts']=aredn_info.all_hosts()
|
info['hosts']=aredn.info.all_hosts()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- SERVICES
|
-- SERVICES
|
||||||
if string.find(nixio.getenv("QUERY_STRING"):lower(),"services=1") then
|
if string.find(nixio.getenv("QUERY_STRING"):lower(),"services=1") then
|
||||||
info['services']=aredn_info.all_services()
|
info['services']=aredn.info.all_services()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- LOCALLY HOSTED SERVICES ONLY
|
-- LOCALLY HOSTED SERVICES ONLY
|
||||||
if string.find(nixio.getenv("QUERY_STRING"):lower(),"services_local=1") then
|
if string.find(nixio.getenv("QUERY_STRING"):lower(),"services_local=1") then
|
||||||
info['services_local']=aredn_info.local_services()
|
info['services_local']=aredn.info.local_services()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- LOCAL NEIGHBORS LINK INFO
|
-- LOCAL NEIGHBORS LINK INFO
|
||||||
if string.find(nixio.getenv("QUERY_STRING"):lower(),"link_info=1") then
|
if string.find(nixio.getenv("QUERY_STRING"):lower(),"link_info=1") then
|
||||||
info['link_info']=aredn_olsr.getCurrentNeighbors(true)
|
info['link_info']=aredn.olsr.getCurrentNeighbors(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- LQM INFO
|
-- LQM INFO
|
||||||
|
@ -202,7 +202,7 @@ end
|
||||||
|
|
||||||
-- MESH NODES COUNT
|
-- MESH NODES COUNT
|
||||||
if string.find(nixio.getenv("QUERY_STRING"):lower(),"nodes=1") then
|
if string.find(nixio.getenv("QUERY_STRING"):lower(),"nodes=1") then
|
||||||
info['nodes']=aredn_info.getOLSRInfo()
|
info['nodes']=aredn.info.getOLSRInfo()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Output the HTTP header for JSON
|
-- Output the HTTP header for JSON
|
||||||
|
|
|
@ -40,7 +40,7 @@ require("aredn.http")
|
||||||
require("aredn.utils")
|
require("aredn.utils")
|
||||||
require("aredn.html")
|
require("aredn.html")
|
||||||
require("aredn.hardware")
|
require("aredn.hardware")
|
||||||
aredn.info = require("aredn.info")
|
require("aredn.info")
|
||||||
require("uci")
|
require("uci")
|
||||||
|
|
||||||
local html = aredn.html
|
local html = aredn.html
|
||||||
|
|
|
@ -40,7 +40,7 @@ require("aredn.http")
|
||||||
require("aredn.utils")
|
require("aredn.utils")
|
||||||
require("aredn.html")
|
require("aredn.html")
|
||||||
require("aredn.hardware")
|
require("aredn.hardware")
|
||||||
aredn.info = require("aredn.info")
|
require("aredn.info")
|
||||||
require("uci")
|
require("uci")
|
||||||
|
|
||||||
local html = aredn.html
|
local html = aredn.html
|
||||||
|
|
Loading…
Reference in New Issue