1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

Update luci-base and luci-mod-admin-full to latest upstream version

This commit is contained in:
Ycarus 2018-07-23 17:36:03 +02:00
parent 7a86a163f5
commit 602a83668e
74 changed files with 7498 additions and 3067 deletions

View file

@ -2,15 +2,15 @@
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg">
<line x1="0" y1="25%" x2="100%" y2="25%" style="stroke:black;stroke-width:0.1" />
<text id="label_75" x="20" y="24%" style="fill:#999999; font-size:9pt"> </text>
<line x1="0" y1="50%" x2="100%" y2="50%" style="stroke:black;stroke-width:0.1" />
<text id="label_50" x="20" y="49%" style="fill:#999999; font-size:9pt"> </text>
<line x1="0" y1="75%" x2="100%" y2="75%" style="stroke:black;stroke-width:0.1" />
<text id="label_25" x="20" y="74%" style="fill:#999999; font-size:9pt"> </text>
<polyline id="rx" points="" style="fill:blue;fill-opacity:0.4;stroke:blue;stroke-width:1" />
<polyline id="tx" points="" style="fill:green;fill-opacity:0.4;stroke:green;stroke-width:1" />
<line x1="0" y1="25%" x2="100%" y2="25%" style="stroke:black;stroke-width:0.1" />
<text id="label_75" x="20" y="24%" style="fill:#eee; font-size:9pt; font-family:sans-serif; text-shadow:1px 1px 1px #000"> </text>
<line x1="0" y1="50%" x2="100%" y2="50%" style="stroke:black;stroke-width:0.1" />
<text id="label_50" x="20" y="49%" style="fill:#eee; font-size:9pt; font-family:sans-serif; text-shadow:1px 1px 1px #000"> </text>
<line x1="0" y1="75%" x2="100%" y2="75%" style="stroke:black;stroke-width:0.1" />
<text id="label_25" x="20" y="74%" style="fill:#eee; font-size:9pt; font-family:sans-serif; text-shadow:1px 1px 1px #000"> </text>
</svg>

Before

Width:  |  Height:  |  Size: 912 B

After

Width:  |  Height:  |  Size: 1 KiB

Before After
Before After

View file

@ -2,16 +2,16 @@
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg">
<line x1="0" y1="25%" x2="100%" y2="25%" style="stroke:black;stroke-width:0.1" />
<text id="label_75" x="20" y="24%" style="fill:#999999; font-size:9pt"> </text>
<line x1="0" y1="50%" x2="100%" y2="50%" style="stroke:black;stroke-width:0.1" />
<text id="label_50" x="20" y="49%" style="fill:#999999; font-size:9pt"> </text>
<line x1="0" y1="75%" x2="100%" y2="75%" style="stroke:black;stroke-width:0.1" />
<text id="label_25" x="20" y="74%" style="fill:#999999; font-size:9pt"> </text>
<polyline id="tcp" points="" style="fill:green;fill-opacity:0.4;stroke:green;stroke-width:1" />
<polyline id="udp" points="" style="fill:blue;fill-opacity:0.4;stroke:blue;stroke-width:1" />
<polyline id="other" points="" style="fill:red;fill-opacity:0.4;stroke:red;stroke-width:1" />
<line x1="0" y1="25%" x2="100%" y2="25%" style="stroke:black;stroke-width:0.1" />
<text id="label_75" x="20" y="24%" style="fill:#eee; font-size:9pt; font-family:sans-serif; text-shadow:1px 1px 1px #000"> </text>
<line x1="0" y1="50%" x2="100%" y2="50%" style="stroke:black;stroke-width:0.1" />
<text id="label_50" x="20" y="49%" style="fill:#eee; font-size:9pt; font-family:sans-serif; text-shadow:1px 1px 1px #000"> </text>
<line x1="0" y1="75%" x2="100%" y2="75%" style="stroke:black;stroke-width:0.1" />
<text id="label_25" x="20" y="74%" style="fill:#eee; font-size:9pt; font-family:sans-serif; text-shadow:1px 1px 1px #000"> </text>
</svg>

Before

Width:  |  Height:  |  Size: 1,009 B

After

Width:  |  Height:  |  Size: 1.1 KiB

Before After
Before After

View file

@ -2,16 +2,16 @@
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg">
<line x1="0" y1="25%" x2="100%" y2="25%" style="stroke:black;stroke-width:0.1" />
<text id="label_75" x="20" y="24%" style="fill:#999999; font-size:9pt"> </text>
<line x1="0" y1="50%" x2="100%" y2="50%" style="stroke:black;stroke-width:0.1" />
<text id="label_50" x="20" y="49%" style="fill:#999999; font-size:9pt"> </text>
<line x1="0" y1="75%" x2="100%" y2="75%" style="stroke:black;stroke-width:0.1" />
<text id="label_25" x="20" y="74%" style="fill:#999999; font-size:9pt"> </text>
<polyline id="load01" points="" style="fill:#ff0000;fill-opacity:0.4;stroke:#ff0000;stroke-width:1" />
<polyline id="load05" points="" style="fill:#ff6600;fill-opacity:0.4;stroke:#ff6600;stroke-width:1" />
<polyline id="load15" points="" style="fill:#ffaa00;fill-opacity:0.4;stroke:#ffaa00;stroke-width:1" />
<line x1="0" y1="25%" x2="100%" y2="25%" style="stroke:black;stroke-width:0.1" />
<text id="label_75" x="20" y="24%" style="fill:#eee; font-size:9pt; font-family:sans-serif; text-shadow:1px 1px 1px #000"> </text>
<line x1="0" y1="50%" x2="100%" y2="50%" style="stroke:black;stroke-width:0.1" />
<text id="label_50" x="20" y="49%" style="fill:#eee; font-size:9pt; font-family:sans-serif; text-shadow:1px 1px 1px #000"> </text>
<line x1="0" y1="75%" x2="100%" y2="75%" style="stroke:black;stroke-width:0.1" />
<text id="label_25" x="20" y="74%" style="fill:#eee; font-size:9pt; font-family:sans-serif; text-shadow:1px 1px 1px #000"> </text>
</svg>

Before

Width:  |  Height:  |  Size: 1 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Before After
Before After

View file

@ -2,14 +2,14 @@
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg">
<polyline id="rate" points="" style="fill:green;fill-opacity:0.4;stroke:green;stroke-width:1" />
<line x1="0" y1="25%" x2="100%" y2="25%" style="stroke:black;stroke-width:0.1" />
<text id="label_75" x="20" y="24%" style="fill:#999999; font-size:9pt"> </text>
<text id="label_75" x="20" y="24%" style="fill:#eee; font-size:9pt; font-family:sans-serif; text-shadow:1px 1px 1px #000"> </text>
<line x1="0" y1="50%" x2="100%" y2="50%" style="stroke:black;stroke-width:0.1" />
<text id="label_50" x="20" y="49%" style="fill:#999999; font-size:9pt"> </text>
<text id="label_50" x="20" y="49%" style="fill:#eee; font-size:9pt; font-family:sans-serif; text-shadow:1px 1px 1px #000"> </text>
<line x1="0" y1="75%" x2="100%" y2="75%" style="stroke:black;stroke-width:0.1" />
<text id="label_25" x="20" y="74%" style="fill:#999999; font-size:9pt"> </text>
<polyline id="rate" points="" style="fill:green;fill-opacity:0.4;stroke:green;stroke-width:1" />
<text id="label_25" x="20" y="74%" style="fill:#eee; font-size:9pt; font-family:sans-serif; text-shadow:1px 1px 1px #000"> </text>
</svg>

Before

Width:  |  Height:  |  Size: 820 B

After

Width:  |  Height:  |  Size: 973 B

Before After
Before After

View file

@ -2,15 +2,15 @@
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg">
<line x1="0" y1="25%" x2="100%" y2="25%" style="stroke:black;stroke-width:0.1" />
<text id="label_75" x="20" y="24%" style="fill:#999999; font-size:9pt"> </text>
<line x1="0" y1="50%" x2="100%" y2="50%" style="stroke:black;stroke-width:0.1" />
<text id="label_50" x="20" y="49%" style="fill:#999999; font-size:9pt"> </text>
<line x1="0" y1="75%" x2="100%" y2="75%" style="stroke:black;stroke-width:0.1" />
<text id="label_25" x="20" y="74%" style="fill:#999999; font-size:9pt"> </text>
<polyline id="rssi" points="" style="fill:blue;fill-opacity:0.4;stroke:blue;stroke-width:1" />
<polyline id="noise" points="" style="fill:red;fill-opacity:0.4;stroke:red;stroke-width:1" />
<line x1="0" y1="25%" x2="100%" y2="25%" style="stroke:black;stroke-width:0.1" />
<text id="label_75" x="20" y="24%" style="fill:#eee; font-size:9pt; font-family:sans-serif; text-shadow:1px 1px 1px #000"> </text>
<line x1="0" y1="50%" x2="100%" y2="50%" style="stroke:black;stroke-width:0.1" />
<text id="label_50" x="20" y="49%" style="fill:#eee; font-size:9pt; font-family:sans-serif; text-shadow:1px 1px 1px #000"> </text>
<line x1="0" y1="75%" x2="100%" y2="75%" style="stroke:black;stroke-width:0.1" />
<text id="label_25" x="20" y="74%" style="fill:#eee; font-size:9pt; font-family:sans-serif; text-shadow:1px 1px 1px #000"> </text>
</svg>

Before

Width:  |  Height:  |  Size: 913 B

After

Width:  |  Height:  |  Size: 1 KiB

Before After
Before After

View file

