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