2015-01-16 22:38:38 +00:00
|
|
|
-- Copyright 2008 Steven Barth <steven@midlink.org>
|
2018-07-12 14:50:40 +00:00
|
|
|
-- Copyright 2011-2018 Jo-Philipp Wich <jo@mein.io>
|
2015-01-16 22:38:38 +00:00
|
|
|
-- Licensed to the public under the Apache License 2.0.
|
2010-10-30 00:46:41 +00:00
|
|
|
|
2008-05-25 17:00:30 +00:00
|
|
|
module("luci.controller.admin.network", package.seeall)
|
2008-05-22 14:04:03 +00:00
|
|
|
|
|
|
|
function index()
|
2008-08-26 23:00:44 +00:00
|
|
|
local uci = require("luci.model.uci").cursor()
|
2010-10-25 22:26:08 +00:00
|
|
|
local page
|
|
|
|
|
2011-11-07 10:44:20 +00:00
|
|
|
-- if page.inreq then
|
2011-11-07 10:38:41 +00:00
|
|
|
local has_switch = false
|
2009-05-13 23:46:56 +00:00
|
|
|
|
2011-11-07 10:38:41 +00:00
|
|
|
uci:foreach("network", "switch",
|
|
|
|
function(s)
|
|
|
|
has_switch = true
|
|
|
|
return false
|
|
|
|
end)
|
|
|
|
|
|
|
|
if has_switch then
|
|
|
|
page = node("admin", "network", "vlan")
|
|
|
|
page.target = cbi("admin_network/vlan")
|
|
|
|
page.title = _("Switch")
|
|
|
|
page.order = 20
|
2012-09-11 14:18:28 +00:00
|
|
|
|
|
|
|
page = entry({"admin", "network", "switch_status"}, call("switch_status"), nil)
|
|
|
|
page.leaf = true
|
2011-11-07 10:38:41 +00:00
|
|
|
end
|
2009-05-13 23:46:56 +00:00
|
|
|
|
2010-10-19 04:08:15 +00:00
|
|
|
|
2011-11-07 10:38:41 +00:00
|
|
|
local has_wifi = false
|
2012-06-26 21:49:27 +00:00
|
|
|
|
2011-11-07 10:38:41 +00:00
|
|
|
uci:foreach("wireless", "wifi-device",
|
|
|
|
function(s)
|
|
|
|
has_wifi = true
|
|
|
|
return false
|
|
|
|
end)
|
2012-06-26 21:49:27 +00:00
|
|
|
|
2011-11-07 10:38:41 +00:00
|
|
|
if has_wifi then
|
2015-10-20 20:17:23 +00:00
|
|
|
page = entry({"admin", "network", "wireless_join"}, post("wifi_join"), nil)
|
2011-11-07 10:38:41 +00:00
|
|
|
page.leaf = true
|
|
|
|
|
2015-10-20 20:17:23 +00:00
|
|
|
page = entry({"admin", "network", "wireless_add"}, post("wifi_add"), nil)
|
2011-11-07 10:38:41 +00:00
|
|
|
page.leaf = true
|
|
|
|
|
|
|
|
page = entry({"admin", "network", "wireless_status"}, call("wifi_status"), nil)
|
|
|
|
page.leaf = true
|
|
|
|
|
2015-10-20 20:17:23 +00:00
|
|
|
page = entry({"admin", "network", "wireless_reconnect"}, post("wifi_reconnect"), nil)
|
2011-11-07 10:38:41 +00:00
|
|
|
page.leaf = true
|
|
|
|
|
2018-07-18 12:43:27 +00:00
|
|
|
page = entry({"admin", "network", "wireless_scan_trigger"}, post("wifi_scan_trigger"), nil)
|
|
|
|
page.leaf = true
|
|
|
|
|
|
|
|
page = entry({"admin", "network", "wireless_scan_results"}, call("wifi_scan_results"), nil)
|
|
|
|
page.leaf = true
|
|
|
|
|
2018-07-11 20:19:50 +00:00
|
|
|
page = entry({"admin", "network", "wireless"}, arcombine(cbi("admin_network/wifi_overview"), cbi("admin_network/wifi")), _("Wireless"), 15)
|
2011-11-07 10:38:41 +00:00
|
|
|
page.leaf = true
|
|
|
|
page.subindex = true
|
|
|
|
|
|
|
|
if page.inreq then
|
|
|
|
local wdev
|
|
|
|
local net = require "luci.model.network".init(uci)
|
|
|
|
for _, wdev in ipairs(net:get_wifidevs()) do
|
|
|
|
local wnet
|
|
|
|
for _, wnet in ipairs(wdev:get_wifinets()) do
|
|
|
|
entry(
|
|
|
|
{"admin", "network", "wireless", wnet:id()},
|
|
|
|
alias("admin", "network", "wireless"),
|
|
|
|
wdev:name() .. ": " .. wnet:shortname()
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2018-04-06 10:10:16 +00:00
|
|
|
page = entry({"admin", "network", "iface_add"}, form("admin_network/iface_add"), nil)
|
2009-12-21 02:50:30 +00:00
|
|
|
page.leaf = true
|
2009-09-26 11:10:01 +00:00
|
|
|
|
2011-11-07 10:38:41 +00:00
|
|
|
page = entry({"admin", "network", "iface_status"}, call("iface_status"), nil)
|
2011-09-25 23:29:21 +00:00
|
|
|
page.leaf = true
|
|
|
|
|
2015-10-20 20:17:23 +00:00
|
|
|
page = entry({"admin", "network", "iface_reconnect"}, post("iface_reconnect"), nil)
|
2011-09-25 23:29:21 +00:00
|
|
|
page.leaf = true
|
|
|
|
|
2011-11-07 10:38:41 +00:00
|
|
|
page = entry({"admin", "network", "network"}, arcombine(cbi("admin_network/network"), cbi("admin_network/ifaces")), _("Interfaces"), 10)
|
|
|
|
page.leaf = true
|
|
|
|
page.subindex = true
|
2009-10-29 02:23:58 +00:00
|
|
|
|
2011-11-07 10:38:41 +00:00
|
|
|
if page.inreq then
|
|
|
|
uci:foreach("network", "interface",
|
|
|
|
function (section)
|
|
|
|
local ifc = section[".name"]
|
|
|
|
if ifc ~= "loopback" then
|
|
|
|
entry({"admin", "network", "network", ifc},
|
|
|
|
true, ifc:upper())
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
end
|
2009-05-13 23:46:56 +00:00
|
|
|
|
2010-11-15 22:04:56 +00:00
|
|
|
|
2011-11-07 10:38:41 +00:00
|
|
|
if nixio.fs.access("/etc/config/dhcp") then
|
|
|
|
page = node("admin", "network", "dhcp")
|
|
|
|
page.target = cbi("admin_network/dhcp")
|
|
|
|
page.title = _("DHCP and DNS")
|
|
|
|
page.order = 30
|
2010-10-25 22:26:08 +00:00
|
|
|
|
2011-11-07 10:38:41 +00:00
|
|
|
page = node("admin", "network", "hosts")
|
|
|
|
page.target = cbi("admin_network/hosts")
|
|
|
|
page.title = _("Hostnames")
|
|
|
|
page.order = 40
|
|
|
|
end
|
2010-11-15 22:04:56 +00:00
|
|
|
|
2011-11-07 10:38:41 +00:00
|
|
|
page = node("admin", "network", "routes")
|
|
|
|
page.target = cbi("admin_network/routes")
|
|
|
|
page.title = _("Static Routes")
|
|
|
|
page.order = 50
|
2010-11-15 22:04:56 +00:00
|
|
|
|
2011-11-07 10:38:41 +00:00
|
|
|
page = node("admin", "network", "diagnostics")
|
|
|
|
page.target = template("admin_network/diagnostics")
|
|
|
|
page.title = _("Diagnostics")
|
|
|
|
page.order = 60
|
2008-09-06 18:21:58 +00:00
|
|
|
|
2015-10-20 20:17:23 +00:00
|
|
|
page = entry({"admin", "network", "diag_ping"}, post("diag_ping"), nil)
|
2011-11-07 10:38:41 +00:00
|
|
|
page.leaf = true
|
2010-11-07 23:31:19 +00:00
|
|
|
|
2015-10-20 20:17:23 +00:00
|
|
|
page = entry({"admin", "network", "diag_nslookup"}, post("diag_nslookup"), nil)
|
2010-11-07 23:31:19 +00:00
|
|
|
page.leaf = true
|
2008-09-06 18:21:58 +00:00
|
|
|
|
2015-10-20 20:17:23 +00:00
|
|
|
page = entry({"admin", "network", "diag_traceroute"}, post("diag_traceroute"), nil)
|
2011-11-07 10:38:41 +00:00
|
|
|
page.leaf = true
|
2012-11-11 12:20:56 +00:00
|
|
|
|
2015-10-20 20:17:23 +00:00
|
|
|
page = entry({"admin", "network", "diag_ping6"}, post("diag_ping6"), nil)
|
2012-11-11 12:20:56 +00:00
|
|
|
page.leaf = true
|
|
|
|
|
2015-10-20 20:17:23 +00:00
|
|
|
page = entry({"admin", "network", "diag_traceroute6"}, post("diag_traceroute6"), nil)
|
2012-11-11 12:20:56 +00:00
|
|
|
page.leaf = true
|
2011-11-07 10:44:20 +00:00
|
|
|
-- end
|
2009-05-13 23:46:56 +00:00
|
|
|
end
|
2009-09-26 11:10:01 +00:00
|
|
|
|
|
|
|
function wifi_join()
|
2015-10-20 20:17:23 +00:00
|
|
|
local tpl = require "luci.template"
|
|
|
|
local http = require "luci.http"
|
|
|
|
local dev = http.formvalue("device")
|
|
|
|
local ssid = http.formvalue("join")
|
2009-09-26 11:10:01 +00:00
|
|
|
|
|
|
|
if dev and ssid then
|
2015-10-20 20:17:23 +00:00
|
|
|
local cancel = (http.formvalue("cancel") or http.formvalue("cbi.cancel"))
|
|
|
|
if not cancel then
|
2009-11-08 02:38:22 +00:00
|
|
|
local cbi = require "luci.cbi"
|
|
|
|
local map = luci.cbi.load("admin_network/wifi_add")[1]
|
|
|
|
|
|
|
|
if map:parse() ~= cbi.FORM_DONE then
|
|
|
|
tpl.render("header")
|
|
|
|
map:render()
|
|
|
|
tpl.render("footer")
|
|
|
|
end
|
2015-10-20 20:17:23 +00:00
|
|
|
|
|
|
|
return
|
2009-09-26 11:10:01 +00:00
|
|
|
end
|
|
|
|
end
|
2015-10-20 20:17:23 +00:00
|
|
|
|
|
|
|
tpl.render("admin_network/wifi_join")
|
2009-09-26 11:10:01 +00:00
|
|
|
end
|
2009-10-29 02:23:58 +00:00
|
|
|
|
2009-12-25 00:41:55 +00:00
|
|
|
function wifi_add()
|
2010-10-19 04:08:15 +00:00
|
|
|
local dev = luci.http.formvalue("device")
|
2010-10-30 00:46:41 +00:00
|
|
|
local ntm = require "luci.model.network".init()
|
2009-12-25 00:41:55 +00:00
|
|
|
|
2010-10-30 00:46:41 +00:00
|
|
|
dev = dev and ntm:get_wifidev(dev)
|
2009-12-25 00:41:55 +00:00
|
|
|
|
2010-10-30 00:46:41 +00:00
|
|
|
if dev then
|
|
|
|
local net = dev:add_wifinet({
|
2009-12-25 00:41:55 +00:00
|
|
|
mode = "ap",
|
|
|
|
ssid = "OpenWrt",
|
2018-07-16 12:39:55 +00:00
|
|
|
encryption = "none",
|
|
|
|
disabled = 1
|
2009-12-25 00:41:55 +00:00
|
|
|
})
|
|
|
|
|
2010-10-30 00:46:41 +00:00
|
|
|
ntm:save("wireless")
|
|
|
|
luci.http.redirect(net:adminlink())
|
2009-12-25 00:41:55 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-11-21 19:29:47 +00:00
|
|
|
function iface_status(ifaces)
|
2010-12-01 21:16:49 +00:00
|
|
|
local netm = require "luci.model.network".init()
|
2010-10-30 00:46:41 +00:00
|
|
|
local rv = { }
|
|
|
|
|
|
|
|
local iface
|
2012-11-21 19:29:47 +00:00
|
|
|
for iface in ifaces:gmatch("[%w%.%-_]+") do
|
2010-12-01 21:16:49 +00:00
|
|
|
local net = netm:get_network(iface)
|
2011-09-24 00:58:58 +00:00
|
|
|
local device = net and net:get_interface()
|
|
|
|
if device then
|
2011-11-02 18:59:18 +00:00
|
|
|
local data = {
|
2011-09-24 00:58:58 +00:00
|
|
|
id = iface,
|
2018-07-12 14:44:31 +00:00
|
|
|
desc = net:get_i18n(),
|
2011-09-24 00:58:58 +00:00
|
|
|
proto = net:proto(),
|
|
|
|
uptime = net:uptime(),
|
|
|
|
gwaddr = net:gwaddr(),
|
2015-11-17 16:36:00 +00:00
|
|
|
ipaddrs = net:ipaddrs(),
|
|
|
|
ip6addrs = net:ip6addrs(),
|
2011-09-24 00:58:58 +00:00
|
|
|
dnsaddrs = net:dnsaddrs(),
|
mod-admin-full: Add IPv6 Prefix Delegation information to Status Pages
The Overview page and Network>Interfaces page currently do not give much information about IPv6, particularly with Prefix Delegated setups. In these setups, ISP will delegate a prefix to the router. Currently LuCI doesn't display this Prefix Delegation from the ISP anywhere. A number of changes was added to this commit:
1) self:_ubus("ipv6-prefix") was extracted and put into protocol.ip6prefix.
2) Network>Interfaces page, if a .ip6prefix is present, show it under Status. (IPv6-PD).
3) On the Overview page, "Type" and "Prefix Delegated" has been added to the IPv6 Network Overview Status:
- Type will display the .proto, similar to the IPv4 case. If a .ip6prefix is present, it'll display a "-pd" at the end of the Type: i.e. dhcpv6-pd vs. dhcpv6.
- If no .ip6prefix is present, it'll do what it does currently, and just show Address, or :: if no address is present.
- If .ip6prefix is present, it'll show the "Prefix Delegated", it'll also hide "Address" if no address is present, else it'll show ifc6.ip6addr as well.
Signed-off-by: Cody R. Brown <dev@codybrown.ca>
2017-01-28 09:38:06 +00:00
|
|
|
ip6prefix = net:ip6prefix(),
|
2018-07-12 14:44:31 +00:00
|
|
|
errors = net:errors(),
|
2011-09-24 00:58:58 +00:00
|
|
|
name = device:shortname(),
|
|
|
|
type = device:type(),
|
2018-07-15 13:18:00 +00:00
|
|
|
typename = device:get_type_i18n(),
|
2011-09-24 00:58:58 +00:00
|
|
|
ifname = device:name(),
|
|
|
|
macaddr = device:mac(),
|
2018-07-12 14:44:31 +00:00
|
|
|
is_up = net:is_up() and device:is_up(),
|
|
|
|
is_alias = net:is_alias(),
|
|
|
|
is_dynamic = net:is_dynamic(),
|
2011-09-24 00:58:58 +00:00
|
|
|
rx_bytes = device:rx_bytes(),
|
|
|
|
tx_bytes = device:tx_bytes(),
|
|
|
|
rx_packets = device:rx_packets(),
|
|
|
|
tx_packets = device:tx_packets(),
|
|
|
|
|
|
|
|
subdevices = { }
|
2011-03-13 14:00:45 +00:00
|
|
|
}
|
2011-09-24 00:58:58 +00:00
|
|
|
|
2011-09-25 22:58:17 +00:00
|
|
|
for _, device in ipairs(net:get_interfaces() or {}) do
|
2011-09-24 00:58:58 +00:00
|
|
|
data.subdevices[#data.subdevices+1] = {
|
|
|
|
name = device:shortname(),
|
|
|
|
type = device:type(),
|
2018-07-15 13:18:00 +00:00
|
|
|
typename = device:get_type_i18n(),
|
2011-09-24 00:58:58 +00:00
|
|
|
ifname = device:name(),
|
|
|
|
macaddr = device:mac(),
|
|
|
|
is_up = device:is_up(),
|
|
|
|
rx_bytes = device:rx_bytes(),
|
|
|
|
tx_bytes = device:tx_bytes(),
|
|
|
|
rx_packets = device:rx_packets(),
|
|
|
|
tx_packets = device:tx_packets(),
|
|
|
|
}
|
2010-12-01 21:16:49 +00:00
|
|
|
end
|
2011-09-24 00:58:58 +00:00
|
|
|
|
|
|
|
rv[#rv+1] = data
|
2011-10-18 13:20:43 +00:00
|
|
|
else
|
|
|
|
rv[#rv+1] = {
|
|
|
|
id = iface,
|
|
|
|
name = iface,
|
|
|
|
type = "ethernet"
|
|
|
|
}
|
2010-10-30 00:46:41 +00:00
|
|
|
end
|
2010-10-25 22:26:08 +00:00
|
|
|
end
|
|
|
|
|
2010-10-30 00:46:41 +00:00
|
|
|
if #rv > 0 then
|
2010-10-25 22:26:08 +00:00
|
|
|
luci.http.prepare_content("application/json")
|
2010-11-07 19:28:07 +00:00
|
|
|
luci.http.write_json(rv)
|
2010-10-25 22:26:08 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
luci.http.status(404, "No such device")
|
|
|
|
end
|
|
|
|
|
2012-11-21 19:29:47 +00:00
|
|
|
function iface_reconnect(iface)
|
2010-11-15 22:04:56 +00:00
|
|
|
local netmd = require "luci.model.network".init()
|
|
|
|
local net = netmd:get_network(iface)
|
|
|
|
if net then
|
2018-04-05 07:32:22 +00:00
|
|
|
luci.sys.call("env -i /sbin/ifup %s >/dev/null 2>/dev/null"
|
|
|
|
% luci.util.shellquote(iface))
|
2010-11-15 22:04:56 +00:00
|
|
|
luci.http.status(200, "Reconnected")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
luci.http.status(404, "No such interface")
|
|
|
|
end
|
|
|
|
|
2012-11-21 19:29:47 +00:00
|
|
|
function wifi_status(devs)
|
2011-03-13 17:25:54 +00:00
|
|
|
local s = require "luci.tools.status"
|
2010-10-30 00:46:41 +00:00
|
|
|
local rv = { }
|
|
|
|
|
2018-05-19 21:28:14 +00:00
|
|
|
if type(devs) == "string" then
|
|
|
|
local dev
|
|
|
|
for dev in devs:gmatch("[%w%.%-]+") do
|
|
|
|
rv[#rv+1] = s.wifi_network(dev)
|
|
|
|
end
|
2010-10-30 00:46:41 +00:00
|
|
|
end
|
2010-10-19 04:08:15 +00:00
|
|
|
|
2010-10-30 00:46:41 +00:00
|
|
|
if #rv > 0 then
|
2010-10-19 04:08:15 +00:00
|
|
|
luci.http.prepare_content("application/json")
|
2010-11-07 19:28:07 +00:00
|
|
|
luci.http.write_json(rv)
|
2010-10-19 04:08:15 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
luci.http.status(404, "No such device")
|
|
|
|
end
|
2010-11-07 23:31:19 +00:00
|
|
|
|
2018-07-11 20:19:50 +00:00
|
|
|
function wifi_reconnect(radio)
|
|
|
|
local rc = luci.sys.call("env -i /sbin/wifi up %s" % luci.util.shellquote(radio))
|
2011-09-22 02:43:38 +00:00
|
|
|
|
2018-07-11 20:19:50 +00:00
|
|
|
if rc == 0 then
|
|
|
|
luci.http.status(200, "Reconnected")
|
|
|
|
else
|
|
|
|
luci.http.status(500, "Error")
|
2011-09-22 02:43:38 +00:00
|
|
|
end
|
2012-11-21 19:29:47 +00:00
|
|
|
end
|
|
|
|
|
2018-07-18 12:43:27 +00:00
|
|
|
local function _wifi_get_scan_results(cache_key)
|
|
|
|
local results = luci.util.ubus("session", "get", {
|
|
|
|
ubus_rpc_session = luci.model.uci:get_session_id(),
|
|
|
|
keys = { cache_key }
|
|
|
|
})
|
|
|
|
|
|
|
|
if type(results) == "table" and
|
|
|
|
type(results.values) == "table" and
|
|
|
|
type(results.values[cache_key]) == "table"
|
|
|
|
then
|
|
|
|
return results.values[cache_key]
|
|
|
|
end
|
|
|
|
|
|
|
|
return { }
|
|
|
|
end
|
|
|
|
|
|
|
|
function wifi_scan_trigger(radio, update)
|
|
|
|
local iw = radio and luci.sys.wifi.getiwinfo(radio)
|
|
|
|
|
|
|
|
if not iw then
|
|
|
|
luci.http.status(404, "No such radio device")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2018-11-23 14:41:56 +00:00
|
|
|
luci.http.status(204, "Scan scheduled")
|
2018-07-18 12:43:27 +00:00
|
|
|
|
|
|
|
if nixio.fork() == 0 then
|
|
|
|
io.stderr:close()
|
|
|
|
io.stdout:close()
|
|
|
|
|
|
|
|
local _, bss
|
|
|
|
local data, bssids = { }, { }
|
|
|
|
local cache_key = "scan_%s" % radio
|
|
|
|
|
|
|
|
luci.util.ubus("session", "set", {
|
|
|
|
ubus_rpc_session = luci.model.uci:get_session_id(),
|
|
|
|
values = { [cache_key] = nil }
|
|
|
|
})
|
|
|
|
|
|
|
|
for _, bss in ipairs(iw.scanlist or { }) do
|
|
|
|
data[_] = bss
|
|
|
|
bssids[bss.bssid] = bss
|
|
|
|
end
|
|
|
|
|
|
|
|
if update then
|
|
|
|
for _, bss in ipairs(_wifi_get_scan_results(cache_key)) do
|
|
|
|
if not bssids[bss.bssid] then
|
|
|
|
bss.stale = true
|
|
|
|
data[#data + 1] = bss
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
luci.util.ubus("session", "set", {
|
|
|
|
ubus_rpc_session = luci.model.uci:get_session_id(),
|
|
|
|
values = { [cache_key] = data }
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function wifi_scan_results(radio)
|
|
|
|
local results = radio and _wifi_get_scan_results("scan_%s" % radio)
|
|
|
|
|
|
|
|
if results and #results > 0 then
|
|
|
|
luci.http.prepare_content("application/json")
|
|
|
|
luci.http.write_json(results)
|
|
|
|
else
|
|
|
|
luci.http.status(404, "No wireless scan results")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-11-21 19:29:47 +00:00
|
|
|
function switch_status(switches)
|
2012-09-11 14:18:28 +00:00
|
|
|
local s = require "luci.tools.status"
|
|
|
|
|
|
|
|
luci.http.prepare_content("application/json")
|
2012-11-21 19:29:47 +00:00
|
|
|
luci.http.write_json(s.switch_status(switches))
|
2012-09-11 14:18:28 +00:00
|
|
|
end
|
|
|
|
|
2012-11-21 19:29:47 +00:00
|
|
|
function diag_command(cmd, addr)
|
2010-11-24 20:09:37 +00:00
|
|
|
if addr and addr:match("^[a-zA-Z0-9%-%.:_]+$") then
|
|
|
|
luci.http.prepare_content("text/plain")
|
|
|
|
|
2018-04-05 07:32:22 +00:00
|
|
|
local util = io.popen(cmd % luci.util.shellquote(addr))
|
2010-11-24 20:09:37 +00:00
|
|
|
if util then
|
|
|
|
while true do
|
|
|
|
local ln = util:read("*l")
|
|
|
|
if not ln then break end
|
|
|
|
luci.http.write(ln)
|
|
|
|
luci.http.write("\n")
|
|
|
|
end
|
|
|
|
|
|
|
|
util:close()
|
|
|
|
end
|
|
|
|
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
luci.http.status(500, "Bad address")
|
|
|
|
end
|
|
|
|
|
2012-11-21 19:29:47 +00:00
|
|
|
function diag_ping(addr)
|
2018-04-05 07:32:22 +00:00
|
|
|
diag_command("ping -c 5 -W 1 %s 2>&1", addr)
|
2010-11-24 20:09:37 +00:00
|
|
|
end
|
|
|
|
|
2012-11-21 19:29:47 +00:00
|
|
|
function diag_traceroute(addr)
|
2018-04-05 07:32:22 +00:00
|
|
|
diag_command("traceroute -q 1 -w 1 -n %s 2>&1", addr)
|
2010-11-24 20:09:37 +00:00
|
|
|
end
|
|
|
|
|
2012-11-21 19:29:47 +00:00
|
|
|
function diag_nslookup(addr)
|
2018-04-05 07:32:22 +00:00
|
|
|
diag_command("nslookup %s 2>&1", addr)
|
2010-11-24 20:09:37 +00:00
|
|
|
end
|
2012-11-11 12:20:56 +00:00
|
|
|
|
2012-11-21 19:29:47 +00:00
|
|
|
function diag_ping6(addr)
|
2018-04-05 07:32:22 +00:00
|
|
|
diag_command("ping6 -c 5 %s 2>&1", addr)
|
2012-11-11 12:20:56 +00:00
|
|
|
end
|
|
|
|
|
2012-11-21 19:29:47 +00:00
|
|
|
function diag_traceroute6(addr)
|
2018-04-05 07:32:22 +00:00
|
|
|
diag_command("traceroute6 -q 1 -w 2 -n %s 2>&1", addr)
|
2012-11-11 12:20:56 +00:00
|
|
|
end
|