@ -1,5 +1,5 @@
-- Copyright 2008 Steven Barth <steven@midlink.org>
-- Copyright 2011-2015 Jo-Philipp Wich <jow@openwrt.org>
-- Copyright 2011-2018 Jo-Philipp Wich <jo@mein.io>
-- Licensed to the public under the Apache License 2.0.
module("luci.controller.admin.network", package.seeall)
@ -45,26 +45,26 @@ function index()
if has_wifi then
page = entry({"admin", "network", "wireless_assoclist"}, call("wifi_assoclist"), nil)
page.leaf = true
page = entry({"admin", "network", "wireless_join"}, post("wifi_join"), nil)
page.leaf = true
page = entry({"admin", "network", "wireless_add"}, post("wifi_add"), nil)
page.leaf = true
page = entry({"admin", "network", "wireless_delete"}, post("wifi_delete"), nil)
page.leaf = true
page = entry({"admin", "network", "wireless_status"}, call("wifi_status"), nil)
page.leaf = true
page = entry({"admin", "network", "wireless_reconnect"}, post("wifi_reconnect"), nil)
page.leaf = true
page = entry({"admin", "network", "wireless_shutdown"}, post("wifi_shutdown"), nil)
page = entry({"admin", "network", "wireless_scan_trigger"}, post("wifi_scan_trigger"), nil)
page.leaf = true
page = entry({"admin", "network", "wireless"}, arcombine(template("admin_network/wifi_overview"), cbi("admin_network/wifi")), _("Wireless"), 15)
page = entry({"admin", "network", "wireless_scan_results"}, call("wifi_scan_results"), nil)
page.leaf = true
page = entry({"admin", "network", "wireless"}, arcombine(cbi("admin_network/wifi_overview"), cbi("admin_network/wifi")), _("Wireless"), 15)
page.leaf = true
page.subindex = true
@ -88,18 +88,12 @@ function index()
page = entry({"admin", "network", "iface_add"}, form("admin_network/iface_add"), nil)
page.leaf = true
page = entry({"admin", "network", "iface_delete"}, post("iface_delete"), nil)
page.leaf = true
page = entry({"admin", "network", "iface_status"}, call("iface_status"), nil)
page.leaf = true
page = entry({"admin", "network", "iface_reconnect"}, post("iface_reconnect"), nil)
page.leaf = true
page = entry({"admin", "network", "iface_shutdown"}, post("iface_shutdown"), nil)
page.leaf = true
page = entry({"admin", "network", "network"}, arcombine(cbi("admin_network/network"), cbi("admin_network/ifaces")), _("Interfaces"), 10)
page.leaf = true
page.subindex = true
@ -156,9 +150,6 @@ function index()
page = entry({"admin", "network", "diag_traceroute6"}, post("diag_traceroute6"), nil)
page.leaf = true
page = entry({"admin", "network", "diag_iperf3"}, post("diag_iperf3"), nil)
page.leaf = true
page = entry({"admin", "network", "diag_speedtest"}, post("diag_speedtest"), nil)
page.leaf = true
@ -213,29 +204,6 @@ function wifi_add()
end
end
function wifi_delete(network)
local ntm = require "luci.model.network".init()
local wnet = ntm:get_wifinet(network)
if wnet then
local dev = wnet:get_device()
local nets = wnet:get_networks()
if dev then
ntm:del_wifinet(network)
ntm:commit("wireless")
local _, net
for _, net in ipairs(nets) do
if net:is_empty() then
ntm:del_network(net:name())
ntm:commit("network")
end
end
luci.sys.call("env -i /bin/ubus call network reload >/dev/null 2>/dev/null")
end
end
luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless"))
end
function iface_status(ifaces)
local netm = require "luci.model.network".init()
local rv = { }
@ -247,6 +215,7 @@ function iface_status(ifaces)
if device then
local data = {
id = iface,
desc = net:get_i18n(),
proto = net:proto(),
uptime = net:uptime(),
gwaddr = net:gwaddr(),
@ -254,11 +223,15 @@ function iface_status(ifaces)
ip6addrs = net:ip6addrs(),
dnsaddrs = net:dnsaddrs(),
ip6prefix = net:ip6prefix(),
errors = net:errors(),
name = device:shortname(),
type = device:type(),
typename = device:get_type_i18n(),
ifname = device:name(),
macaddr = device:mac(),
is_up = device:is_up(),
is_up = net:is_up() and device:is_up(),
is_alias = net:is_alias(),
is_dynamic = net:is_dynamic(),
rx_bytes = device:rx_bytes(),
tx_bytes = device:tx_bytes(),
rx_packets = device:rx_packets(),
@ -271,6 +244,7 @@ function iface_status(ifaces)
data.subdevices[#data.subdevices+1] = {
name = device:shortname(),
type = device:type(),
typename = device:get_type_i18n(),
ifname = device:name(),
macaddr = device:mac(),
is_up = device:is_up(),
@ -313,34 +287,6 @@ function iface_reconnect(iface)
luci.http.status(404, "No such interface")
end
function iface_shutdown(iface)
local netmd = require "luci.model.network".init()
local net = netmd:get_network(iface)
if net then
luci.sys.call("env -i /sbin/ifdown %s >/dev/null 2>/dev/null"
% luci.util.shellquote(iface))
luci.http.status(200, "Shutdown")
return
end
luci.http.status(404, "No such interface")
end
function iface_delete(iface)
local netmd = require "luci.model.network".init()
local net = netmd:del_network(iface)
if net then
luci.sys.call("env -i /sbin/ifdown %s >/dev/null 2>/dev/null"
% luci.util.shellquote(iface))
luci.http.redirect(luci.dispatcher.build_url("admin/network/network"))
netmd:commit("network")
netmd:commit("wireless")
return
end
luci.http.status(404, "No such interface")
end
function wifi_status(devs)
local s = require "luci.tools.status"
local rv = { }
@ -361,39 +307,95 @@ function wifi_status(devs)
luci.http.status(404, "No such device")
end
local function wifi_reconnect_shutdown(shutdown, wnet)
local netmd = require "luci.model.network".init()
local net = netmd:get_wifinet(wnet)
local dev = net:get_device()
if dev and net then
dev:set("disabled", nil)
net:set("disabled", shutdown and 1 or nil)
netmd:commit("wireless")
function wifi_reconnect(radio)
local rc = luci.sys.call("env -i /sbin/wifi up %s" % luci.util.shellquote(radio))
luci.sys.call("env -i /bin/ubus call network reload >/dev/null 2>/dev/null")
luci.http.status(200, shutdown and "Shutdown" or "Reconnected")
return
if rc == 0 then
luci.http.status(200, "Reconnected")
else
luci.http.status(500, "Error")
end
luci.http.status(404, "No such radio")
end
function wifi_reconnect(wnet)
wifi_reconnect_shutdown(false, wnet)
end
function wifi_shutdown(wnet)
wifi_reconnect_shutdown(true, wnet)
end
function wifi_assoclist()
local s = require "luci.tools.status"
luci.http.prepare_content("application/json")
luci.http.write_json(s.wifi_assoclist())
end
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
luci.http.status(200, "Scan scheduled")
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
function lease_status()
local s = require "luci.tools.status"
@ -454,10 +456,6 @@ function diag_traceroute6(addr)
diag_command("traceroute6 -q 1 -w 2 -n %s 2>&1", addr)
end
function diag_iperf3(addr)
diag_command("iperf3 -c %q 2>&1", addr)
end
function diag_getip(addr)
diag_command("curl %q", addr)
end

View file

@ -122,12 +122,12 @@ function action_connections()
luci.http.prepare_content("application/json")
luci.http.write("{ connections: ")
luci.http.write('{ "connections": ')
luci.http.write_json(sys.net.conntrack())
local bwc = io.popen("luci-bwc -c 2>/dev/null")
if bwc then
luci.http.write(", statistics: [")
luci.http.write(', "statistics": [')
while true do
local ln = bwc:read("*l")

View file

@ -341,9 +341,17 @@ function action_restore()
local upload = http.formvalue("archive")
if upload and #upload > 0 then
luci.template.render("admin_system/applyreboot")
os.execute("tar -C / -xzf %q >/dev/null 2>&1" % archive_tmp)
luci.sys.reboot()
if os.execute("gunzip -t %q >/dev/null 2>&1" % archive_tmp) == 0 then
luci.template.render("admin_system/applyreboot")
os.execute("tar -C / -xzf %q >/dev/null 2>&1" % archive_tmp)
luci.sys.reboot()
else
luci.template.render("admin_system/flashops", {
reset_avail = supports_reset(),
upgrade_avail = supports_sysupgrade(),
backup_invalid = true
})
end
return
end

View file

@ -122,6 +122,9 @@ s:taboption("advanced", Flag, "strictorder",
translate("<abbr title=\"Domain Name System\">DNS</abbr> servers will be queried in the " ..
"order of the resolvfile")).optional = true
s:taboption("advanced", Flag, "allservers",
translate("All Servers"),
translate("Query all available upstream <abbr title=\"Domain Name System\">DNS</abbr> servers")).optional = true
bn = s:taboption("advanced", DynamicList, "bogusnxdomain", translate("Bogus NX Domain Override"),
translate("List of hosts that supply bogus NX domain results"))

View file

@ -10,6 +10,10 @@ m = SimpleForm("network", translate("Create Interface"))
m.redirect = luci.dispatcher.build_url("admin/network/network")
m.reset = false
function m.on_cancel()
luci.http.redirect(luci.dispatcher.build_url("admin/network/network"))
end
newnet = m:field(Value, "_netname", translate("Name of the new interface"),
translate("The allowed characters are: <code>A-Z</code>, <code>a-z</code>, " ..
"<code>0-9</code> and <code>_</code>"

View file

@ -315,6 +315,7 @@ if not net:is_floating() then
ifname_single.template = "cbi/network_ifacelist"
ifname_single.widget = "radio"
ifname_single.nobridges = true
ifname_single.noaliases = false
ifname_single.rmempty = false
ifname_single.network = arg[1]
ifname_single:depends("type", "")
@ -325,12 +326,18 @@ if not net:is_floating() then
end
function ifname_single.write(self, s, val)
local i
local _, i
local new_ifs = { }
local old_ifs = { }
for _, i in ipairs(net:get_interfaces() or { net:get_interface() }) do
old_ifs[#old_ifs+1] = i:name()
local alias = net:is_alias()
if alias then
old_ifs[1] = '@' .. alias
else
for _, i in ipairs(net:get_interfaces() or { net:get_interface() }) do
old_ifs[#old_ifs+1] = i:name()
end
end
for i in ut.imatch(val) do
@ -365,6 +372,7 @@ if not net:is_virtual() then
ifname_multi = s:taboption("physical", Value, "ifname_multi", translate("Interface"))
ifname_multi.template = "cbi/network_ifacelist"
ifname_multi.nobridges = true
ifname_multi.noaliases = true
ifname_multi.rmempty = false
ifname_multi.network = arg[1]
ifname_multi.widget = "checkbox"

View file

@ -3,12 +3,147 @@
-- Licensed to the public under the Apache License 2.0.
local fs = require "nixio.fs"
local tpl = require "luci.template"
local ntm = require "luci.model.network".init()
local fwm = require "luci.model.firewall".init()
local json = require "luci.jsonc"
local sys = require "luci.sys"
m = Map("network", translate("Interfaces"))
m:chain("wireless")
m:chain("firewall")
m:chain("dhcp")
m.pageaction = false
m:section(SimpleSection).template = "admin_network/iface_overview"
local tpl_networks = tpl.Template(nil, [[
<div class="cbi-section-node">
<div class="table">
<%
for i, net in ipairs(netlist) do
local z = net[3]
local c = z and z:get_color() or "#EEEEEE"
local t = z and translate("Part of zone %q" % z:name()) or translate("No zone assigned")
local disabled = (net[4]:get("auto") == "0")
local dynamic = net[4]:is_dynamic()
%>
<div class="tr cbi-rowstyle-<%=i % 2 + 1%>">
<div class="td col-3 center middle">
<div class="ifacebox">
<div class="ifacebox-head" style="background-color:<%=c%>" title="<%=pcdata(t)%>">
<strong><%=net[1]:upper()%></strong>
</div>
<div class="ifacebox-body" id="<%=net[1]%>-ifc-devices" data-network="<%=net[1]%>">
<img src="<%=resource%>/icons/ethernet_disabled.png" style="width:16px; height:16px" /><br />
<small>?</small>
</div>
</div>
</div>
<div class="td col-5 left middle" id="<%=net[1]%>-ifc-description">
<em><%:Collecting data...%></em>
</div>
<div class="td cbi-section-actions">
<div>
<input type="button" class="cbi-button cbi-button-neutral" onclick="iface_reconnect('<%=net[1]%>')" title="<%:Reconnect this interface%>" value="<%:Restart%>"<%=ifattr(disabled or dynamic, "disabled", "disabled")%> />
<% if disabled then %>
<input type="hidden" name="cbid.network.<%=net[1]%>.__disable__" value="1" />
<input type="submit" name="cbi.apply" class="cbi-button cbi-button-neutral" onclick="this.previousElementSibling.value='0'" title="<%:Reconnect this interface%>" value="<%:Connect%>"<%=ifattr(dynamic, "disabled", "disabled")%> />
<% else %>
<input type="hidden" name="cbid.network.<%=net[1]%>.__disable__" value="0" />
<input type="submit" name="cbi.apply" class="cbi-button cbi-button-neutral" onclick="this.previousElementSibling.value='1'" title="<%:Shutdown this interface%>" value="<%:Stop%>"<%=ifattr(dynamic, "disabled", "disabled")%> />
<% end %>
<input type="button" class="cbi-button cbi-button-action important" onclick="location.href='<%=url("admin/network/network", net[1])%>'" title="<%:Edit this interface%>" value="<%:Edit%>" id="<%=net[1]%>-ifc-edit"<%=ifattr(dynamic, "disabled", "disabled")%> />
<input type="hidden" name="cbid.network.<%=net[1]%>.__delete__" value="" />
<input type="submit" name="cbi.apply" class="cbi-button cbi-button-negative" onclick="iface_delete(event)" value="<%:Delete%>"<%=ifattr(dynamic, "disabled", "disabled")%> />
</div>
</div>
</div>
<% end %>
</div>
</div>
<div class="cbi-section-create">
<input type="button" class="cbi-button cbi-button-add" value="<%:Add new interface...%>" onclick="location.href='<%=url("admin/network/iface_add")%>'" />
</div>
]])
local _, net
local ifaces, netlist = { }, { }
for _, net in ipairs(ntm:get_networks()) do
if net:name() ~= "loopback" then
local zn = net:zonename()
local z = zn and fwm:get_zone(zn) or fwm:get_zone_by_network(net:name())
local w = 1
if net:is_alias() then
w = 2
elseif net:is_dynamic() then
w = 3
end
ifaces[#ifaces+1] = net:name()
netlist[#netlist+1] = {
net:name(), z and z:name() or "-", z, net, w
}
end
end
table.sort(netlist,
function(a, b)
if a[2] ~= b[2] then
return a[2] < b[2]
elseif a[5] ~= b[5] then
return a[5] < b[5]
else
return a[1] < b[1]
end
end)
s = m:section(TypedSection, "interface", translate("Interface Overview"))
function s.sections(self)
local _, net, sl = nil, nil, { }
for _, net in ipairs(netlist) do
sl[#sl+1] = net[1]
end
return sl
end
function s.render(self)
tpl_networks:render({
netlist = netlist
})
end
o = s:option(Value, "__disable__")
function o.cfgvalue(self, sid)
return (m:get(sid, "auto") == "0") and "1" or "0"
end
function o.write(self, sid, value)
if value ~= "1" then
m:set(sid, "auto", "")
else
m:set(sid, "auto", "0")
end
end
o.remove = o.write
o = s:option(Value, "__delete__")
function o.write(self, sid, value)
ntm:del_network(sid)
end
m:section(SimpleSection).template = "admin_network/iface_overview_status"
if fs.access("/etc/init.d/dsl_control") then
local ok, boarddata = pcall(json.parse, fs.readfile("/etc/board.json"))

View file

@ -16,7 +16,7 @@ local acct_port, acct_secret, acct_server, anonymous_identity, ant1, ant2,
mp, nasid, network, password, pmk_r1_push, privkey, privkey2, privkeypwd,
privkeypwd2, r0_key_lifetime, r0kh, r1_key_holder, r1kh,
reassociation_deadline, retry_timeout, ssid, st, tp, wepkey, wepslot,
wmm, wpakey, wps
wmm, wpakey, wps, disassoc_low_ack, short_preamble, beacon_int, dtim_period
arg[1] = arg[1] or ""
@ -250,6 +250,14 @@ if hwtype == "mac80211" then
s:taboption("advanced", Value, "frag", translate("Fragmentation Threshold"))
s:taboption("advanced", Value, "rts", translate("RTS/CTS Threshold"))
s:taboption("advanced", Flag, "noscan", translate("Force 40MHz mode"),
translate("Always use 40MHz channels even if the secondary channel overlaps. Using this option does not comply with IEEE 802.11n-2009!")).optional = true
beacon_int = s:taboption("advanced", Value, "beacon_int", translate("Beacon Interval"))
beacon_int.optional = true
beacon_int.placeholder = 100
beacon_int.datatype = "range(15,65535)"
end
@ -491,6 +499,18 @@ if hwtype == "mac80211" then
ifname = s:taboption("advanced", Value, "ifname", translate("Interface name"), translate("Override default interface name"))
ifname.optional = true
short_preamble = s:taboption("advanced", Flag, "short_preamble", translate("Short Preamble"))
short_preamble.default = short_preamble.enabled
dtim_period = s:taboption("advanced", Value, "dtim_period", translate("DTIM Interval"), translate("Delivery Traffic Indication Message Interval"))
dtim_period.optional = true
dtim_period.placeholder = 2
dtim_period.datatype = "range(1,255)"
disassoc_low_ack = s:taboption("advanced", Flag, "disassoc_low_ack", translate("Disassociate On Low Acknowledgement"),
translate("Allow AP mode to disconnect STAs based on low ACK condition"))
disassoc_low_ack.default = disassoc_low_ack.enabled
end

View file

@ -0,0 +1,223 @@
-- Copyright 2018 Jo-Philipp Wich <jo@mein.io>
-- Licensed to the public under the Apache License 2.0.
local fs = require "nixio.fs"
local utl = require "luci.util"
local tpl = require "luci.template"
local ntm = require "luci.model.network"
local has_iwinfo = pcall(require, "iwinfo")
function guess_wifi_hw(dev)
local bands = ""
local ifname = dev:name()
local name, idx = ifname:match("^([a-z]+)(%d+)")
idx = tonumber(idx)
if has_iwinfo then
local bl = dev.iwinfo.hwmodelist
if bl and next(bl) then
if bl.a then bands = bands .. "a" end
if bl.b then bands = bands .. "b" end
if bl.g then bands = bands .. "g" end
if bl.n then bands = bands .. "n" end
if bl.ac then bands = bands .. "ac" end
end
local hw = dev.iwinfo.hardware_name
if hw then
return "%s 802.11%s" %{ hw, bands }
end
end
-- wl.o
if name == "wl" then
local name = translatef("Broadcom 802.11%s Wireless Controller", bands)
local nm = 0
local fd = nixio.open("/proc/bus/pci/devices", "r")
if fd then
local ln
for ln in fd:linesource() do
if ln:match("wl$") then
if nm == idx then
local version = ln:match("^%S+%s+%S%S%S%S([0-9a-f]+)")
name = translatef(
"Broadcom BCM%04x 802.11 Wireless Controller",
tonumber(version, 16)
)
break
else
nm = nm + 1
end
end
end
fd:close()
end
return name
-- dunno yet
else
return translatef("Generic 802.11%s Wireless Controller", bands)
end
end
local tpl_radio = tpl.Template(nil, [[
<div class="cbi-section-node">
<div class="table">
<!-- physical device -->
<div class="tr cbi-rowstyle-2">
<div class="td col-2 center middle">
<span class="ifacebadge"><img src="<%=resource%>/icons/wifi_toggled.png" id="<%=dev:name()%>-iw-upstate" /> <%=dev:name()%></span>
</div>
<div class="td col-7 left middle">
<big><strong><%=hw%></strong></big><br />
<span id="<%=dev:name()%>-iw-devinfo"></span>
</div>
<div class="td middle cbi-section-actions">
<div>
<input type="button" class="cbi-button cbi-button-neutral" title="<%:Restart radio interface%>" value="<%:Restart%>" data-radio="<%=dev:name()%>" onclick="wifi_restart(event)" />
<input type="button" class="cbi-button cbi-button-action important" title="<%:Find and join network%>" value="<%:Scan%>" onclick="cbi_submit(this, 'device', '<%=dev:name()%>', '<%=url('admin/network/wireless_join')%>')" />
<input type="button" class="cbi-button cbi-button-add" title="<%:Provide new network%>" value="<%:Add%>" onclick="cbi_submit(this, 'device', '<%=dev:name()%>', '<%=url('admin/network/wireless_add')%>')" />
</div>
</div>
</div>
<!-- /physical device -->
<!-- network list -->
<% if #wnets > 0 then %>
<% for i, net in ipairs(wnets) do local disabled = (dev:get("disabled") == "1" or net:get("disabled") == "1") %>
<div class="tr cbi-rowstyle-<%=1 + ((i-1) % 2)%>">
<div class="td col-2 center middle" id="<%=net:id()%>-iw-signal">
<span class="ifacebadge" title="<%:Not associated%>"><img src="<%=resource%>/icons/signal-<%= disabled and "none" or "0" %>.png" /> 0%</span>
</div>
<div class="td col-7 left middle" id="<%=net:id()%>-iw-status" data-network="<%=net:id()%>" data-disabled="<%= disabled and "true" or "false" %>">
<em><%= disabled and translate("Wireless is disabled") or translate("Collecting data...") %></em>
</div>
<div class="td middle cbi-section-actions">
<div>
<% if disabled then %>
<input name="cbid.wireless.<%=net:name()%>.__disable__" type="hidden" value="1" />
<input name="cbi.apply" type="submit" class="cbi-button cbi-button-neutral" title="<%:Enable this network%>" value="<%:Enable%>" onclick="this.previousElementSibling.value='0'" />
<% else %>
<input name="cbid.wireless.<%=net:name()%>.__disable__" type="hidden" value="0" />
<input name="cbi.apply" type="submit" class="cbi-button cbi-button-neutral" title="<%:Disable this network%>" value="<%:Disable%>" onclick="this.previousElementSibling.value='1'" />
<% end %>
<input type="button" class="cbi-button cbi-button-action important" onclick="location.href='<%=net:adminlink()%>'" title="<%:Edit this network%>" value="<%:Edit%>" />
<input name="cbid.wireless.<%=net:name()%>.__delete__" type="hidden" value="" />
<input name="cbi.apply" type="submit" class="cbi-button cbi-button-negative" title="<%:Delete this network%>" value="<%:Remove%>" onclick="wifi_delete(event)" />
</div>
</div>
</div>
<% end %>
<% else %>
<div class="tr cbi-rowstyle-2">
<div class="td left">
<em><%:No network configured on this device%></em>
</div>
</div>
<% end %>
<!-- /network list -->
</div>
</div>
]])
m = Map("wireless", translate("Wireless Overview"))
m:chain("network")
m.pageaction = false
if not has_iwinfo then
s = m:section(NamedSection, "__warning__")
function s.render(self)
tpl.render_string([[
<div class="alert-message warning">
<h4><%:Package libiwinfo required!%></h4>
<p><%_The <em>libiwinfo-lua</em> package is not installed. You must install this component for working wireless configuration!%></p>
</div>
]])
end
end
local _, dev, net
for _, dev in ipairs(ntm:get_wifidevs()) do
s = m:section(TypedSection)
s.wnets = dev:get_wifinets()
function s.render(self, sid)
tpl_radio:render({
hw = guess_wifi_hw(dev),
dev = dev,
wnets = self.wnets
})
end
function s.cfgsections(self)
local _, net, sl = nil, nil, { }
for _, net in ipairs(self.wnets) do
sl[#sl+1] = net:name()
self.wnets[net:name()] = net
end
return sl
end
o = s:option(Value, "__disable__")
function o.cfgvalue(self, sid)
local wnet = self.section.wnets[sid]
local wdev = wnet:get_device()
return ((wnet and wnet:get("disabled") == "1") or
(wdev and wdev:get("disabled") == "1")) and "1" or "0"
end
function o.write(self, sid, value)
local wnet = self.section.wnets[sid]
local wdev = wnet:get_device()
if value ~= "1" then
wnet:set("disabled", nil)
wdev:set("disabled", nil)
else
wnet:set("disabled", "1")
end
end
o.remove = o.write
o = s:option(Value, "__delete__")
function o.write(self, sid, value)
local wnet = self.section.wnets[sid]
local nets = wnet:get_networks()
ntm:del_wifinet(wnet:id())
local _, net
for _, net in ipairs(nets) do
if net:is_empty() then
ntm:del_network(net:name())
end
end
end
end
s = m:section(NamedSection, "__script__")
s.template = "admin_network/wifi_overview_status"
s = m:section(NamedSection, "__assoclist__")
function s.render(self, sid)
tpl.render_string([[
<h2><%:Associated Stations%></h2>
<%+admin_network/wifi_assoclist%>
]])
end
return m

View file

@ -8,20 +8,17 @@
<%
local fs = require "nixio.fs"
local has_ping6 = fs.access("/bin/ping6") or fs.access("/usr/bin/ping6")
local has_traceroute6 = fs.access("/usr/bin/traceroute6")
local has_traceroute6 = fs.access("/bin/traceroute6") or fs.access("/usr/bin/traceroute6")
local has_speedtest = fs.access("/usr/sbin/speedtestc")
local has_iperf3 = fs.access("/usr/bin/iperf3")
local has_curl = fs.access("/usr/bin/curl")
local has_netstat = fs.access("/bin/netstat")
local dns_host = luci.config.diag and luci.config.diag.dns or "dev.openwrt.org"
local ping_host = luci.config.diag and luci.config.diag.ping or "dev.openwrt.org"
local route_host = luci.config.diag and luci.config.diag.route or "dev.openwrt.org"
local iperf3_host = luci.config.diag and luci.config.diag.iperf3 or "ping-ams1.online.net"
local getip_host = luci.config.diag and luci.config.diag.getip or "ifconfig.co"
%>
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<script type="text/javascript">//<![CDATA[
var stxhr = new XHR();
@ -113,13 +110,6 @@ local getip_host = luci.config.diag and luci.config.diag.getip or "ifconfig.co"
</div>
<% end %>
<% if has_iperf3 then %>
<div class="td left">
<input style="margin: 5px 0" type="text" value="<%=iperf3_host%>" name="iperf3" /><br />
<input type="button" value="<%:Iperf3%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.iperf3)" />
</div>
<% end %>
<% if has_curl then %>
<div class="td left">
<input style="margin: 5px 0" type="hidden" value="<%=getip_host%>" name="getip" /><br />

View file

@ -1,251 +0,0 @@
<%#
Copyright 2010 Jo-Philipp Wich <jow@openwrt.org>
Licensed to the public under the Apache License 2.0.
-%>
<%-
local ntm = require "luci.model.network".init()
local fwm = require "luci.model.firewall".init()
local net
local ifaces = { }
local netlist = { }
for _, net in ipairs(ntm:get_networks()) do
if net:name() ~= "loopback" then
local z = fwm:get_zone_by_network(net:name())
ifaces[#ifaces+1] = net:name()
netlist[#netlist+1] = {
net:name(), z and z:name() or "-", z
}
end
end
table.sort(netlist,
function(a, b)
if a[2] ~= b[2] then
return a[2] < b[2]
else
return a[1] < b[1]
end
end)
-%>
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<script type="text/javascript">//<![CDATA[
function iface_shutdown(id, reconnect) {
if (!reconnect && !confirm(<%=luci.http.write_json(translate('Really shutdown interface "%s"? You might lose access to this device if you are connected via this interface.'))%>.format(id)))
return;
var d = document.getElementById(id + '-ifc-description');
if (d)
d.innerHTML = reconnect
? '<em><%:Interface is reconnecting...%></em>'
: '<em><%:Interface is shutting down...%></em>';
var s = document.getElementById('ifc-rc-status');
if (s)
{
s.parentNode.style.display = 'block';
s.innerHTML = '<%:Waiting for changes to be applied...%>';
}
(new XHR()).post('<%=url('admin/network')%>/iface_' + (reconnect ? 'reconnect' : 'shutdown') + '/' + id, { token: '<%=token%>' },
function(x)
{
if (s)
{
s.innerHTML = reconnect
? '<%:Interface reconnected%>'
: '<%:Interface shut down%>';
window.setTimeout(function() {
s.parentNode.style.display = 'none';
}, 1000);
}
}
);
}
function iface_delete(id) {
if (!confirm(<%=luci.http.write_json(translate('Really delete this interface? The deletion cannot be undone! You might lose access to this device if you are connected via this interface'))%>))
return;
(new XHR()).post('<%=url('admin/network/iface_delete')%>/' + id, { token: '<%=token%>' },
function(x) {
location.href = '<%=url('admin/network/network')%>';
}
);
}
var iwxhr = new XHR();
var wifidevs = <%=luci.http.write_json(netdevs)%>;
var arptable = <%=luci.http.write_json(arpcache)%>;
XHR.poll(5, '<%=url('admin/network/iface_status', table.concat(ifaces, ","))%>', null,
function(x, ifcs)
{
if (ifcs)
{
for (var idx = 0; idx < ifcs.length; idx++)
{
var ifc = ifcs[idx];
var html = '';
var s = document.getElementById(ifc.id + '-ifc-devices');
if (s)
{
var stat = String.format(
'<img src="<%=resource%>/icons/%s%s.png" style="width:16px; height:16px; vertical-align:middle" />',
ifc.type,
ifc.is_up ? '' : '_disabled'
);
if (ifc.subdevices && ifc.subdevices.length)
{
stat += ' <strong>(';
for (var j = 0; j < ifc.subdevices.length; j++)
{
var sif = ifc.subdevices[j];
stat += String.format(
'<img src="<%=resource%>/icons/%s%s.png" style="width:16px; height:16px; vertical-align:middle" title="%h" />',
sif.type,
sif.is_up ? '' : '_disabled',
sif.name
);
}
stat += ')</strong>';
}
stat += String.format(
'<br /><small>%h</small>',
ifc.name
);
s.innerHTML = stat;
}
var d = document.getElementById(ifc.id + '-ifc-description');
if (d && ifc.proto && ifc.ifname)
{
if (ifc.is_up)
{
html += String.format('<strong><%:Uptime%>:</strong> %t<br />', ifc.uptime);
}
if (ifc.macaddr)
{
html += String.format('<strong><%:MAC-Address%>:</strong> %s<br />', ifc.macaddr);
}
html += String.format(
'<strong><%:RX%>:</strong> %.2mB (%d <%:Pkts.%>)<br />' +
'<strong><%:TX%>:</strong> %.2mB (%d <%:Pkts.%>)<br />',
ifc.rx_bytes, ifc.rx_packets,
ifc.tx_bytes, ifc.tx_packets
);
if (ifc.ipaddrs && ifc.ipaddrs.length)
{
for (var i = 0; i < ifc.ipaddrs.length; i++)
html += String.format(
'<strong><%:IPv4%>:</strong> %s<br />',
ifc.ipaddrs[i]
);
}
if (ifc.ip6addrs && ifc.ip6addrs.length)
{
for (var i = 0; i < ifc.ip6addrs.length; i++)
html += String.format(
'<strong><%:IPv6%>:</strong> %s<br />',
ifc.ip6addrs[i]
);
}
if (ifc.ip6prefix)
{
html += String.format('<strong><%:IPv6-PD%>:</strong> %s<br />', ifc.ip6prefix);
}
d.innerHTML = html;
}
else if (d && !ifc.proto)
{
var e = document.getElementById(ifc.id + '-ifc-edit');
if (e)
e.disabled = true;
d.innerHTML = String.format(
'<em><%:Unsupported protocol type.%></em><br />' +
'<a href="%h"><%:Install protocol extensions...%></a>',
'<%=url("admin/system/packages")%>?query=luci-proto&display=available'
);
}
else if (d && !ifc.ifname)
{
d.innerHTML = String.format(
'<em><%:Network without interfaces.%></em><br />' +
'<a href="<%=url("admin/network/network/%s")%>?tab.network.%s=physical"><%:Assign interfaces...%></a>',
ifc.name, ifc.name
);
}
else if (d)
{
d.innerHTML = '<em><%:Interface not present or not connected yet.%></em>';
}
}
}
}
);
//]]></script>
<fieldset class="cbi-section" style="display:none">
<legend><%:Reconnecting interface%></legend>
<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" />
<span id="ifc-rc-status"><%:Waiting for changes to be applied...%></span>
</fieldset>
<div class="cbi-map">
<div class="cbi-section">
<legend><%:Interface Overview%></legend>
<div class="cbi-section-node">
<div class="table">
<%
for i, net in ipairs(netlist) do
local z = net[3]
local c = z and z:get_color() or "#EEEEEE"
local t = z and translate("Part of zone %q" % z:name()) or translate("No zone assigned")
%>
<div class="tr cbi-rowstyle-<%=i % 2 + 1%>">
<div class="td col-3 center middle">
<div class="ifacebox">
<div class="ifacebox-head" style="background-color:<%=c%>" title="<%=pcdata(t)%>">
<strong><%=net[1]:upper()%></strong>
</div>
<div class="ifacebox-body" id="<%=net[1]%>-ifc-devices">
<img src="<%=resource%>/icons/ethernet_disabled.png" style="width:16px; height:16px" /><br />
<small>?</small>
</div>
</div>
</div>
<div class="td col-5 left" id="<%=net[1]%>-ifc-description">
<em><%:Collecting data...%></em>
</div>
<div class="td cbi-section-actions">
<input type="button" class="cbi-button cbi-button-neutral" onclick="iface_shutdown('<%=net[1]%>', true)" title="<%:Reconnect this interface%>" value="<%:Connect%>" />
<input type="button" class="cbi-button cbi-button-neutral" onclick="iface_shutdown('<%=net[1]%>', false)" title="<%:Shutdown this interface%>" value="<%:Stop%>" />
<input type="button" class="cbi-button cbi-button-action important" onclick="location.href='<%=url("admin/network/network", net[1])%>'" title="<%:Edit this interface%>" value="<%:Edit%>" id="<%=net[1]%>-ifc-edit" />
<input type="button" class="cbi-button cbi-button-negative" onclick="iface_delete('<%=net[1]%>')" value="<%:Delete%>" />
</div>
</div>
<% end %>
</div>
</div>
<input type="button" class="cbi-button cbi-button-add" value="<%:Add new interface...%>" onclick="location.href='<%=url("admin/network/iface_add")%>'" />
</div>
</div>

View file

@ -0,0 +1,183 @@
<%#
Copyright 2010-2018 Jo-Philipp Wich <jo@mein.io>
Licensed to the public under the Apache License 2.0.
-%>
<script type="text/javascript">//<![CDATA[
function iface_reconnect(id) {
XHR.halt();
var d = document.getElementById(id + '-ifc-description');
if (d) d.innerHTML = '<em><%:Interface is reconnecting...%></em>';
(new XHR()).post('<%=url('admin/network/iface_reconnect')%>/' + id,
{ token: '<%=token%>' }, XHR.run);
}
function iface_delete(ev) {
if (!confirm(<%=luci.http.write_json(translate('Really delete this interface? The deletion cannot be undone! You might lose access to this device if you are connected via this interface'))%>)) {
ev.preventDefault();
return false;
}
ev.target.previousElementSibling.value = '1';
return true;
}
var networks = [];
document.querySelectorAll('[data-network]').forEach(function(n) {
networks.push(n.getAttribute('data-network'));
});
function render_iface(ifc) {
return E('span', { class: 'cbi-tooltip-container' }, [
E('img', { 'class' : 'middle', 'src': '<%=resource%>/icons/%s%s.png'.format(
ifc.is_alias ? 'alias' : ifc.type,
ifc.is_up ? '' : '_disabled') }),
E('span', { 'class': 'cbi-tooltip ifacebadge large' }, [
E('img', { 'src': '<%=resource%>/icons/%s%s.png'.format(
ifc.type, ifc.is_up ? '' : '_disabled') }),
E('span', { 'class': 'left' }, [
E('strong', '<%:Type%>: '), ifc.typename, E('br'),
E('strong', '<%:Device%>: '), ifc.ifname, E('br'),
E('strong', '<%:Connected%>: '), ifc.is_up ? '<%:yes%>' : '<%:no%>', E('br'),
ifc.macaddr ? E('strong', '<%:MAC%>: ') : '',
ifc.macaddr ? ifc.macaddr : '',
ifc.macaddr ? E('br') : '',
E('strong', '<%:RX%>: '), '%.2mB (%d <%:Pkts.%>)'.format(ifc.rx_bytes, ifc.rx_packets), E('br'),
E('strong', '<%:TX%>: '), '%.2mB (%d <%:Pkts.%>)'.format(ifc.tx_bytes, ifc.tx_packets)
])
])
]);
}
XHR.poll(5, '<%=url('admin/network/iface_status')%>/' + networks.join(','), null,
function(x, ifcs)
{
if (ifcs)
{
for (var idx = 0; idx < ifcs.length; idx++)
{
var ifc = ifcs[idx];
var html = '';
var s = document.getElementById(ifc.id + '-ifc-devices');
if (s)
{
while (s.firstChild)
s.removeChild(s.firstChild);
s.appendChild(render_iface(ifc));
if (ifc.subdevices && ifc.subdevices.length)
{
var sifs = [ ' (' ];
for (var j = 0; j < ifc.subdevices.length; j++)
sifs.push(render_iface(ifc.subdevices[j]));
sifs.push(')');
s.appendChild(E('span', {}, sifs));
}
s.appendChild(E('br'));
s.appendChild(E('small', {}, ifc.is_alias ? '<%:Alias of "%s"%>'.format(ifc.is_alias) : ifc.name));
}
var d = document.getElementById(ifc.id + '-ifc-description');
if (d && ifc.proto && ifc.ifname)
{
var desc = null;
if (ifc.is_dynamic)
desc = '<%:Virtual dynamic interface%>';
else if (ifc.is_alias)
desc = '<%:Alias interface%>';
if (ifc.desc)
desc = desc ? '%s (%s)'.format(desc, ifc.desc) : ifc.desc;
html += String.format('<strong><%:Protocol%>:</strong> %h<br />', desc || '?');
if (ifc.is_up)
{
html += String.format('<strong><%:Uptime%>:</strong> %t<br />', ifc.uptime);
}
if (!ifc.is_dynamic && !ifc.is_alias)
{
if (ifc.macaddr)
html += String.format('<strong><%:MAC-Address%>:</strong> %s<br />', ifc.macaddr);
html += String.format(
'<strong><%:RX%>:</strong> %.2mB (%d <%:Pkts.%>)<br />' +
'<strong><%:TX%>:</strong> %.2mB (%d <%:Pkts.%>)<br />',
ifc.rx_bytes, ifc.rx_packets,
ifc.tx_bytes, ifc.tx_packets
);
}
if (ifc.ipaddrs && ifc.ipaddrs.length)
{
for (var i = 0; i < ifc.ipaddrs.length; i++)
html += String.format(
'<strong><%:IPv4%>:</strong> %s<br />',
ifc.ipaddrs[i]
);
}
if (ifc.ip6addrs && ifc.ip6addrs.length)
{
for (var i = 0; i < ifc.ip6addrs.length; i++)
html += String.format(
'<strong><%:IPv6%>:</strong> %s<br />',
ifc.ip6addrs[i]
);
}
if (ifc.ip6prefix)
html += String.format('<strong><%:IPv6-PD%>:</strong> %s<br />', ifc.ip6prefix);
if (ifc.errors)
{
for (var i = 0; i < ifc.errors.length; i++)
html += String.format(
'<em class="error"><strong><%:Error%>:</strong> %h</em><br />',
ifc.errors[i]
);
}
d.innerHTML = html;
}
else if (d && !ifc.proto)
{
var e = document.getElementById(ifc.id + '-ifc-edit');
if (e)
e.disabled = true;
d.innerHTML = String.format(
'<em><%:Unsupported protocol type.%></em><br />' +
'<a href="%h"><%:Install protocol extensions...%></a>',
'<%=url("admin/system/packages")%>?query=luci-proto&display=available'
);
}
else if (d && !ifc.ifname)
{
d.innerHTML = String.format(
'<em><%:Network without interfaces.%></em><br />' +
'<a href="<%=url("admin/network/network/%s")%>?tab.network.%s=physical"><%:Assign interfaces...%></a>',
ifc.name, ifc.name
);
}
else if (d)
{
d.innerHTML = '<em><%:Interface not present or not connected yet.%></em>';
}
}
}
}
);
//]]></script>

View file

@ -8,56 +8,6 @@
local sys = require "luci.sys"
local utl = require "luci.util"
function guess_wifi_signal(info)
local scale = (100 / (info.quality_max or 100) * (info.quality or 0))
local icon
if not info.bssid or info.bssid == "00:00:00:00:00:00" then
icon = resource .. "/icons/signal-none.png"
elseif scale < 15 then
icon = resource .. "/icons/signal-0.png"
elseif scale < 35 then
icon = resource .. "/icons/signal-0-25.png"
elseif scale < 55 then
icon = resource .. "/icons/signal-25-50.png"
elseif scale < 75 then
icon = resource .. "/icons/signal-50-75.png"
else
icon = resource .. "/icons/signal-75-100.png"
end
return icon
end
function percent_wifi_signal(info)
local qc = info.quality or 0
local qm = info.quality_max or 0
if info.bssid and qc > 0 and qm > 0 then
return math.floor((100 / qm) * qc)
else
return 0
end
end
function format_wifi_encryption(info)
if info.wep == true then
return "WEP"
elseif info.wpa > 0 then
return translatef("<abbr title='Pairwise: %s / Group: %s'>%s - %s</abbr>",
table.concat(info.pair_ciphers, ", "),
table.concat(info.group_ciphers, ", "),
(info.wpa == 3) and translate("mixed WPA/WPA2")
or (info.wpa == 2 and "WPA2" or "WPA"),
table.concat(info.auth_suites, ", ")
)
elseif info.enabled then
return "<em>%s</em>" % translate("unknown")
else
return "<em>%s</em>" % translate("open")
end
end
local dev = luci.http.formvalue("device")
local iw = luci.sys.wifi.getiwinfo(dev)
@ -65,91 +15,198 @@
luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless"))
return
end
function scanlist(times)
local i, k, v
local l = { }
local s = { }
for i = 1, times do
for k, v in ipairs(iw.scanlist or { }) do
if not s[v.bssid] then
l[#l+1] = v
s[v.bssid] = true
end
end
end
return l
end
-%>
<%+header%>
<script type="text/javascript">//<![CDATA[
var xhr = new XHR(),
poll = null;
function format_signal(bss) {
var qval = bss.quality || 0,
qmax = bss.quality_max || 100,
scale = 100 / qmax * qval,
range = 'none';
if (!bss.bssid || bss.bssid == '00:00:00:00:00:00')
range = 'none';
else if (scale < 15)
range = '0';
else if (scale < 35)
range = '0-25';
else if (scale < 55)
range = '25-50';
else if (scale < 75)
range = '50-75';
else
range = '75-100';
return E('span', {
class: 'ifacebadge',
title: '<%:Signal%>: %d<%:dB%> / <%:Quality%>: %d/%d'.format(bss.signal, qval, qmax)
}, [
E('img', { src: '<%=resource%>/icons/signal-%s.png'.format(range) }),
' %d%%'.format(scale)
]);
}
function format_encryption(bss) {
var enc = bss.encryption || { }
if (enc.wep === true)
return 'WEP';
else if (enc.wpa > 0)
return E('abbr', {
title: 'Pairwise: %h / Group: %h'.format(
enc.pair_ciphers.join(', '),
enc.group_ciphers.join(', '))
},
'%h - %h'.format(
(enc.wpa === 3) ? '<%:mixed WPA/WPA2%>' : (enc.wpa === 2 ? 'WPA2' : 'WPA'),
enc.auth_suites.join(', ')));
else if (enc.enabled)
return '<em><%:unknown%></em>';
else
return '<em><%:open%></em>';
}
function format_actions(bss) {
var enc = bss.encryption || { },
input = [
E('input', { type: 'submit', class: 'cbi-button cbi-button-action important', value: '<%:Join Network%>' }),
E('input', { type: 'hidden', name: 'token', value: '<%=token%>' }),
E('input', { type: 'hidden', name: 'device', value: '<%=dev%>' }),
E('input', { type: 'hidden', name: 'join', value: bss.ssid }),
E('input', { type: 'hidden', name: 'mode', value: bss.mode }),
E('input', { type: 'hidden', name: 'bssid', value: bss.bssid }),
E('input', { type: 'hidden', name: 'channel', value: bss.channel }),
E('input', { type: 'hidden', name: 'clbridge', value: <%=iw.type == "wl" and 1 or 0%> }),
E('input', { type: 'hidden', name: 'wep', value: enc.wep ? 1 : 0 })
];
if (enc.wpa) {
input.push(E('input', { type: 'hidden', name: 'wpa_version', value: enc.wpa }));
enc.auth_suites.forEach(function(s) {
input.push(E('input', { type: 'hidden', name: 'wpa_suites', value: s }));
});
enc.group_ciphers.forEach(function(s) {
input.push(E('input', { type: 'hidden', name: 'wpa_group', value: s }));
});
enc.pair_ciphers.forEach(function(s) {
input.push(E('input', { type: 'hidden', name: 'wpa_pairwise', value: s }));
});
}
return E('form', {
class: 'inline',
method: 'post',
action: '<%=url("admin/network/wireless_join")%>'
}, input);
}
function fade(bss, content) {
if (bss.stale)
return E('span', { style: 'opacity:0.5' }, content);
else
return content;
}
function flush() {
XHR.stop(poll);
XHR.halt();
scan();
}
function scan() {
var tbl = document.getElementById('scan_results');
cbi_update_table(tbl, [], '<em><img src="<%=resource%>/icons/loading.gif" class="middle" /> <%:Starting wireless scan...%></em>');
xhr.post('<%=url("admin/network/wireless_scan_trigger", dev)%>', { token: '<%=token%>' },
function(s) {
if (s.status !== 200) {
cbi_update_table(tbl, [], '<em><%:Scan request failed%></em>');
return;
}
var count = 0;
poll = XHR.poll(3, '<%=url("admin/network/wireless_scan_results", dev)%>', null,
function(s, results) {
if (Array.isArray(results)) {
var bss = [];
results.sort(function(a, b) {
var diff = (b.quality - a.quality) || (a.channel - b.channel);
if (diff)
return diff;
if (a.ssid < b.ssid)
return -1;
else if (a.ssid > b.ssid)
return 1;
if (a.bssid < b.bssid)
return -1;
else if (a.bssid > b.bssid)
return 1;
}).forEach(function(res) {
bss.push([
fade(res, format_signal(res)),
fade(res, res.ssid ? '%h'.format(res.ssid) : E('em', {}, '<%:hidden%>')),
fade(res, res.channel),
fade(res, res.mode),
fade(res, res.bssid),
fade(res, format_encryption(res)),
format_actions(res)
]);
});
cbi_update_table(tbl, bss, '<em><img src="<%=resource%>/icons/loading.gif" class="middle" /> <%:No scan results available yet...%>');
}
if (count++ >= 3) {
count = 0;
xhr.post('<%=url("admin/network/wireless_scan_trigger", dev, "1")%>',
{ token: '<%=token%>' }, function() { });
}
});
XHR.run();
});
}
document.addEventListener('DOMContentLoaded', scan);
//]]></script>
<h2 name="content"><%:Join Network: Wireless Scan%></h2>
<div class="cbi-map">
<div class="cbi-section">
<div class="table">
<div class="table" id="scan_results">
<div class="tr table-titles">
<div class="th col-1 center"><%:Signal%></div>
<div class="th col-5 left"><%:SSID%></div>
<div class="th col-2 center"><%:Channel%></div>
<div class="th col-2 left"><%:Mode%></div>
<div class="th col-3 left"><%:BSSID%></div>
<div class="th col-2 left"><%:Encryption%></div>
<div class="th col-1 middle center"><%:Signal%></div>
<div class="th col-5 middle left"><%:SSID%></div>
<div class="th col-2 middle center"><%:Channel%></div>
<div class="th col-2 middle left"><%:Mode%></div>
<div class="th col-3 middle left"><%:BSSID%></div>
<div class="th col-2 middle left"><%:Encryption%></div>
<div class="th cbi-section-actions">&#160;</div>
</div>
<!-- scan list -->
<% for i, net in ipairs(scanlist(3)) do net.encryption = net.encryption or { } %>
<div class="tr cbi-rowstyle-<%=1 + ((i-1) % 2)%>">
<div class="td col-1 center">
<abbr title="<%:Signal%>: <%=net.signal%> <%:dB%> / <%:Quality%>: <%=net.quality%>/<%=net.quality_max%>">
<img src="<%=guess_wifi_signal(net)%>" /><br />
<small><%=percent_wifi_signal(net)%>%</small>
</abbr>
</div>
<div class="td col-5 left" data-title="<%:SSID%>">
<strong><%=net.ssid and utl.pcdata(net.ssid) or "<em>%s</em>" % translate("hidden")%></strong>
</div>
<div class="td col-2 center" data-title="<%:Channel%>">
<%=net.channel%>
</div>
<div class="td col-2 left" data-title="<%:Mode%>">
<%=net.mode%>
</div>
<div class="td col-3 left" data-title="<%:BSSID%>">
<%=net.bssid%>
</div>
<div class="td col-2 left" data-title="<%:Encryption%>">
<%=format_wifi_encryption(net.encryption)%>
</div>
<div class="td cbi-section-actions">
<form action="<%=url('admin/network/wireless_join')%>" method="post">
<input type="hidden" name="token" value="<%=token%>" />
<input type="hidden" name="device" value="<%=utl.pcdata(dev)%>" />
<input type="hidden" name="join" value="<%=utl.pcdata(net.ssid)%>" />
<input type="hidden" name="mode" value="<%=net.mode%>" />
<input type="hidden" name="bssid" value="<%=net.bssid%>" />
<input type="hidden" name="channel" value="<%=net.channel%>" />
<input type="hidden" name="wep" value="<%=net.encryption.wep and 1 or 0%>" />
<% if net.encryption.wpa then %>
<input type="hidden" name="wpa_version" value="<%=net.encryption.wpa%>" />
<% for _, v in ipairs(net.encryption.auth_suites) do %><input type="hidden" name="wpa_suites" value="<%=v%>" />
<% end; for _, v in ipairs(net.encryption.group_ciphers) do %><input type="hidden" name="wpa_group" value="<%=v%>" />
<% end; for _, v in ipairs(net.encryption.pair_ciphers) do %><input type="hidden" name="wpa_pairwise" value="<%=v%>" />
<% end; end %>
<input type="hidden" name="clbridge" value="<%=iw.type == "wl" and 1 or 0%>" />
<input class="cbi-button cbi-button-action important" type="submit" value="<%:Join Network%>" />
</form>
<div class="tr placeholder">
<div class="td">
<img src="<%=resource%>/icons/loading.gif" class="middle" />
<em><%:Collecting data...%></em>
</div>
</div>
<% end %>
<!-- /scan list -->
</div>
</div>
</div>
@ -160,7 +217,7 @@
<form class="inline" action="<%=url('admin/network/wireless_join')%>" method="post">
<input type="hidden" name="token" value="<%=token%>" />
<input type="hidden" name="device" value="<%=utl.pcdata(dev)%>" />
<input class="cbi-button cbi-button-action" type="submit" value="<%:Repeat scan%>" />
<input type="button" class="cbi-button cbi-button-action" value="<%:Repeat scan%>" onclick="flush()" />
</form>
</div>

View file

@ -1,354 +0,0 @@
<%#
Copyright 2008-2009 Steven Barth <steven@midlink.org>
Copyright 2008-2015 Jo-Philipp Wich <jow@openwrt.org>
Licensed to the public under the Apache License 2.0.
-%>
<%-
local ip = require "luci.ip"
local fs = require "nixio.fs"
local utl = require "luci.util"
local uci = require "luci.model.uci".cursor()
local ntm = require "luci.model.network"
local has_iwinfo = pcall(require, "iwinfo")
ntm.init(uci)
function guess_wifi_hw(dev)
local bands = ""
local ifname = dev:name()
local name, idx = ifname:match("^([a-z]+)(%d+)")
idx = tonumber(idx)
if has_iwinfo then
local bl = dev.iwinfo.hwmodelist
if bl and next(bl) then
if bl.a then bands = bands .. "a" end
if bl.b then bands = bands .. "b" end
if bl.g then bands = bands .. "g" end
if bl.n then bands = bands .. "n" end
if bl.ac then bands = bands .. "ac" end
end
local hw = dev.iwinfo.hardware_name
if hw then
return "%s 802.11%s" %{ hw, bands }
end
end
-- wl.o
if name == "wl" then
local name = translatef("Broadcom 802.11%s Wireless Controller", bands)
local nm = 0
local fd = nixio.open("/proc/bus/pci/devices", "r")
if fd then
local ln
for ln in fd:linesource() do
if ln:match("wl$") then
if nm == idx then
local version = ln:match("^%S+%s+%S%S%S%S([0-9a-f]+)")
name = translatef(
"Broadcom BCM%04x 802.11 Wireless Controller",
tonumber(version, 16)
)
break
else
nm = nm + 1
end
end
end
fd:close()
end
return name
-- ralink
elseif name == "ra" then
return translatef("RaLink 802.11%s Wireless Controller", bands)
-- hermes
elseif name == "eth" then
return translate("Hermes 802.11b Wireless Controller")
-- hostap
elseif name == "wlan" and fs.stat("/proc/net/hostap/" .. ifname, "type") == "dir" then
return translate("Prism2/2.5/3 802.11b Wireless Controller")
-- dunno yet
else
return translatef("Generic 802.11%s Wireless Controller", bands)
end
end
local devices = ntm:get_wifidevs()
local netlist = { }
local netdevs = { }
local dev
for _, dev in ipairs(devices) do
local net
for _, net in ipairs(dev:get_wifinets()) do
netlist[#netlist+1] = net:id()
netdevs[net:id()] = dev:name()
end
end
-%>
<%+header%>
<% if not has_iwinfo then %>
<div class="alert-message warning">
<h4><%:Package libiwinfo required!%></h4>
<p><%_The <em>libiwinfo-lua</em> package is not installed. You must install this component for working wireless configuration!%></p>
</div>
<% end %>
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<script type="text/javascript">//<![CDATA[
var wifidevs = <%=luci.http.write_json(netdevs)%>;
var is_reconnecting = false;
function wifi_shutdown(id, toggle) {
var reconnect = (toggle.getAttribute('active') == 'false');
if (!reconnect && !confirm(<%=luci.http.write_json(translate('Really shut down network? You might lose access to this device if you are connected via this interface'))%>))
return;
is_reconnecting = true;
var s = document.getElementById('iw-rc-status');
if (s)
{
s.parentNode.style.display = 'block';
s.innerHTML = '<%:Waiting for changes to be applied...%>';
}
for (var net in wifidevs)
{
var st = document.getElementById(net + '-iw-status');
if (st)
st.innerHTML = '<em><%:Wireless is restarting...%></em>';
}
(new XHR()).post('<%=url('admin/network')%>/wireless_' + (reconnect ? 'reconnect' : 'shutdown') + '/' + id, { token: '<%=token%>' },
function(x)
{
if (s)
{
s.innerHTML = reconnect
? '<%:Wireless restarted%>'
: '<%:Wireless shut down%>';
window.setTimeout(function() {
s.parentNode.style.display = 'none';
is_reconnecting = false;
}, 1000);
}
}
);
}
function wifi_delete(id) {
if (!confirm(<%=luci.http.write_json(translate('Really delete this wireless network? The deletion cannot be undone! You might lose access to this device if you are connected via this network.'))%>))
return;
(new XHR()).post('<%=url('admin/network/wireless_delete')%>/' + id, { token: '<%=token%>' },
function(x) {
location.href = '<%=url('admin/network/wireless')%>';
}
);
}
var hosts = <%=luci.http.write_json(luci.sys.net.host_hints())%>;
XHR.poll(5, '<%=url('admin/network/wireless_status', table.concat(netlist, ","))%>', null,
function(x, st)
{
if (st)
{
var rowstyle = 1;
var radiostate = { };
st.forEach(function(s) {
var r = radiostate[wifidevs[s.id]] || (radiostate[wifidevs[s.id]] = {});
s.is_assoc = (s.bssid && s.bssid != '00:00:00:00:00:00' && s.channel && s.mode != 'Unknown' && !s.disabled);
r.up = r.up || s.is_assoc;
r.channel = r.channel || s.channel;
r.bitrate = r.bitrate || s.bitrate;
r.frequency = r.frequency || s.frequency;
});
for( var i = 0; i < st.length; i++ )
{
var iw = st[i];
var p = iw.quality;
var q = iw.is_assoc ? p : -1;
var icon;
if (q < 0)
icon = "<%=resource%>/icons/signal-none.png";
else if (q == 0)
icon = "<%=resource%>/icons/signal-0.png";
else if (q < 25)
icon = "<%=resource%>/icons/signal-0-25.png";
else if (q < 50)
icon = "<%=resource%>/icons/signal-25-50.png";
else if (q < 75)
icon = "<%=resource%>/icons/signal-50-75.png";
else
icon = "<%=resource%>/icons/signal-75-100.png";
var sig = document.getElementById(iw.id + '-iw-signal');
if (sig)
sig.innerHTML = String.format(
'<span class="ifacebadge" title="<%:Signal%>: %d <%:dBm%> / <%:Noise%>: %d <%:dBm%>"><img src="%s" /> %d%%</span>',
iw.signal, iw.noise, icon, p
);
var toggle = document.getElementById(iw.id + '-iw-toggle');
if (toggle)
{
if (!iw.disabled)
{
toggle.className = 'cbi-button cbi-button-neutral';
toggle.value = '<%:Disable%>';
toggle.title = '<%:Shutdown this network%>';
}
else
{
toggle.className = 'cbi-button cbi-button-neutral';
toggle.value = '<%:Enable%>';
toggle.title = '<%:Activate this network%>';
}
toggle.setAttribute('active', !iw.disabled);
}
var info = document.getElementById(iw.id + '-iw-status');
if (info)
{
if (iw.is_assoc)
info.innerHTML = String.format(
'<strong><%:SSID%>:</strong> %h | ' +
'<strong><%:Mode%>:</strong> %s<br />' +
'<strong><%:BSSID%>:</strong> %s | ' +
'<strong><%:Encryption%>:</strong> %s',
iw.ssid, iw.mode, iw.bssid,
iw.encryption ? iw.encryption : '<%:None%>'
);
else
info.innerHTML = String.format(
'<strong><%:SSID%>:</strong> %h | ' +
'<strong><%:Mode%>:</strong> %s<br />' +
'<em>%s</em>',
iw.ssid || '?', iw.mode,
is_reconnecting
? '<em><%:Wireless is restarting...%></em>'
: '<em><%:Wireless is disabled or not associated%></em>'
);
}
}
for (var dev in radiostate)
{
var img = document.getElementById(dev + '-iw-upstate');
if (img)
img.src = '<%=resource%>/icons/wifi' + (radiostate[dev].up ? '' : '_disabled') + '.png';
var stat = document.getElementById(dev + '-iw-devinfo');
if (stat)
stat.innerHTML = String.format(
'<strong><%:Channel%>:</strong> %s (%s <%:GHz%>) | ' +
'<strong><%:Bitrate%>:</strong> %s <%:Mbit/s%>',
radiostate[dev].channel ? radiostate[dev].channel : '?',
radiostate[dev].frequency ? radiostate[dev].frequency : '?',
radiostate[dev].bitrate ? radiostate[dev].bitrate : '?'
);
}
}
}
);
//]]></script>
<h2 name="content"><%:Wireless Overview%></h2>
<div class="cbi-section" style="display:none">
<legend><%:Reconnecting interface%></legend>
<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" />
<span id="iw-rc-status"><%:Waiting for changes to be applied...%></span>
</div>
<div id="cbi-wireless-overview" class="cbi-map">
<% for _, dev in ipairs(devices) do local nets = dev:get_wifinets() %>
<!-- device <%=dev:name()%> -->
<div class="cbi-section-node">
<div class="table">
<!-- physical device -->
<div class="tr">
<div class="td col-2 center">
<span class="ifacebadge"><img src="<%=resource%>/icons/wifi_disabled.png" id="<%=dev:name()%>-iw-upstate" /> <%=dev:name()%></span>
</div>
<div class="td col-7 left">
<big><strong><%=guess_wifi_hw(dev)%></strong></big><br />
<span id="<%=dev:name()%>-iw-devinfo"></span>
</div>
<div class="td cbi-section-actions">
<form action="<%=url('admin/network/wireless_join')%>" method="post" class="inline">
<input type="hidden" name="device" value="<%=dev:name()%>" />
<input type="hidden" name="token" value="<%=token%>" />
<input type="submit" class="cbi-button cbi-button-action" title="<%:Find and join network%>" value="<%:Scan%>" />
</form>
<form action="<%=url('admin/network/wireless_add')%>" method="post" class="inline">
<input type="hidden" name="device" value="<%=dev:name()%>" />
<input type="hidden" name="token" value="<%=token%>" />
<input type="submit" class="cbi-button cbi-button-add" title="<%:Provide new network%>" value="<%:Add%>" />
</form>
</div>
</div>
<!-- /physical device -->
<!-- network list -->
<% if #nets > 0 then %>
<% for i, net in ipairs(nets) do %>
<div class="tr cbi-rowstyle-<%=1 + ((i-1) % 2)%>">
<div class="td col-2 center" id="<%=net:id()%>-iw-signal">
<span class="ifacebadge" title="<%:Not associated%>"><img src="<%=resource%>/icons/signal-none.png" /> 0%</span>
</div>
<div class="td col-7 left" id="<%=net:id()%>-iw-status">
<em><%:Collecting data...%></em>
</div>
<div class="td cbi-section-actions">
<input id="<%=net:id()%>-iw-toggle" type="button" class="cbi-button cbi-button-neutral" onclick="wifi_shutdown('<%=net:id()%>', this)" title="<%:Enable this network%>" value="<%:Enable%>" />
<input type="button" class="cbi-button cbi-button-action important" onclick="location.href='<%=net:adminlink()%>'" title="<%:Edit this network%>" value="<%:Edit%>" />
<input type="button" class="cbi-button cbi-button-negative" onclick="wifi_delete('<%=net:id()%>')" title="<%:Delete this network%>" value="<%:Remove%>" />
</div>
</div>
<% end %>
<% else %>
<div class="tr cbi-rowstyle-2">
<div class="td left">
<em><%:No network configured on this device%></em>
</div>
</div>
<% end %>
<!-- /network list -->
</div>
</div>
<!-- /device <%=dev:name()%> -->
<% end %>
<h2><%:Associated Stations%></h2>
<%+admin_network/wifi_assoclist%>
</div>
<%+footer%>

View file

@ -0,0 +1,127 @@
<%#
Copyright 2008-2009 Steven Barth <steven@midlink.org>
Copyright 2008-2018 Jo-Philipp Wich <jo@mein.io>
Licensed to the public under the Apache License 2.0.
-%>
<script type="text/javascript">//<![CDATA[
function wifi_delete(ev) {
if (!confirm(<%=luci.http.write_json(translate('Really delete this wireless network? The deletion cannot be undone! You might lose access to this device if you are connected via this network.'))%>)) {
ev.preventDefault();
return false;
}
ev.target.previousElementSibling.value = '1';
return true;
}
function wifi_restart(ev) {
XHR.halt();
findParent(ev.target, '.table').querySelectorAll('[data-disabled="false"]').forEach(function(s) {
s.innerHTML = '<em><%:Wireless is restarting...%></em>';
});
(new XHR()).post('<%=url('admin/network/wireless_reconnect')%>/' + ev.target.getAttribute('data-radio'),
{ token: '<%=token%>' }, XHR.run);
}
var networks = [ ];
document.querySelectorAll('[data-network]').forEach(function(n) {
networks.push(n.getAttribute('data-network'));
});
XHR.poll(5, '<%=url('admin/network/wireless_status')%>/' + networks.join(','), null,
function(x, st)
{
if (st)
{
var rowstyle = 1;
var radiostate = { };
st.forEach(function(s) {
var r = radiostate[s.device.device] || (radiostate[s.device.device] = {});
s.is_assoc = (s.bssid && s.bssid != '00:00:00:00:00:00' && s.channel && s.mode != 'Unknown' && !s.disabled);
r.up = r.up || s.is_assoc;
r.channel = r.channel || s.channel;
r.bitrate = r.bitrate || s.bitrate;
r.frequency = r.frequency || s.frequency;
});
for( var i = 0; i < st.length; i++ )
{
var iw = st[i],
sig = document.getElementById(iw.id + '-iw-signal'),
info = document.getElementById(iw.id + '-iw-status'),
disabled = (info && info.getAttribute('data-disabled') === 'true');
var p = iw.quality;
var q = disabled ? -1 : p;
var icon;
if (q < 0)
icon = "<%=resource%>/icons/signal-none.png";
else if (q == 0)
icon = "<%=resource%>/icons/signal-0.png";
else if (q < 25)
icon = "<%=resource%>/icons/signal-0-25.png";
else if (q < 50)
icon = "<%=resource%>/icons/signal-25-50.png";
else if (q < 75)
icon = "<%=resource%>/icons/signal-50-75.png";
else
icon = "<%=resource%>/icons/signal-75-100.png";
if (sig)
sig.innerHTML = String.format(
'<span class="ifacebadge" title="<%:Signal%>: %d <%:dBm%> / <%:Noise%>: %d <%:dBm%>"><img src="%s" /> %d%%</span>',
iw.signal, iw.noise, icon, p
);
if (info)
{
if (iw.is_assoc)
info.innerHTML = String.format(
'<strong><%:SSID%>:</strong> %h | ' +
'<strong><%:Mode%>:</strong> %s<br />' +
'<strong><%:BSSID%>:</strong> %s | ' +
'<strong><%:Encryption%>:</strong> %s',
iw.ssid, iw.mode, iw.bssid,
iw.encryption ? iw.encryption : '<%:None%>'
);
else
info.innerHTML = String.format(
'<strong><%:SSID%>:</strong> %h | ' +
'<strong><%:Mode%>:</strong> %s<br />' +
'<em>%s</em>',
iw.ssid || '?', iw.mode,
disabled ? '<em><%:Wireless is disabled%></em>'
: '<em><%:Wireless is not associated%></em>'
);
}
}
for (var dev in radiostate)
{
var img = document.getElementById(dev + '-iw-upstate');
if (img)
img.src = '<%=resource%>/icons/wifi' + (radiostate[dev].up ? '' : '_disabled') + '.png';
var stat = document.getElementById(dev + '-iw-devinfo');
if (stat)
stat.innerHTML = String.format(
'<strong><%:Channel%>:</strong> %s (%s <%:GHz%>) | ' +
'<strong><%:Bitrate%>:</strong> %s <%:Mbit/s%>',
radiostate[dev].channel ? radiostate[dev].channel : '?',
radiostate[dev].frequency ? radiostate[dev].frequency : '?',
radiostate[dev].bitrate ? radiostate[dev].bitrate : '?'
);
}
}
}
);
//]]></script>

View file

@ -8,7 +8,7 @@
{
var is_assoc = (iw.bssid && iw.bssid != '00:00:00:00:00:00' && iw.channel && !iw.disabled);
var p = iw.quality;
var q = is_assoc ? p : -1;
var q = iw.disabled ? -1 : p;
var icon;
if (q < 0)
@ -55,8 +55,10 @@
info.innerHTML = String.format(
'<strong><%:SSID%>:</strong> %h | ' +
'<strong><%:Mode%>:</strong> %s<br />' +
'<em><%:Wireless is disabled or not associated%></em>',
iw.ssid || '?', iw.mode
'<em>%s</em>',
iw.ssid || '?', iw.mode,
iw.disabled ? '<em><%:Wireless is disabled%></em>'
: '<em><%:Wireless is not associated%></em>'
);
}
}

View file

@ -19,7 +19,6 @@
<%+header%>
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<script type="text/javascript">//<![CDATA[
var bwxhr = new XHR();
@ -59,6 +58,8 @@
var label_scale;
Math.log2 = Math.log2 || function(x) { return Math.log(x) * Math.LOG2E; };
function bandwidth_label(bytes, br)
{
var uby = '<%:kB/s%>';
@ -149,7 +150,7 @@
var text = G.createElementNS('http://www.w3.org/2000/svg', 'text');
text.setAttribute('x', i + 5);
text.setAttribute('y', 15);
text.setAttribute('style', 'fill:#999999; font-size:9pt');
text.setAttribute('style', 'fill:#eee; font-size:9pt; font-family:sans-serif; text-shadow:1px 1px 1px #000');
text.appendChild(G.createTextNode(Math.round((width - i) / step / 60) + 'm'));
label_25.parentNode.appendChild(line);

View file

@ -5,7 +5,6 @@
<%+header%>
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<script type="text/javascript">//<![CDATA[
var bwxhr = new XHR();
@ -124,7 +123,7 @@
var text = G.createElementNS('http://www.w3.org/2000/svg', 'text');
text.setAttribute('x', i + 5);
text.setAttribute('y', 15);
text.setAttribute('style', 'fill:#999999; font-size:9pt');
text.setAttribute('style', 'fill:#eee; font-size:9pt; font-family:sans-serif; text-shadow:1px 1px 1px #000');
text.appendChild(G.createTextNode(Math.round((width - i) / step / 60) + 'm'));
label_25.parentNode.appendChild(line);
@ -137,12 +136,9 @@
XHR.poll(3, '<%=build_url("admin/status/realtime/connections_status")%>', null,
function(x, json)
{
var rows = [];
var conn = json.connections;
while (conn_table.firstElementChild !== conn_table.lastElementChild)
conn_table.removeChild(conn_table.lastElementChild);
var lookup_queue = [ ];
conn.sort(function(a, b) {
@ -166,15 +162,17 @@
var src = dns_cache[c.src] || (c.layer3 == 'ipv6' ? '[' + c.src + ']' : c.src);
var dst = dns_cache[c.dst] || (c.layer3 == 'ipv6' ? '[' + c.dst + ']' : c.dst);
conn_table.appendChild(E('<div class="tr cbi-section-table-row cbi-rowstyle-%d">'.format(1 + (i % 2)), [
E('<div class="td">', c.layer3.toUpperCase()),
E('<div class="td">', c.layer4.toUpperCase()),
E('<div class="td">', [ src, ':', c.sport ]),
E('<div class="td">', [ dst, ':', c.dport ]),
E('<div class="td" style="white-space:nowrap">', '%1024.2mB (%d <%:Pkts.%>)'.format(c.bytes, c.packets)),
]));
rows.push([
c.layer3.toUpperCase(),
c.layer4.toUpperCase(),
src + ':' + c.sport,
dst + ':' + c.dport,
'%1024.2mB (%d <%:Pkts.%>)'.format(c.bytes, c.packets)
]);
}
cbi_update_table(conn_table, rows, '<em><%:No information available%></em>');
if (lookup_queue.length > 0)
XHR.get('<%=build_url("admin/status/nameinfo")%>/' + lookup_queue.slice(0, 100).join('/'), null,
function(x, json)
@ -322,7 +320,7 @@
<div style="text-align:right"><small id="scale">-</small></div>
<br />
<div class="table" style="width:100%; table-layout:fixed" cellspacing="5">
<div class="table">
<div class="tr">
<div class="td" style="text-align:right; vertical-align:top"><strong style="border-bottom:2px solid blue"><%:UDP:%></strong></div>
<div class="td" id="lb_udp_cur">0</div>
@ -357,16 +355,20 @@
<br />
<div class="cbi-section-node">
<div class="table cbi-section-table" id="connections">
<div class="tr cbi-section-table-titles">
<div class="th cbi-section-table-cell"><%:Network%></div>
<div class="th cbi-section-table-cell"><%:Protocol%></div>
<div class="th cbi-section-table-cell"><%:Source%></div>
<div class="th cbi-section-table-cell"><%:Destination%></div>
<div class="th cbi-section-table-cell"><%:Transfer%></div>
<div class="table" id="connections">
<div class="tr table-titles">
<div class="th col-2 hide-xs"><%:Network%></div>
<div class="th col-2"><%:Protocol%></div>
<div class="th col-7"><%:Source%></div>
<div class="th col-7"><%:Destination%></div>
<div class="th col-4"><%:Transfer%></div>
</div>
<div class="tr"><div class="td" colspan="5"><em><%:Collecting data...%></em></div></div>
<div class="tr placeholder">
<div class="td">
<em><%:Collecting data...%></em>
</div>
</div>
</div>
</div>
</fieldset>

View file

@ -115,7 +115,6 @@
<%+header%>
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<script type="text/javascript">//<![CDATA[
function progressbar(v, m)
{
@ -303,9 +302,9 @@
var is_assoc = (net.bssid != '00:00:00:00:00:00' && net.channel && !net.disabled);
var icon;
if (!is_assoc)
if (net.disabled)
icon = "<%=resource%>/icons/signal-none.png";
else if (net.quality == 0)
else if (net.quality <= 0)
icon = "<%=resource%>/icons/signal-0.png";
else if (net.quality < 25)
icon = "<%=resource%>/icons/signal-0-25.png";
@ -324,7 +323,7 @@
'<%:BSSID%>', is_assoc ? (net.bssid || '-') : null,
'<%:Encryption%>', is_assoc ? net.encryption : null,
'<%:Associations%>', is_assoc ? (net.num_assoc || '-') : null,
null, is_assoc ? null : E('em', '<%:Wireless is disabled or not associated%>')));
null, is_assoc ? null : E('em', net.disabled ? '<%:Wireless is disabled%>' : '<%:Wireless is not associated%>')));
}
ws.appendChild(renderBox(
@ -436,11 +435,13 @@
<div class="cbi-section">
<h3><%:Network%></h3>
<% if has_mptcp == 0 then %>
<div id="upstream_status_table" class="network-status-table">
<em><%:Collecting data...%></em>
<p><em><%:Collecting data...%></em></p>
</div>
<% end %>
<div class="table" width="100%">
<div class="tr"><div class="td left" width="33%"><%:Active Connections%></div><div class="td left" id="conns">-</div></div>
</div>
@ -477,7 +478,7 @@
<h3><%:Wireless%></h3>
<div id="wifi_status_table" class="network-status-table">
<em><%:Collecting data...%></em>
<p><em><%:Collecting data...%></em></p>
</div>
</div>

View file

@ -62,7 +62,6 @@
<%+header%>
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<style type="text/css">
span:target {
color: blue;

View file

@ -5,7 +5,6 @@
<%+header%>
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<script type="text/javascript">//<![CDATA[
var bwxhr = new XHR();
@ -119,7 +118,7 @@
var text = G.createElementNS('http://www.w3.org/2000/svg', 'text');
text.setAttribute('x', i + 5);
text.setAttribute('y', 15);
text.setAttribute('style', 'fill:#999999; font-size:9pt');
text.setAttribute('style', 'fill:#eee; font-size:9pt; font-family:sans-serif; text-shadow:1px 1px 1px #000');
text.appendChild(G.createTextNode(Math.round((width - i) / step / 60) + 'm'));
label_25.parentNode.appendChild(line);

View file

@ -32,7 +32,6 @@
<%+header%>
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<div class="cbi-map" id="cbi-network">
<h2 name="content"><%:Routes%></h2>

View file

@ -19,7 +19,6 @@
<%+header%>
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<script type="text/javascript">//<![CDATA[
var bwxhr = new XHR();
@ -141,7 +140,7 @@
var text = G.createElementNS('http://www.w3.org/2000/svg', 'text');
text.setAttribute('x', i + 5);
text.setAttribute('y', 15);
text.setAttribute('style', 'fill:#999999; font-size:9pt');
text.setAttribute('style', 'fill:#eee; font-size:9pt; font-family:sans-serif; text-shadow:1px 1px 1px #000');
text.appendChild(G.createTextNode(Math.round((width - i) / step / 60) + 'm'));
label_25.parentNode.appendChild(line);
@ -158,7 +157,7 @@
var text2 = G2.createElementNS('http://www.w3.org/2000/svg', 'text');
text2.setAttribute('x', i + 5);
text2.setAttribute('y', 15);
text2.setAttribute('style', 'fill:#999999; font-size:9pt');
text2.setAttribute('style', 'fill:#eee; font-size:9pt; font-family:sans-serif; text-shadow:1px 1px 1px #000');
text2.appendChild(G.createTextNode(Math.round((width - i) / step / 60) + 'm'));
label_25_2.parentNode.appendChild(line2);

View file

@ -10,12 +10,12 @@
<ul class="cbi-tabmenu">
<li class="cbi-tab"><a href="#"><%:Actions%></a></li>
<li class="cbi-tab-disabled"><a href="<%=REQUEST_URI%>/backupfiles"><%:Configuration%></a></li>
<li class="cbi-tab-disabled"><a href="<%=url('admin/system/flashops/backupfiles')%>"><%:Configuration%></a></li>
</ul>
<div class="cbi-section">
<h3><%:Backup / Restore%></h3>
<div class="cbi-section-descr"><%:Click "Generate archive" to download a tar archive of the current configuration files. To reset the firmware to its initial state, click "Perform reset" (only possible with squashfs images).%></div>
<h3><%:Backup%></h3>
<div class="cbi-section-descr"><%:Click "Generate archive" to download a tar archive of the current configuration files.%></div>
<div class="cbi-section-node">
<form class="inline" method="post" action="<%=url('admin/system/flashops/backup')%>">
<input type="hidden" name="token" value="<%=token%>" />
@ -26,6 +26,11 @@
</div>
</div>
</form>
</div>
<h3><%:Restore%></h3>
<div class="cbi-section-descr"><%:To restore configuration files, you can upload a previously generated backup archive here. To reset the firmware to its initial state, click "Perform reset" (only possible with squashfs images).%></div>
<div class="cbi-section-node">
<% if reset_avail then %>
<form class="inline" method="post" action="<%=url('admin/system/flashops/reset')%>">
<input type="hidden" name="token" value="<%=token%>" />
@ -37,9 +42,6 @@
</div>
</form>
<% end %>
</div>
<div class="cbi-section-descr"><%:To restore configuration files, you can upload a previously generated backup archive here.%></div>
<div class="cbi-section-node">
<form class="inline" method="post" action="<%=url('admin/system/flashops/restore')%>" enctype="multipart/form-data">
<div class="cbi-value cbi-value-last">
<label class="cbi-value-title" for="archive"><%:Restore backup%>:</label>
@ -47,13 +49,16 @@
<input type="hidden" name="token" value="<%=token%>" />
<input type="file" name="archive" id="archive" />
<input type="submit" class="cbi-button cbi-button-action important" name="restore" value="<%:Upload archive...%>" />
<% if reset_avail then %>
<div class="cbi-value-description"><%:Custom files (certificates, scripts) may remain on the system. To prevent this, perform a factory-reset first.%></div>
<% end %>
</div>
</div>
</form>
<% if backup_invalid then %>
<div class="cbi-section-error"><%:The backup archive does not appear to be a valid gzip file.%></div>
<% end %>
</div>
<% if reset_avail then %>
<div class="alert-message warning"><%:Custom files (certificates, scripts) may remain on the system. To prevent this, perform a factory-reset first.%></div>
<% end %>
</div>
<div class="cbi-section">

View file

@ -44,7 +44,6 @@ end
<%+header%>
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<h2 name="content"><%:Software%></h2>

View file

@ -16,18 +16,24 @@
<hr />
<input class="cbi-button cbi-button-action important" type="button" value="<%:Perform reboot%>" onclick="reboot(this)" />
<p class="alert-message notice reboot-message" style="display:none">
<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" />
<span><%:Device is rebooting...%></span>
</p>
<script type="text/javascript">//<![CDATA[
var tries = 0;
var tries = 0,
message = document.querySelector('p.reboot-message'),
label = message.querySelector('span');
function ok() {
window.location = '<%=controller%>/admin';
window.location = '<%=url("admin")%>';
}
function check() {
if (tries++ < 12)
window.setTimeout(ping, 5000);
else
alert('<%:Device unreachable%>');
window.setTimeout(ping, 5000);
}
function ping() {
@ -37,22 +43,20 @@
img.onerror = check;
img.src = '<%=resource%>/icons/loading.gif?' + Math.random();
document.getElementById('reboot-message').innerHTML = '<%:Waiting for device...%>';
if (tries++ >= 30) {
message.classList.remove('notice');
message.classList.add('warning');
label.innerHTML = '<%:Device unreachable! Still waiting for device...%>';
}
}
function reboot(button) {
button.style.display = 'none';
document.getElementById('reboot-message').parentNode.style.display = '';
message.style.display = '';
label.innerHTML = '<%:Waiting for device...%>';
(new XHR()).post('<%=controller%>/admin/system/reboot/call', { token: '<%=token%>' }, check);
(new XHR()).post('<%=url("admin/system/reboot/call")%>', { token: '<%=token%>' }, check);
}
//]]></script>
<input class="cbi-button cbi-button-action important" type="button" value="<%:Perform reboot%>" onclick="reboot(this)" />
<p class="alert-message" style="display:none">
<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" />
<span id="reboot-message"><%:Device is rebooting...%></span>
</p>
<%+footer%>