diff options
Diffstat (limited to 'modules/admin-full/luasrc')
58 files changed, 0 insertions, 9554 deletions
diff --git a/modules/admin-full/luasrc/controller/admin/filebrowser.lua b/modules/admin-full/luasrc/controller/admin/filebrowser.lua deleted file mode 100644 index d83139fd70..0000000000 --- a/modules/admin-full/luasrc/controller/admin/filebrowser.lua +++ /dev/null @@ -1,20 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- - -module("luci.controller.admin.filebrowser", package.seeall) - -function index() - entry( {"admin", "filebrowser"}, template("cbi/filebrowser") ).leaf = true -end diff --git a/modules/admin-full/luasrc/controller/admin/index.lua b/modules/admin-full/luasrc/controller/admin/index.lua deleted file mode 100644 index 4e832529d9..0000000000 --- a/modules/admin-full/luasrc/controller/admin/index.lua +++ /dev/null @@ -1,49 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2008 Steven Barth <steven@midlink.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- - -module("luci.controller.admin.index", package.seeall) - -function index() - local root = node() - if not root.target then - root.target = alias("admin") - root.index = true - end - - local page = node("admin") - page.target = firstchild() - page.title = _("Administration") - page.order = 10 - page.sysauth = "root" - page.sysauth_authenticator = "htmlauth" - page.ucidata = true - page.index = true - - -- Empty services menu to be populated by addons - entry({"admin", "services"}, firstchild(), _("Services"), 40).index = true - - entry({"admin", "logout"}, call("action_logout"), _("Logout"), 90) -end - -function action_logout() - local dsp = require "luci.dispatcher" - local sauth = require "luci.sauth" - if dsp.context.authsession then - sauth.kill(dsp.context.authsession) - dsp.context.urltoken.stok = nil - end - - luci.http.header("Set-Cookie", "sysauth=; path=" .. dsp.build_url()) - luci.http.redirect(luci.dispatcher.build_url()) -end diff --git a/modules/admin-full/luasrc/controller/admin/network.lua b/modules/admin-full/luasrc/controller/admin/network.lua deleted file mode 100644 index 4388864eb1..0000000000 --- a/modules/admin-full/luasrc/controller/admin/network.lua +++ /dev/null @@ -1,465 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2011 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -]]-- - -module("luci.controller.admin.network", package.seeall) - -function index() - local uci = require("luci.model.uci").cursor() - local page - - page = node("admin", "network") - page.target = firstchild() - page.title = _("Network") - page.order = 50 - page.index = true - --- if page.inreq then - local has_switch = false - - 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 - - page = entry({"admin", "network", "switch_status"}, call("switch_status"), nil) - page.leaf = true - end - - - local has_wifi = false - - uci:foreach("wireless", "wifi-device", - function(s) - has_wifi = true - return false - end) - - if has_wifi then - page = entry({"admin", "network", "wireless_join"}, call("wifi_join"), nil) - page.leaf = true - - page = entry({"admin", "network", "wireless_add"}, call("wifi_add"), nil) - page.leaf = true - - page = entry({"admin", "network", "wireless_delete"}, call("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"}, call("wifi_reconnect"), nil) - page.leaf = true - - page = entry({"admin", "network", "wireless_shutdown"}, call("wifi_shutdown"), nil) - page.leaf = true - - page = entry({"admin", "network", "wireless"}, arcombine(template("admin_network/wifi_overview"), cbi("admin_network/wifi")), _("Wifi"), 15) - 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 - - - page = entry({"admin", "network", "iface_add"}, cbi("admin_network/iface_add"), nil) - page.leaf = true - - page = entry({"admin", "network", "iface_delete"}, call("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"}, call("iface_reconnect"), nil) - page.leaf = true - - page = entry({"admin", "network", "iface_shutdown"}, call("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 - - 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 - - - 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 - - page = entry({"admin", "network", "dhcplease_status"}, call("lease_status"), nil) - page.leaf = true - - page = node("admin", "network", "hosts") - page.target = cbi("admin_network/hosts") - page.title = _("Hostnames") - page.order = 40 - end - - page = node("admin", "network", "routes") - page.target = cbi("admin_network/routes") - page.title = _("Static Routes") - page.order = 50 - - page = node("admin", "network", "diagnostics") - page.target = template("admin_network/diagnostics") - page.title = _("Diagnostics") - page.order = 60 - - page = entry({"admin", "network", "diag_ping"}, call("diag_ping"), nil) - page.leaf = true - - page = entry({"admin", "network", "diag_nslookup"}, call("diag_nslookup"), nil) - page.leaf = true - - page = entry({"admin", "network", "diag_traceroute"}, call("diag_traceroute"), nil) - page.leaf = true - - page = entry({"admin", "network", "diag_ping6"}, call("diag_ping6"), nil) - page.leaf = true - - page = entry({"admin", "network", "diag_traceroute6"}, call("diag_traceroute6"), nil) - page.leaf = true --- end -end - -function wifi_join() - local function param(x) - return luci.http.formvalue(x) - end - - local function ptable(x) - x = param(x) - return x and (type(x) ~= "table" and { x } or x) or {} - end - - local dev = param("device") - local ssid = param("join") - - if dev and ssid then - local cancel = (param("cancel") or param("cbi.cancel")) and true or false - - if cancel then - luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless_join?device=" .. dev)) - else - local cbi = require "luci.cbi" - local tpl = require "luci.template" - 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 - end - else - luci.template.render("admin_network/wifi_join") - end -end - -function wifi_add() - local dev = luci.http.formvalue("device") - local ntm = require "luci.model.network".init() - - dev = dev and ntm:get_wifidev(dev) - - if dev then - local net = dev:add_wifinet({ - mode = "ap", - ssid = "OpenWrt", - encryption = "none" - }) - - ntm:save("wireless") - luci.http.redirect(net:adminlink()) - 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 = { } - - local iface - for iface in ifaces:gmatch("[%w%.%-_]+") do - local net = netm:get_network(iface) - local device = net and net:get_interface() - if device then - local data = { - id = iface, - proto = net:proto(), - uptime = net:uptime(), - gwaddr = net:gwaddr(), - dnsaddrs = net:dnsaddrs(), - name = device:shortname(), - type = device:type(), - 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(), - - ipaddrs = { }, - ip6addrs = { }, - subdevices = { } - } - - local _, a - for _, a in ipairs(device:ipaddrs()) do - data.ipaddrs[#data.ipaddrs+1] = { - addr = a:host():string(), - netmask = a:mask():string(), - prefix = a:prefix() - } - end - for _, a in ipairs(device:ip6addrs()) do - if not a:is6linklocal() then - data.ip6addrs[#data.ip6addrs+1] = { - addr = a:host():string(), - netmask = a:mask():string(), - prefix = a:prefix() - } - end - end - - for _, device in ipairs(net:get_interfaces() or {}) do - data.subdevices[#data.subdevices+1] = { - name = device:shortname(), - type = device:type(), - ifname = device:name(), - macaddr = device:mac(), - 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(), - } - end - - rv[#rv+1] = data - else - rv[#rv+1] = { - id = iface, - name = iface, - type = "ethernet" - } - end - end - - if #rv > 0 then - luci.http.prepare_content("application/json") - luci.http.write_json(rv) - return - end - - luci.http.status(404, "No such device") -end - -function iface_reconnect(iface) - local netmd = require "luci.model.network".init() - local net = netmd:get_network(iface) - if net then - luci.sys.call("env -i /sbin/ifup %q >/dev/null 2>/dev/null" % iface) - luci.http.status(200, "Reconnected") - return - end - - 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 %q >/dev/null 2>/dev/null" % 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 %q >/dev/null 2>/dev/null" % 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 = { } - - local dev - for dev in devs:gmatch("[%w%.%-]+") do - rv[#rv+1] = s.wifi_network(dev) - end - - if #rv > 0 then - luci.http.prepare_content("application/json") - luci.http.write_json(rv) - return - end - - 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") - - 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 - 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 lease_status() - local s = require "luci.tools.status" - - luci.http.prepare_content("application/json") - luci.http.write('[') - luci.http.write_json(s.dhcp_leases()) - luci.http.write(',') - luci.http.write_json(s.dhcp6_leases()) - luci.http.write(']') -end - -function switch_status(switches) - local s = require "luci.tools.status" - - luci.http.prepare_content("application/json") - luci.http.write_json(s.switch_status(switches)) -end - -function diag_command(cmd, addr) - if addr and addr:match("^[a-zA-Z0-9%-%.:_]+$") then - luci.http.prepare_content("text/plain") - - local util = io.popen(cmd % addr) - 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 - -function diag_ping(addr) - diag_command("ping -c 5 -W 1 %q 2>&1", addr) -end - -function diag_traceroute(addr) - diag_command("traceroute -q 1 -w 1 -n %q 2>&1", addr) -end - -function diag_nslookup(addr) - diag_command("nslookup %q 2>&1", addr) -end - -function diag_ping6(addr) - diag_command("ping6 -c 5 %q 2>&1", addr) -end - -function diag_traceroute6(addr) - diag_command("traceroute6 -q 1 -w 2 -n %q 2>&1", addr) -end diff --git a/modules/admin-full/luasrc/controller/admin/status.lua b/modules/admin-full/luasrc/controller/admin/status.lua deleted file mode 100644 index 89ebda7353..0000000000 --- a/modules/admin-full/luasrc/controller/admin/status.lua +++ /dev/null @@ -1,164 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2011 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- - -module("luci.controller.admin.status", package.seeall) - -function index() - entry({"admin", "status"}, alias("admin", "status", "overview"), _("Status"), 20).index = true - entry({"admin", "status", "overview"}, template("admin_status/index"), _("Overview"), 1) - entry({"admin", "status", "iptables"}, call("action_iptables"), _("Firewall"), 2).leaf = true - entry({"admin", "status", "routes"}, template("admin_status/routes"), _("Routes"), 3) - entry({"admin", "status", "syslog"}, call("action_syslog"), _("System Log"), 4) - entry({"admin", "status", "dmesg"}, call("action_dmesg"), _("Kernel Log"), 5) - entry({"admin", "status", "processes"}, cbi("admin_status/processes"), _("Processes"), 6) - - entry({"admin", "status", "realtime"}, alias("admin", "status", "realtime", "load"), _("Realtime Graphs"), 7) - - entry({"admin", "status", "realtime", "load"}, template("admin_status/load"), _("Load"), 1).leaf = true - entry({"admin", "status", "realtime", "load_status"}, call("action_load")).leaf = true - - entry({"admin", "status", "realtime", "bandwidth"}, template("admin_status/bandwidth"), _("Traffic"), 2).leaf = true - entry({"admin", "status", "realtime", "bandwidth_status"}, call("action_bandwidth")).leaf = true - - entry({"admin", "status", "realtime", "wireless"}, template("admin_status/wireless"), _("Wireless"), 3).leaf = true - entry({"admin", "status", "realtime", "wireless_status"}, call("action_wireless")).leaf = true - - entry({"admin", "status", "realtime", "connections"}, template("admin_status/connections"), _("Connections"), 4).leaf = true - entry({"admin", "status", "realtime", "connections_status"}, call("action_connections")).leaf = true - - entry({"admin", "status", "nameinfo"}, call("action_nameinfo")).leaf = true -end - -function action_syslog() - local syslog = luci.sys.syslog() - luci.template.render("admin_status/syslog", {syslog=syslog}) -end - -function action_dmesg() - local dmesg = luci.sys.dmesg() - luci.template.render("admin_status/dmesg", {dmesg=dmesg}) -end - -function action_iptables() - if luci.http.formvalue("zero") then - if luci.http.formvalue("zero") == "6" then - luci.util.exec("ip6tables -Z") - else - luci.util.exec("iptables -Z") - end - luci.http.redirect( - luci.dispatcher.build_url("admin", "status", "iptables") - ) - elseif luci.http.formvalue("restart") == "1" then - luci.util.exec("/etc/init.d/firewall reload") - luci.http.redirect( - luci.dispatcher.build_url("admin", "status", "iptables") - ) - else - luci.template.render("admin_status/iptables") - end -end - -function action_bandwidth(iface) - luci.http.prepare_content("application/json") - - local bwc = io.popen("luci-bwc -i %q 2>/dev/null" % iface) - if bwc then - luci.http.write("[") - - while true do - local ln = bwc:read("*l") - if not ln then break end - luci.http.write(ln) - end - - luci.http.write("]") - bwc:close() - end -end - -function action_wireless(iface) - luci.http.prepare_content("application/json") - - local bwc = io.popen("luci-bwc -r %q 2>/dev/null" % iface) - if bwc then - luci.http.write("[") - - while true do - local ln = bwc:read("*l") - if not ln then break end - luci.http.write(ln) - end - - luci.http.write("]") - bwc:close() - end -end - -function action_load() - luci.http.prepare_content("application/json") - - local bwc = io.popen("luci-bwc -l 2>/dev/null") - if bwc then - luci.http.write("[") - - while true do - local ln = bwc:read("*l") - if not ln then break end - luci.http.write(ln) - end - - luci.http.write("]") - bwc:close() - end -end - -function action_connections() - local sys = require "luci.sys" - - luci.http.prepare_content("application/json") - - 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: [") - - while true do - local ln = bwc:read("*l") - if not ln then break end - luci.http.write(ln) - end - - luci.http.write("]") - bwc:close() - end - - luci.http.write(" }") -end - -function action_nameinfo(...) - local i - local rv = { } - for i = 1, select('#', ...) do - local addr = select(i, ...) - local fqdn = nixio.getnameinfo(addr) - rv[addr] = fqdn or (addr:match(":") and "[%s]" % addr or addr) - end - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end diff --git a/modules/admin-full/luasrc/controller/admin/system.lua b/modules/admin-full/luasrc/controller/admin/system.lua deleted file mode 100644 index 5fa4c3a387..0000000000 --- a/modules/admin-full/luasrc/controller/admin/system.lua +++ /dev/null @@ -1,393 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2008-2011 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- - -module("luci.controller.admin.system", package.seeall) - -function index() - entry({"admin", "system"}, alias("admin", "system", "system"), _("System"), 30).index = true - entry({"admin", "system", "system"}, cbi("admin_system/system"), _("System"), 1) - entry({"admin", "system", "clock_status"}, call("action_clock_status")) - - entry({"admin", "system", "admin"}, cbi("admin_system/admin"), _("Administration"), 2) - - if nixio.fs.access("/bin/opkg") then - entry({"admin", "system", "packages"}, call("action_packages"), _("Software"), 10) - entry({"admin", "system", "packages", "ipkg"}, form("admin_system/ipkg")) - end - - entry({"admin", "system", "startup"}, form("admin_system/startup"), _("Startup"), 45) - entry({"admin", "system", "crontab"}, form("admin_system/crontab"), _("Scheduled Tasks"), 46) - - if nixio.fs.access("/etc/config/fstab") then - entry({"admin", "system", "fstab"}, cbi("admin_system/fstab"), _("Mount Points"), 50) - entry({"admin", "system", "fstab", "mount"}, cbi("admin_system/fstab/mount"), nil).leaf = true - entry({"admin", "system", "fstab", "swap"}, cbi("admin_system/fstab/swap"), nil).leaf = true - end - - if nixio.fs.access("/sys/class/leds") then - entry({"admin", "system", "leds"}, cbi("admin_system/leds"), _("<abbr title=\"Light Emitting Diode\">LED</abbr> Configuration"), 60) - end - - entry({"admin", "system", "flashops"}, call("action_flashops"), _("Backup / Flash Firmware"), 70) - entry({"admin", "system", "flashops", "backupfiles"}, form("admin_system/backupfiles")) - - entry({"admin", "system", "reboot"}, call("action_reboot"), _("Reboot"), 90) -end - -function action_clock_status() - local set = tonumber(luci.http.formvalue("set")) - if set ~= nil and set > 0 then - local date = os.date("*t", set) - if date then - luci.sys.call("date -s '%04d-%02d-%02d %02d:%02d:%02d'" %{ - date.year, date.month, date.day, date.hour, date.min, date.sec - }) - end - end - - luci.http.prepare_content("application/json") - luci.http.write_json({ timestring = os.date("%c") }) -end - -function action_packages() - local ipkg = require("luci.model.ipkg") - local submit = luci.http.formvalue("submit") - local changes = false - local install = { } - local remove = { } - local stdout = { "" } - local stderr = { "" } - local out, err - - -- Display - local display = luci.http.formvalue("display") or "installed" - - -- Letter - local letter = string.byte(luci.http.formvalue("letter") or "A", 1) - letter = (letter == 35 or (letter >= 65 and letter <= 90)) and letter or 65 - - -- Search query - local query = luci.http.formvalue("query") - query = (query ~= '') and query or nil - - - -- Packets to be installed - local ninst = submit and luci.http.formvalue("install") - local uinst = nil - - -- Install from URL - local url = luci.http.formvalue("url") - if url and url ~= '' and submit then - uinst = url - end - - -- Do install - if ninst then - install[ninst], out, err = ipkg.install(ninst) - stdout[#stdout+1] = out - stderr[#stderr+1] = err - changes = true - end - - if uinst then - local pkg - for pkg in luci.util.imatch(uinst) do - install[uinst], out, err = ipkg.install(pkg) - stdout[#stdout+1] = out - stderr[#stderr+1] = err - changes = true - end - end - - -- Remove packets - local rem = submit and luci.http.formvalue("remove") - if rem then - remove[rem], out, err = ipkg.remove(rem) - stdout[#stdout+1] = out - stderr[#stderr+1] = err - changes = true - end - - - -- Update all packets - local update = luci.http.formvalue("update") - if update then - update, out, err = ipkg.update() - stdout[#stdout+1] = out - stderr[#stderr+1] = err - end - - - -- Upgrade all packets - local upgrade = luci.http.formvalue("upgrade") - if upgrade then - upgrade, out, err = ipkg.upgrade() - stdout[#stdout+1] = out - stderr[#stderr+1] = err - end - - - -- List state - local no_lists = true - local old_lists = false - local tmp = nixio.fs.dir("/var/opkg-lists/") - if tmp then - for tmp in tmp do - no_lists = false - tmp = nixio.fs.stat("/var/opkg-lists/"..tmp) - if tmp and tmp.mtime < (os.time() - (24 * 60 * 60)) then - old_lists = true - break - end - end - end - - - luci.template.render("admin_system/packages", { - display = display, - letter = letter, - query = query, - install = install, - remove = remove, - update = update, - upgrade = upgrade, - no_lists = no_lists, - old_lists = old_lists, - stdout = table.concat(stdout, ""), - stderr = table.concat(stderr, "") - }) - - -- Remove index cache - if changes then - nixio.fs.unlink("/tmp/luci-indexcache") - end -end - -function action_flashops() - local sys = require "luci.sys" - local fs = require "luci.fs" - - local upgrade_avail = nixio.fs.access("/lib/upgrade/platform.sh") - local reset_avail = os.execute([[grep '"rootfs_data"' /proc/mtd >/dev/null 2>&1]]) == 0 - - local restore_cmd = "tar -xzC/ >/dev/null 2>&1" - local backup_cmd = "sysupgrade --create-backup - 2>/dev/null" - local image_tmp = "/tmp/firmware.img" - - local function image_supported() - -- XXX: yay... - return ( 0 == os.execute( - ". /lib/functions.sh; " .. - "include /lib/upgrade; " .. - "platform_check_image %q >/dev/null" - % image_tmp - ) ) - end - - local function image_checksum() - return (luci.sys.exec("md5sum %q" % image_tmp):match("^([^%s]+)")) - end - - local function storage_size() - local size = 0 - if nixio.fs.access("/proc/mtd") then - for l in io.lines("/proc/mtd") do - local d, s, e, n = l:match('^([^%s]+)%s+([^%s]+)%s+([^%s]+)%s+"([^%s]+)"') - if n == "linux" or n == "firmware" then - size = tonumber(s, 16) - break - end - end - elseif nixio.fs.access("/proc/partitions") then - for l in io.lines("/proc/partitions") do - local x, y, b, n = l:match('^%s*(%d+)%s+(%d+)%s+([^%s]+)%s+([^%s]+)') - if b and n and not n:match('[0-9]') then - size = tonumber(b) * 1024 - break - end - end - end - return size - end - - - local fp - luci.http.setfilehandler( - function(meta, chunk, eof) - if not fp then - if meta and meta.name == "image" then - fp = io.open(image_tmp, "w") - else - fp = io.popen(restore_cmd, "w") - end - end - if chunk then - fp:write(chunk) - end - if eof then - fp:close() - end - end - ) - - if luci.http.formvalue("backup") then - -- - -- Assemble file list, generate backup - -- - local reader = ltn12_popen(backup_cmd) - luci.http.header('Content-Disposition', 'attachment; filename="backup-%s-%s.tar.gz"' % { - luci.sys.hostname(), os.date("%Y-%m-%d")}) - luci.http.prepare_content("application/x-targz") - luci.ltn12.pump.all(reader, luci.http.write) - elseif luci.http.formvalue("restore") then - -- - -- Unpack received .tar.gz - -- - local upload = luci.http.formvalue("archive") - if upload and #upload > 0 then - luci.template.render("admin_system/applyreboot") - luci.sys.reboot() - end - elseif luci.http.formvalue("image") or luci.http.formvalue("step") then - -- - -- Initiate firmware flash - -- - local step = tonumber(luci.http.formvalue("step") or 1) - if step == 1 then - if image_supported() then - luci.template.render("admin_system/upgrade", { - checksum = image_checksum(), - storage = storage_size(), - size = nixio.fs.stat(image_tmp).size, - keep = (not not luci.http.formvalue("keep")) - }) - else - nixio.fs.unlink(image_tmp) - luci.template.render("admin_system/flashops", { - reset_avail = reset_avail, - upgrade_avail = upgrade_avail, - image_invalid = true - }) - end - -- - -- Start sysupgrade flash - -- - elseif step == 2 then - local keep = (luci.http.formvalue("keep") == "1") and "" or "-n" - luci.template.render("admin_system/applyreboot", { - title = luci.i18n.translate("Flashing..."), - msg = luci.i18n.translate("The system is flashing now.<br /> DO NOT POWER OFF THE DEVICE!<br /> Wait a few minutes before you try to reconnect. It might be necessary to renew the address of your computer to reach the device again, depending on your settings."), - addr = (#keep > 0) and "192.168.1.1" or nil - }) - fork_exec("killall dropbear uhttpd; sleep 1; /sbin/sysupgrade %s %q" %{ keep, image_tmp }) - end - elseif reset_avail and luci.http.formvalue("reset") then - -- - -- Reset system - -- - luci.template.render("admin_system/applyreboot", { - title = luci.i18n.translate("Erasing..."), - msg = luci.i18n.translate("The system is erasing the configuration partition now and will reboot itself when finished."), - addr = "192.168.1.1" - }) - fork_exec("killall dropbear uhttpd; sleep 1; mtd -r erase rootfs_data") - else - -- - -- Overview - -- - luci.template.render("admin_system/flashops", { - reset_avail = reset_avail, - upgrade_avail = upgrade_avail - }) - end -end - -function action_passwd() - local p1 = luci.http.formvalue("pwd1") - local p2 = luci.http.formvalue("pwd2") - local stat = nil - - if p1 or p2 then - if p1 == p2 then - stat = luci.sys.user.setpasswd("root", p1) - else - stat = 10 - end - end - - luci.template.render("admin_system/passwd", {stat=stat}) -end - -function action_reboot() - local reboot = luci.http.formvalue("reboot") - luci.template.render("admin_system/reboot", {reboot=reboot}) - if reboot then - luci.sys.reboot() - end -end - -function fork_exec(command) - local pid = nixio.fork() - if pid > 0 then - return - elseif pid == 0 then - -- change to root dir - nixio.chdir("/") - - -- patch stdin, out, err to /dev/null - local null = nixio.open("/dev/null", "w+") - if null then - nixio.dup(null, nixio.stderr) - nixio.dup(null, nixio.stdout) - nixio.dup(null, nixio.stdin) - if null:fileno() > 2 then - null:close() - end - end - - -- replace with target command - nixio.exec("/bin/sh", "-c", command) - end -end - -function ltn12_popen(command) - - local fdi, fdo = nixio.pipe() - local pid = nixio.fork() - - if pid > 0 then - fdo:close() - local close - return function() - local buffer = fdi:read(2048) - local wpid, stat = nixio.waitpid(pid, "nohang") - if not close and wpid and stat == "exited" then - close = true - end - - if buffer and #buffer > 0 then - return buffer - elseif close then - fdi:close() - return nil - end - end - elseif pid == 0 then - nixio.dup(fdo, nixio.stdout) - fdi:close() - fdo:close() - nixio.exec("/bin/sh", "-c", command) - end -end diff --git a/modules/admin-full/luasrc/controller/admin/uci.lua b/modules/admin-full/luasrc/controller/admin/uci.lua deleted file mode 100644 index 34e40ee624..0000000000 --- a/modules/admin-full/luasrc/controller/admin/uci.lua +++ /dev/null @@ -1,75 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2010 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- - -module("luci.controller.admin.uci", package.seeall) - -function index() - local redir = luci.http.formvalue("redir", true) or - luci.dispatcher.build_url(unpack(luci.dispatcher.context.request)) - - entry({"admin", "uci"}, nil, _("Configuration")) - entry({"admin", "uci", "changes"}, call("action_changes"), _("Changes"), 40).query = {redir=redir} - entry({"admin", "uci", "revert"}, call("action_revert"), _("Revert"), 30).query = {redir=redir} - entry({"admin", "uci", "apply"}, call("action_apply"), _("Apply"), 20).query = {redir=redir} - entry({"admin", "uci", "saveapply"}, call("action_apply"), _("Save & Apply"), 10).query = {redir=redir} -end - -function action_changes() - local uci = luci.model.uci.cursor() - local changes = uci:changes() - - luci.template.render("admin_uci/changes", { - changes = next(changes) and changes - }) -end - -function action_apply() - local path = luci.dispatcher.context.path - local uci = luci.model.uci.cursor() - local changes = uci:changes() - local reload = {} - - -- Collect files to be applied and commit changes - for r, tbl in pairs(changes) do - table.insert(reload, r) - if path[#path] ~= "apply" then - uci:load(r) - uci:commit(r) - uci:unload(r) - end - end - - luci.template.render("admin_uci/apply", { - changes = next(changes) and changes, - configs = reload - }) -end - - -function action_revert() - local uci = luci.model.uci.cursor() - local changes = uci:changes() - - -- Collect files to be reverted - for r, tbl in pairs(changes) do - uci:load(r) - uci:revert(r) - uci:unload(r) - end - - luci.template.render("admin_uci/revert", { - changes = next(changes) and changes - }) -end diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua b/modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua deleted file mode 100644 index bd6f403c53..0000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua +++ /dev/null @@ -1,264 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2008 Steven Barth <steven@midlink.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- - -local sys = require "luci.sys" - -m = Map("dhcp", translate("DHCP and DNS"), - translate("Dnsmasq is a combined <abbr title=\"Dynamic Host Configuration Protocol" .. - "\">DHCP</abbr>-Server and <abbr title=\"Domain Name System\">DNS</abbr>-" .. - "Forwarder for <abbr title=\"Network Address Translation\">NAT</abbr> " .. - "firewalls")) - -s = m:section(TypedSection, "dnsmasq", translate("Server Settings")) -s.anonymous = true -s.addremove = false - -s:tab("general", translate("General Settings")) -s:tab("files", translate("Resolv and Hosts Files")) -s:tab("tftp", translate("TFTP Settings")) -s:tab("advanced", translate("Advanced Settings")) - -s:taboption("general", Flag, "domainneeded", - translate("Domain required"), - translate("Don't forward <abbr title=\"Domain Name System\">DNS</abbr>-Requests without " .. - "<abbr title=\"Domain Name System\">DNS</abbr>-Name")) - -s:taboption("general", Flag, "authoritative", - translate("Authoritative"), - translate("This is the only <abbr title=\"Dynamic Host Configuration Protocol\">DHCP</" .. - "abbr> in the local network")) - - -s:taboption("files", Flag, "readethers", - translate("Use <code>/etc/ethers</code>"), - translate("Read <code>/etc/ethers</code> to configure the <abbr title=\"Dynamic Host " .. - "Configuration Protocol\">DHCP</abbr>-Server")) - -s:taboption("files", Value, "leasefile", - translate("Leasefile"), - translate("file where given <abbr title=\"Dynamic Host Configuration Protocol\">DHCP</" .. - "abbr>-leases will be stored")) - -s:taboption("files", Flag, "noresolv", - translate("Ignore resolve file")).optional = true - -rf = s:taboption("files", Value, "resolvfile", - translate("Resolve file"), - translate("local <abbr title=\"Domain Name System\">DNS</abbr> file")) - -rf:depends("noresolv", "") -rf.optional = true - - -s:taboption("files", Flag, "nohosts", - translate("Ignore Hosts files")).optional = true - -hf = s:taboption("files", DynamicList, "addnhosts", - translate("Additional Hosts files")) - -hf:depends("nohosts", "") -hf.optional = true - - -s:taboption("advanced", Flag, "boguspriv", - translate("Filter private"), - translate("Do not forward reverse lookups for local networks")) - -s:taboption("advanced", Flag, "filterwin2k", - translate("Filter useless"), - translate("Do not forward requests that cannot be answered by public name servers")) - - -s:taboption("advanced", Flag, "localise_queries", - translate("Localise queries"), - translate("Localise hostname depending on the requesting subnet if multiple IPs are available")) - -s:taboption("general", Value, "local", - translate("Local server"), - translate("Local domain specification. Names matching this domain are never forwarded and are resolved from DHCP or hosts files only")) - -s:taboption("general", Value, "domain", - translate("Local domain"), - translate("Local domain suffix appended to DHCP names and hosts file entries")) - -s:taboption("advanced", Flag, "expandhosts", - translate("Expand hosts"), - translate("Add local domain suffix to names served from hosts files")) - -s:taboption("advanced", Flag, "nonegcache", - translate("No negative cache"), - translate("Do not cache negative replies, e.g. for not existing domains")) - -s:taboption("advanced", Flag, "strictorder", - translate("Strict order"), - translate("<abbr title=\"Domain Name System\">DNS</abbr> servers will be queried in the " .. - "order of the resolvfile")).optional = true - - -bn = s:taboption("advanced", DynamicList, "bogusnxdomain", translate("Bogus NX Domain Override"), - translate("List of hosts that supply bogus NX domain results")) - -bn.optional = true -bn.placeholder = "67.215.65.132" - - -s:taboption("general", Flag, "logqueries", - translate("Log queries"), - translate("Write received DNS requests to syslog")).optional = true - -df = s:taboption("general", DynamicList, "server", translate("DNS forwardings"), - translate("List of <abbr title=\"Domain Name System\">DNS</abbr> " .. - "servers to forward requests to")) - -df.optional = true -df.placeholder = "/example.org/10.1.2.3" - - -rp = s:taboption("general", Flag, "rebind_protection", - translate("Rebind protection"), - translate("Discard upstream RFC1918 responses")) - -rp.rmempty = false - - -rl = s:taboption("general", Flag, "rebind_localhost", - translate("Allow localhost"), - translate("Allow upstream responses in the 127.0.0.0/8 range, e.g. for RBL services")) - -rl:depends("rebind_protection", "1") - - -rd = s:taboption("general", DynamicList, "rebind_domain", - translate("Domain whitelist"), - translate("List of domains to allow RFC1918 responses for")) - -rd:depends("rebind_protection", "1") -rd.datatype = "host" -rd.placeholder = "ihost.netflix.com" - - -pt = s:taboption("advanced", Value, "port", - translate("<abbr title=\"Domain Name System\">DNS</abbr> server port"), - translate("Listening port for inbound DNS queries")) - -pt.optional = true -pt.datatype = "port" -pt.placeholder = 53 - - -qp = s:taboption("advanced", Value, "queryport", - translate("<abbr title=\"Domain Name System\">DNS</abbr> query port"), - translate("Fixed source port for outbound DNS queries")) - -qp.optional = true -qp.datatype = "port" -qp.placeholder = translate("any") - - -lm = s:taboption("advanced", Value, "dhcpleasemax", - translate("<abbr title=\"maximal\">Max.</abbr> <abbr title=\"Dynamic Host Configuration " .. - "Protocol\">DHCP</abbr> leases"), - translate("Maximum allowed number of active DHCP leases")) - -lm.optional = true -lm.datatype = "uinteger" -lm.placeholder = translate("unlimited") - - -em = s:taboption("advanced", Value, "ednspacket_max", - translate("<abbr title=\"maximal\">Max.</abbr> <abbr title=\"Extension Mechanisms for " .. - "Domain Name System\">EDNS0</abbr> packet size"), - translate("Maximum allowed size of EDNS.0 UDP packets")) - -em.optional = true -em.datatype = "uinteger" -em.placeholder = 1280 - - -cq = s:taboption("advanced", Value, "dnsforwardmax", - translate("<abbr title=\"maximal\">Max.</abbr> concurrent queries"), - translate("Maximum allowed number of concurrent DNS queries")) - -cq.optional = true -cq.datatype = "uinteger" -cq.placeholder = 150 - - -s:taboption("tftp", Flag, "enable_tftp", - translate("Enable TFTP server")).optional = true - -tr = s:taboption("tftp", Value, "tftp_root", - translate("TFTP server root"), - translate("Root directory for files served via TFTP")) - -tr.optional = true -tr:depends("enable_tftp", "1") -tr.placeholder = "/" - - -db = s:taboption("tftp", Value, "dhcp_boot", - translate("Network boot image"), - translate("Filename of the boot image advertised to clients")) - -db.optional = true -db:depends("enable_tftp", "1") -db.placeholder = "pxelinux.0" - - -m:section(SimpleSection).template = "admin_network/lease_status" - -s = m:section(TypedSection, "host", translate("Static Leases"), - translate("Static leases are used to assign fixed IP addresses and symbolic hostnames to " .. - "DHCP clients. They are also required for non-dynamic interface configurations where " .. - "only hosts with a corresponding lease are served.") .. "<br />" .. - translate("Use the <em>Add</em> Button to add a new lease entry. The <em>MAC-Address</em> " .. - "indentifies the host, the <em>IPv4-Address</em> specifies to the fixed address to " .. - "use and the <em>Hostname</em> is assigned as symbolic name to the requesting host.")) - -s.addremove = true -s.anonymous = true -s.template = "cbi/tblsection" - -name = s:option(Value, "name", translate("Hostname")) -name.datatype = "hostname" -name.rmempty = true - -mac = s:option(Value, "mac", translate("<abbr title=\"Media Access Control\">MAC</abbr>-Address")) -mac.datatype = "list(macaddr)" -mac.rmempty = true - -ip = s:option(Value, "ip", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Address")) -ip.datatype = "or(ip4addr,'ignore')" - -hostid = s:option(Value, "hostid", translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Suffix (hex)")) - -sys.net.arptable(function(entry) - ip:value(entry["IP address"]) - mac:value( - entry["HW address"], - entry["HW address"] .. " (" .. entry["IP address"] .. ")" - ) -end) - -function ip.validate(self, value, section) - local m = mac:formvalue(section) or "" - local n = name:formvalue(section) or "" - if value and #n == 0 and #m == 0 then - return nil, translate("One of hostname or mac address must be specified!") - end - return Value.validate(self, value, section) -end - - -return m diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/hosts.lua b/modules/admin-full/luasrc/model/cbi/admin_network/hosts.lua deleted file mode 100644 index b4fee8cf07..0000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_network/hosts.lua +++ /dev/null @@ -1,41 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2010 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- - -require("luci.sys") -require("luci.util") -m = Map("dhcp", translate("Hostnames")) - -s = m:section(TypedSection, "domain", translate("Host entries")) -s.addremove = true -s.anonymous = true -s.template = "cbi/tblsection" - -hn = s:option(Value, "name", translate("Hostname")) -hn.datatype = "hostname" -hn.rmempty = true - -ip = s:option(Value, "ip", translate("IP address")) -ip.datatype = "ipaddr" -ip.rmempty = true - -local arptable = luci.sys.net.arptable() or {} -for i, dataset in ipairs(arptable) do - ip:value( - dataset["IP address"], - "%s (%s)" %{ dataset["IP address"], dataset["HW address"] } - ) -end - -return m diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/iface_add.lua b/modules/admin-full/luasrc/model/cbi/admin_network/iface_add.lua deleted file mode 100644 index 92026b157b..0000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_network/iface_add.lua +++ /dev/null @@ -1,104 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2009-2010 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ - -]]-- - -local nw = require "luci.model.network".init() -local fw = require "luci.model.firewall".init() -local utl = require "luci.util" -local uci = require "luci.model.uci".cursor() - -m = SimpleForm("network", translate("Create Interface")) -m.redirect = luci.dispatcher.build_url("admin/network/network") -m.reset = false - -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>" - )) - -newnet:depends("_attach", "") -newnet.default = arg[1] and "net_" .. arg[1]:gsub("[^%w_]+", "_") -newnet.datatype = "uciname" - -newproto = m:field(ListValue, "_netproto", translate("Protocol of the new interface")) - -netbridge = m:field(Flag, "_bridge", translate("Create a bridge over multiple interfaces")) - - -sifname = m:field(Value, "_ifname", translate("Cover the following interface")) - -sifname.widget = "radio" -sifname.template = "cbi/network_ifacelist" -sifname.nobridges = true - - -mifname = m:field(Value, "_ifnames", translate("Cover the following interfaces")) - -mifname.widget = "checkbox" -mifname.template = "cbi/network_ifacelist" -mifname.nobridges = true - - -local _, p -for _, p in ipairs(nw:get_protocols()) do - if p:is_installed() then - newproto:value(p:proto(), p:get_i18n()) - if not p:is_virtual() then netbridge:depends("_netproto", p:proto()) end - if not p:is_floating() then - sifname:depends({ _bridge = "", _netproto = p:proto()}) - mifname:depends({ _bridge = "1", _netproto = p:proto()}) - end - end -end - -function newproto.validate(self, value, section) - local name = newnet:formvalue(section) - if not name or #name == 0 then - newnet:add_error(section, translate("No network name specified")) - elseif m:get(name) then - newnet:add_error(section, translate("The given network name is not unique")) - end - - local proto = nw:get_protocol(value) - if proto and not proto:is_floating() then - local br = (netbridge:formvalue(section) == "1") - local ifn = br and mifname:formvalue(section) or sifname:formvalue(section) - for ifn in utl.imatch(ifn) do - return value - end - return nil, translate("The selected protocol needs a device assigned") - end - return value -end - -function newproto.write(self, section, value) - local name = newnet:formvalue(section) - if name and #name > 0 then - local br = (netbridge:formvalue(section) == "1") and "bridge" or nil - local net = nw:add_network(name, { proto = value, type = br }) - if net then - local ifn - for ifn in utl.imatch( - br and mifname:formvalue(section) or sifname:formvalue(section) - ) do - net:add_interface(ifn) - end - nw:save("network") - nw:save("wireless") - end - luci.http.redirect(luci.dispatcher.build_url("admin/network/network", name)) - end -end - -return m diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua b/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua deleted file mode 100644 index 9be5ff1a7d..0000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua +++ /dev/null @@ -1,527 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2008-2011 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- - -local fs = require "nixio.fs" -local ut = require "luci.util" -local pt = require "luci.tools.proto" -local nw = require "luci.model.network" -local fw = require "luci.model.firewall" - -arg[1] = arg[1] or "" - -local has_dnsmasq = fs.access("/etc/config/dhcp") -local has_firewall = fs.access("/etc/config/firewall") - -m = Map("network", translate("Interfaces") .. " - " .. arg[1]:upper(), translate("On this page you can configure the network interfaces. You can bridge several interfaces by ticking the \"bridge interfaces\" field and enter the names of several network interfaces separated by spaces. You can also use <abbr title=\"Virtual Local Area Network\">VLAN</abbr> notation <samp>INTERFACE.VLANNR</samp> (<abbr title=\"for example\">e.g.</abbr>: <samp>eth0.1</samp>).")) -m:chain("wireless") - -if has_firewall then - m:chain("firewall") -end - -nw.init(m.uci) -fw.init(m.uci) - - -local net = nw:get_network(arg[1]) - -local function backup_ifnames(is_bridge) - if not net:is_floating() and not m:get(net:name(), "_orig_ifname") then - local ifcs = net:get_interfaces() or { net:get_interface() } - if ifcs then - local _, ifn - local ifns = { } - for _, ifn in ipairs(ifcs) do - ifns[#ifns+1] = ifn:name() - end - if #ifns > 0 then - m:set(net:name(), "_orig_ifname", table.concat(ifns, " ")) - m:set(net:name(), "_orig_bridge", tostring(net:is_bridge())) - end - end - end -end - - --- redirect to overview page if network does not exist anymore (e.g. after a revert) -if not net then - luci.http.redirect(luci.dispatcher.build_url("admin/network/network")) - return -end - --- protocol switch was requested, rebuild interface config and reload page -if m:formvalue("cbid.network.%s._switch" % net:name()) then - -- get new protocol - local ptype = m:formvalue("cbid.network.%s.proto" % net:name()) or "-" - local proto = nw:get_protocol(ptype, net:name()) - if proto then - -- backup default - backup_ifnames() - - -- if current proto is not floating and target proto is not floating, - -- then attempt to retain the ifnames - --error(net:proto() .. " > " .. proto:proto()) - if not net:is_floating() and not proto:is_floating() then - -- if old proto is a bridge and new proto not, then clip the - -- interface list to the first ifname only - if net:is_bridge() and proto:is_virtual() then - local _, ifn - local first = true - for _, ifn in ipairs(net:get_interfaces() or { net:get_interface() }) do - if first then - first = false - else - net:del_interface(ifn) - end - end - m:del(net:name(), "type") - end - - -- if the current proto is floating, the target proto not floating, - -- then attempt to restore ifnames from backup - elseif net:is_floating() and not proto:is_floating() then - -- if we have backup data, then re-add all orphaned interfaces - -- from it and restore the bridge choice - local br = (m:get(net:name(), "_orig_bridge") == "true") - local ifn - local ifns = { } - for ifn in ut.imatch(m:get(net:name(), "_orig_ifname")) do - ifn = nw:get_interface(ifn) - if ifn and not ifn:get_network() then - proto:add_interface(ifn) - if not br then - break - end - end - end - if br then - m:set(net:name(), "type", "bridge") - end - - -- in all other cases clear the ifnames - else - local _, ifc - for _, ifc in ipairs(net:get_interfaces() or { net:get_interface() }) do - net:del_interface(ifc) - end - m:del(net:name(), "type") - end - - -- clear options - local k, v - for k, v in pairs(m:get(net:name())) do - if k:sub(1,1) ~= "." and - k ~= "type" and - k ~= "ifname" and - k ~= "_orig_ifname" and - k ~= "_orig_bridge" - then - m:del(net:name(), k) - end - end - - -- set proto - m:set(net:name(), "proto", proto:proto()) - m.uci:save("network") - m.uci:save("wireless") - - -- reload page - luci.http.redirect(luci.dispatcher.build_url("admin/network/network", arg[1])) - return - end -end - --- dhcp setup was requested, create section and reload page -if m:formvalue("cbid.dhcp._enable._enable") then - m.uci:section("dhcp", "dhcp", nil, { - interface = arg[1], - start = "100", - limit = "150", - leasetime = "12h" - }) - - m.uci:save("dhcp") - luci.http.redirect(luci.dispatcher.build_url("admin/network/network", arg[1])) - return -end - -local ifc = net:get_interface() - -s = m:section(NamedSection, arg[1], "interface", translate("Common Configuration")) -s.addremove = false - -s:tab("general", translate("General Setup")) -s:tab("advanced", translate("Advanced Settings")) -s:tab("physical", translate("Physical Settings")) - -if has_firewall then - s:tab("firewall", translate("Firewall Settings")) -end - - -st = s:taboption("general", DummyValue, "__status", translate("Status")) - -local function set_status() - -- if current network is empty, print a warning - if not net:is_floating() and net:is_empty() then - st.template = "cbi/dvalue" - st.network = nil - st.value = translate("There is no device assigned yet, please attach a network device in the \"Physical Settings\" tab") - else - st.template = "admin_network/iface_status" - st.network = arg[1] - st.value = nil - end -end - -m.on_init = set_status -m.on_after_save = set_status - - -p = s:taboption("general", ListValue, "proto", translate("Protocol")) -p.default = net:proto() - - -if not net:is_installed() then - p_install = s:taboption("general", Button, "_install") - p_install.title = translate("Protocol support is not installed") - p_install.inputtitle = translate("Install package %q" % net:opkg_package()) - p_install.inputstyle = "apply" - p_install:depends("proto", net:proto()) - - function p_install.write() - return luci.http.redirect( - luci.dispatcher.build_url("admin/system/packages") .. - "?submit=1&install=%s" % net:opkg_package() - ) - end -end - - -p_switch = s:taboption("general", Button, "_switch") -p_switch.title = translate("Really switch protocol?") -p_switch.inputtitle = translate("Switch protocol") -p_switch.inputstyle = "apply" - -local _, pr -for _, pr in ipairs(nw:get_protocols()) do - p:value(pr:proto(), pr:get_i18n()) - if pr:proto() ~= net:proto() then - p_switch:depends("proto", pr:proto()) - end -end - - -auto = s:taboption("advanced", Flag, "auto", translate("Bring up on boot")) -auto.default = (net:proto() == "none") and auto.disabled or auto.enabled - -delegate = s:taboption("advanced", Flag, "delegate", translate("Use builtin IPv6-management")) -delegate.default = delegate.enabled - - -if not net:is_virtual() then - br = s:taboption("physical", Flag, "type", translate("Bridge interfaces"), translate("creates a bridge over specified interface(s)")) - br.enabled = "bridge" - br.rmempty = true - br:depends("proto", "static") - br:depends("proto", "dhcp") - br:depends("proto", "none") - - stp = s:taboption("physical", Flag, "stp", translate("Enable <abbr title=\"Spanning Tree Protocol\">STP</abbr>"), - translate("Enables the Spanning Tree Protocol on this bridge")) - stp:depends("type", "bridge") - stp.rmempty = true -end - - -if not net:is_floating() then - ifname_single = s:taboption("physical", Value, "ifname_single", translate("Interface")) - ifname_single.template = "cbi/network_ifacelist" - ifname_single.widget = "radio" - ifname_single.nobridges = true - ifname_single.rmempty = false - ifname_single.network = arg[1] - ifname_single:depends("type", "") - - function ifname_single.cfgvalue(self, s) - -- let the template figure out the related ifaces through the network model - return nil - end - - function ifname_single.write(self, s, val) - 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() - end - - for i in ut.imatch(val) do - new_ifs[#new_ifs+1] = i - - -- if this is not a bridge, only assign first interface - if self.option == "ifname_single" then - break - end - end - - table.sort(old_ifs) - table.sort(new_ifs) - - for i = 1, math.max(#old_ifs, #new_ifs) do - if old_ifs[i] ~= new_ifs[i] then - backup_ifnames() - for i = 1, #old_ifs do - net:del_interface(old_ifs[i]) - end - for i = 1, #new_ifs do - net:add_interface(new_ifs[i]) - end - break - end - end - end -end - - -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.rmempty = false - ifname_multi.network = arg[1] - ifname_multi.widget = "checkbox" - ifname_multi:depends("type", "bridge") - ifname_multi.cfgvalue = ifname_single.cfgvalue - ifname_multi.write = ifname_single.write -end - - -if has_firewall then - fwzone = s:taboption("firewall", Value, "_fwzone", - translate("Create / Assign firewall-zone"), - translate("Choose the firewall zone you want to assign to this interface. Select <em>unspecified</em> to remove the interface from the associated zone or fill out the <em>create</em> field to define a new zone and attach the interface to it.")) - - fwzone.template = "cbi/firewall_zonelist" - fwzone.network = arg[1] - fwzone.rmempty = false - - function fwzone.cfgvalue(self, section) - self.iface = section - local z = fw:get_zone_by_network(section) - return z and z:name() - end - - function fwzone.write(self, section, value) - local zone = fw:get_zone(value) - - if not zone and value == '-' then - value = m:formvalue(self:cbid(section) .. ".newzone") - if value and #value > 0 then - zone = fw:add_zone(value) - else - fw:del_network(section) - end - end - - if zone then - fw:del_network(section) - zone:add_network(section) - end - end -end - - -function p.write() end -function p.remove() end -function p.validate(self, value, section) - if value == net:proto() then - if not net:is_floating() and net:is_empty() then - local ifn = ((br and (br:formvalue(section) == "bridge")) - and ifname_multi:formvalue(section) - or ifname_single:formvalue(section)) - - for ifn in ut.imatch(ifn) do - return value - end - return nil, translate("The selected protocol needs a device assigned") - end - end - return value -end - - -local form, ferr = loadfile( - ut.libpath() .. "/model/cbi/admin_network/proto_%s.lua" % net:proto() -) - -if not form then - s:taboption("general", DummyValue, "_error", - translate("Missing protocol extension for proto %q" % net:proto()) - ).value = ferr -else - setfenv(form, getfenv(1))(m, s, net) -end - - -local _, field -for _, field in ipairs(s.children) do - if field ~= st and field ~= p and field ~= p_install and field ~= p_switch then - if next(field.deps) then - local _, dep - for _, dep in ipairs(field.deps) do - dep.deps.proto = net:proto() - end - else - field:depends("proto", net:proto()) - end - end -end - - --- --- Display DNS settings if dnsmasq is available --- - -if has_dnsmasq and net:proto() == "static" then - m2 = Map("dhcp", "", "") - - local has_section = false - - m2.uci:foreach("dhcp", "dhcp", function(s) - if s.interface == arg[1] then - has_section = true - return false - end - end) - - if not has_section and has_dnsmasq then - - s = m2:section(TypedSection, "dhcp", translate("DHCP Server")) - s.anonymous = true - s.cfgsections = function() return { "_enable" } end - - x = s:option(Button, "_enable") - x.title = translate("No DHCP Server configured for this interface") - x.inputtitle = translate("Setup DHCP Server") - x.inputstyle = "apply" - - elseif has_section then - - s = m2:section(TypedSection, "dhcp", translate("DHCP Server")) - s.addremove = false - s.anonymous = true - s:tab("general", translate("General Setup")) - s:tab("advanced", translate("Advanced Settings")) - s:tab("ipv6", translate("IPv6 Settings")) - - function s.filter(self, section) - return m2.uci:get("dhcp", section, "interface") == arg[1] - end - - local ignore = s:taboption("general", Flag, "ignore", - translate("Ignore interface"), - translate("Disable <abbr title=\"Dynamic Host Configuration Protocol\">DHCP</abbr> for " .. - "this interface.")) - - local start = s:taboption("general", Value, "start", translate("Start"), - translate("Lowest leased address as offset from the network address.")) - start.optional = true - start.datatype = "or(uinteger,ip4addr)" - start.default = "100" - - local limit = s:taboption("general", Value, "limit", translate("Limit"), - translate("Maximum number of leased addresses.")) - limit.optional = true - limit.datatype = "uinteger" - limit.default = "150" - - local ltime = s:taboption("general", Value, "leasetime", translate("Leasetime"), - translate("Expiry time of leased addresses, minimum is 2 minutes (<code>2m</code>).")) - ltime.rmempty = true - ltime.default = "12h" - - local dd = s:taboption("advanced", Flag, "dynamicdhcp", - translate("Dynamic <abbr title=\"Dynamic Host Configuration Protocol\">DHCP</abbr>"), - translate("Dynamically allocate DHCP addresses for clients. If disabled, only " .. - "clients having static leases will be served.")) - dd.default = dd.enabled - - s:taboption("advanced", Flag, "force", translate("Force"), - translate("Force DHCP on this network even if another server is detected.")) - - -- XXX: is this actually useful? - --s:taboption("advanced", Value, "name", translate("Name"), - -- translate("Define a name for this network.")) - - mask = s:taboption("advanced", Value, "netmask", - translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Netmask"), - translate("Override the netmask sent to clients. Normally it is calculated " .. - "from the subnet that is served.")) - - mask.optional = true - mask.datatype = "ip4addr" - - s:taboption("advanced", DynamicList, "dhcp_option", translate("DHCP-Options"), - translate("Define additional DHCP options, for example \"<code>6,192.168.2.1," .. - "192.168.2.2</code>\" which advertises different DNS servers to clients.")) - - for i, n in ipairs(s.children) do - if n ~= ignore then - n:depends("ignore", "") - end - end - - o = s:taboption("ipv6", ListValue, "ra", translate("Router Advertisement-Service")) - o:value("", translate("disabled")) - o:value("server", translate("server mode")) - o:value("relay", translate("relay mode")) - o:value("hybrid", translate("hybrid mode")) - - o = s:taboption("ipv6", ListValue, "dhcpv6", translate("DHCPv6-Service")) - o:value("", translate("disabled")) - o:value("server", translate("server mode")) - o:value("relay", translate("relay mode")) - o:value("hybrid", translate("hybrid mode")) - - o = s:taboption("ipv6", ListValue, "ndp", translate("NDP-Proxy")) - o:value("", translate("disabled")) - o:value("relay", translate("relay mode")) - o:value("hybrid", translate("hybrid mode")) - - o = s:taboption("ipv6", ListValue, "ra_management", translate("DHCPv6-Mode")) - o:value("", translate("stateless")) - o:value("1", translate("stateless + stateful")) - o:value("2", translate("stateful-only")) - o:depends("dhcpv6", "server") - o:depends("dhcpv6", "hybrid") - o.default = "1" - - o = s:taboption("ipv6", Flag, "ra_default", translate("Always announce default router"), - translate("Announce as default router even if no public prefix is available.")) - o:depends("ra", "server") - o:depends("ra", "hybrid") - - s:taboption("ipv6", DynamicList, "dns", translate("Announced DNS servers")) - s:taboption("ipv6", DynamicList, "domain", translate("Announced DNS domains")) - - else - m2 = nil - end -end - - -return m, m2 diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/network.lua b/modules/admin-full/luasrc/model/cbi/admin_network/network.lua deleted file mode 100644 index f2984b5810..0000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_network/network.lua +++ /dev/null @@ -1,82 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- - -local fs = require "nixio.fs" - -m = Map("network", translate("Interfaces")) -m.pageaction = false -m:section(SimpleSection).template = "admin_network/iface_overview" - --- Show ATM bridge section if we have the capabilities -if fs.access("/usr/sbin/br2684ctl") then - atm = m:section(TypedSection, "atm-bridge", translate("ATM Bridges"), - translate("ATM bridges expose encapsulated ethernet in AAL5 " .. - "connections as virtual Linux network interfaces which can " .. - "be used in conjunction with DHCP or PPP to dial into the " .. - "provider network.")) - - atm.addremove = true - atm.anonymous = true - - atm.create = function(self, section) - local sid = TypedSection.create(self, section) - local max_unit = -1 - - m.uci:foreach("network", "atm-bridge", - function(s) - local u = tonumber(s.unit) - if u ~= nil and u > max_unit then - max_unit = u - end - end) - - m.uci:set("network", sid, "unit", max_unit + 1) - m.uci:set("network", sid, "atmdev", 0) - m.uci:set("network", sid, "encaps", "llc") - m.uci:set("network", sid, "payload", "bridged") - m.uci:set("network", sid, "vci", 35) - m.uci:set("network", sid, "vpi", 8) - - return sid - end - - atm:tab("general", translate("General Setup")) - atm:tab("advanced", translate("Advanced Settings")) - - vci = atm:taboption("general", Value, "vci", translate("ATM Virtual Channel Identifier (VCI)")) - vpi = atm:taboption("general", Value, "vpi", translate("ATM Virtual Path Identifier (VPI)")) - encaps = atm:taboption("general", ListValue, "encaps", translate("Encapsulation mode")) - encaps:value("llc", translate("LLC")) - encaps:value("vc", translate("VC-Mux")) - - atmdev = atm:taboption("advanced", Value, "atmdev", translate("ATM device number")) - unit = atm:taboption("advanced", Value, "unit", translate("Bridge unit number")) - payload = atm:taboption("advanced", ListValue, "payload", translate("Forwarding mode")) - payload:value("bridged", translate("bridged")) - payload:value("routed", translate("routed")) - m.pageaction = true -end - -local network = require "luci.model.network" -if network:has_ipv6() then - local s = m:section(NamedSection, "globals", "globals", translate("Global network options")) - local o = s:option(Value, "ula_prefix", translate("IPv6 ULA-Prefix")) - o.datatype = "ip6addr" - o.rmempty = true - m.pageaction = true -end - - -return m diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/proto_ahcp.lua b/modules/admin-full/luasrc/model/cbi/admin_network/proto_ahcp.lua deleted file mode 100644 index 26dc33abb8..0000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_network/proto_ahcp.lua +++ /dev/null @@ -1,76 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2011 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 -]]-- - -local map, section, net = ... - -local device, apn, service, pincode, username, password -local ipv6, maxwait, defaultroute, metric, peerdns, dns, - keepalive_failure, keepalive_interval, demand - - -mca = s:taboption("ahcp", Value, "multicast_address", translate("Multicast address")) -mca.optional = true -mca.placeholder = "ff02::cca6:c0f9:e182:5359" -mca.datatype = "ip6addr" -mca:depends("proto", "ahcp") - -port = s:taboption("ahcp", Value, "port", translate("Port")) -port.optional = true -port.placeholder = 5359 -port.datatype = "port" -port:depends("proto", "ahcp") - -fam = s:taboption("ahcp", ListValue, "_family", translate("Protocol family")) -fam:value("", translate("IPv4 and IPv6")) -fam:value("ipv4", translate("IPv4 only")) -fam:value("ipv6", translate("IPv6 only")) -fam:depends("proto", "ahcp") - -function fam.cfgvalue(self, section) - local v4 = m.uci:get_bool("network", section, "ipv4_only") - local v6 = m.uci:get_bool("network", section, "ipv6_only") - if v4 then - return "ipv4" - elseif v6 then - return "ipv6" - end - return "" -end - -function fam.write(self, section, value) - if value == "ipv4" then - m.uci:set("network", section, "ipv4_only", "true") - m.uci:delete("network", section, "ipv6_only") - elseif value == "ipv6" then - m.uci:set("network", section, "ipv6_only", "true") - m.uci:delete("network", section, "ipv4_only") - end -end - -function fam.remove(self, section) - m.uci:delete("network", section, "ipv4_only") - m.uci:delete("network", section, "ipv6_only") -end - -nodns = s:taboption("ahcp", Flag, "no_dns", translate("Disable DNS setup")) -nodns.optional = true -nodns.enabled = "true" -nodns.disabled = "false" -nodns.default = nodns.disabled -nodns:depends("proto", "ahcp") - -ltime = s:taboption("ahcp", Value, "lease_time", translate("Lease validity time")) -ltime.optional = true -ltime.placeholder = 3666 -ltime.datatype = "uinteger" -ltime:depends("proto", "ahcp") - diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/routes.lua b/modules/admin-full/luasrc/model/cbi/admin_network/routes.lua deleted file mode 100644 index 469748c87a..0000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_network/routes.lua +++ /dev/null @@ -1,86 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2008 Steven Barth <steven@midlink.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- - -require("luci.tools.webadmin") -m = Map("network", - translate("Routes"), - translate("Routes specify over which interface and gateway a certain host or network " .. - "can be reached.")) - -local routes6 = luci.sys.net.routes6() -local bit = require "bit" - -s = m:section(TypedSection, "route", translate("Static IPv4 Routes")) -s.addremove = true -s.anonymous = true - -s.template = "cbi/tblsection" - -iface = s:option(ListValue, "interface", translate("Interface")) -luci.tools.webadmin.cbi_add_networks(iface) - -t = s:option(Value, "target", translate("Target"), translate("Host-<abbr title=\"Internet Protocol Address\">IP</abbr> or Network")) -t.datatype = "ip4addr" -t.rmempty = false - -n = s:option(Value, "netmask", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Netmask"), translate("if target is a network")) -n.placeholder = "255.255.255.255" -n.datatype = "ip4addr" -n.rmempty = true - -g = s:option(Value, "gateway", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Gateway")) -g.datatype = "ip4addr" -g.rmempty = true - -metric = s:option(Value, "metric", translate("Metric")) -metric.placeholder = 0 -metric.datatype = "range(0,255)" -metric.rmempty = true - -mtu = s:option(Value, "mtu", translate("MTU")) -mtu.placeholder = 1500 -mtu.datatype = "range(64,9000)" -mtu.rmempty = true - -if routes6 then - s = m:section(TypedSection, "route6", translate("Static IPv6 Routes")) - s.addremove = true - s.anonymous = true - - s.template = "cbi/tblsection" - - iface = s:option(ListValue, "interface", translate("Interface")) - luci.tools.webadmin.cbi_add_networks(iface) - - t = s:option(Value, "target", translate("Target"), translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Address or Network (CIDR)")) - t.datatype = "ip6addr" - t.rmempty = false - - g = s:option(Value, "gateway", translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Gateway")) - g.datatype = "ip6addr" - g.rmempty = true - - metric = s:option(Value, "metric", translate("Metric")) - metric.placeholder = 0 - metric.datatype = "range(0,65535)" -- XXX: not sure - metric.rmempty = true - - mtu = s:option(Value, "mtu", translate("MTU")) - mtu.placeholder = 1500 - mtu.datatype = "range(64,9000)" - mtu.rmempty = true -end - - -return m diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/vlan.lua b/modules/admin-full/luasrc/model/cbi/admin_network/vlan.lua deleted file mode 100644 index fbea03af98..0000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_network/vlan.lua +++ /dev/null @@ -1,315 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2010-2011 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -]]-- - -m = Map("network", translate("Switch"), translate("The network ports on this device can be combined to several <abbr title=\"Virtual Local Area Network\">VLAN</abbr>s in which computers can communicate directly with each other. <abbr title=\"Virtual Local Area Network\">VLAN</abbr>s are often used to separate different network segments. Often there is by default one Uplink port for a connection to the next greater network like the internet and other ports for a local network.")) - -local fs = require "nixio.fs" -local switches = { } - -m.uci:foreach("network", "switch", - function(x) - local sid = x['.name'] - local switch_name = x.name or sid - local has_vlan = nil - local has_learn = nil - local has_vlan4k = nil - local has_jumbo3 = nil - local has_mirror = nil - local min_vid = 0 - local max_vid = 16 - local num_vlans = 16 - local cpu_port = tonumber(fs.readfile("/proc/switch/eth0/cpuport") or 5) - local num_ports = cpu_port + 1 - - local switch_title - local enable_vlan4k = false - - -- Parse some common switch properties from swconfig help output. - local swc = io.popen("swconfig dev %q help 2>/dev/null" % switch_name) - if swc then - - local is_port_attr = false - local is_vlan_attr = false - - while true do - local line = swc:read("*l") - if not line then break end - - if line:match("^%s+%-%-vlan") then - is_vlan_attr = true - - elseif line:match("^%s+%-%-port") then - is_vlan_attr = false - is_port_attr = true - - elseif line:match("cpu @") then - switch_title = line:match("^switch%d: %w+%((.-)%)") - num_ports, cpu_port, num_vlans = - line:match("ports: (%d+) %(cpu @ (%d+)%), vlans: (%d+)") - - num_ports = tonumber(num_ports) or 6 - num_vlans = tonumber(num_vlans) or 16 - cpu_port = tonumber(cpu_port) or 5 - min_vid = 1 - - elseif line:match(": pvid") or line:match(": tag") or line:match(": vid") then - if is_vlan_attr then has_vlan4k = line:match(": (%w+)") end - - elseif line:match(": enable_vlan4k") then - enable_vlan4k = true - - elseif line:match(": enable_vlan") then - has_vlan = "enable_vlan" - - elseif line:match(": enable_learning") then - has_learn = "enable_learning" - - elseif line:match(": enable_mirror_rx") then - has_mirror = "enable_mirror_rx" - - elseif line:match(": max_length") then - has_jumbo3 = "max_length" - end - end - - swc:close() - end - - - -- Switch properties - s = m:section(NamedSection, x['.name'], "switch", - switch_title and translatef("Switch %q (%s)", switch_name, switch_title) - or translatef("Switch %q", switch_name)) - - s.addremove = false - - if has_vlan then - s:option(Flag, has_vlan, translate("Enable VLAN functionality")) - end - - if has_learn then - x = s:option(Flag, has_learn, translate("Enable learning and aging")) - x.default = x.enabled - end - - if has_jumbo3 then - x = s:option(Flag, has_jumbo3, translate("Enable Jumbo Frame passthrough")) - x.enabled = "3" - x.rmempty = true - end - - -- Does this switch support port mirroring? - if has_mirror then - s:option(Flag, "enable_mirror_rx", translate("Enable mirroring of incoming packets")) - s:option(Flag, "enable_mirror_tx", translate("Enable mirroring of outgoing packets")) - - local sp = s:option(ListValue, "mirror_source_port", translate("Mirror source port")) - local mp = s:option(ListValue, "mirror_monitor_port", translate("Mirror monitor port")) - - local pt - for pt = 0, num_ports - 1 do - local name - - name = (pt == cpu_port) and translate("CPU") or translatef("Port %d", pt) - - sp:value(pt, name) - mp:value(pt, name) - end - end - - -- VLAN table - s = m:section(TypedSection, "switch_vlan", - switch_title and translatef("VLANs on %q (%s)", switch_name, switch_title) - or translatef("VLANs on %q", switch_name)) - - s.template = "cbi/tblsection" - s.addremove = true - s.anonymous = true - - -- Filter by switch - s.filter = function(self, section) - local device = m:get(section, "device") - return (device and device == switch_name) - end - - -- Override cfgsections callback to enforce row ordering by vlan id. - s.cfgsections = function(self) - local osections = TypedSection.cfgsections(self) - local sections = { } - local section - - for _, section in luci.util.spairs( - osections, - function(a, b) - return (tonumber(m:get(osections[a], has_vlan4k or "vlan")) or 9999) - < (tonumber(m:get(osections[b], has_vlan4k or "vlan")) or 9999) - end - ) do - sections[#sections+1] = section - end - - return sections - end - - -- When creating a new vlan, preset it with the highest found vid + 1. - s.create = function(self, section, origin) - -- Filter by switch - if m:get(origin, "device") ~= switch_name then - return - end - - local sid = TypedSection.create(self, section) - - local max_nr = 0 - local max_id = 0 - - m.uci:foreach("network", "switch_vlan", - function(s) - if s.device == switch_name then - local nr = tonumber(s.vlan) - local id = has_vlan4k and tonumber(s[has_vlan4k]) - if nr ~= nil and nr > max_nr then max_nr = nr end - if id ~= nil and id > max_id then max_id = id end - end - end) - - m:set(sid, "device", switch_name) - m:set(sid, "vlan", max_nr + 1) - - if has_vlan4k then - m:set(sid, has_vlan4k, max_id + 1) - end - - return sid - end - - - local port_opts = { } - local untagged = { } - - -- Parse current tagging state from the "ports" option. - local portvalue = function(self, section) - local pt - for pt in (m:get(section, "ports") or ""):gmatch("%w+") do - local pc, tu = pt:match("^(%d+)([tu]*)") - if pc == self.option then return (#tu > 0) and tu or "u" end - end - return "" - end - - -- Validate port tagging. Ensure that a port is only untagged once, - -- bail out if not. - local portvalidate = function(self, value, section) - -- ensure that the ports appears untagged only once - if value == "u" then - if not untagged[self.option] then - untagged[self.option] = true - elseif min_vid > 0 or tonumber(self.option) ~= cpu_port then -- enable multiple untagged cpu ports due to weird broadcom default setup - return nil, - translatef("Port %d is untagged in multiple VLANs!", tonumber(self.option) + 1) - end - end - return value - end - - - local vid = s:option(Value, has_vlan4k or "vlan", "VLAN ID", "<div id='portstatus-%s'></div>" % switch_name) - local mx_vid = has_vlan4k and 4094 or (num_vlans - 1) - - vid.rmempty = false - vid.forcewrite = true - vid.vlan_used = { } - vid.datatype = "and(uinteger,range("..min_vid..","..mx_vid.."))" - - -- Validate user provided VLAN ID, make sure its within the bounds - -- allowed by the switch. - vid.validate = function(self, value, section) - local v = tonumber(value) - local m = has_vlan4k and 4094 or (num_vlans - 1) - if v ~= nil and v >= min_vid and v <= m then - if not self.vlan_used[v] then - self.vlan_used[v] = true - return value - else - return nil, - translatef("Invalid VLAN ID given! Only unique IDs are allowed") - end - else - return nil, - translatef("Invalid VLAN ID given! Only IDs between %d and %d are allowed.", min_vid, m) - end - end - - -- When writing the "vid" or "vlan" option, serialize the port states - -- as well and write them as "ports" option to uci. - vid.write = function(self, section, value) - local o - local p = { } - - for _, o in ipairs(port_opts) do - local v = o:formvalue(section) - if v == "t" then - p[#p+1] = o.option .. v - elseif v == "u" then - p[#p+1] = o.option - end - end - - if enable_vlan4k then - m:set(sid, "enable_vlan4k", "1") - end - - m:set(section, "ports", table.concat(p, " ")) - return Value.write(self, section, value) - end - - -- Fallback to "vlan" option if "vid" option is supported but unset. - vid.cfgvalue = function(self, section) - return m:get(section, has_vlan4k or "vlan") - or m:get(section, "vlan") - end - - -- Build per-port off/untagged/tagged choice lists. - local pt - for pt = 0, num_ports - 1 do - local title - if pt == cpu_port then - title = translate("CPU") - else - title = translatef("Port %d", pt) - end - - local po = s:option(ListValue, tostring(pt), title) - - po:value("", translate("off")) - po:value("u", translate("untagged")) - po:value("t", translate("tagged")) - - po.cfgvalue = portvalue - po.validate = portvalidate - po.write = function() end - - port_opts[#port_opts+1] = po - end - - switches[#switches+1] = switch_name - end -) - --- Switch status template -s = m:section(SimpleSection) -s.template = "admin_network/switch_status" -s.switches = switches - -return m diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua b/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua deleted file mode 100644 index f61fda3737..0000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua +++ /dev/null @@ -1,956 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2008 Steven Barth <steven@midlink.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- - -local wa = require "luci.tools.webadmin" -local nw = require "luci.model.network" -local ut = require "luci.util" -local nt = require "luci.sys".net -local fs = require "nixio.fs" - -arg[1] = arg[1] or "" - -m = Map("wireless", "", - translate("The <em>Device Configuration</em> section covers physical settings of the radio " .. - "hardware such as channel, transmit power or antenna selection which are shared among all " .. - "defined wireless networks (if the radio hardware is multi-SSID capable). Per network settings " .. - "like encryption or operation mode are grouped in the <em>Interface Configuration</em>.")) - -m:chain("network") -m:chain("firewall") - -local ifsection - -function m.on_commit(map) - local wnet = nw:get_wifinet(arg[1]) - if ifsection and wnet then - ifsection.section = wnet.sid - m.title = luci.util.pcdata(wnet:get_i18n()) - end -end - -nw.init(m.uci) - -local wnet = nw:get_wifinet(arg[1]) -local wdev = wnet and wnet:get_device() - --- redirect to overview page if network does not exist anymore (e.g. after a revert) -if not wnet or not wdev then - luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless")) - return -end - --- wireless toggle was requested, commit and reload page -function m.parse(map) - if m:formvalue("cbid.wireless.%s.__toggle" % wdev:name()) then - if wdev:get("disabled") == "1" or wnet:get("disabled") == "1" then - wnet:set("disabled", nil) - else - wnet:set("disabled", "1") - end - wdev:set("disabled", nil) - - nw:commit("wireless") - luci.sys.call("(env -i /bin/ubus call network reload) >/dev/null 2>/dev/null") - - luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless", arg[1])) - return - end - Map.parse(map) -end - -m.title = luci.util.pcdata(wnet:get_i18n()) - - -local function txpower_list(iw) - local list = iw.txpwrlist or { } - local off = tonumber(iw.txpower_offset) or 0 - local new = { } - local prev = -1 - local _, val - for _, val in ipairs(list) do - local dbm = val.dbm + off - local mw = math.floor(10 ^ (dbm / 10)) - if mw ~= prev then - prev = mw - new[#new+1] = { - display_dbm = dbm, - display_mw = mw, - driver_dbm = val.dbm, - driver_mw = val.mw - } - end - end - return new -end - -local function txpower_current(pwr, list) - pwr = tonumber(pwr) - if pwr ~= nil then - local _, item - for _, item in ipairs(list) do - if item.driver_dbm >= pwr then - return item.driver_dbm - end - end - end - return (list[#list] and list[#list].driver_dbm) or pwr or 0 -end - -local iw = luci.sys.wifi.getiwinfo(arg[1]) -local hw_modes = iw.hwmodelist or { } -local tx_power_list = txpower_list(iw) -local tx_power_cur = txpower_current(wdev:get("txpower"), tx_power_list) - -s = m:section(NamedSection, wdev:name(), "wifi-device", translate("Device Configuration")) -s.addremove = false - -s:tab("general", translate("General Setup")) -s:tab("macfilter", translate("MAC-Filter")) -s:tab("advanced", translate("Advanced Settings")) - ---[[ -back = s:option(DummyValue, "_overview", translate("Overview")) -back.value = "" -back.titleref = luci.dispatcher.build_url("admin", "network", "wireless") -]] - -st = s:taboption("general", DummyValue, "__status", translate("Status")) -st.template = "admin_network/wifi_status" -st.ifname = arg[1] - -en = s:taboption("general", Button, "__toggle") - -if wdev:get("disabled") == "1" or wnet:get("disabled") == "1" then - en.title = translate("Wireless network is disabled") - en.inputtitle = translate("Enable") - en.inputstyle = "apply" -else - en.title = translate("Wireless network is enabled") - en.inputtitle = translate("Disable") - en.inputstyle = "reset" -end - - -local hwtype = wdev:get("type") - --- NanoFoo -local nsantenna = wdev:get("antenna") - --- Check whether there are client interfaces on the same radio, --- if yes, lock the channel choice as these stations will dicatate the freq -local found_sta = nil -local _, net -if wnet:mode() ~= "sta" then - for _, net in ipairs(wdev:get_wifinets()) do - if net:mode() == "sta" then - if not found_sta then - found_sta = {} - found_sta.channel = net:channel() - found_sta.names = {} - end - found_sta.names[#found_sta.names+1] = net:shortname() - end - end -end - -if found_sta then - ch = s:taboption("general", DummyValue, "choice", translate("Channel")) - ch.value = translatef("Locked to channel %d used by: %s", - found_sta.channel, table.concat(found_sta.names, ", ")) -else - ch = s:taboption("general", Value, "_mode_freq", '<br />'..translate("Operating frequency")) - ch.hwmodes = iw.hwmodelist - ch.freqlist = iw.freqlist - ch.template = "cbi/wireless_modefreq" - - function ch.cfgvalue(self, section) - return { - m:get(section, "hwmode") or "", - m:get(section, "channel") or "auto", - m:get(section, "htmode") or "" - } - end - - function ch.formvalue(self, section) - return { - m:formvalue(self:cbid(section) .. ".band") or (iw.hwmodelist.g and "11g" or "11a"), - m:formvalue(self:cbid(section) .. ".channel") or "auto", - m:formvalue(self:cbid(section) .. ".htmode") or "" - } - end - - function ch.write(self, section, value) - m:set(section, "hwmode", value[1]) - m:set(section, "channel", value[2]) - m:set(section, "htmode", value[3]) - end -end - -------------------- MAC80211 Device ------------------ - -if hwtype == "mac80211" then - if #tx_power_list > 1 then - tp = s:taboption("general", ListValue, - "txpower", translate("Transmit Power"), "dBm") - tp.rmempty = true - tp.default = tx_power_cur - function tp.cfgvalue(...) - return txpower_current(Value.cfgvalue(...), tx_power_list) - end - - for _, p in ipairs(tx_power_list) do - tp:value(p.driver_dbm, "%i dBm (%i mW)" - %{ p.display_dbm, p.display_mw }) - end - end - - local cl = iw and iw.countrylist - if cl and #cl > 0 then - cc = s:taboption("advanced", ListValue, "country", translate("Country Code"), translate("Use ISO/IEC 3166 alpha2 country codes.")) - cc.default = tostring(iw and iw.country or "00") - for _, c in ipairs(cl) do - cc:value(c.alpha2, "%s - %s" %{ c.alpha2, c.name }) - end - else - s:taboption("advanced", Value, "country", translate("Country Code"), translate("Use ISO/IEC 3166 alpha2 country codes.")) - end - - s:taboption("advanced", Value, "distance", translate("Distance Optimization"), - translate("Distance to farthest network member in meters.")) - - -- external antenna profiles - local eal = iw and iw.extant - if eal and #eal > 0 then - ea = s:taboption("advanced", ListValue, "extant", translate("Antenna Configuration")) - for _, eap in ipairs(eal) do - ea:value(eap.id, "%s (%s)" %{ eap.name, eap.description }) - if eap.selected then - ea.default = eap.id - end - end - end - - s:taboption("advanced", Value, "frag", translate("Fragmentation Threshold")) - s:taboption("advanced", Value, "rts", translate("RTS/CTS Threshold")) -end - - -------------------- Madwifi Device ------------------ - -if hwtype == "atheros" then - tp = s:taboption("general", - (#tx_power_list > 0) and ListValue or Value, - "txpower", translate("Transmit Power"), "dBm") - - tp.rmempty = true - tp.default = tx_power_cur - - function tp.cfgvalue(...) - return txpower_current(Value.cfgvalue(...), tx_power_list) - end - - for _, p in ipairs(tx_power_list) do - tp:value(p.driver_dbm, "%i dBm (%i mW)" - %{ p.display_dbm, p.display_mw }) - end - - s:taboption("advanced", Flag, "diversity", translate("Diversity")).rmempty = false - - if not nsantenna then - ant1 = s:taboption("advanced", ListValue, "txantenna", translate("Transmitter Antenna")) - ant1.widget = "radio" - ant1.orientation = "horizontal" - ant1:depends("diversity", "") - ant1:value("0", translate("auto")) - ant1:value("1", translate("Antenna 1")) - ant1:value("2", translate("Antenna 2")) - - ant2 = s:taboption("advanced", ListValue, "rxantenna", translate("Receiver Antenna")) - ant2.widget = "radio" - ant2.orientation = "horizontal" - ant2:depends("diversity", "") - ant2:value("0", translate("auto")) - ant2:value("1", translate("Antenna 1")) - ant2:value("2", translate("Antenna 2")) - - else -- NanoFoo - local ant = s:taboption("advanced", ListValue, "antenna", translate("Transmitter Antenna")) - ant:value("auto") - ant:value("vertical") - ant:value("horizontal") - ant:value("external") - end - - s:taboption("advanced", Value, "distance", translate("Distance Optimization"), - translate("Distance to farthest network member in meters.")) - s:taboption("advanced", Value, "regdomain", translate("Regulatory Domain")) - s:taboption("advanced", Value, "country", translate("Country Code")) - s:taboption("advanced", Flag, "outdoor", translate("Outdoor Channels")) - - --s:option(Flag, "nosbeacon", translate("Disable HW-Beacon timer")) -end - - - -------------------- Broadcom Device ------------------ - -if hwtype == "broadcom" then - tp = s:taboption("general", - (#tx_power_list > 0) and ListValue or Value, - "txpower", translate("Transmit Power"), "dBm") - - tp.rmempty = true - tp.default = tx_power_cur - - function tp.cfgvalue(...) - return txpower_current(Value.cfgvalue(...), tx_power_list) - end - - for _, p in ipairs(tx_power_list) do - tp:value(p.driver_dbm, "%i dBm (%i mW)" - %{ p.display_dbm, p.display_mw }) - end - - ant1 = s:taboption("advanced", ListValue, "txantenna", translate("Transmitter Antenna")) - ant1.widget = "radio" - ant1:depends("diversity", "") - ant1:value("3", translate("auto")) - ant1:value("0", translate("Antenna 1")) - ant1:value("1", translate("Antenna 2")) - - ant2 = s:taboption("advanced", ListValue, "rxantenna", translate("Receiver Antenna")) - ant2.widget = "radio" - ant2:depends("diversity", "") - ant2:value("3", translate("auto")) - ant2:value("0", translate("Antenna 1")) - ant2:value("1", translate("Antenna 2")) - - s:taboption("advanced", Flag, "frameburst", translate("Frame Bursting")) - - s:taboption("advanced", Value, "distance", translate("Distance Optimization")) - --s:option(Value, "slottime", translate("Slot time")) - - s:taboption("advanced", Value, "country", translate("Country Code")) - s:taboption("advanced", Value, "maxassoc", translate("Connection Limit")) -end - - ---------------------- HostAP Device --------------------- - -if hwtype == "prism2" then - s:taboption("advanced", Value, "txpower", translate("Transmit Power"), "att units").rmempty = true - - s:taboption("advanced", Flag, "diversity", translate("Diversity")).rmempty = false - - s:taboption("advanced", Value, "txantenna", translate("Transmitter Antenna")) - s:taboption("advanced", Value, "rxantenna", translate("Receiver Antenna")) -end - - ------------------------ Interface ----------------------- - -s = m:section(NamedSection, wnet.sid, "wifi-iface", translate("Interface Configuration")) -ifsection = s -s.addremove = false -s.anonymous = true -s.defaults.device = wdev:name() - -s:tab("general", translate("General Setup")) -s:tab("encryption", translate("Wireless Security")) -s:tab("macfilter", translate("MAC-Filter")) -s:tab("advanced", translate("Advanced Settings")) - -s:taboption("general", Value, "ssid", translate("<abbr title=\"Extended Service Set Identifier\">ESSID</abbr>")) - -mode = s:taboption("general", ListValue, "mode", translate("Mode")) -mode.override_values = true -mode:value("ap", translate("Access Point")) -mode:value("sta", translate("Client")) -mode:value("adhoc", translate("Ad-Hoc")) - -bssid = s:taboption("general", Value, "bssid", translate("<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>")) - -network = s:taboption("general", Value, "network", translate("Network"), - translate("Choose the network(s) you want to attach to this wireless interface or " .. - "fill out the <em>create</em> field to define a new network.")) - -network.rmempty = true -network.template = "cbi/network_netlist" -network.widget = "checkbox" -network.novirtual = true - -function network.write(self, section, value) - local i = nw:get_interface(section) - if i then - if value == '-' then - value = m:formvalue(self:cbid(section) .. ".newnet") - if value and #value > 0 then - local n = nw:add_network(value, {proto="none"}) - if n then n:add_interface(i) end - else - local n = i:get_network() - if n then n:del_interface(i) end - end - else - local v - for _, v in ipairs(i:get_networks()) do - v:del_interface(i) - end - for v in ut.imatch(value) do - local n = nw:get_network(v) - if n then - if not n:is_empty() then - n:set("type", "bridge") - end - n:add_interface(i) - end - end - end - end -end - --------------------- MAC80211 Interface ---------------------- - -if hwtype == "mac80211" then - if fs.access("/usr/sbin/iw") then - mode:value("mesh", "802.11s") - end - - mode:value("ahdemo", translate("Pseudo Ad-Hoc (ahdemo)")) - mode:value("monitor", translate("Monitor")) - bssid:depends({mode="adhoc"}) - bssid:depends({mode="sta"}) - bssid:depends({mode="sta-wds"}) - - mp = s:taboption("macfilter", ListValue, "macfilter", translate("MAC-Address Filter")) - mp:depends({mode="ap"}) - mp:depends({mode="ap-wds"}) - mp:value("", translate("disable")) - mp:value("allow", translate("Allow listed only")) - mp:value("deny", translate("Allow all except listed")) - - ml = s:taboption("macfilter", DynamicList, "maclist", translate("MAC-List")) - ml.datatype = "macaddr" - ml:depends({macfilter="allow"}) - ml:depends({macfilter="deny"}) - nt.mac_hints(function(mac, name) ml:value(mac, "%s (%s)" %{ mac, name }) end) - - mode:value("ap-wds", "%s (%s)" % {translate("Access Point"), translate("WDS")}) - mode:value("sta-wds", "%s (%s)" % {translate("Client"), translate("WDS")}) - - function mode.write(self, section, value) - if value == "ap-wds" then - ListValue.write(self, section, "ap") - m.uci:set("wireless", section, "wds", 1) - elseif value == "sta-wds" then - ListValue.write(self, section, "sta") - m.uci:set("wireless", section, "wds", 1) - else - ListValue.write(self, section, value) - m.uci:delete("wireless", section, "wds") - end - end - - function mode.cfgvalue(self, section) - local mode = ListValue.cfgvalue(self, section) - local wds = m.uci:get("wireless", section, "wds") == "1" - - if mode == "ap" and wds then - return "ap-wds" - elseif mode == "sta" and wds then - return "sta-wds" - else - return mode - end - end - - hidden = s:taboption("general", Flag, "hidden", translate("Hide <abbr title=\"Extended Service Set Identifier\">ESSID</abbr>")) - hidden:depends({mode="ap"}) - hidden:depends({mode="ap-wds"}) - - wmm = s:taboption("general", Flag, "wmm", translate("WMM Mode")) - wmm:depends({mode="ap"}) - wmm:depends({mode="ap-wds"}) - wmm.default = wmm.enabled -end - - - --------------------- Madwifi Interface ---------------------- - -if hwtype == "atheros" then - mode:value("ahdemo", translate("Pseudo Ad-Hoc (ahdemo)")) - mode:value("monitor", translate("Monitor")) - mode:value("ap-wds", "%s (%s)" % {translate("Access Point"), translate("WDS")}) - mode:value("sta-wds", "%s (%s)" % {translate("Client"), translate("WDS")}) - mode:value("wds", translate("Static WDS")) - - function mode.write(self, section, value) - if value == "ap-wds" then - ListValue.write(self, section, "ap") - m.uci:set("wireless", section, "wds", 1) - elseif value == "sta-wds" then - ListValue.write(self, section, "sta") - m.uci:set("wireless", section, "wds", 1) - else - ListValue.write(self, section, value) - m.uci:delete("wireless", section, "wds") - end - end - - function mode.cfgvalue(self, section) - local mode = ListValue.cfgvalue(self, section) - local wds = m.uci:get("wireless", section, "wds") == "1" - - if mode == "ap" and wds then - return "ap-wds" - elseif mode == "sta" and wds then - return "sta-wds" - else - return mode - end - end - - bssid:depends({mode="adhoc"}) - bssid:depends({mode="ahdemo"}) - bssid:depends({mode="wds"}) - - wdssep = s:taboption("advanced", Flag, "wdssep", translate("Separate WDS")) - wdssep:depends({mode="ap-wds"}) - - s:taboption("advanced", Flag, "doth", "802.11h") - hidden = s:taboption("general", Flag, "hidden", translate("Hide <abbr title=\"Extended Service Set Identifier\">ESSID</abbr>")) - hidden:depends({mode="ap"}) - hidden:depends({mode="adhoc"}) - hidden:depends({mode="ap-wds"}) - hidden:depends({mode="sta-wds"}) - isolate = s:taboption("advanced", Flag, "isolate", translate("Separate Clients"), - translate("Prevents client-to-client communication")) - isolate:depends({mode="ap"}) - s:taboption("advanced", Flag, "bgscan", translate("Background Scan")) - - mp = s:taboption("macfilter", ListValue, "macpolicy", translate("MAC-Address Filter")) - mp:value("", translate("disable")) - mp:value("allow", translate("Allow listed only")) - mp:value("deny", translate("Allow all except listed")) - - ml = s:taboption("macfilter", DynamicList, "maclist", translate("MAC-List")) - ml.datatype = "macaddr" - ml:depends({macpolicy="allow"}) - ml:depends({macpolicy="deny"}) - nt.mac_hints(function(mac, name) ml:value(mac, "%s (%s)" %{ mac, name }) end) - - s:taboption("advanced", Value, "rate", translate("Transmission Rate")) - s:taboption("advanced", Value, "mcast_rate", translate("Multicast Rate")) - s:taboption("advanced", Value, "frag", translate("Fragmentation Threshold")) - s:taboption("advanced", Value, "rts", translate("RTS/CTS Threshold")) - s:taboption("advanced", Value, "minrate", translate("Minimum Rate")) - s:taboption("advanced", Value, "maxrate", translate("Maximum Rate")) - s:taboption("advanced", Flag, "compression", translate("Compression")) - - s:taboption("advanced", Flag, "bursting", translate("Frame Bursting")) - s:taboption("advanced", Flag, "turbo", translate("Turbo Mode")) - s:taboption("advanced", Flag, "ff", translate("Fast Frames")) - - s:taboption("advanced", Flag, "wmm", translate("WMM Mode")) - s:taboption("advanced", Flag, "xr", translate("XR Support")) - s:taboption("advanced", Flag, "ar", translate("AR Support")) - - local swm = s:taboption("advanced", Flag, "sw_merge", translate("Disable HW-Beacon timer")) - swm:depends({mode="adhoc"}) - - local nos = s:taboption("advanced", Flag, "nosbeacon", translate("Disable HW-Beacon timer")) - nos:depends({mode="sta"}) - nos:depends({mode="sta-wds"}) - - local probereq = s:taboption("advanced", Flag, "probereq", translate("Do not send probe responses")) - probereq.enabled = "0" - probereq.disabled = "1" -end - - --------------------- Broadcom Interface ---------------------- - -if hwtype == "broadcom" then - mode:value("wds", translate("WDS")) - mode:value("monitor", translate("Monitor")) - - hidden = s:taboption("general", Flag, "hidden", translate("Hide <abbr title=\"Extended Service Set Identifier\">ESSID</abbr>")) - hidden:depends({mode="ap"}) - hidden:depends({mode="adhoc"}) - hidden:depends({mode="wds"}) - - isolate = s:taboption("advanced", Flag, "isolate", translate("Separate Clients"), - translate("Prevents client-to-client communication")) - isolate:depends({mode="ap"}) - - s:taboption("advanced", Flag, "doth", "802.11h") - s:taboption("advanced", Flag, "wmm", translate("WMM Mode")) - - bssid:depends({mode="wds"}) - bssid:depends({mode="adhoc"}) -end - - ------------------------ HostAP Interface --------------------- - -if hwtype == "prism2" then - mode:value("wds", translate("WDS")) - mode:value("monitor", translate("Monitor")) - - hidden = s:taboption("general", Flag, "hidden", translate("Hide <abbr title=\"Extended Service Set Identifier\">ESSID</abbr>")) - hidden:depends({mode="ap"}) - hidden:depends({mode="adhoc"}) - hidden:depends({mode="wds"}) - - bssid:depends({mode="sta"}) - - mp = s:taboption("macfilter", ListValue, "macpolicy", translate("MAC-Address Filter")) - mp:value("", translate("disable")) - mp:value("allow", translate("Allow listed only")) - mp:value("deny", translate("Allow all except listed")) - ml = s:taboption("macfilter", DynamicList, "maclist", translate("MAC-List")) - ml:depends({macpolicy="allow"}) - ml:depends({macpolicy="deny"}) - nt.mac_hints(function(mac, name) ml:value(mac, "%s (%s)" %{ mac, name }) end) - - s:taboption("advanced", Value, "rate", translate("Transmission Rate")) - s:taboption("advanced", Value, "frag", translate("Fragmentation Threshold")) - s:taboption("advanced", Value, "rts", translate("RTS/CTS Threshold")) -end - - -------------------- WiFI-Encryption ------------------- - -encr = s:taboption("encryption", ListValue, "encryption", translate("Encryption")) -encr.override_values = true -encr.override_depends = true -encr:depends({mode="ap"}) -encr:depends({mode="sta"}) -encr:depends({mode="adhoc"}) -encr:depends({mode="ahdemo"}) -encr:depends({mode="ap-wds"}) -encr:depends({mode="sta-wds"}) -encr:depends({mode="mesh"}) - -cipher = s:taboption("encryption", ListValue, "cipher", translate("Cipher")) -cipher:depends({encryption="wpa"}) -cipher:depends({encryption="wpa2"}) -cipher:depends({encryption="psk"}) -cipher:depends({encryption="psk2"}) -cipher:depends({encryption="wpa-mixed"}) -cipher:depends({encryption="psk-mixed"}) -cipher:value("auto", translate("auto")) -cipher:value("ccmp", translate("Force CCMP (AES)")) -cipher:value("tkip", translate("Force TKIP")) -cipher:value("tkip+ccmp", translate("Force TKIP and CCMP (AES)")) - -function encr.cfgvalue(self, section) - local v = tostring(ListValue.cfgvalue(self, section)) - if v == "wep" then - return "wep-open" - elseif v and v:match("%+") then - return (v:gsub("%+.+$", "")) - end - return v -end - -function encr.write(self, section, value) - local e = tostring(encr:formvalue(section)) - local c = tostring(cipher:formvalue(section)) - if value == "wpa" or value == "wpa2" then - self.map.uci:delete("wireless", section, "key") - end - if e and (c == "tkip" or c == "ccmp" or c == "tkip+ccmp") then - e = e .. "+" .. c - end - self.map:set(section, "encryption", e) -end - -function cipher.cfgvalue(self, section) - local v = tostring(ListValue.cfgvalue(encr, section)) - if v and v:match("%+") then - v = v:gsub("^[^%+]+%+", "") - if v == "aes" then v = "ccmp" - elseif v == "tkip+aes" then v = "tkip+ccmp" - elseif v == "aes+tkip" then v = "tkip+ccmp" - elseif v == "ccmp+tkip" then v = "tkip+ccmp" - end - end - return v -end - -function cipher.write(self, section) - return encr:write(section) -end - - -encr:value("none", "No Encryption") -encr:value("wep-open", translate("WEP Open System"), {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"}, {mode="adhoc"}, {mode="ahdemo"}, {mode="wds"}) -encr:value("wep-shared", translate("WEP Shared Key"), {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"}, {mode="adhoc"}, {mode="ahdemo"}, {mode="wds"}) - -if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then - local supplicant = fs.access("/usr/sbin/wpa_supplicant") - local hostapd = fs.access("/usr/sbin/hostapd") - - -- Probe EAP support - local has_ap_eap = (os.execute("hostapd -veap >/dev/null 2>/dev/null") == 0) - local has_sta_eap = (os.execute("wpa_supplicant -veap >/dev/null 2>/dev/null") == 0) - - if hostapd and supplicant then - encr:value("psk", "WPA-PSK", {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"}) - encr:value("psk2", "WPA2-PSK", {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"}) - encr:value("psk-mixed", "WPA-PSK/WPA2-PSK Mixed Mode", {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"}) - if has_ap_eap and has_sta_eap then - encr:value("wpa", "WPA-EAP", {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"}) - encr:value("wpa2", "WPA2-EAP", {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"}) - end - elseif hostapd and not supplicant then - encr:value("psk", "WPA-PSK", {mode="ap"}, {mode="ap-wds"}) - encr:value("psk2", "WPA2-PSK", {mode="ap"}, {mode="ap-wds"}) - encr:value("psk-mixed", "WPA-PSK/WPA2-PSK Mixed Mode", {mode="ap"}, {mode="ap-wds"}) - if has_ap_eap then - encr:value("wpa", "WPA-EAP", {mode="ap"}, {mode="ap-wds"}) - encr:value("wpa2", "WPA2-EAP", {mode="ap"}, {mode="ap-wds"}) - end - encr.description = translate( - "WPA-Encryption requires wpa_supplicant (for client mode) or hostapd (for AP " .. - "and ad-hoc mode) to be installed." - ) - elseif not hostapd and supplicant then - encr:value("psk", "WPA-PSK", {mode="sta"}, {mode="sta-wds"}) - encr:value("psk2", "WPA2-PSK", {mode="sta"}, {mode="sta-wds"}) - encr:value("psk-mixed", "WPA-PSK/WPA2-PSK Mixed Mode", {mode="sta"}, {mode="sta-wds"}) - if has_sta_eap then - encr:value("wpa", "WPA-EAP", {mode="sta"}, {mode="sta-wds"}) - encr:value("wpa2", "WPA2-EAP", {mode="sta"}, {mode="sta-wds"}) - end - encr.description = translate( - "WPA-Encryption requires wpa_supplicant (for client mode) or hostapd (for AP " .. - "and ad-hoc mode) to be installed." - ) - else - encr.description = translate( - "WPA-Encryption requires wpa_supplicant (for client mode) or hostapd (for AP " .. - "and ad-hoc mode) to be installed." - ) - end -elseif hwtype == "broadcom" then - encr:value("psk", "WPA-PSK") - encr:value("psk2", "WPA2-PSK") - encr:value("psk+psk2", "WPA-PSK/WPA2-PSK Mixed Mode") -end - -auth_server = s:taboption("encryption", Value, "auth_server", translate("Radius-Authentication-Server")) -auth_server:depends({mode="ap", encryption="wpa"}) -auth_server:depends({mode="ap", encryption="wpa2"}) -auth_server:depends({mode="ap-wds", encryption="wpa"}) -auth_server:depends({mode="ap-wds", encryption="wpa2"}) -auth_server.rmempty = true -auth_server.datatype = "host" - -auth_port = s:taboption("encryption", Value, "auth_port", translate("Radius-Authentication-Port"), translatef("Default %d", 1812)) -auth_port:depends({mode="ap", encryption="wpa"}) -auth_port:depends({mode="ap", encryption="wpa2"}) -auth_port:depends({mode="ap-wds", encryption="wpa"}) -auth_port:depends({mode="ap-wds", encryption="wpa2"}) -auth_port.rmempty = true -auth_port.datatype = "port" - -auth_secret = s:taboption("encryption", Value, "auth_secret", translate("Radius-Authentication-Secret")) -auth_secret:depends({mode="ap", encryption="wpa"}) -auth_secret:depends({mode="ap", encryption="wpa2"}) -auth_secret:depends({mode="ap-wds", encryption="wpa"}) -auth_secret:depends({mode="ap-wds", encryption="wpa2"}) -auth_secret.rmempty = true -auth_secret.password = true - -acct_server = s:taboption("encryption", Value, "acct_server", translate("Radius-Accounting-Server")) -acct_server:depends({mode="ap", encryption="wpa"}) -acct_server:depends({mode="ap", encryption="wpa2"}) -acct_server:depends({mode="ap-wds", encryption="wpa"}) -acct_server:depends({mode="ap-wds", encryption="wpa2"}) -acct_server.rmempty = true -acct_server.datatype = "host" - -acct_port = s:taboption("encryption", Value, "acct_port", translate("Radius-Accounting-Port"), translatef("Default %d", 1813)) -acct_port:depends({mode="ap", encryption="wpa"}) -acct_port:depends({mode="ap", encryption="wpa2"}) -acct_port:depends({mode="ap-wds", encryption="wpa"}) -acct_port:depends({mode="ap-wds", encryption="wpa2"}) -acct_port.rmempty = true -acct_port.datatype = "port" - -acct_secret = s:taboption("encryption", Value, "acct_secret", translate("Radius-Accounting-Secret")) -acct_secret:depends({mode="ap", encryption="wpa"}) -acct_secret:depends({mode="ap", encryption="wpa2"}) -acct_secret:depends({mode="ap-wds", encryption="wpa"}) -acct_secret:depends({mode="ap-wds", encryption="wpa2"}) -acct_secret.rmempty = true -acct_secret.password = true - -wpakey = s:taboption("encryption", Value, "_wpa_key", translate("Key")) -wpakey:depends("encryption", "psk") -wpakey:depends("encryption", "psk2") -wpakey:depends("encryption", "psk+psk2") -wpakey:depends("encryption", "psk-mixed") -wpakey.datatype = "wpakey" -wpakey.rmempty = true -wpakey.password = true - -wpakey.cfgvalue = function(self, section, value) - local key = m.uci:get("wireless", section, "key") - if key == "1" or key == "2" or key == "3" or key == "4" then - return nil - end - return key -end - -wpakey.write = function(self, section, value) - self.map.uci:set("wireless", section, "key", value) - self.map.uci:delete("wireless", section, "key1") -end - - -wepslot = s:taboption("encryption", ListValue, "_wep_key", translate("Used Key Slot")) -wepslot:depends("encryption", "wep-open") -wepslot:depends("encryption", "wep-shared") -wepslot:value("1", translatef("Key #%d", 1)) -wepslot:value("2", translatef("Key #%d", 2)) -wepslot:value("3", translatef("Key #%d", 3)) -wepslot:value("4", translatef("Key #%d", 4)) - -wepslot.cfgvalue = function(self, section) - local slot = tonumber(m.uci:get("wireless", section, "key")) - if not slot or slot < 1 or slot > 4 then - return 1 - end - return slot -end - -wepslot.write = function(self, section, value) - self.map.uci:set("wireless", section, "key", value) -end - -local slot -for slot=1,4 do - wepkey = s:taboption("encryption", Value, "key" .. slot, translatef("Key #%d", slot)) - wepkey:depends("encryption", "wep-open") - wepkey:depends("encryption", "wep-shared") - wepkey.datatype = "wepkey" - wepkey.rmempty = true - wepkey.password = true - - function wepkey.write(self, section, value) - if value and (#value == 5 or #value == 13) then - value = "s:" .. value - end - return Value.write(self, section, value) - end -end - - -if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then - nasid = s:taboption("encryption", Value, "nasid", translate("NAS ID")) - nasid:depends({mode="ap", encryption="wpa"}) - nasid:depends({mode="ap", encryption="wpa2"}) - nasid:depends({mode="ap-wds", encryption="wpa"}) - nasid:depends({mode="ap-wds", encryption="wpa2"}) - nasid.rmempty = true - - eaptype = s:taboption("encryption", ListValue, "eap_type", translate("EAP-Method")) - eaptype:value("tls", "TLS") - eaptype:value("ttls", "TTLS") - eaptype:value("peap", "PEAP") - eaptype:depends({mode="sta", encryption="wpa"}) - eaptype:depends({mode="sta", encryption="wpa2"}) - eaptype:depends({mode="sta-wds", encryption="wpa"}) - eaptype:depends({mode="sta-wds", encryption="wpa2"}) - - cacert = s:taboption("encryption", FileUpload, "ca_cert", translate("Path to CA-Certificate")) - cacert:depends({mode="sta", encryption="wpa"}) - cacert:depends({mode="sta", encryption="wpa2"}) - cacert:depends({mode="sta-wds", encryption="wpa"}) - cacert:depends({mode="sta-wds", encryption="wpa2"}) - - clientcert = s:taboption("encryption", FileUpload, "client_cert", translate("Path to Client-Certificate")) - clientcert:depends({mode="sta", encryption="wpa"}) - clientcert:depends({mode="sta", encryption="wpa2"}) - clientcert:depends({mode="sta-wds", encryption="wpa"}) - clientcert:depends({mode="sta-wds", encryption="wpa2"}) - - privkey = s:taboption("encryption", FileUpload, "priv_key", translate("Path to Private Key")) - privkey:depends({mode="sta", eap_type="tls", encryption="wpa2"}) - privkey:depends({mode="sta", eap_type="tls", encryption="wpa"}) - privkey:depends({mode="sta-wds", eap_type="tls", encryption="wpa2"}) - privkey:depends({mode="sta-wds", eap_type="tls", encryption="wpa"}) - - privkeypwd = s:taboption("encryption", Value, "priv_key_pwd", translate("Password of Private Key")) - privkeypwd:depends({mode="sta", eap_type="tls", encryption="wpa2"}) - privkeypwd:depends({mode="sta", eap_type="tls", encryption="wpa"}) - privkeypwd:depends({mode="sta-wds", eap_type="tls", encryption="wpa2"}) - privkeypwd:depends({mode="sta-wds", eap_type="tls", encryption="wpa"}) - - - auth = s:taboption("encryption", Value, "auth", translate("Authentication")) - auth:value("PAP") - auth:value("CHAP") - auth:value("MSCHAP") - auth:value("MSCHAPV2") - auth:depends({mode="sta", eap_type="peap", encryption="wpa2"}) - auth:depends({mode="sta", eap_type="peap", encryption="wpa"}) - auth:depends({mode="sta", eap_type="ttls", encryption="wpa2"}) - auth:depends({mode="sta", eap_type="ttls", encryption="wpa"}) - auth:depends({mode="sta-wds", eap_type="peap", encryption="wpa2"}) - auth:depends({mode="sta-wds", eap_type="peap", encryption="wpa"}) - auth:depends({mode="sta-wds", eap_type="ttls", encryption="wpa2"}) - auth:depends({mode="sta-wds", eap_type="ttls", encryption="wpa"}) - - - identity = s:taboption("encryption", Value, "identity", translate("Identity")) - identity:depends({mode="sta", eap_type="peap", encryption="wpa2"}) - identity:depends({mode="sta", eap_type="peap", encryption="wpa"}) - identity:depends({mode="sta", eap_type="ttls", encryption="wpa2"}) - identity:depends({mode="sta", eap_type="ttls", encryption="wpa"}) - identity:depends({mode="sta-wds", eap_type="peap", encryption="wpa2"}) - identity:depends({mode="sta-wds", eap_type="peap", encryption="wpa"}) - identity:depends({mode="sta-wds", eap_type="ttls", encryption="wpa2"}) - identity:depends({mode="sta-wds", eap_type="ttls", encryption="wpa"}) - - password = s:taboption("encryption", Value, "password", translate("Password")) - password:depends({mode="sta", eap_type="peap", encryption="wpa2"}) - password:depends({mode="sta", eap_type="peap", encryption="wpa"}) - password:depends({mode="sta", eap_type="ttls", encryption="wpa2"}) - password:depends({mode="sta", eap_type="ttls", encryption="wpa"}) - password:depends({mode="sta-wds", eap_type="peap", encryption="wpa2"}) - password:depends({mode="sta-wds", eap_type="peap", encryption="wpa"}) - password:depends({mode="sta-wds", eap_type="ttls", encryption="wpa2"}) - password:depends({mode="sta-wds", eap_type="ttls", encryption="wpa"}) -end - -if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then - local wpasupplicant = fs.access("/usr/sbin/wpa_supplicant") - local hostcli = fs.access("/usr/sbin/hostapd_cli") - if hostcli and wpasupplicant then - wps = s:taboption("encryption", Flag, "wps_pushbutton", translate("Enable WPS pushbutton, requires WPA(2)-PSK")) - wps.enabled = "1" - wps.disabled = "0" - wps.rmempty = false - wps:depends("encryption", "psk") - wps:depends("encryption", "psk2") - wps:depends("encryption", "psk-mixed") - end -end - -return m diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/wifi_add.lua b/modules/admin-full/luasrc/model/cbi/admin_network/wifi_add.lua deleted file mode 100644 index cb42648865..0000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_network/wifi_add.lua +++ /dev/null @@ -1,184 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2009 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- - -local fs = require "nixio.fs" -local nw = require "luci.model.network" -local fw = require "luci.model.firewall" -local uci = require "luci.model.uci".cursor() -local http = require "luci.http" - -local iw = luci.sys.wifi.getiwinfo(http.formvalue("device")) - -local has_firewall = fs.access("/etc/config/firewall") - -if not iw then - luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless")) - return -end - -m = SimpleForm("network", translate("Join Network: Settings")) -m.cancel = translate("Back to scan results") -m.reset = false - -function m.on_cancel() - local dev = http.formvalue("device") - http.redirect(luci.dispatcher.build_url( - dev and "admin/network/wireless_join?device=" .. dev - or "admin/network/wireless" - )) -end - -nw.init(uci) -fw.init(uci) - -m.hidden = { - device = http.formvalue("device"), - join = http.formvalue("join"), - channel = http.formvalue("channel"), - mode = http.formvalue("mode"), - bssid = http.formvalue("bssid"), - wep = http.formvalue("wep"), - wpa_suites = http.formvalue("wpa_suites"), - wpa_version = http.formvalue("wpa_version") -} - -if iw and iw.mbssid_support then - replace = m:field(Flag, "replace", translate("Replace wireless configuration"), - translate("An additional network will be created if you leave this unchecked.")) - - function replace.cfgvalue() return "1" end -else - replace = m:field(DummyValue, "replace", translate("Replace wireless configuration")) - replace.default = translate("The hardware is not multi-SSID capable and the existing " .. - "configuration will be replaced if you proceed.") - - function replace.formvalue() return "1" end -end - -if http.formvalue("wep") == "1" then - key = m:field(Value, "key", translate("WEP passphrase"), - translate("Specify the secret encryption key here.")) - - key.password = true - key.datatype = "wepkey" - -elseif (tonumber(m.hidden.wpa_version) or 0) > 0 and - (m.hidden.wpa_suites == "PSK" or m.hidden.wpa_suites == "PSK2") -then - key = m:field(Value, "key", translate("WPA passphrase"), - translate("Specify the secret encryption key here.")) - - key.password = true - key.datatype = "wpakey" - --m.hidden.wpa_suite = (tonumber(http.formvalue("wpa_version")) or 0) >= 2 and "psk2" or "psk" -end - -newnet = m:field(Value, "_netname_new", translate("Name of the new network"), - translate("The allowed characters are: <code>A-Z</code>, <code>a-z</code>, " .. - "<code>0-9</code> and <code>_</code>" - )) - -newnet.default = m.hidden.mode == "Ad-Hoc" and "mesh" or "wwan" -newnet.datatype = "uciname" - -if has_firewall then - fwzone = m:field(Value, "_fwzone", - translate("Create / Assign firewall-zone"), - translate("Choose the firewall zone you want to assign to this interface. Select <em>unspecified</em> to remove the interface from the associated zone or fill out the <em>create</em> field to define a new zone and attach the interface to it.")) - - fwzone.template = "cbi/firewall_zonelist" - fwzone.default = m.hidden.mode == "Ad-Hoc" and "mesh" or "wan" -end - -function newnet.parse(self, section) - local net, zone - - if has_firewall then - local zval = fwzone:formvalue(section) - zone = fw:get_zone(zval) - - if not zone and zval == '-' then - zval = m:formvalue(fwzone:cbid(section) .. ".newzone") - if zval and #zval > 0 then - zone = fw:add_zone(zval) - end - end - end - - local wdev = nw:get_wifidev(m.hidden.device) - - wdev:set("disabled", false) - wdev:set("channel", m.hidden.channel) - - if replace:formvalue(section) then - local n - for _, n in ipairs(wdev:get_wifinets()) do - wdev:del_wifinet(n) - end - end - - local wconf = { - device = m.hidden.device, - ssid = m.hidden.join, - mode = (m.hidden.mode == "Ad-Hoc" and "adhoc" or "sta") - } - - if m.hidden.wep == "1" then - wconf.encryption = "wep-open" - wconf.key = "1" - wconf.key1 = key and key:formvalue(section) or "" - elseif (tonumber(m.hidden.wpa_version) or 0) > 0 then - wconf.encryption = (tonumber(m.hidden.wpa_version) or 0) >= 2 and "psk2" or "psk" - wconf.key = key and key:formvalue(section) or "" - else - wconf.encryption = "none" - end - - if wconf.mode == "adhoc" or wconf.mode == "sta" then - wconf.bssid = m.hidden.bssid - end - - local value = self:formvalue(section) - net = nw:add_network(value, { proto = "dhcp" }) - - if not net then - self.error = { [section] = "missing" } - else - wconf.network = net:name() - - local wnet = wdev:add_wifinet(wconf) - if wnet then - if zone then - fw:del_network(net:name()) - zone:add_network(net:name()) - end - - uci:save("wireless") - uci:save("network") - uci:save("firewall") - - luci.http.redirect(wnet:adminlink()) - end - end -end - -if has_firewall then - function fwzone.cfgvalue(self, section) - self.iface = section - local z = fw:get_zone_by_network(section) - return z and z:name() - end -end - -return m diff --git a/modules/admin-full/luasrc/model/cbi/admin_status/processes.lua b/modules/admin-full/luasrc/model/cbi/admin_status/processes.lua deleted file mode 100644 index c34c70ffae..0000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_status/processes.lua +++ /dev/null @@ -1,44 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- -f = SimpleForm("processes", translate("Processes"), translate("This list gives an overview over currently running system processes and their status.")) -f.reset = false -f.submit = false - -t = f:section(Table, luci.sys.process.list()) -t:option(DummyValue, "PID", translate("PID")) -t:option(DummyValue, "USER", translate("Owner")) -t:option(DummyValue, "COMMAND", translate("Command")) -t:option(DummyValue, "%CPU", translate("CPU usage (%)")) -t:option(DummyValue, "%MEM", translate("Memory usage (%)")) - -hup = t:option(Button, "_hup", translate("Hang Up")) -hup.inputstyle = "reload" -function hup.write(self, section) - null, self.tag_error[section] = luci.sys.process.signal(section, 1) -end - -term = t:option(Button, "_term", translate("Terminate")) -term.inputstyle = "remove" -function term.write(self, section) - null, self.tag_error[section] = luci.sys.process.signal(section, 15) -end - -kill = t:option(Button, "_kill", translate("Kill")) -kill.inputstyle = "reset" -function kill.write(self, section) - null, self.tag_error[section] = luci.sys.process.signal(section, 9) -end - -return f
\ No newline at end of file diff --git a/modules/admin-full/luasrc/model/cbi/admin_system/admin.lua b/modules/admin-full/luasrc/model/cbi/admin_system/admin.lua deleted file mode 100644 index a3da6beb6f..0000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_system/admin.lua +++ /dev/null @@ -1,130 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2011 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- - -local fs = require "nixio.fs" - -m = Map("system", translate("Router Password"), - translate("Changes the administrator password for accessing the device")) - -s = m:section(TypedSection, "_dummy", "") -s.addremove = false -s.anonymous = true - -pw1 = s:option(Value, "pw1", translate("Password")) -pw1.password = true - -pw2 = s:option(Value, "pw2", translate("Confirmation")) -pw2.password = true - -function s.cfgsections() - return { "_pass" } -end - -function m.on_commit(map) - local v1 = pw1:formvalue("_pass") - local v2 = pw2:formvalue("_pass") - - if v1 and v2 and #v1 > 0 and #v2 > 0 then - if v1 == v2 then - if luci.sys.user.setpasswd(luci.dispatcher.context.authuser, v1) == 0 then - m.message = translate("Password successfully changed!") - else - m.message = translate("Unknown Error, password not changed!") - end - else - m.message = translate("Given password confirmation did not match, password not changed!") - end - end -end - - -if fs.access("/etc/config/dropbear") then - -m2 = Map("dropbear", translate("SSH Access"), - translate("Dropbear offers <abbr title=\"Secure Shell\">SSH</abbr> network shell access and an integrated <abbr title=\"Secure Copy\">SCP</abbr> server")) - -s = m2:section(TypedSection, "dropbear", translate("Dropbear Instance")) -s.anonymous = true -s.addremove = true - - -ni = s:option(Value, "Interface", translate("Interface"), - translate("Listen only on the given interface or, if unspecified, on all")) - -ni.template = "cbi/network_netlist" -ni.nocreate = true -ni.unspecified = true - - -pt = s:option(Value, "Port", translate("Port"), - translate("Specifies the listening port of this <em>Dropbear</em> instance")) - -pt.datatype = "port" -pt.default = 22 - - -pa = s:option(Flag, "PasswordAuth", translate("Password authentication"), - translate("Allow <abbr title=\"Secure Shell\">SSH</abbr> password authentication")) - -pa.enabled = "on" -pa.disabled = "off" -pa.default = pa.enabled -pa.rmempty = false - - -ra = s:option(Flag, "RootPasswordAuth", translate("Allow root logins with password"), - translate("Allow the <em>root</em> user to login with password")) - -ra.enabled = "on" -ra.disabled = "off" -ra.default = ra.enabled - - -gp = s:option(Flag, "GatewayPorts", translate("Gateway ports"), - translate("Allow remote hosts to connect to local SSH forwarded ports")) - -gp.enabled = "on" -gp.disabled = "off" -gp.default = gp.disabled - - -s2 = m2:section(TypedSection, "_dummy", translate("SSH-Keys"), - translate("Here you can paste public SSH-Keys (one per line) for SSH public-key authentication.")) -s2.addremove = false -s2.anonymous = true -s2.template = "cbi/tblsection" - -function s2.cfgsections() - return { "_keys" } -end - -keys = s2:option(TextValue, "_data", "") -keys.wrap = "off" -keys.rows = 3 -keys.rmempty = false - -function keys.cfgvalue() - return fs.readfile("/etc/dropbear/authorized_keys") or "" -end - -function keys.write(self, section, value) - if value then - fs.writefile("/etc/dropbear/authorized_keys", value:gsub("\r\n", "\n")) - end -end - -end - -return m, m2 diff --git a/modules/admin-full/luasrc/model/cbi/admin_system/backupfiles.lua b/modules/admin-full/luasrc/model/cbi/admin_system/backupfiles.lua deleted file mode 100644 index a063ec0aa4..0000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_system/backupfiles.lua +++ /dev/null @@ -1,92 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2011 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- - - -if luci.http.formvalue("cbid.luci.1._list") then - luci.http.redirect(luci.dispatcher.build_url("admin/system/flashops/backupfiles") .. "?display=list") -elseif luci.http.formvalue("cbid.luci.1._edit") then - luci.http.redirect(luci.dispatcher.build_url("admin/system/flashops/backupfiles") .. "?display=edit") - return -end - -m = SimpleForm("luci", translate("Backup file list")) -m:append(Template("admin_system/backupfiles")) - -if luci.http.formvalue("display") ~= "list" then - f = m:section(SimpleSection, nil, translate("This is a list of shell glob patterns for matching files and directories to include during sysupgrade. Modified files in /etc/config/ and certain other configurations are automatically preserved.")) - - l = f:option(Button, "_list", translate("Show current backup file list")) - l.inputtitle = translate("Open list...") - l.inputstyle = "apply" - - c = f:option(TextValue, "_custom") - c.rmempty = false - c.cols = 70 - c.rows = 30 - - c.cfgvalue = function(self, section) - return nixio.fs.readfile("/etc/sysupgrade.conf") - end - - c.write = function(self, section, value) - value = value:gsub("\r\n?", "\n") - return nixio.fs.writefile("/etc/sysupgrade.conf", value) - end -else - m.submit = false - m.reset = false - - f = m:section(SimpleSection, nil, translate("Below is the determined list of files to backup. It consists of changed configuration files marked by opkg, essential base files and the user defined backup patterns.")) - - l = f:option(Button, "_edit", translate("Back to configuration")) - l.inputtitle = translate("Close list...") - l.inputstyle = "link" - - - d = f:option(DummyValue, "_detected") - d.rawhtml = true - d.cfgvalue = function(s) - local list = io.popen( - "( find $(sed -ne '/^[[:space:]]*$/d; /^#/d; p' /etc/sysupgrade.conf " .. - "/lib/upgrade/keep.d/* 2>/dev/null) -type f 2>/dev/null; " .. - "opkg list-changed-conffiles ) | sort -u" - ) - - if list then - local files = { "<ul>" } - - while true do - local ln = list:read("*l") - if not ln then - break - else - files[#files+1] = "<li>" - files[#files+1] = luci.util.pcdata(ln) - files[#files+1] = "</li>" - end - end - - list:close() - files[#files+1] = "</ul>" - - return table.concat(files, "") - end - - return "<em>" .. translate("No files found") .. "</em>" - end - -end - -return m diff --git a/modules/admin-full/luasrc/model/cbi/admin_system/buttons.lua b/modules/admin-full/luasrc/model/cbi/admin_system/buttons.lua deleted file mode 100644 index d7581830d3..0000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_system/buttons.lua +++ /dev/null @@ -1,38 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2008 Steven Barth <steven@midlink.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- - -m = Map("system", translate("Buttons"), - translate("This page allows the configuration of custom button actions")) - -s = m:section(TypedSection, "button", "") -s.anonymous = true -s.addremove = true - -s:option(Value, "button", translate("Name")) - -act = s:option(ListValue, "action", - translate("Action"), - translate("Specifies the button state to handle")) - -act:value("released") - -s:option(Value, "handler", - translate("Handler"), - translate("Path to executable which handles the button event")) - -min = s:option(Value, "min", translate("Minimum hold time")) -min.rmempty = true - -max = s:option(Value, "max", translate("Maximum hold time")) -max.rmempty = true diff --git a/modules/admin-full/luasrc/model/cbi/admin_system/crontab.lua b/modules/admin-full/luasrc/model/cbi/admin_system/crontab.lua deleted file mode 100644 index 3e1b9d85d0..0000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_system/crontab.lua +++ /dev/null @@ -1,38 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2008-2013 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- - -local fs = require "nixio.fs" -local cronfile = "/etc/crontabs/root" - -f = SimpleForm("crontab", translate("Scheduled Tasks"), translate("This is the system crontab in which scheduled tasks can be defined.")) - -t = f:field(TextValue, "crons") -t.rmempty = true -t.rows = 10 -function t.cfgvalue() - return fs.readfile(cronfile) or "" -end - -function f.handle(self, state, data) - if state == FORM_VALID then - if data.crons then - fs.writefile(cronfile, data.crons:gsub("\r\n", "\n")) - luci.sys.call("/usr/bin/crontab %q" % cronfile) - end - end - return true -end - -return f diff --git a/modules/admin-full/luasrc/model/cbi/admin_system/fstab.lua b/modules/admin-full/luasrc/model/cbi/admin_system/fstab.lua deleted file mode 100644 index 8ac3d6d5e7..0000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_system/fstab.lua +++ /dev/null @@ -1,156 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2008 Steven Barth <steven@midlink.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- - -require("luci.tools.webadmin") - -local fs = require "nixio.fs" -local util = require "nixio.util" - -local devices = {} -util.consume((fs.glob("/dev/sd*")), devices) -util.consume((fs.glob("/dev/hd*")), devices) -util.consume((fs.glob("/dev/scd*")), devices) -util.consume((fs.glob("/dev/mmc*")), devices) - -local size = {} -for i, dev in ipairs(devices) do - local s = tonumber((fs.readfile("/sys/class/block/%s/size" % dev:sub(6)))) - size[dev] = s and math.floor(s / 2048) -end - - -m = Map("fstab", translate("Mount Points")) - -local mounts = luci.sys.mounts() - -v = m:section(Table, mounts, translate("Mounted file systems")) - -fs = v:option(DummyValue, "fs", translate("Filesystem")) - -mp = v:option(DummyValue, "mountpoint", translate("Mount Point")) - -avail = v:option(DummyValue, "avail", translate("Available")) -function avail.cfgvalue(self, section) - return luci.tools.webadmin.byte_format( - ( tonumber(mounts[section].available) or 0 ) * 1024 - ) .. " / " .. luci.tools.webadmin.byte_format( - ( tonumber(mounts[section].blocks) or 0 ) * 1024 - ) -end - -used = v:option(DummyValue, "used", translate("Used")) -function used.cfgvalue(self, section) - return ( mounts[section].percent or "0%" ) .. " (" .. - luci.tools.webadmin.byte_format( - ( tonumber(mounts[section].used) or 0 ) * 1024 - ) .. ")" -end - - - -mount = m:section(TypedSection, "mount", translate("Mount Points"), translate("Mount Points define at which point a memory device will be attached to the filesystem")) -mount.anonymous = true -mount.addremove = true -mount.template = "cbi/tblsection" -mount.extedit = luci.dispatcher.build_url("admin/system/fstab/mount/%s") - -mount.create = function(...) - local sid = TypedSection.create(...) - if sid then - luci.http.redirect(mount.extedit % sid) - return - end -end - - -mount:option(Flag, "enabled", translate("Enabled")).rmempty = false - -dev = mount:option(DummyValue, "device", translate("Device")) -dev.cfgvalue = function(self, section) - local v - - v = m.uci:get("fstab", section, "uuid") - if v then return "UUID: %s" % v end - - v = m.uci:get("fstab", section, "label") - if v then return "Label: %s" % v end - - v = Value.cfgvalue(self, section) or "?" - return size[v] and "%s (%s MB)" % {v, size[v]} or v -end - -mp = mount:option(DummyValue, "target", translate("Mount Point")) -mp.cfgvalue = function(self, section) - if m.uci:get("fstab", section, "is_rootfs") == "1" then - return "/overlay" - else - return Value.cfgvalue(self, section) or "?" - end -end - -fs = mount:option(DummyValue, "fstype", translate("Filesystem")) -fs.cfgvalue = function(self, section) - return Value.cfgvalue(self, section) or "?" -end - -op = mount:option(DummyValue, "options", translate("Options")) -op.cfgvalue = function(self, section) - return Value.cfgvalue(self, section) or "defaults" -end - -rf = mount:option(DummyValue, "is_rootfs", translate("Root")) -rf.cfgvalue = function(self, section) - return Value.cfgvalue(self, section) == "1" - and translate("yes") or translate("no") -end - -ck = mount:option(DummyValue, "enabled_fsck", translate("Check")) -ck.cfgvalue = function(self, section) - return Value.cfgvalue(self, section) == "1" - and translate("yes") or translate("no") -end - - -swap = m:section(TypedSection, "swap", "SWAP", translate("If your physical memory is insufficient unused data can be temporarily swapped to a swap-device resulting in a higher amount of usable <abbr title=\"Random Access Memory\">RAM</abbr>. Be aware that swapping data is a very slow process as the swap-device cannot be accessed with the high datarates of the <abbr title=\"Random Access Memory\">RAM</abbr>.")) -swap.anonymous = true -swap.addremove = true -swap.template = "cbi/tblsection" -swap.extedit = luci.dispatcher.build_url("admin/system/fstab/swap/%s") - -swap.create = function(...) - local sid = TypedSection.create(...) - if sid then - luci.http.redirect(swap.extedit % sid) - return - end -end - - -swap:option(Flag, "enabled", translate("Enabled")).rmempty = false - -dev = swap:option(DummyValue, "device", translate("Device")) -dev.cfgvalue = function(self, section) - local v - - v = m.uci:get("fstab", section, "uuid") - if v then return "UUID: %s" % v end - - v = m.uci:get("fstab", section, "label") - if v then return "Label: %s" % v end - - v = Value.cfgvalue(self, section) or "?" - return size[v] and "%s (%s MB)" % {v, size[v]} or v -end - -return m diff --git a/modules/admin-full/luasrc/model/cbi/admin_system/fstab/mount.lua b/modules/admin-full/luasrc/model/cbi/admin_system/fstab/mount.lua deleted file mode 100644 index bac886888a..0000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_system/fstab/mount.lua +++ /dev/null @@ -1,108 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2010 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- - -local fs = require "nixio.fs" -local util = require "nixio.util" - -local has_extroot = fs.access("/sbin/block") -local has_fscheck = fs.access("/usr/sbin/e2fsck") - -local devices = {} -util.consume((fs.glob("/dev/sd*")), devices) -util.consume((fs.glob("/dev/hd*")), devices) -util.consume((fs.glob("/dev/scd*")), devices) -util.consume((fs.glob("/dev/mmc*")), devices) - -local size = {} -for i, dev in ipairs(devices) do - local s = tonumber((fs.readfile("/sys/class/block/%s/size" % dev:sub(6)))) - size[dev] = s and math.floor(s / 2048) -end - - -m = Map("fstab", translate("Mount Points - Mount Entry")) -m.redirect = luci.dispatcher.build_url("admin/system/fstab") - -if not arg[1] or m.uci:get("fstab", arg[1]) ~= "mount" then - luci.http.redirect(m.redirect) - return -end - - - -mount = m:section(NamedSection, arg[1], "mount", translate("Mount Entry")) -mount.anonymous = true -mount.addremove = false - -mount:tab("general", translate("General Settings")) -mount:tab("advanced", translate("Advanced Settings")) - - -mount:taboption("general", Flag, "enabled", translate("Enable this mount")).rmempty = false - - -o = mount:taboption("general", Value, "device", translate("Device"), - translate("The device file of the memory or partition (<abbr title=\"for example\">e.g.</abbr> <code>/dev/sda1</code>)")) - -for i, d in ipairs(devices) do - o:value(d, size[d] and "%s (%s MB)" % {d, size[d]}) -end - -o = mount:taboption("advanced", Value, "uuid", translate("UUID"), - translate("If specified, mount the device by its UUID instead of a fixed device node")) - -o = mount:taboption("advanced", Value, "label", translate("Label"), - translate("If specified, mount the device by the partition label instead of a fixed device node")) - - -o = mount:taboption("general", Value, "target", translate("Mount point"), - translate("Specifies the directory the device is attached to")) - -o:depends("is_rootfs", "") - - -o = mount:taboption("general", Value, "fstype", translate("Filesystem"), - translate("The filesystem that was used to format the memory (<abbr title=\"for example\">e.g.</abbr> <samp><abbr title=\"Third Extended Filesystem\">ext3</abbr></samp>)")) - -local fs -for fs in io.lines("/proc/filesystems") do - fs = fs:match("%S+") - if fs ~= "nodev" then - o:value(fs) - end -end - - -o = mount:taboption("advanced", Value, "options", translate("Mount options"), - translate("See \"mount\" manpage for details")) - -o.placeholder = "defaults" - - -if has_extroot then - o = mount:taboption("general", Flag, "is_rootfs", translate("Use as root filesystem"), - translate("Configures this mount as overlay storage for block-extroot")) - - o:depends("fstype", "jffs") - o:depends("fstype", "ext2") - o:depends("fstype", "ext3") - o:depends("fstype", "ext4") -end - -if has_fscheck then - o = mount:taboption("general", Flag, "enabled_fsck", translate("Run filesystem check"), - translate("Run a filesystem check before mounting the device")) -end - -return m diff --git a/modules/admin-full/luasrc/model/cbi/admin_system/fstab/swap.lua b/modules/admin-full/luasrc/model/cbi/admin_system/fstab/swap.lua deleted file mode 100644 index 01d0ff90a5..0000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_system/fstab/swap.lua +++ /dev/null @@ -1,65 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2010 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- - -local fs = require "nixio.fs" -local util = require "nixio.util" - -local devices = {} -util.consume((fs.glob("/dev/sd*")), devices) -util.consume((fs.glob("/dev/hd*")), devices) -util.consume((fs.glob("/dev/scd*")), devices) -util.consume((fs.glob("/dev/mmc*")), devices) - -local size = {} -for i, dev in ipairs(devices) do - local s = tonumber((fs.readfile("/sys/class/block/%s/size" % dev:sub(6)))) - size[dev] = s and math.floor(s / 2048) -end - - -m = Map("fstab", translate("Mount Points - Swap Entry")) -m.redirect = luci.dispatcher.build_url("admin/system/fstab") - -if not arg[1] or m.uci:get("fstab", arg[1]) ~= "swap" then - luci.http.redirect(m.redirect) - return -end - - -mount = m:section(NamedSection, arg[1], "swap", translate("Swap Entry")) -mount.anonymous = true -mount.addremove = false - -mount:tab("general", translate("General Settings")) -mount:tab("advanced", translate("Advanced Settings")) - - -mount:taboption("general", Flag, "enabled", translate("Enable this swap")).rmempty = false - - -o = mount:taboption("general", Value, "device", translate("Device"), - translate("The device file of the memory or partition (<abbr title=\"for example\">e.g.</abbr> <code>/dev/sda1</code>)")) - -for i, d in ipairs(devices) do - o:value(d, size[d] and "%s (%s MB)" % {d, size[d]}) -end - -o = mount:taboption("advanced", Value, "uuid", translate("UUID"), - translate("If specified, mount the device by its UUID instead of a fixed device node")) - -o = mount:taboption("advanced", Value, "label", translate("Label"), - translate("If specified, mount the device by the partition label instead of a fixed device node")) - - -return m diff --git a/modules/admin-full/luasrc/model/cbi/admin_system/ipkg.lua b/modules/admin-full/luasrc/model/cbi/admin_system/ipkg.lua deleted file mode 100644 index e9ff5b1460..0000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_system/ipkg.lua +++ /dev/null @@ -1,36 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2008-2011 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- - -local ipkgfile = "/etc/opkg.conf" - -f = SimpleForm("ipkgconf", translate("OPKG-Configuration")) - -f:append(Template("admin_system/ipkg")) - -t = f:field(TextValue, "lines") -t.rows = 10 -function t.cfgvalue() - return nixio.fs.readfile(ipkgfile) or "" -end - -function t.write(self, section, data) - return nixio.fs.writefile(ipkgfile, data:gsub("\r\n", "\n")) -end - -function f.handle(self, state, data) - return true -end - -return f diff --git a/modules/admin-full/luasrc/model/cbi/admin_system/leds.lua b/modules/admin-full/luasrc/model/cbi/admin_system/leds.lua deleted file mode 100644 index b912f5ece8..0000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_system/leds.lua +++ /dev/null @@ -1,129 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2008 Steven Barth <steven@midlink.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- -m = Map("system", translate("<abbr title=\"Light Emitting Diode\">LED</abbr> Configuration"), translate("Customizes the behaviour of the device <abbr title=\"Light Emitting Diode\">LED</abbr>s if possible.")) - -local sysfs_path = "/sys/class/leds/" -local leds = {} - -local fs = require "nixio.fs" -local util = require "nixio.util" - -if fs.access(sysfs_path) then - leds = util.consume((fs.dir(sysfs_path))) -end - -if #leds == 0 then - return m -end - - -s = m:section(TypedSection, "led", "") -s.anonymous = true -s.addremove = true - -function s.parse(self, ...) - TypedSection.parse(self, ...) - os.execute("/etc/init.d/led enable") -end - - -s:option(Value, "name", translate("Name")) - - -sysfs = s:option(ListValue, "sysfs", translate("<abbr title=\"Light Emitting Diode\">LED</abbr> Name")) -for k, v in ipairs(leds) do - sysfs:value(v) -end - -s:option(Flag, "default", translate("Default state")).rmempty = false - - -trigger = s:option(ListValue, "trigger", translate("Trigger")) - -local triggers = fs.readfile(sysfs_path .. leds[1] .. "/trigger") -for t in triggers:gmatch("[%w-]+") do - trigger:value(t, translate(t:gsub("-", ""))) -end - - -delayon = s:option(Value, "delayon", translate ("On-State Delay")) -delayon:depends("trigger", "timer") - -delayoff = s:option(Value, "delayoff", translate ("Off-State Delay")) -delayoff:depends("trigger", "timer") - - -dev = s:option(ListValue, "_net_dev", translate("Device")) -dev.rmempty = true -dev:value("") -dev:depends("trigger", "netdev") - -function dev.cfgvalue(self, section) - return m.uci:get("system", section, "dev") -end - -function dev.write(self, section, value) - m.uci:set("system", section, "dev", value) -end - -function dev.remove(self, section) - local t = trigger:formvalue(section) - if t ~= "netdev" and t ~= "usbdev" then - m.uci:delete("system", section, "dev") - end -end - -for k, v in pairs(luci.sys.net.devices()) do - if v ~= "lo" then - dev:value(v) - end -end - - -mode = s:option(MultiValue, "mode", translate("Trigger Mode")) -mode.rmempty = true -mode:depends("trigger", "netdev") -mode:value("link", translate("Link On")) -mode:value("tx", translate("Transmit")) -mode:value("rx", translate("Receive")) - - -usbdev = s:option(ListValue, "_usb_dev", translate("USB Device")) -usbdev:depends("trigger", "usbdev") -usbdev.rmempty = true -usbdev:value("") - -function usbdev.cfgvalue(self, section) - return m.uci:get("system", section, "dev") -end - -function usbdev.write(self, section, value) - m.uci:set("system", section, "dev", value) -end - -function usbdev.remove(self, section) - local t = trigger:formvalue(section) - if t ~= "netdev" and t ~= "usbdev" then - m.uci:delete("system", section, "dev") - end -end - -for p in nixio.fs.glob("/sys/bus/usb/devices/[0-9]*/manufacturer") do - local id = p:match("%d+-%d+") - local mf = nixio.fs.readfile("/sys/bus/usb/devices/" .. id .. "/manufacturer") or "?" - local pr = nixio.fs.readfile("/sys/bus/usb/devices/" .. id .. "/product") or "?" - usbdev:value(id, "%s (%s - %s)" %{ id, mf, pr }) -end - -return m diff --git a/modules/admin-full/luasrc/model/cbi/admin_system/startup.lua b/modules/admin-full/luasrc/model/cbi/admin_system/startup.lua deleted file mode 100644 index fc35f774a9..0000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_system/startup.lua +++ /dev/null @@ -1,109 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2010-2012 Jo-Philipp Wich <xm@subsignal.org> -Copyright 2010 Manuel Munz <freifunk at somakoma dot de> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- - -require "luci.fs" -require "luci.sys" -require "luci.util" - -local inits = { } - -for _, name in ipairs(luci.sys.init.names()) do - local index = luci.sys.init.index(name) - local enabled = luci.sys.init.enabled(name) - - if index < 255 then - inits["%02i.%s" % { index, name }] = { - name = name, - index = tostring(index), - enabled = enabled - } - end -end - - -m = SimpleForm("initmgr", translate("Initscripts"), translate("You can enable or disable installed init scripts here. Changes will applied after a device reboot.<br /><strong>Warning: If you disable essential init scripts like \"network\", your device might become inaccessible!</strong>")) -m.reset = false -m.submit = false - - -s = m:section(Table, inits) - -i = s:option(DummyValue, "index", translate("Start priority")) -n = s:option(DummyValue, "name", translate("Initscript")) - - -e = s:option(Button, "endisable", translate("Enable/Disable")) - -e.render = function(self, section, scope) - if inits[section].enabled then - self.title = translate("Enabled") - self.inputstyle = "save" - else - self.title = translate("Disabled") - self.inputstyle = "reset" - end - - Button.render(self, section, scope) -end - -e.write = function(self, section) - if inits[section].enabled then - inits[section].enabled = false - return luci.sys.init.disable(inits[section].name) - else - inits[section].enabled = true - return luci.sys.init.enable(inits[section].name) - end -end - - -start = s:option(Button, "start", translate("Start")) -start.inputstyle = "apply" -start.write = function(self, section) - luci.sys.call("/etc/init.d/%s %s >/dev/null" %{ inits[section].name, self.option }) -end - -restart = s:option(Button, "restart", translate("Restart")) -restart.inputstyle = "reload" -restart.write = start.write - -stop = s:option(Button, "stop", translate("Stop")) -stop.inputstyle = "remove" -stop.write = start.write - - - -f = SimpleForm("rc", translate("Local Startup"), - translate("This is the content of /etc/rc.local. Insert your own commands here (in front of 'exit 0') to execute them at the end of the boot process.")) - -t = f:field(TextValue, "rcs") -t.rmempty = true -t.rows = 20 - -function t.cfgvalue() - return luci.fs.readfile("/etc/rc.local") or "" -end - -function f.handle(self, state, data) - if state == FORM_VALID then - if data.rcs then - luci.fs.writefile("/etc/rc.local", data.rcs:gsub("\r\n", "\n")) - end - end - return true -end - -return m, f diff --git a/modules/admin-full/luasrc/model/cbi/admin_system/system.lua b/modules/admin-full/luasrc/model/cbi/admin_system/system.lua deleted file mode 100644 index 5e82289bd8..0000000000 --- a/modules/admin-full/luasrc/model/cbi/admin_system/system.lua +++ /dev/null @@ -1,228 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2011 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- - -require("luci.sys") -require("luci.sys.zoneinfo") -require("luci.tools.webadmin") -require("luci.fs") -require("luci.config") - -local m, s, o -local has_ntpd = luci.fs.access("/usr/sbin/ntpd") - -m = Map("system", translate("System"), translate("Here you can configure the basic aspects of your device like its hostname or the timezone.")) -m:chain("luci") - - -s = m:section(TypedSection, "system", translate("System Properties")) -s.anonymous = true -s.addremove = false - -s:tab("general", translate("General Settings")) -s:tab("logging", translate("Logging")) -s:tab("language", translate("Language and Style")) - - --- --- System Properties --- - -o = s:taboption("general", DummyValue, "_systime", translate("Local Time")) -o.template = "admin_system/clock_status" - - -o = s:taboption("general", Value, "hostname", translate("Hostname")) -o.datatype = "hostname" - -function o.write(self, section, value) - Value.write(self, section, value) - luci.sys.hostname(value) -end - - -o = s:taboption("general", ListValue, "zonename", translate("Timezone")) -o:value("UTC") - -for i, zone in ipairs(luci.sys.zoneinfo.TZ) do - o:value(zone[1]) -end - -function o.write(self, section, value) - local function lookup_zone(title) - for _, zone in ipairs(luci.sys.zoneinfo.TZ) do - if zone[1] == title then return zone[2] end - end - end - - AbstractValue.write(self, section, value) - local timezone = lookup_zone(value) or "GMT0" - self.map.uci:set("system", section, "timezone", timezone) - luci.fs.writefile("/etc/TZ", timezone .. "\n") -end - - --- --- Logging --- - -o = s:taboption("logging", Value, "log_size", translate("System log buffer size"), "kiB") -o.optional = true -o.placeholder = 16 -o.datatype = "uinteger" - -o = s:taboption("logging", Value, "log_ip", translate("External system log server")) -o.optional = true -o.placeholder = "0.0.0.0" -o.datatype = "ip4addr" - -o = s:taboption("logging", Value, "log_port", translate("External system log server port")) -o.optional = true -o.placeholder = 514 -o.datatype = "port" - -o = s:taboption("logging", ListValue, "conloglevel", translate("Log output level")) -o:value(8, translate("Debug")) -o:value(7, translate("Info")) -o:value(6, translate("Notice")) -o:value(5, translate("Warning")) -o:value(4, translate("Error")) -o:value(3, translate("Critical")) -o:value(2, translate("Alert")) -o:value(1, translate("Emergency")) - -o = s:taboption("logging", ListValue, "cronloglevel", translate("Cron Log Level")) -o.default = 8 -o:value(5, translate("Debug")) -o:value(8, translate("Normal")) -o:value(9, translate("Warning")) - - --- --- Langauge & Style --- - -o = s:taboption("language", ListValue, "_lang", translate("Language")) -o:value("auto") - -local i18ndir = luci.i18n.i18ndir .. "base." -for k, v in luci.util.kspairs(luci.config.languages) do - local file = i18ndir .. k:gsub("_", "-") - if k:sub(1, 1) ~= "." and luci.fs.access(file .. ".lmo") then - o:value(k, v) - end -end - -function o.cfgvalue(...) - return m.uci:get("luci", "main", "lang") -end - -function o.write(self, section, value) - m.uci:set("luci", "main", "lang", value) -end - - -o = s:taboption("language", ListValue, "_mediaurlbase", translate("Design")) -for k, v in pairs(luci.config.themes) do - if k:sub(1, 1) ~= "." then - o:value(v, k) - end -end - -function o.cfgvalue(...) - return m.uci:get("luci", "main", "mediaurlbase") -end - -function o.write(self, section, value) - m.uci:set("luci", "main", "mediaurlbase", value) -end - - --- --- NTP --- - -if has_ntpd then - - -- timeserver setup was requested, create section and reload page - if m:formvalue("cbid.system._timeserver._enable") then - m.uci:section("system", "timeserver", "ntp", - { - server = { "0.openwrt.pool.ntp.org", "1.openwrt.pool.ntp.org", "2.openwrt.pool.ntp.org", "3.openwrt.pool.ntp.org" } - } - ) - - m.uci:save("system") - luci.http.redirect(luci.dispatcher.build_url("admin/system", arg[1])) - return - end - - local has_section = false - m.uci:foreach("system", "timeserver", - function(s) - has_section = true - return false - end) - - if not has_section then - - s = m:section(TypedSection, "timeserver", translate("Time Synchronization")) - s.anonymous = true - s.cfgsections = function() return { "_timeserver" } end - - x = s:option(Button, "_enable") - x.title = translate("Time Synchronization is not configured yet.") - x.inputtitle = translate("Set up Time Synchronization") - x.inputstyle = "apply" - - else - - s = m:section(TypedSection, "timeserver", translate("Time Synchronization")) - s.anonymous = true - s.addremove = false - - o = s:option(Flag, "enable", translate("Enable NTP client")) - o.rmempty = false - - function o.cfgvalue(self) - return luci.sys.init.enabled("sysntpd") - and self.enabled or self.disabled - end - - function o.write(self, section, value) - if value == self.enabled then - luci.sys.init.enable("sysntpd") - luci.sys.call("env -i /etc/init.d/sysntpd start >/dev/null") - else - luci.sys.call("env -i /etc/init.d/sysntpd stop >/dev/null") - luci.sys.init.disable("sysntpd") - end - end - - - o = s:option(Flag, "enable_server", translate("Provide NTP server")) - o:depends("enable", "1") - - - o = s:option(DynamicList, "server", translate("NTP server candidates")) - o.datatype = "host" - o:depends("enable", "1") - - -- retain server list even if disabled - function o.remove() end - - end -end - -return m diff --git a/modules/admin-full/luasrc/view/admin_network/diagnostics.htm b/modules/admin-full/luasrc/view/admin_network/diagnostics.htm deleted file mode 100644 index d1bef2a8b7..0000000000 --- a/modules/admin-full/luasrc/view/admin_network/diagnostics.htm +++ /dev/null @@ -1,120 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2010 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ - --%> - -<%+header%> - -<% -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") -%> - -<script type="text/javascript" src="<%=resource%>/cbi.js"></script> -<script type="text/javascript">//<![CDATA[ - var stxhr = new XHR(); - - function update_status(field, proto) - { - var tool = field.name; - var addr = field.value; - var protocol = proto ? "6" : ""; - - var legend = document.getElementById('diag-rc-legend'); - var output = document.getElementById('diag-rc-output'); - - if (legend && output) - { - output.innerHTML = - '<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' + - '<%:Waiting for command to complete...%>' - ; - - legend.parentNode.style.display = 'block'; - legend.style.display = 'inline'; - - stxhr.get('<%=luci.dispatcher.build_url("admin", "network")%>/diag_' + tool + protocol + '/' + addr, null, - function(x) - { - if (x.responseText) - { - legend.style.display = 'none'; - output.innerHTML = String.format('<pre>%h</pre>', x.responseText); - } - else - { - legend.style.display = 'none'; - output.innerHTML = '<span class="error"><%:Bad address specified!%></span>'; - } - } - ); - } - } -//]]></script> - -<form method="post" action="<%=pcdata(luci.http.getenv("REQUEST_URI"))%>"> - <div class="cbi-map"> - <h2><a id="content" name="content"><%:Diagnostics%></a></h2> - - <fieldset class="cbi-section"> - <legend><%:Network Utilities%></legend> - - <br /> - - <div style="width:30%; float:left"> - <input style="margin: 5px 0" type="text" value="openwrt.org" name="ping" /><br /> - <% if has_ping6 then %> - <select name="ping_proto" style="width:auto"> - <option value="" selected="selected"><%:IPv4%></option> - <option value="6"><%:IPv6%></option> - </select> - <input type="button" value="<%:Ping%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.ping, this.form.ping_proto.selectedIndex)" /> - <% else %> - <input type="button" value="<%:Ping%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.ping)" /> - <% end %> - </div> - - <div style="width:33%; float:left"> - <input style="margin: 5px 0" type="text" value="openwrt.org" name="traceroute" /><br /> - <% if has_traceroute6 then %> - <select name="traceroute_proto" style="width:auto"> - <option value="" selected="selected"><%:IPv4%></option> - <option value="6"><%:IPv6%></option> - </select> - <input type="button" value="<%:Traceroute%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.traceroute, this.form.traceroute_proto.selectedIndex)" /> - <% else %> - <input type="button" value="<%:Traceroute%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.traceroute)" /> - <% end %> - <% if not has_traceroute6 then %> - <p> </p> - <p><%:Install iputils-traceroute6 for IPv6 traceroute%></p> - <% end %> - </div> - - <div style="width:33%; float:left;"> - <input style="margin: 5px 0" type="text" value="openwrt.org" name="nslookup" /><br /> - <input type="button" value="<%:Nslookup%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.nslookup)" /> - </div> - - <br style="clear:both" /><br /> - - </fieldset> - </div> - - <fieldset class="cbi-section" style="display:none"> - <legend id="diag-rc-legend"><%:Collecting data...%></legend> - <span id="diag-rc-output"></span> - </fieldset> -</form> - -<%+footer%> diff --git a/modules/admin-full/luasrc/view/admin_network/iface_overview.htm b/modules/admin-full/luasrc/view/admin_network/iface_overview.htm deleted file mode 100644 index 4be062985a..0000000000 --- a/modules/admin-full/luasrc/view/admin_network/iface_overview.htm +++ /dev/null @@ -1,258 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2010 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/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(String.format('<%_Really shutdown interface "%s" ?\nYou might lose access to this device if you are connected via this interface.%>', 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...%>'; - } - - XHR.get('<%=luci.dispatcher.build_url("admin", "network")%>/iface_' + (reconnect ? 'reconnect' : 'shutdown') + '/' + id, null, - function(x) - { - if (s) - { - s.innerHTML = reconnect - ? '<%:Interface reconnected%>' - : '<%:Interface shut down%>'; - - window.setTimeout(function() { - s.parentNode.style.display = 'none'; - }, 1000); - } - } - ); - } - - - var iwxhr = new XHR(); - var wifidevs = <%=luci.http.write_json(netdevs)%>; - var arptable = <%=luci.http.write_json(arpcache)%>; - - XHR.poll(5, '<%=luci.dispatcher.build_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.type != 'tunnel') - { - 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) - { - html += '<strong><%:IPv4%>: </strong>'; - - for (var i = 0; i < ifc.ipaddrs.length; i++) - html += String.format( - '%s%s/%d', - i ? ', ' : '', - ifc.ipaddrs[i].addr, - ifc.ipaddrs[i].prefix - ); - - html += '<br />'; - } - - if (ifc.ip6addrs && ifc.ip6addrs.length) - { - html += '<strong><%:IPv6%>: </strong>'; - - for (var i = 0; i < ifc.ip6addrs.length; i++) - html += String.format( - '%s%s/%d', - i ? ', ' : '', - ifc.ip6addrs[i].addr.toUpperCase(), - ifc.ip6addrs[i].prefix - ); - - html += '<br />'; - } - - 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>', - '<%=luci.dispatcher.build_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="<%=luci.dispatcher.build_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"> - <fieldset class="cbi-section"> - <legend><%:Interface Overview%></legend> - - <table class="cbi-section-table" style="margin:10px; empty-cells:hide"> - <tr class="cbi-section-table-titles"> - <th class="cbi-section-table-cell"><%:Network%></th> - <th class="cbi-section-table-cell" style="text-align:left"><%:Status%></th> - <th class="cbi-section-table-cell"><%:Actions%></th> - </tr> - <% - 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") - %> - <tr class="cbi-section-table-row cbi-rowstyle-<%=i % 2 + 1%>"> - <td class="cbi-value-field" style="padding:3px"> - <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> - </td> - <td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px" id="<%=net[1]%>-ifc-description"> - <em><%:Collecting data...%></em> - </td> - <td style="width:420px"> - <input type="button" class="cbi-button cbi-button-reload" style="width:100px" onclick="iface_shutdown('<%=net[1]%>', true)" title="<%:Reconnect this interface%>" value="<%:Connect%>" /> - <input type="button" class="cbi-button cbi-button-reset" style="width:100px" onclick="iface_shutdown('<%=net[1]%>', false)" title="<%:Shutdown this interface%>" value="<%:Stop%>" /> - <input type="button" class="cbi-button cbi-button-edit" style="width:100px" onclick="location.href='<%=luci.dispatcher.build_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-remove" style="width:100px" onclick="if (confirm('<%:Really delete this interface? The deletion cannot be undone!\nYou might lose access to this device if you are connected via this interface.%>')) location.href='<%=luci.dispatcher.build_url("admin/network/iface_delete", net[1])%>'" title="<%:Delete this interface%>" value="<%:Delete%>" /> - </td> - </tr> - <% end %> - </table> - - <input type="button" class="cbi-button cbi-button-add" value="<%:Add new interface...%>" onclick="location.href='<%=luci.dispatcher.build_url("admin/network/iface_add")%>'" /> - </fieldset> -</div> diff --git a/modules/admin-full/luasrc/view/admin_network/iface_status.htm b/modules/admin-full/luasrc/view/admin_network/iface_status.htm deleted file mode 100644 index 8136383969..0000000000 --- a/modules/admin-full/luasrc/view/admin_network/iface_status.htm +++ /dev/null @@ -1,94 +0,0 @@ -<%+cbi/valueheader%> - -<script type="text/javascript">//<![CDATA[ - XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "iface_status", self.network)%>', null, - function(x, ifc) - { - if (ifc && (ifc = ifc[0])) - { - var html = ''; - - var s = document.getElementById('<%=self.option%>-ifc-signal'); - if (s) - s.innerHTML = String.format( - '<img src="<%=resource%>/icons/%s%s.png" style="width:16px; height:16px" />' + - '<br /><small>%s</small>', - ifc.type, ifc.is_up ? '' : '_disabled', - ifc.name - ); - - var d = document.getElementById('<%=self.option%>-ifc-description'); - if (d && ifc.ifname) - { - if (ifc.is_up) - { - html += String.format('<strong><%:Uptime%>:</strong> %t<br />', ifc.uptime); - } - - if (ifc.type != 'tunnel') - { - 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) - { - html += '<strong><%:IPv4%>: </strong>'; - - for (var i = 0; i < ifc.ipaddrs.length; i++) - html += String.format( - '%s%s/%d', - i ? ', ' : '', - ifc.ipaddrs[i].addr, - ifc.ipaddrs[i].prefix - ); - - html += '<br />'; - } - - if (ifc.ip6addrs && ifc.ip6addrs.length) - { - html += '<strong><%:IPv6%>: </strong>'; - - for (var i = 0; i < ifc.ip6addrs.length; i++) - html += String.format( - '%s%s/%d', - i ? ', ' : '', - ifc.ip6addrs[i].addr.toUpperCase(), - ifc.ip6addrs[i].prefix - ); - - html += '<br />'; - } - - d.innerHTML = html; - } - else if (d) - { - d.innerHTML = '<em><%:Interface not present or not connected yet.%></em>'; - } - } - } - ); -//]]></script> - -<table> - <tr class="cbi-section-table"> - <td></td> - <td class="cbi-value-field" style="min-width:16px; padding:3px; text-align:center" id="<%=self.option%>-ifc-signal"> - <img src="<%=resource%>/icons/ethernet_disabled.png" style="width:16px; height:16px" /><br /> - <small>?</small> - </td> - <td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px" id="<%=self.option%>-ifc-description"> - <em><%:Collecting data...%></em> - </td> - </tr> -</table> - -<%+cbi/valuefooter%> diff --git a/modules/admin-full/luasrc/view/admin_network/lease_status.htm b/modules/admin-full/luasrc/view/admin_network/lease_status.htm deleted file mode 100644 index 0ba334ee9d..0000000000 --- a/modules/admin-full/luasrc/view/admin_network/lease_status.htm +++ /dev/null @@ -1,118 +0,0 @@ -<script type="text/javascript">//<![CDATA[ - XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "dhcplease_status")%>', null, - function(x, st) - { - var tb = document.getElementById('lease_status_table'); - if (st && st[0] && tb) - { - /* clear all rows */ - while( tb.rows.length > 1 ) - tb.deleteRow(1); - - for( var i = 0; i < st[0].length; i++ ) - { - var timestr; - - if (st[0][i].expires <= 0) - { - timestr = '<em><%:expired%></em>'; - } - else - { - timestr = String.format('%t', st[0][i].expires); - } - - var tr = tb.insertRow(-1); - tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1); - - tr.insertCell(-1).innerHTML = st[0][i].hostname ? st[0][i].hostname : '?'; - tr.insertCell(-1).innerHTML = st[0][i].ipaddr; - tr.insertCell(-1).innerHTML = st[0][i].macaddr; - tr.insertCell(-1).innerHTML = timestr; - } - - if( tb.rows.length == 1 ) - { - var tr = tb.insertRow(-1); - tr.className = 'cbi-section-table-row'; - - var td = tr.insertCell(-1); - td.colSpan = 4; - td.innerHTML = '<em><br /><%:There are no active leases.%></em>'; - } - } - - var tb6 = document.getElementById('lease6_status_table'); - if (st && st[1] && tb6) - { - tb6.parentNode.style.display = 'block'; - - /* clear all rows */ - while( tb6.rows.length > 1 ) - tb6.deleteRow(1); - - for( var i = 0; i < st[1].length; i++ ) - { - var timestr; - - if (st[1][i].expires <= 0) - { - timestr = '<em><%:expired%></em>'; - } - else - { - timestr = String.format('%t', st[1][i].expires); - } - - var tr = tb6.insertRow(-1); - tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1); - - tr.insertCell(-1).innerHTML = st[1][i].hostname ? st[1][i].hostname : '?'; - tr.insertCell(-1).innerHTML = st[1][i].ip6addr; - tr.insertCell(-1).innerHTML = st[1][i].duid; - tr.insertCell(-1).innerHTML = timestr; - } - - if( tb6.rows.length == 1 ) - { - var tr = tb6.insertRow(-1); - tr.className = 'cbi-section-table-row'; - - var td = tr.insertCell(-1); - td.colSpan = 4; - td.innerHTML = '<em><br /><%:There are no active leases.%></em>'; - } - } - } - ); -//]]></script> - -<fieldset class="cbi-section"> - <legend><%:Active DHCP Leases%></legend> - <table class="cbi-section-table" id="lease_status_table"> - <tr class="cbi-section-table-titles"> - <th class="cbi-section-table-cell"><%:Hostname%></th> - <th class="cbi-section-table-cell"><%:IPv4-Address%></th> - <th class="cbi-section-table-cell"><%:MAC-Address%></th> - <th class="cbi-section-table-cell"><%:Leasetime remaining%></th> - </tr> - <tr class="cbi-section-table-row"> - <td colspan="4"><em><br /><%:Collecting data...%></em></td> - </tr> - </table> -</fieldset> - -<fieldset class="cbi-section" style="display:none"> - <legend><%:Active DHCPv6 Leases%></legend> - <table class="cbi-section-table" id="lease6_status_table"> - <tr class="cbi-section-table-titles"> - <th class="cbi-section-table-cell"><%:Hostname%></th> - <th class="cbi-section-table-cell"><%:IPv6-Address%></th> - <th class="cbi-section-table-cell"><%:DUID%></th> - <th class="cbi-section-table-cell"><%:Leasetime remaining%></th> - </tr> - <tr class="cbi-section-table-row"> - <td colspan="4"><em><br /><%:Collecting data...%></em></td> - </tr> - </table> -</fieldset> diff --git a/modules/admin-full/luasrc/view/admin_network/switch_status.htm b/modules/admin-full/luasrc/view/admin_network/switch_status.htm deleted file mode 100644 index b299575e2f..0000000000 --- a/modules/admin-full/luasrc/view/admin_network/switch_status.htm +++ /dev/null @@ -1,41 +0,0 @@ -<script type="text/javascript">//<![CDATA[ - var switches = [ '<%=table.concat(self.switches, "', '")%>' ]; - XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "switch_status")%>/' + switches.join(','), null, - function(x, st) - { - for (var i = 0; i < switches.length; i++) - { - var ports = st[switches[i]]; - var th0 = document.getElementById('portstatus-' + switches[i]); - - if (th0 && ports && ports.length) - { - if (!th0.innerHTML) - th0.innerHTML = '<%:Port status:%>'; - - for (var j = 0; j < ports.length; j++) - { - var th = th0.parentNode.parentNode.childNodes[j+1]; - - if (ports[j].link) - { - th.innerHTML = String.format( - '<small><img src="<%=resource%>/icons/port_up.png" />' + - '<br />%d<%:baseT%><br />%s</small>', - ports[j].speed, ports[j].duplex - ? '<%:full-duplex%>' : '<%:half-duplex%>' - ); - } - else - { - th.innerHTML = String.format( - '<small><img src="<%=resource%>/icons/port_down.png" />' + - '<br /><%:no link%></small>' - ); - } - } - } - } - } - ); -//]]></script> diff --git a/modules/admin-full/luasrc/view/admin_network/wifi_join.htm b/modules/admin-full/luasrc/view/admin_network/wifi_join.htm deleted file mode 100644 index f3b6dddefc..0000000000 --- a/modules/admin-full/luasrc/view/admin_network/wifi_join.htm +++ /dev/null @@ -1,156 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2009 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ - --%> - -<%- - - 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) - - if not iw then - 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%> - -<h2><a id="content" name="content"><%:Join Network: Wireless Scan%></a></h2> - -<div class="cbi-map"> - <fieldset class="cbi-section"> - <table class="cbi-section-table" style="empty-cells:hide"> - <!-- scan list --> - <% for i, net in ipairs(scanlist(3)) do net.encryption = net.encryption or { } %> - <tr class="cbi-section-table-row cbi-rowstyle-<%=1 + ((i-1) % 2)%>"> - <td class="cbi-value-field" style="width:16px; padding:3px"> - <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> - </td> - <td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px"> - <big><strong><%=net.ssid and utl.pcdata(net.ssid) or "<em>%s</em>" % translate("hidden")%></strong></big><br /> - <strong>Channel:</strong> <%=net.channel%> | - <strong>Mode:</strong> <%=net.mode%> | - <strong>BSSID:</strong> <%=net.bssid%> | - <strong>Encryption:</strong> <%=format_wifi_encryption(net.encryption)%> - </td> - <td class="cbi-value-field" style="width:40px"> - <form action="<%=REQUEST_URI%>" method="post"> - <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-apply" type="submit" value="<%:Join Network%>" /> - </form> - </td> - </tr> - <% end %> - <!-- /scan list --> - </table> - </fieldset> -</div> -<div class="cbi-page-actions right"> - <form class="inline" action="<%=luci.dispatcher.build_url("admin/network/wireless")%>" method="get"> - <input class="cbi-button cbi-button-reset" type="submit" value="<%:Back to overview%>" /> - </form> - <form class="inline" action="<%=REQUEST_URI%>" method="get"> - <input type="hidden" name="device" value="<%=utl.pcdata(dev)%>" /> - <input class="cbi-button cbi-input-find" type="submit" value="<%:Repeat scan%>" /> - </form> -</div> - -<%+footer%> diff --git a/modules/admin-full/luasrc/view/admin_network/wifi_overview.htm b/modules/admin-full/luasrc/view/admin_network/wifi_overview.htm deleted file mode 100644 index 312fd08654..0000000000 --- a/modules/admin-full/luasrc/view/admin_network/wifi_overview.htm +++ /dev/null @@ -1,441 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2008-2009 Steven Barth <steven@midlink.org> -Copyright 2008-2013 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - --%> - -<%- - - local sys = require "luci.sys" - local fs = require "luci.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 - - -- madwifi - elseif name == "ath" or name == "wifi" then - return translatef("Atheros 802.11%s Wireless Controller", bands) - - -- 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.isdirectory("/proc/net/hostap/" .. ifname) 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 arpcache = { } - sys.net.arptable(function(e) arpcache[e["HW address"]:upper()] = e["IP address"] end) - - 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="errorbox"> - <strong><%:Package libiwinfo required!%></strong><br /> - <%_The <em>libiwinfo-lua</em> package is not installed. You must install this component for working wireless configuration!%> - </div> -<% end %> - -<script type="text/javascript" src="<%=resource%>/cbi.js"></script> -<script type="text/javascript">//<![CDATA[ - var wifidevs = <%=luci.http.write_json(netdevs)%>; - var arptable = <%=luci.http.write_json(arpcache)%>; - - var is_reconnecting = false; - - function nowrap(s) { - return s.replace(/ /g, ' '); - } - - function wifi_shutdown(id, toggle) { - var reconnect = (toggle.getAttribute('active') == 'false'); - - if (!reconnect && !confirm(String.format('<%:Really shut down network?\nYou 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>'; - } - - XHR.get('<%=luci.dispatcher.build_url("admin", "network")%>/wireless_' + (reconnect ? 'reconnect' : 'shutdown') + '/' + id, null, - function(x) - { - if (s) - { - s.innerHTML = reconnect - ? '<%:Wireless restarted%>' - : '<%:Wireless shut down%>'; - - window.setTimeout(function() { - s.parentNode.style.display = 'none'; - is_reconnecting = false; - }, 1000); - } - } - ); - } - - XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "wireless_status", table.concat(netlist, ","))%>', null, - function(x, st) - { - if (st) - { - var assoctable = document.getElementById('iw-assoclist'); - if (assoctable) - while (assoctable.rows.length > 1) - assoctable.rows[1].parentNode.removeChild(assoctable.rows[1]); - - var devup = { }; - var rowstyle = 1; - - for( var i = 0; i < st.length; i++ ) - { - var iw = st[i]; - var is_assoc = (iw.bssid && iw.bssid != '00:00:00:00:00:00' && iw.channel && iw.mode != 'Unknown'); - var p = iw.quality; - var q = 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"; - - if (!devup[wifidevs[iw.id]]) - devup[wifidevs[iw.id]] = is_assoc; - - var sig = document.getElementById(iw.id + '-iw-signal'); - if (sig) - sig.innerHTML = String.format( - '<img src="%s" title="<%:Signal%>: %d <%:dBm%> / <%:Noise%>: %d <%:dBm%>" /><br />' + - '<small>%d%%</small>', icon, iw.signal, iw.noise, p - ); - - var toggle = document.getElementById(iw.id + '-iw-toggle'); - if (toggle) - { - if (!iw.disabled) - { - toggle.className = 'cbi-button cbi-button-reset'; - toggle.value = '<%:Disable%>'; - toggle.title = '<%:Shutdown this network%>'; - } - else - { - toggle.className = 'cbi-button cbi-button-reload'; - toggle.value = '<%:Enable%>'; - toggle.title = '<%:Activate this network%>'; - } - - toggle.setAttribute('active', !iw.disabled); - } - - var info = document.getElementById(iw.id + '-iw-status'); - if (info) - { - if (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>' - ); - } - - var dev = document.getElementById(wifidevs[iw.id] + '-iw-devinfo'); - if (dev) - { - if (is_assoc) - dev.innerHTML = String.format( - '<strong><%:Channel%>:</strong> %s (%s <%:GHz%>) | ' + - '<strong><%:Bitrate%>:</strong> %s <%:Mbit/s%>', - iw.channel ? iw.channel : '?', - iw.frequency ? iw.frequency : '?', - iw.bitrate ? iw.bitrate : '?' - ); - else - dev.innerHTML = ''; - } - - if (assoctable) - { - var assoclist = [ ]; - for( var bssid in iw.assoclist ) - { - assoclist.push(iw.assoclist[bssid]); - assoclist[assoclist.length-1].bssid = bssid; - } - - assoclist.sort(function(a, b) { a.bssid < b.bssid }); - - for( var j = 0; j < assoclist.length; j++ ) - { - var tr = assoctable.insertRow(-1); - tr.className = 'cbi-section-table-row cbi-rowstyle-' + rowstyle; - - var icon; - var q = (-1 * (assoclist[j].noise - assoclist[j].signal)) / 5; - if (q < 1) - icon = "<%=resource%>/icons/signal-0.png"; - else if (q < 2) - icon = "<%=resource%>/icons/signal-0-25.png"; - else if (q < 3) - icon = "<%=resource%>/icons/signal-25-50.png"; - else if (q < 4) - icon = "<%=resource%>/icons/signal-50-75.png"; - else - icon = "<%=resource%>/icons/signal-75-100.png"; - - tr.insertCell(-1).innerHTML = String.format( - '<img src="%s" title="<%:Signal%>: %d <%:dBm%> / <%:Noise%>: %d <%:dBm%>" />', - icon, assoclist[j].signal, assoclist[j].noise - ); - - tr.insertCell(-1).innerHTML = nowrap(String.format('%h', iw.ssid ? iw.ssid : '?')); - tr.insertCell(-1).innerHTML = assoclist[j].bssid; - - tr.insertCell(-1).innerHTML = arptable[assoclist[j].bssid] - ? arptable[assoclist[j].bssid] : '?'; - - tr.insertCell(-1).innerHTML = nowrap(String.format('%d <%:dBm%>', assoclist[j].signal)); - tr.insertCell(-1).innerHTML = nowrap(String.format('%d <%:dBm%>', assoclist[j].noise)); - - tr.insertCell(-1).innerHTML = nowrap((assoclist[j].rx_mcs > -1) - ? String.format('%.1f <%:Mbit/s%>, MCS %d, %d<%:MHz%>', assoclist[j].rx_rate / 1000, assoclist[j].rx_mcs, assoclist[j].rx_40mhz ? 40 : 20) - : String.format('%.1f <%:Mbit/s%>', assoclist[j].rx_rate / 1000) - ); - - tr.insertCell(-1).innerHTML = nowrap((assoclist[j].tx_mcs > -1) - ? String.format('%.1f <%:Mbit/s%>, MCS %d, %d<%:MHz%>', assoclist[j].tx_rate / 1000, assoclist[j].tx_mcs, assoclist[j].tx_40mhz ? 40 : 20) - : String.format('%.1f <%:Mbit/s%>', assoclist[j].tx_rate / 1000) - ); - - rowstyle = (rowstyle == 1) ? 2 : 1; - } - } - } - - if (assoctable && assoctable.rows.length == 1) - { - var tr = assoctable.insertRow(-1); - tr.className = 'cbi-section-table-row'; - - var td = tr.insertCell(-1); - td.colSpan = 8; - td.innerHTML = '<br /><em><%:No information available%></em>'; - } - - for (var dev in devup) - { - var img = document.getElementById(dev + '-iw-upstate'); - if (img) - img.src = '<%=resource%>/icons/wifi_big' + (devup[dev] ? '' : '_disabled') + '.png'; - } - } - } - ); -//]]></script> - -<h2><a id="content" name="content"><%:Wireless Overview%></a></h2> - -<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="iw-rc-status"><%:Waiting for changes to be applied...%></span> -</fieldset> - -<div class="cbi-map"> - - <% for _, dev in ipairs(devices) do local nets = dev:get_wifinets() %> - <!-- device <%=dev:name()%> --> - <fieldset class="cbi-section"> - <table class="cbi-section-table" style="margin:10px; empty-cells:hide"> - <!-- physical device --> - <tr> - <td style="width:34px"><img src="<%=resource%>/icons/wifi_big_disabled.png" style="float:left; margin-right:10px" id="<%=dev:name()%>-iw-upstate" /></td> - <td colspan="2" style="text-align:left"> - <big><strong><%=guess_wifi_hw(dev)%> (<%=dev:name()%>)</strong></big><br /> - <span id="<%=dev:name()%>-iw-devinfo"></span> - </td> - <td style="width:310px;text-align:right"> - <input type="button" class="cbi-button cbi-button-find" style="width:100px" onclick="location.href='<%=luci.dispatcher.build_url("admin/network/wireless_join")%>?device=<%=dev:name()%>'" title="<%:Find and join network%>" value="<%:Scan%>" /> - <input type="button" class="cbi-button cbi-button-add" style="width:100px" onclick="location.href='<%=luci.dispatcher.build_url("admin/network/wireless_add")%>?device=<%=dev:name()%>'" title="<%:Provide new network%>" value="<%:Add%>" /> - </td> - </tr> - <!-- /physical device --> - - <!-- network list --> - <% if #nets > 0 then %> - <% for i, net in ipairs(nets) do %> - <tr class="cbi-section-table-row cbi-rowstyle-<%=1 + ((i-1) % 2)%>"> - <td></td> - <td class="cbi-value-field" style="width:16px; padding:3px" id="<%=net:id()%>-iw-signal"> - <img src="<%=resource%>/icons/signal-none.png" title="<%:Not associated%>" /><br /> - <small>0%</small> - </td> - <td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px" id="<%=net:id()%>-iw-status"> - <em><%:Collecting data...%></em> - </td> - <td class="cbi-value-field" style="width:310px;text-align:right"> - <input id="<%=net:id()%>-iw-toggle" type="button" class="cbi-button cbi-button-reload" style="width:100px" onclick="wifi_shutdown('<%=net:id()%>', this)" title="<%:Delete this network%>" value="<%:Enable%>" /> - <input type="button" class="cbi-button cbi-button-edit" style="width:100px" onclick="location.href='<%=net:adminlink()%>'" title="<%:Edit this network%>" value="<%:Edit%>" /> - <input type="button" class="cbi-button cbi-button-remove" style="width:100px" onclick="if (confirm('<%:Really delete this wireless network? The deletion cannot be undone!\nYou might lose access to this device if you are connected via this network.%>')) location.href='<%=luci.dispatcher.build_url("admin/network/wireless_delete", net:ifname())%>'" title="<%:Delete this network%>" value="<%:Remove%>" /> - </td> - </tr> - <% end %> - <% else %> - <tr class="cbi-section-table-row cbi-rowstyle-2"> - <td></td> - <td colspan="3" class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px"> - <em><%:No network configured on this device%></em> - </td> - </tr> - <% end %> - <!-- /network list --> - </table> - </fieldset> - <!-- /device <%=dev:name()%> --> - <% end %> - - - <h2><a id="content" name="content"><%:Associated Stations%></a></h2> - - <fieldset class="cbi-section"> - <table class="cbi-section-table" style="margin:10px" id="iw-assoclist"> - <tr class="cbi-section-table-titles"> - <th class="cbi-section-table-cell"></th> - <th class="cbi-section-table-cell"><%:SSID%></th> - <th class="cbi-section-table-cell"><%:MAC-Address%></th> - <th class="cbi-section-table-cell"><%:IPv4-Address%></th> - <th class="cbi-section-table-cell"><%:Signal%></th> - <th class="cbi-section-table-cell"><%:Noise%></th> - <th class="cbi-section-table-cell"><%:RX Rate%></th> - <th class="cbi-section-table-cell"><%:TX Rate%></th> - </tr> - <tr class="cbi-section-table-row cbi-rowstyle-2"> - <td class="cbi-value-field" colspan="8"> - <em><%:Collecting data...%></em> - </td> - </tr> - </table> - </fieldset> -</div> - -<%+footer%> diff --git a/modules/admin-full/luasrc/view/admin_network/wifi_status.htm b/modules/admin-full/luasrc/view/admin_network/wifi_status.htm deleted file mode 100644 index 2484fd3c6b..0000000000 --- a/modules/admin-full/luasrc/view/admin_network/wifi_status.htm +++ /dev/null @@ -1,78 +0,0 @@ -<%+cbi/valueheader%> - -<script type="text/javascript">//<![CDATA[ - XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "wireless_status", self.ifname)%>', null, - function(x, iw) - { - if (iw && (iw = iw[0])) - { - var is_assoc = (iw.bssid && iw.bssid != '00:00:00:00:00:00' && iw.channel); - var p = iw.quality; - var q = 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 s = document.getElementById('<%=self.option%>-iw-signal'); - if (s) - s.innerHTML = String.format( - '<img src="%s" title="<%:Signal%>: %d <%:dBm%> / <%:Noise%>: %d <%:dBm%>" /><br />' + - '<small>%d%%</small>', icon, iw.signal, iw.noise, p - ); - - var d = document.getElementById('<%=self.option%>-iw-description'); - if (d && is_assoc) - d.innerHTML = String.format( - '<strong><%:Mode%>:</strong> %s | ' + - '<strong><%:SSID%>:</strong> %h<br />' + - '<strong><%:BSSID%>:</strong> %s | ' + - '<strong><%:Encryption%>:</strong> %s<br />' + - '<strong><%:Channel%>:</strong> %d (%.3f <%:GHz%>) | ' + - '<strong><%:Tx-Power%>:</strong> %d <%:dBm%><br />' + - '<strong><%:Signal%>:</strong> %d <%:dBm%> | ' + - '<strong><%:Noise%>:</strong> %d <%:dBm%><br />' + - '<strong><%:Bitrate%>:</strong> %.1f <%:Mbit/s%> | ' + - '<strong><%:Country%>:</strong> %s', - iw.mode, iw.ssid, iw.bssid, - iw.encryption ? iw.encryption : '<%:None%>', - iw.channel, iw.frequency ? iw.frequency : 0, - iw.txpower, iw.signal, iw.noise, - iw.bitrate ? iw.bitrate : 0, iw.country - ); - else if (d) - d.innerHTML = String.format( - '<strong><%:SSID%>:</strong> %h | ' + - '<strong><%:Mode%>:</strong> %s<br />' + - '<em><%:Wireless is disabled or not associated%></em>', - iw.ssid || '?', iw.mode - ); - } - } - ); -//]]></script> - -<table> - <tr class="cbi-section-table"> - <td></td> - <td class="cbi-value-field" style="width:16px; padding:3px" id="<%=self.option%>-iw-signal"> - <img src="<%=resource%>/icons/signal-none.png" title="<%:Not associated%>" /><br /> - <small>0%</small> - </td> - <td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px" id="<%=self.option%>-iw-description"> - <em><%:Collecting data...%></em> - </td> - </tr> -</table> - -<%+cbi/valuefooter%> diff --git a/modules/admin-full/luasrc/view/admin_status/bandwidth.htm b/modules/admin-full/luasrc/view/admin_status/bandwidth.htm deleted file mode 100644 index 0c53c95bed..0000000000 --- a/modules/admin-full/luasrc/view/admin_status/bandwidth.htm +++ /dev/null @@ -1,311 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2010 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ - --%> - -<%- - local ntm = require "luci.model.network".init() - - local dev - local devices = { } - for _, dev in luci.util.vspairs(luci.sys.net.devices()) do - if dev ~= "lo" and not ntm:ignore_interface(dev) then - devices[#devices+1] = dev - end - end - - local curdev = luci.dispatcher.context.requestpath - curdev = curdev[#curdev] ~= "bandwidth" and curdev[#curdev] or devices[1] --%> - -<%+header%> - -<script type="text/javascript" src="<%=resource%>/cbi.js"></script> -<script type="text/javascript">//<![CDATA[ - var bwxhr = new XHR(); - - var G; - var TIME = 0; - var RXB = 1; - var RXP = 2; - var TXB = 3; - var TXP = 4; - - var width = 760; - var height = 300; - var step = 5; - - var data_wanted = Math.floor(width / step); - var data_fill = 0; - var data_stamp = 0; - - var data_rx = [ ]; - var data_tx = [ ]; - - var line_rx; - var line_tx; - - var label_25; - var label_50; - var label_75; - - var label_rx_cur; - var label_rx_avg; - var label_rx_peak; - - var label_tx_cur; - var label_tx_avg; - var label_tx_peak; - - var label_scale; - - - function bandwidth_label(bytes, br) - { - var uby = '<%:kB/s%>'; - var kby = (bytes / 1024); - - if (kby >= 1024) - { - uby = '<%:MB/s%>'; - kby = kby / 1024; - } - - var ubi = '<%:kbit/s%>'; - var kbi = (bytes * 8 / 1024); - - if (kbi >= 1024) - { - ubi = '<%:Mbit/s%>'; - kbi = kbi / 1024; - } - - return String.format("%f %s%s(%f %s)", - kbi.toFixed(2), ubi, - br ? '<br />' : ' ', - kby.toFixed(2), uby - ); - } - - /* wait for SVG */ - window.setTimeout( - function() { - var svg = document.getElementById('bwsvg'); - - try { - G = svg.getSVGDocument - ? svg.getSVGDocument() : svg.contentDocument; - } - catch(e) { - G = document.embeds['bwsvg'].getSVGDocument(); - } - - if (!G) - { - window.setTimeout(arguments.callee, 1000); - } - else - { - /* find sizes */ - width = svg.offsetWidth - 2; - height = svg.offsetHeight - 2; - data_wanted = Math.ceil(width / step); - - /* prefill datasets */ - for (var i = 0; i < data_wanted; i++) - { - data_rx[i] = 0; - data_tx[i] = 0; - } - - /* find svg elements */ - line_rx = G.getElementById('rx'); - line_tx = G.getElementById('tx'); - - label_25 = G.getElementById('label_25'); - label_50 = G.getElementById('label_50'); - label_75 = G.getElementById('label_75'); - - label_rx_cur = document.getElementById('rx_bw_cur'); - label_rx_avg = document.getElementById('rx_bw_avg'); - label_rx_peak = document.getElementById('rx_bw_peak'); - - label_tx_cur = document.getElementById('tx_bw_cur'); - label_tx_avg = document.getElementById('tx_bw_avg'); - label_tx_peak = document.getElementById('tx_bw_peak'); - - label_scale = document.getElementById('scale'); - - - /* plot horizontal time interval lines */ - for (var i = width % (step * 60); i < width; i += step * 60) - { - var line = G.createElementNS('http://www.w3.org/2000/svg', 'line'); - line.setAttribute('x1', i); - line.setAttribute('y1', 0); - line.setAttribute('x2', i); - line.setAttribute('y2', '100%'); - line.setAttribute('style', 'stroke:black;stroke-width:0.1'); - - 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.appendChild(G.createTextNode(Math.round((width - i) / step / 60) + 'm')); - - label_25.parentNode.appendChild(line); - label_25.parentNode.appendChild(text); - } - - label_scale.innerHTML = String.format('<%:(%d minute window, %d second interval)%>', data_wanted / 60, 3); - - /* render datasets, start update interval */ - XHR.poll(3, '<%=build_url("admin/status/realtime/bandwidth_status", curdev)%>', null, - function(x, data) - { - var data_max = 0; - var data_scale = 0; - - var data_rx_avg = 0; - var data_tx_avg = 0; - - var data_rx_peak = 0; - var data_tx_peak = 0; - - for (var i = data_stamp ? 0 : 1; i < data.length; i++) - { - /* skip overlapping entries */ - if (data[i][TIME] <= data_stamp) - continue; - - /* normalize difference against time interval */ - if (i > 0) - { - var time_delta = data[i][TIME] - data[i-1][TIME]; - if (time_delta) - { - data_rx.push((data[i][RXB] - data[i-1][RXB]) / time_delta); - data_tx.push((data[i][TXB] - data[i-1][TXB]) / time_delta); - } - } - } - - /* cut off outdated entries */ - data_rx = data_rx.slice(data_rx.length - data_wanted, data_rx.length); - data_tx = data_tx.slice(data_tx.length - data_wanted, data_tx.length); - - /* find peak */ - for (var i = 0; i < data_rx.length; i++) - { - data_max = Math.max(data_max, data_rx[i]); - data_max = Math.max(data_max, data_tx[i]); - - data_rx_peak = Math.max(data_rx_peak, data_rx[i]); - data_tx_peak = Math.max(data_tx_peak, data_tx[i]); - - if (i > 0) - { - data_rx_avg = (data_rx_avg + data_rx[i]) / 2; - data_tx_avg = (data_tx_avg + data_tx[i]) / 2; - } - else - { - data_rx_avg = data_rx[i]; - data_tx_avg = data_tx[i]; - } - } - - /* remember current timestamp, calculate horizontal scale */ - data_stamp = data[data.length-1][TIME]; - data_scale = height / (data_max * 1.1); - - - /* plot data */ - var pt_rx = '0,' + height; - var pt_tx = '0,' + height; - - var y_rx = 0; - var y_tx = 0; - - for (var i = 0; i < data_rx.length; i++) - { - var x = i * step; - - y_rx = height - Math.floor(data_rx[i] * data_scale); - y_tx = height - Math.floor(data_tx[i] * data_scale); - - pt_rx += ' ' + x + ',' + y_rx; - pt_tx += ' ' + x + ',' + y_tx; - } - - pt_rx += ' ' + width + ',' + y_rx + ' ' + width + ',' + height; - pt_tx += ' ' + width + ',' + y_tx + ' ' + width + ',' + height; - - - line_rx.setAttribute('points', pt_rx); - line_tx.setAttribute('points', pt_tx); - - label_25.firstChild.data = bandwidth_label(1.1 * 0.25 * data_max); - label_50.firstChild.data = bandwidth_label(1.1 * 0.50 * data_max); - label_75.firstChild.data = bandwidth_label(1.1 * 0.75 * data_max); - - label_rx_cur.innerHTML = bandwidth_label(data_rx[data_rx.length-1], true); - label_tx_cur.innerHTML = bandwidth_label(data_tx[data_tx.length-1], true); - - label_rx_avg.innerHTML = bandwidth_label(data_rx_avg, true); - label_tx_avg.innerHTML = bandwidth_label(data_tx_avg, true); - - label_rx_peak.innerHTML = bandwidth_label(data_rx_peak, true); - label_tx_peak.innerHTML = bandwidth_label(data_tx_peak, true); - } - ); - } - }, 1000 - ); -//]]></script> - -<h2><a id="content" name="content"><%:Realtime Traffic%></a></h2> - -<ul class="cbi-tabmenu"> - <% for _, dev in ipairs(devices) do %> - <li class="cbi-tab<%= dev == curdev and "" or "-disabled" %>"><a href="<%=pcdata(dev)%>"><%=pcdata(dev)%></a></li> - <% end %> -</ul> - -<embed id="bwsvg" style="width:100%; height:300px; border:1px solid #000000; background-color:#FFFFFF" src="<%=resource%>/bandwidth.svg" /> -<div style="text-align:right"><small id="scale">-</small></div> -<br /> - -<table style="width:100%; table-layout:fixed" cellspacing="5"> - <tr> - <td style="text-align:right; vertical-align:top"><strong style="border-bottom:2px solid blue"><%:Inbound:%></strong></td> - <td id="rx_bw_cur">0 <%:kbit/s%><br />(0 <%:kB/s%>)</td> - - <td style="text-align:right; vertical-align:top"><strong><%:Average:%></strong></td> - <td id="rx_bw_avg">0 <%:kbit/s%><br />(0 <%:kB/s%>)</td> - - <td style="text-align:right; vertical-align:top"><strong><%:Peak:%></strong></td> - <td id="rx_bw_peak">0 <%:kbit/s%><br />(0 <%:kB/s%>)</td> - </tr> - <tr> - <td style="text-align:right; vertical-align:top"><strong style="border-bottom:2px solid green"><%:Outbound:%></strong></td> - <td id="tx_bw_cur">0 <%:kbit/s%><br />(0 <%:kB/s%>)</td> - - <td style="text-align:right; vertical-align:top"><strong><%:Average:%></strong></td> - <td id="tx_bw_avg">0 <%:kbit/s%><br />(0 <%:kB/s%>)</td> - - <td style="text-align:right; vertical-align:top"><strong><%:Peak:%></strong></td> - <td id="tx_bw_peak">0 <%:kbit/s%><br />(0 <%:kB/s%>)</td> - </tr> -</table> - -<%+footer%> diff --git a/modules/admin-full/luasrc/view/admin_status/connections.htm b/modules/admin-full/luasrc/view/admin_status/connections.htm deleted file mode 100644 index 80c8b70e3c..0000000000 --- a/modules/admin-full/luasrc/view/admin_status/connections.htm +++ /dev/null @@ -1,382 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2010 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - --%> - -<%+header%> - -<script type="text/javascript" src="<%=resource%>/cbi.js"></script> -<script type="text/javascript">//<![CDATA[ - var bwxhr = new XHR(); - - var G; - var TIME = 0; - var UDP = 1; - var TCP = 2; - var OTHER = 3; - - var width = 760; - var height = 300; - var step = 5; - - var data_wanted = Math.floor(width / step); - var data_fill = 0; - var data_stamp = 0; - - var data_udp = [ ]; - var data_tcp = [ ]; - var data_otr = [ ]; - - var line_udp; - var line_tcp; - - var label_25; - var label_50; - var label_75; - - var label_udp_cur; - var label_udp_avg; - var label_udp_peak; - - var label_tcp_cur; - var label_tcp_avg; - var label_tcp_peak; - - var label_otr_cur; - var label_otr_avg; - var label_otr_peak; - - var label_scale; - - var conn_table; - - var dns_cache = { }; - - - /* wait for SVG */ - window.setTimeout( - function() { - var svg = document.getElementById('bwsvg'); - - try { - G = svg.getSVGDocument - ? svg.getSVGDocument() : svg.contentDocument; - } - catch(e) { - G = document.embeds['bwsvg'].getSVGDocument(); - } - - if (!G) - { - window.setTimeout(arguments.callee, 1000); - } - else - { - /* find sizes */ - width = svg.offsetWidth - 2; - height = svg.offsetHeight - 2; - data_wanted = Math.ceil(width / step); - - /* prefill datasets */ - for (var i = 0; i < data_wanted; i++) - { - data_udp[i] = 0; - data_tcp[i] = 0; - data_otr[i] = 0; - } - - /* find svg elements */ - line_udp = G.getElementById('udp'); - line_tcp = G.getElementById('tcp'); - line_otr = G.getElementById('other'); - - label_25 = G.getElementById('label_25'); - label_50 = G.getElementById('label_50'); - label_75 = G.getElementById('label_75'); - - label_udp_cur = document.getElementById('lb_udp_cur'); - label_udp_avg = document.getElementById('lb_udp_avg'); - label_udp_peak = document.getElementById('lb_udp_peak'); - - label_tcp_cur = document.getElementById('lb_tcp_cur'); - label_tcp_avg = document.getElementById('lb_tcp_avg'); - label_tcp_peak = document.getElementById('lb_tcp_peak'); - - label_otr_cur = document.getElementById('lb_otr_cur'); - label_otr_avg = document.getElementById('lb_otr_avg'); - label_otr_peak = document.getElementById('lb_otr_peak'); - - label_scale = document.getElementById('scale'); - - conn_table = document.getElementById('connections'); - - - /* plot horizontal time interval lines */ - for (var i = width % (step * 60); i < width; i += step * 60) - { - var line = G.createElementNS('http://www.w3.org/2000/svg', 'line'); - line.setAttribute('x1', i); - line.setAttribute('y1', 0); - line.setAttribute('x2', i); - line.setAttribute('y2', '100%'); - line.setAttribute('style', 'stroke:black;stroke-width:0.1'); - - 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.appendChild(G.createTextNode(Math.round((width - i) / step / 60) + 'm')); - - label_25.parentNode.appendChild(line); - label_25.parentNode.appendChild(text); - } - - label_scale.innerHTML = String.format('<%:(%d minute window, %d second interval)%>', data_wanted / 60, 3); - - /* render datasets, start update interval */ - XHR.poll(3, '<%=build_url("admin/status/realtime/connections_status")%>', null, - function(x, json) - { - var conn = json.connections; - - while (conn_table.rows.length > 1) - conn_table.rows[0].parentNode.deleteRow(-1); - - - var lookup_queue = [ ]; - - conn.sort(function(a, b) { - return b.bytes - a.bytes; - }); - - for (var i = 0; i < conn.length; i++) - { - var c = conn[i]; - - if (c.src == '127.0.0.1' && c.dst == '127.0.0.1') - continue; - - var tr = conn_table.rows[0].parentNode.insertRow(-1); - tr.className = 'cbi-section-table-row cbi-rowstyle-' + (1 + (i % 2)); - - if (!dns_cache[c.src]) - lookup_queue.push(c.src); - - if (!dns_cache[c.dst]) - lookup_queue.push(c.dst); - - 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); - - tr.insertCell(-1).innerHTML = c.layer3.toUpperCase(); - tr.insertCell(-1).innerHTML = c.layer4.toUpperCase(); - tr.insertCell(-1).innerHTML = String.format('%s:%d', src, c.sport); - tr.insertCell(-1).innerHTML = String.format('%s:%d', dst, c.dport); - - var traf = tr.insertCell(-1); - traf.style.whiteSpace = 'nowrap'; - traf.innerHTML = String.format('%1024.2mB (%d <%:Pkts.%>)', c.bytes, c.packets); - } - - if (lookup_queue.length > 0) - XHR.get('<%=build_url("admin/status/nameinfo")%>/' + lookup_queue.slice(0, 100).join('/'), null, - function(x, json) - { - for (var addr in json) - dns_cache[addr] = json[addr]; - } - ); - - - var data = json.statistics; - - var data_max = 0; - var data_scale = 0; - - var data_udp_avg = 0; - var data_tcp_avg = 0; - var data_otr_avg = 0; - - var data_udp_peak = 0; - var data_tcp_peak = 0; - var data_otr_peak = 0; - - for (var i = data_stamp ? 0 : 1; i < data.length; i++) - { - /* skip overlapping entries */ - if (data[i][TIME] <= data_stamp) - continue; - - data_udp.push(data[i][UDP]); - data_tcp.push(data[i][TCP]); - data_otr.push(data[i][OTHER]); - } - - /* cut off outdated entries */ - data_udp = data_udp.slice(data_udp.length - data_wanted, data_udp.length); - data_tcp = data_tcp.slice(data_tcp.length - data_wanted, data_tcp.length); - data_otr = data_otr.slice(data_otr.length - data_wanted, data_otr.length); - - /* find peak */ - for (var i = 0; i < data_udp.length; i++) - { - data_max = Math.max(data_max, data_udp[i]); - data_max = Math.max(data_max, data_tcp[i]); - data_max = Math.max(data_max, data_otr[i]); - - data_udp_peak = Math.max(data_udp_peak, data_udp[i]); - data_tcp_peak = Math.max(data_tcp_peak, data_tcp[i]); - data_otr_peak = Math.max(data_otr_peak, data_otr[i]); - - if (i > 0) - { - data_udp_avg = (data_udp_avg + data_udp[i]) / 2; - data_tcp_avg = (data_tcp_avg + data_tcp[i]) / 2; - data_otr_avg = (data_otr_avg + data_otr[i]) / 2; - } - else - { - data_udp_avg = data_udp[i]; - data_tcp_avg = data_tcp[i]; - data_otr_avg = data_otr[i]; - } - } - - /* remember current timestamp, calculate horizontal scale */ - data_stamp = data[data.length-1][TIME]; - data_scale = height / (data_max * 1.1); - - - /* plot data */ - var pt_udp = '0,' + height; - var pt_tcp = '0,' + height; - var pt_otr = '0,' + height; - - var y_udp = 0; - var y_tcp = 0; - var y_otr = 0; - - for (var i = 0; i < data_udp.length; i++) - { - var x = i * step; - - y_udp = height - Math.floor(data_udp[i] * data_scale); - y_tcp = height - Math.floor(data_tcp[i] * data_scale); - y_otr = height - Math.floor(data_otr[i] * data_scale); - - pt_udp += ' ' + x + ',' + y_udp; - pt_tcp += ' ' + x + ',' + y_tcp; - pt_otr += ' ' + x + ',' + y_otr; - } - - pt_udp += ' ' + width + ',' + y_udp + ' ' + width + ',' + height; - pt_tcp += ' ' + width + ',' + y_tcp + ' ' + width + ',' + height; - pt_otr += ' ' + width + ',' + y_otr + ' ' + width + ',' + height; - - - var order = [ - [ line_udp, data_udp[data_udp.length-1] ], - [ line_tcp, data_tcp[data_tcp.length-1] ], - [ line_otr, data_otr[data_otr.length-1] ] - ]; - - order.sort(function(a, b) { return b[1] - a[1] }); - - for (var i = 0; i < order.length; i++) - order[i][0].parentNode.appendChild(order[i][0]); - - - line_udp.setAttribute('points', pt_udp); - line_tcp.setAttribute('points', pt_tcp); - line_otr.setAttribute('points', pt_otr); - - label_25.firstChild.data = Math.floor(1.1 * 0.25 * data_max); - label_50.firstChild.data = Math.floor(1.1 * 0.50 * data_max); - label_75.firstChild.data = Math.floor(1.1 * 0.75 * data_max); - - label_udp_cur.innerHTML = Math.floor(data_udp[data_udp.length-1]); - label_tcp_cur.innerHTML = Math.floor(data_tcp[data_tcp.length-1]); - label_otr_cur.innerHTML = Math.floor(data_otr[data_otr.length-1]); - - label_udp_avg.innerHTML = Math.floor(data_udp_avg); - label_tcp_avg.innerHTML = Math.floor(data_tcp_avg); - label_otr_avg.innerHTML = Math.floor(data_otr_avg); - - label_udp_peak.innerHTML = Math.floor(data_udp_peak); - label_tcp_peak.innerHTML = Math.floor(data_tcp_peak); - label_otr_peak.innerHTML = Math.floor(data_otr_peak); - } - ); - } - }, 1000 - ); -//]]></script> - -<h2><a id="content" name="content"><%:Realtime Connections%></a></h2> - -<div class="cbi-map-descr"><%:This page gives an overview over currently active network connections.%></div> - -<fieldset class="cbi-section" id="cbi-table-table"> - <legend><%:Active Connections%></legend> - - <embed id="bwsvg" style="width:100%; height:300px; border:1px solid #000000; background-color:#FFFFFF" src="<%=resource%>/connections.svg" /> - <div style="text-align:right"><small id="scale">-</small></div> - <br /> - - <table style="width:100%; table-layout:fixed" cellspacing="5"> - <tr> - <td style="text-align:right; vertical-align:top"><strong style="border-bottom:2px solid blue"><%:UDP:%></strong></td> - <td id="lb_udp_cur">0</td> - - <td style="text-align:right; vertical-align:top"><strong><%:Average:%></strong></td> - <td id="lb_udp_avg">0</td> - - <td style="text-align:right; vertical-align:top"><strong><%:Peak:%></strong></td> - <td id="lb_udp_peak">0</td> - </tr> - <tr> - <td style="text-align:right; vertical-align:top"><strong style="border-bottom:2px solid green"><%:TCP:%></strong></td> - <td id="lb_tcp_cur">0</td> - - <td style="text-align:right; vertical-align:top"><strong><%:Average:%></strong></td> - <td id="lb_tcp_avg">0</td> - - <td style="text-align:right; vertical-align:top"><strong><%:Peak:%></strong></td> - <td id="lb_tcp_peak">0</td> - </tr> - <tr> - <td style="text-align:right; vertical-align:top"><strong style="border-bottom:2px solid red"><%:Other:%></strong></td> - <td id="lb_otr_cur">0</td> - - <td style="text-align:right; vertical-align:top"><strong><%:Average:%></strong></td> - <td id="lb_otr_avg">0</td> - - <td style="text-align:right; vertical-align:top"><strong><%:Peak:%></strong></td> - <td id="lb_otr_peak">0</td> - </tr> - </table> - <br /> - - <div class="cbi-section-node"> - <table class="cbi-section-table" id="connections"> - <tr class="cbi-section-table-titles"> - <th class="cbi-section-table-cell"><%:Network%></th> - <th class="cbi-section-table-cell"><%:Protocol%></th> - <th class="cbi-section-table-cell"><%:Source%></th> - <th class="cbi-section-table-cell"><%:Destination%></th> - <th class="cbi-section-table-cell"><%:Transfer%></th> - </tr> - - <tr><td colspan="5"><em><%:Collecting data...%></em></td></tr> - </table> - </div> -</fieldset> - -<%+footer%> diff --git a/modules/admin-full/luasrc/view/admin_status/dmesg.htm b/modules/admin-full/luasrc/view/admin_status/dmesg.htm deleted file mode 100644 index 7757460a05..0000000000 --- a/modules/admin-full/luasrc/view/admin_status/dmesg.htm +++ /dev/null @@ -1,20 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id: syslog.htm 3622 2008-10-23 16:05:55Z jow $ - --%> -<%+header%> -<h2><a id="content" name="content"><%:Kernel Log%></a></h2> -<div id="content_syslog"> -<textarea readonly="readonly" wrap="off" rows="<%=dmesg:cmatch("\n")+2%>" id="syslog"><%=dmesg:pcdata()%></textarea> -</div> -<%+footer%> diff --git a/modules/admin-full/luasrc/view/admin_status/index.htm b/modules/admin-full/luasrc/view/admin_status/index.htm deleted file mode 100644 index cfeb91ac7a..0000000000 --- a/modules/admin-full/luasrc/view/admin_status/index.htm +++ /dev/null @@ -1,713 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2008-2011 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - --%> - -<% - require "luci.fs" - require "luci.tools.status" - - local has_ipv6 = luci.fs.access("/proc/net/ipv6_route") - local has_dhcp = luci.fs.access("/etc/config/dhcp") - local has_wifi = luci.fs.stat("/etc/config/wireless") - has_wifi = has_wifi and has_wifi.size > 0 - local _, _, memtotal, memcached, membuffers, memfree, _, swaptotal, swapcached, swapfree = luci.sys.sysinfo() - local has_swap - if swaptotal > 0 then - has_swap = 1 - end - local has_dsl = luci.fs.stat("/etc/init.d/dsl_control") - - if luci.http.formvalue("status") == "1" then - local ntm = require "luci.model.network".init() - local wan = ntm:get_wannet() - local wan6 = ntm:get_wan6net() - - local conn_count = tonumber(( - luci.sys.exec("wc -l /proc/net/nf_conntrack") or - luci.sys.exec("wc -l /proc/net/ip_conntrack") or - ""):match("%d+")) or 0 - - local conn_max = tonumber(( - luci.sys.exec("sysctl net.nf_conntrack_max") or - luci.sys.exec("sysctl net.ipv4.netfilter.ip_conntrack_max") or - ""):match("%d+")) or 4096 - - local rv = { - uptime = luci.sys.uptime(), - localtime = os.date(), - loadavg = { luci.sys.loadavg() }, - memtotal = memtotal, - memcached = memcached, - membuffers = membuffers, - memfree = memfree, - swaptotal = swaptotal, - swapcached = swapcached, - swapfree = swapfree, - connmax = conn_max, - conncount = conn_count, - leases = luci.tools.status.dhcp_leases(), - leases6 = luci.tools.status.dhcp6_leases(), - wifinets = luci.tools.status.wifi_networks() - } - - if wan then - rv.wan = { - ipaddr = wan:ipaddr(), - gwaddr = wan:gwaddr(), - netmask = wan:netmask(), - dns = wan:dnsaddrs(), - expires = wan:expires(), - uptime = wan:uptime(), - proto = wan:proto(), - ifname = wan:ifname(), - link = wan:adminlink() - } - end - - if wan6 then - rv.wan6 = { - ip6addr = wan6:ip6addr(), - gw6addr = wan6:gw6addr(), - dns = wan6:dns6addrs(), - uptime = wan6:uptime(), - ifname = wan6:ifname(), - link = wan6:adminlink() - } - end - - if has_dsl then - local dsl_stat = luci.sys.exec("/etc/init.d/dsl_control lucistat") - local dsl_func = loadstring(dsl_stat) - rv.dsl = dsl_func() - end - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) - - return - end - - local system, model = luci.sys.sysinfo() --%> - -<%+header%> - -<script type="text/javascript" src="<%=resource%>/cbi.js"></script> -<script type="text/javascript">//<![CDATA[ - function progressbar(v, m) - { - var vn = parseInt(v) || 0; - var mn = parseInt(m) || 100; - var pc = Math.floor((100 / mn) * vn); - - return String.format( - '<div style="width:200px; position:relative; border:1px solid #999999">' + - '<div style="background-color:#CCCCCC; width:%d%%; height:15px">' + - '<div style="position:absolute; left:0; top:0; text-align:center; width:100%%; color:#000000">' + - '<small>%s / %s (%d%%)</small>' + - '</div>' + - '</div>' + - '</div>', pc, v, m, pc - ); - } - - var wifidevs = <%=luci.http.write_json(netdevs)%>; - var arptable = <%=luci.http.write_json(arpcache)%>; - - XHR.poll(5, '<%=REQUEST_URI%>', { status: 1 }, - function(x, info) - { - var si = document.getElementById('wan4_i'); - var ss = document.getElementById('wan4_s'); - var ifc = info.wan; - - if (ifc && ifc.ifname && ifc.proto != 'none') - { - var s = String.format( - '<strong><%:Type%>: </strong>%s<br />' + - '<strong><%:Address%>: </strong>%s<br />' + - '<strong><%:Netmask%>: </strong>%s<br />' + - '<strong><%:Gateway%>: </strong>%s<br />', - ifc.proto, - (ifc.ipaddr) ? ifc.ipaddr : '0.0.0.0', - (ifc.netmask && ifc.netmask != ifc.ipaddr) ? ifc.netmask : '255.255.255.255', - (ifc.gwaddr) ? ifc.gwaddr : '0.0.0.0' - ); - - for (var i = 0; i < ifc.dns.length; i++) - { - s += String.format( - '<strong><%:DNS%> %d: </strong>%s<br />', - i + 1, ifc.dns[i] - ); - } - - if (ifc.expires > -1) - { - s += String.format( - '<strong><%:Expires%>: </strong>%t<br />', - ifc.expires - ); - } - - if (ifc.uptime > 0) - { - s += String.format( - '<strong><%:Connected%>: </strong>%t<br />', - ifc.uptime - ); - } - - ss.innerHTML = String.format('<small>%s</small>', s); - si.innerHTML = String.format( - '<img src="<%=resource%>/icons/ethernet.png" />' + - '<br /><small><a href="%s">%s</a></small>', - ifc.link, ifc.ifname - ); - } - else - { - si.innerHTML = '<img src="<%=resource%>/icons/ethernet_disabled.png" /><br /><small>?</small>'; - ss.innerHTML = '<em><%:Not connected%></em>'; - } - - <% if has_ipv6 then %> - var si6 = document.getElementById('wan6_i'); - var ss6 = document.getElementById('wan6_s'); - var ifc6 = info.wan6; - - if (ifc6 && ifc6.ifname && ifc6.proto != 'none') - { - var s = String.format( - '<strong><%:Address%>: </strong>%s<br />' + - '<strong><%:Gateway%>: </strong>%s<br />', - (ifc6.ip6addr) ? ifc6.ip6addr : '::', - (ifc6.gw6addr) ? ifc6.gw6addr : '::' - ); - - for (var i = 0; i < ifc6.dns.length; i++) - { - s += String.format( - '<strong><%:DNS%> %d: </strong>%s<br />', - i + 1, ifc6.dns[i] - ); - } - - if (ifc6.uptime > 0) - { - s += String.format( - '<strong><%:Connected%>: </strong>%t<br />', - ifc6.uptime - ); - } - - ss6.innerHTML = String.format('<small>%s</small>', s); - si6.innerHTML = String.format( - '<img src="<%=resource%>/icons/ethernet.png" />' + - '<br /><small><a href="%s">%s</a></small>', - ifc6.link, ifc6.ifname - ); - } - else - { - si6.innerHTML = '<img src="<%=resource%>/icons/ethernet_disabled.png" /><br /><small>?</small>'; - ss6.innerHTML = '<em><%:Not connected%></em>'; - } - <% end %> - - <% if has_dsl then %> - var dsl_i = document.getElementById('dsl_i'); - var dsl_s = document.getElementById('dsl_s'); - - var s = String.format( - '<strong><%:Status%>: </strong>%s<br />' + - '<strong><%:Line State%>: </strong>%s [0x%x]<br />' + - '<strong><%:Line Speed%>: </strong>%s/s / %s/s<br />' + - '<strong><%:Line Attenuation%>: </strong>%s dB / %s dB<br />' + - '<strong><%:Noise Margin%>: </strong>%s dB / %s dB<br />', - info.dsl.line_state, info.dsl.line_state_detail, - info.dsl.line_state_num, - info.dsl.data_rate_down_s, info.dsl.data_rate_up_s, - info.dsl.line_attenuation_down, info.dsl.line_attenuation_up, - info.dsl.noise_margin_down, info.dsl.noise_margin_up - ); - - dsl_s.innerHTML = String.format('<small>%s</small>', s); - dsl_i.innerHTML = String.format( - '<img src="<%=resource%>/icons/ethernet.png" />' + - '<br /><small>ADSL</small>' - ); - <% end %> - - <% if has_dhcp then %> - var ls = document.getElementById('lease_status_table'); - if (ls) - { - /* clear all rows */ - while( ls.rows.length > 1 ) - ls.rows[0].parentNode.deleteRow(1); - - for( var i = 0; i < info.leases.length; i++ ) - { - var timestr; - - if (info.leases[i].expires <= 0) - timestr = '<em><%:expired%></em>'; - else - timestr = String.format('%t', info.leases[i].expires); - - var tr = ls.rows[0].parentNode.insertRow(-1); - tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1); - - tr.insertCell(-1).innerHTML = info.leases[i].hostname ? info.leases[i].hostname : '?'; - tr.insertCell(-1).innerHTML = info.leases[i].ipaddr; - tr.insertCell(-1).innerHTML = info.leases[i].macaddr; - tr.insertCell(-1).innerHTML = timestr; - } - - if( ls.rows.length == 1 ) - { - var tr = ls.rows[0].parentNode.insertRow(-1); - tr.className = 'cbi-section-table-row'; - - var td = tr.insertCell(-1); - td.colSpan = 4; - td.innerHTML = '<em><br /><%:There are no active leases.%></em>'; - } - } - - var ls6 = document.getElementById('lease6_status_table'); - if (ls6 && info.leases6) - { - ls6.parentNode.style.display = 'block'; - - /* clear all rows */ - while( ls6.rows.length > 1 ) - ls6.rows[0].parentNode.deleteRow(1); - - for( var i = 0; i < info.leases6.length; i++ ) - { - var timestr; - - if (info.leases6[i].expires <= 0) - timestr = '<em><%:expired%></em>'; - else - timestr = String.format('%t', info.leases6[i].expires); - - var tr = ls6.rows[0].parentNode.insertRow(-1); - tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1); - - tr.insertCell(-1).innerHTML = info.leases6[i].hostname ? info.leases6[i].hostname : '?'; - tr.insertCell(-1).innerHTML = info.leases6[i].ip6addr; - tr.insertCell(-1).innerHTML = info.leases6[i].duid; - tr.insertCell(-1).innerHTML = timestr; - } - - if( ls6.rows.length == 1 ) - { - var tr = ls6.rows[0].parentNode.insertRow(-1); - tr.className = 'cbi-section-table-row'; - - var td = tr.insertCell(-1); - td.colSpan = 4; - td.innerHTML = '<em><br /><%:There are no active leases.%></em>'; - } - } - <% end %> - - <% if has_wifi then %> - var assoclist = [ ]; - - var ws = document.getElementById('wifi_status_table'); - if (ws) - { - var wsbody = ws.rows[0].parentNode; - while (ws.rows.length > 0) - wsbody.deleteRow(0); - - for (var didx = 0; didx < info.wifinets.length; didx++) - { - var dev = info.wifinets[didx]; - - var tr = wsbody.insertRow(-1); - var td; - - td = tr.insertCell(-1); - td.width = "33%"; - td.innerHTML = dev.name; - td.style.verticalAlign = "top"; - - td = tr.insertCell(-1); - - var s = ''; - - for (var nidx = 0; nidx < dev.networks.length; nidx++) - { - var net = dev.networks[nidx]; - var is_assoc = (net.bssid != '00:00:00:00:00:00' && net.channel); - - var icon; - if (!is_assoc) - icon = "<%=resource%>/icons/signal-none.png"; - else if (net.quality == 0) - icon = "<%=resource%>/icons/signal-0.png"; - else if (net.quality < 25) - icon = "<%=resource%>/icons/signal-0-25.png"; - else if (net.quality < 50) - icon = "<%=resource%>/icons/signal-25-50.png"; - else if (net.quality < 75) - icon = "<%=resource%>/icons/signal-50-75.png"; - else - icon = "<%=resource%>/icons/signal-75-100.png"; - - s += String.format( - '<table><tr><td style="text-align:center; width:32px; padding:3px">' + - '<img src="%s" title="<%:Signal%>: %d dBm / <%:Noise%>: %d dBm" />' + - '<br /><small>%d%%</small>' + - '</td><td style="text-align:left; padding:3px"><small>' + - '<strong><%:SSID%>:</strong> <a href="%s">%h</a><br />' + - '<strong><%:Mode%>:</strong> %s<br />' + - '<strong><%:Channel%>:</strong> %d (%.3f <%:GHz%>)<br />' + - '<strong><%:Bitrate%>:</strong> %s <%:Mbit/s%><br />', - icon, net.signal, net.noise, - net.quality, - net.link, net.ssid, - net.mode, - net.channel, net.frequency, - net.bitrate || '?' - ); - - if (is_assoc) - { - s += String.format( - '<strong><%:BSSID%>:</strong> %s<br />' + - '<strong><%:Encryption%>:</strong> %s', - net.bssid, - net.encryption - ); - } - else - { - s += '<em><%:Wireless is disabled or not associated%></em>'; - } - - s += '</small></td></tr></table>'; - - for (var bssid in net.assoclist) - { - assoclist.push({ - bssid: bssid, - signal: net.assoclist[bssid].signal, - noise: net.assoclist[bssid].noise, - rx_rate: net.assoclist[bssid].rx_rate, - rx_mcs: net.assoclist[bssid].rx_mcs, - rx_40mhz: net.assoclist[bssid].rx_40mhz, - tx_rate: net.assoclist[bssid].tx_rate, - tx_mcs: net.assoclist[bssid].tx_mcs, - tx_40mhz: net.assoclist[bssid].tx_40mhz, - link: net.link, - name: net.name - }); - } - } - - if (!s) - s = '<em><%:No information available%></em>'; - - td.innerHTML = s; - } - } - - var ac = document.getElementById('wifi_assoc_table'); - if (ac) - { - /* clear all rows */ - while( ac.rows.length > 1 ) - ac.rows[0].parentNode.deleteRow(1); - - assoclist.sort(function(a, b) { - return (a.name == b.name) - ? (a.bssid < b.bssid) - : (a.name > b.name ) - ; - }); - - for( var i = 0; i < assoclist.length; i++ ) - { - var tr = ac.rows[0].parentNode.insertRow(-1); - tr.className = 'cbi-section-table-row cbi-rowstyle-' + (1 + (i % 2)); - - var icon; - var q = (-1 * (assoclist[i].noise - assoclist[i].signal)) / 5; - if (q < 1) - icon = "<%=resource%>/icons/signal-0.png"; - else if (q < 2) - icon = "<%=resource%>/icons/signal-0-25.png"; - else if (q < 3) - icon = "<%=resource%>/icons/signal-25-50.png"; - else if (q < 4) - icon = "<%=resource%>/icons/signal-50-75.png"; - else - icon = "<%=resource%>/icons/signal-75-100.png"; - - tr.insertCell(-1).innerHTML = String.format( - '<img src="%s" title="<%:Signal%>: %d <%:dBm%> / <%:Noise%>: %d <%:dBm%>" />', - icon, assoclist[i].signal, assoclist[i].noise - ); - - tr.insertCell(-1).innerHTML = assoclist[i].bssid; - - tr.insertCell(-1).innerHTML = String.format( - '<a href="%s">%s</a>', - assoclist[i].link, - '%h'.format(assoclist[i].name).nobr() - ); - - tr.insertCell(-1).innerHTML = String.format('%d <%:dBm%>', assoclist[i].signal).nobr(); - tr.insertCell(-1).innerHTML = String.format('%d <%:dBm%>', assoclist[i].noise).nobr(); - - tr.insertCell(-1).innerHTML = (assoclist[i].rx_mcs > -1) - ? String.format('%.1f <%:Mbit/s%>, MCS %d, %d<%:MHz%>', assoclist[i].rx_rate / 1000, assoclist[i].rx_mcs, assoclist[i].rx_40mhz ? 40 : 20).nobr() - : String.format('%.1f <%:Mbit/s%>', assoclist[i].rx_rate / 1000).nobr() - ; - - tr.insertCell(-1).innerHTML = (assoclist[i].tx_mcs > -1) - ? String.format('%.1f <%:Mbit/s%>, MCS %d, %d<%:MHz%>', assoclist[i].tx_rate / 1000, assoclist[i].tx_mcs, assoclist[i].tx_40mhz ? 40 : 20).nobr() - : String.format('%.1f <%:Mbit/s%>', assoclist[i].tx_rate / 1000).nobr() - ; - } - - if (ac.rows.length == 1) - { - var tr = ac.rows[0].parentNode.insertRow(-1); - tr.className = 'cbi-section-table-row'; - - var td = tr.insertCell(-1); - td.colSpan = 7; - td.innerHTML = '<br /><em><%:No information available%></em>'; - } - } - <% end %> - - var e; - - if (e = document.getElementById('localtime')) - e.innerHTML = info.localtime; - - if (e = document.getElementById('uptime')) - e.innerHTML = String.format('%t', info.uptime); - - if (e = document.getElementById('loadavg')) - e.innerHTML = String.format('%.02f, %.02f, %.02f', - info.loadavg[0], info.loadavg[1], info.loadavg[2]); - - if (e = document.getElementById('memtotal')) - e.innerHTML = progressbar( - (info.memfree + info.membuffers + info.memcached) + " <%:kB%>", - info.memtotal + " <%:kB%>" - ); - - if (e = document.getElementById('memfree')) - e.innerHTML = progressbar( - info.memfree + " <%:kB%>", info.memtotal + " <%:kB%>" - ); - - if (e = document.getElementById('memcache')) - e.innerHTML = progressbar( - info.memcached + " <%:kB%>", info.memtotal + " <%:kB%>" - ); - - if (e = document.getElementById('membuff')) - e.innerHTML = progressbar( - info.membuffers + " <%:kB%>", info.memtotal + " <%:kB%>" - ); - - if (e = document.getElementById('swapcache')) - e.innerHTML = progressbar( - info.swapcached + " <%:kB%>", info.swaptotal + " <%:kB%>" - ); - - if (e = document.getElementById('swaptotal')) - e.innerHTML = progressbar( - (info.swapfree + info.swapcached) + " <%:kB%>", - info.swaptotal + " <%:kB%>" - ); - - if (e = document.getElementById('swapfree')) - e.innerHTML = progressbar( - info.swapfree + " <%:kB%>", info.swaptotal + " <%:kB%>" - ); - - if (e = document.getElementById('conns')) - e.innerHTML = progressbar(info.conncount, info.connmax); - - } - ); -//]]></script> - -<h2><a id="content" name="content"><%:Status%></a></h2> - -<fieldset class="cbi-section"> - <legend><%:System%></legend> - - <table width="100%" cellspacing="10"> - <tr><td width="33%"><%:Hostname%></td><td><%=luci.sys.hostname() or "?"%></td></tr> - <tr><td width="33%"><%:Model%></td><td><%=pcdata(model or "?")%></td></tr> - <tr><td width="33%"><%:Firmware Version%></td><td> - <%=pcdata(luci.version.distname)%> <%=pcdata(luci.version.distversion)%> / - <%=pcdata(luci.version.luciname)%> (<%=pcdata(luci.version.luciversion)%>) - </td></tr> - <tr><td width="33%"><%:Kernel Version%></td><td><%=luci.sys.exec("uname -r")%></td></tr> - <tr><td width="33%"><%:Local Time%></td><td id="localtime">-</td></tr> - <tr><td width="33%"><%:Uptime%></td><td id="uptime">-</td></tr> - <tr><td width="33%"><%:Load Average%></td><td id="loadavg">-</td></tr> - </table> -</fieldset> - -<fieldset class="cbi-section"> - <legend><%:Memory%></legend> - - <table width="100%" cellspacing="10"> - <tr><td width="33%"><%:Total Available%></td><td id="memtotal">-</td></tr> - <tr><td width="33%"><%:Free%></td><td id="memfree">-</td></tr> - <tr><td width="33%"><%:Cached%></td><td id="memcache">-</td></tr> - <tr><td width="33%"><%:Buffered%></td><td id="membuff">-</td></tr> - </table> -</fieldset> - -<% if has_swap then %> -<fieldset class="cbi-section"> - <legend><%:Swap%></legend> - - <table width="100%" cellspacing="10"> - <tr><td width="33%"><%:Total Available%></td><td id="swaptotal">-</td></tr> - <tr><td width="33%"><%:Free%></td><td id="swapfree">-</td></tr> - <tr><td width="33%"><%:Cached%></td><td id="swapcache">-</td></tr> - </table> -</fieldset> -<% end %> - -<fieldset class="cbi-section"> - <legend><%:Network%></legend> - - <table width="100%" cellspacing="10"> - <tr><td width="33%" style="vertical-align:top"><%:IPv4 WAN Status%></td><td> - <table><tr> - <td id="wan4_i" style="width:16px; text-align:center; padding:3px"><img src="<%=resource%>/icons/ethernet_disabled.png" /><br /><small>?</small></td> - <td id="wan4_s" style="vertical-align:middle; padding: 3px"><em><%:Collecting data...%></em></td> - </tr></table> - </td></tr> - <% if has_ipv6 then %> - <tr><td width="33%" style="vertical-align:top"><%:IPv6 WAN Status%></td><td> - <table><tr> - <td id="wan6_i" style="width:16px; text-align:center; padding:3px"><img src="<%=resource%>/icons/ethernet_disabled.png" /><br /><small>?</small></td> - <td id="wan6_s" style="vertical-align:middle; padding: 3px"><em><%:Collecting data...%></em></td> - </tr></table> - </td></tr> - <% end %> - <tr><td width="33%"><%:Active Connections%></td><td id="conns">-</td></tr> - </table> -</fieldset> - -<% if has_dhcp then %> -<fieldset class="cbi-section"> - <legend><%:DHCP Leases%></legend> - - <table class="cbi-section-table" id="lease_status_table"> - <tr class="cbi-section-table-titles"> - <th class="cbi-section-table-cell"><%:Hostname%></th> - <th class="cbi-section-table-cell"><%:IPv4-Address%></th> - <th class="cbi-section-table-cell"><%:MAC-Address%></th> - <th class="cbi-section-table-cell"><%:Leasetime remaining%></th> - </tr> - <tr class="cbi-section-table-row"> - <td colspan="4"><em><br /><%:Collecting data...%></em></td> - </tr> - </table> -</fieldset> - -<fieldset class="cbi-section" style="display:none"> - <legend><%:DHCPv6 Leases%></legend> - - <table class="cbi-section-table" id="lease6_status_table"> - <tr class="cbi-section-table-titles"> - <th class="cbi-section-table-cell"><%:Hostname%></th> - <th class="cbi-section-table-cell"><%:IPv6-Address%></th> - <th class="cbi-section-table-cell"><%:DUID%></th> - <th class="cbi-section-table-cell"><%:Leasetime remaining%></th> - </tr> - <tr class="cbi-section-table-row"> - <td colspan="4"><em><br /><%:Collecting data...%></em></td> - </tr> - </table> -</fieldset> -<% end %> - -<% if has_dsl then %> -<fieldset class="cbi-section"> - <legend><%:ADSL%></legend> - <table width="100%" cellspacing="10"> - <tr><td width="33%" style="vertical-align:top"><%:ADSL Status%></td><td> - <table><tr> - <td id="dsl_i" style="width:16px; text-align:center; padding:3px"><img src="<%=resource%>/icons/ethernet_disabled.png" /><br /><small>?</small></td> - <td id="dsl_s" style="vertical-align:middle; padding: 3px"><em><%:Collecting data...%></em></td> - </tr></table> - </td></tr> - </table> -</fieldset> -<% end %> - -<% if has_wifi then %> -<fieldset class="cbi-section"> - <legend><%:Wireless%></legend> - - <table id="wifi_status_table" width="100%" cellspacing="10"> - <tr><td><em><%:Collecting data...%></em></td></tr> - </table> -</fieldset> - -<fieldset class="cbi-section"> - <legend><%:Associated Stations%></legend> - - <table class="cbi-section-table" id="wifi_assoc_table"> - <tr class="cbi-section-table-titles"> - <th class="cbi-section-table-cell"> </th> - <th class="cbi-section-table-cell"><%:MAC-Address%></th> - <th class="cbi-section-table-cell"><%:Network%></th> - <th class="cbi-section-table-cell"><%:Signal%></th> - <th class="cbi-section-table-cell"><%:Noise%></th> - <th class="cbi-section-table-cell"><%:RX Rate%></th> - <th class="cbi-section-table-cell"><%:TX Rate%></th> - </tr> - <tr class="cbi-section-table-row"> - <td colspan="7"><em><br /><%:Collecting data...%></em></td> - </tr> - </table> -</fieldset> -<% end %> - -<%- - require "luci.util" - require "nixio.fs" - - local plugins = nixio.fs.dir(luci.util.libpath() .. "/view/admin_status/index") - if plugins then - local inc - for inc in plugins do - if inc:match("%.htm$") then - include("admin_status/index/" .. inc:gsub("%.htm$", "")) - end - end - end --%> - -<%+footer%> diff --git a/modules/admin-full/luasrc/view/admin_status/iptables.htm b/modules/admin-full/luasrc/view/admin_status/iptables.htm deleted file mode 100644 index 957604e8af..0000000000 --- a/modules/admin-full/luasrc/view/admin_status/iptables.htm +++ /dev/null @@ -1,159 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2008-2009 Steven Barth <steven@midlink.org> -Copyright 2008-2011 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ - --%> - -<%- - - require "luci.sys.iptparser" - require "luci.tools.webadmin" - require "luci.fs" - - local has_ip6tables = luci.fs.access("/usr/sbin/ip6tables") - local mode = 4 - - if has_ip6tables then - mode = luci.dispatcher.context.requestpath - mode = tonumber(mode[#mode] ~= "iptables" and mode[#mode]) or 4 - end - - local ipt = luci.sys.iptparser.IptParser(mode) - local wba = luci.tools.webadmin - - local rowcnt = 1 - function rowstyle() - rowcnt = rowcnt + 1 - return (rowcnt % 2) + 1 - end - - function link_target(t,c) - if ipt:is_custom_target(c) then - return '<a href="#rule_%s_%s">%s</a>' %{ t:lower(), c, c } - end - return c - end - - function link_iface(i) - local net = wba.iface_get_network(i) - if net and i ~= "lo" then - return '<a href="%s">%s</a>' %{ - luci.dispatcher.build_url("admin", "network", "network", net), i - } - - end - return i - end - - local tables = { "Filter", "NAT", "Mangle", "Raw" } - if mode == 6 then - tables = { "Filter", "Mangle", "Raw" } - end --%> - -<%+header%> - -<style type="text/css"> - span:target { - color: blue; - text-decoration: underline; - } -</style> - -<h2><a id="content" name="content"><%:Firewall Status%></a></h2> - -<% if has_ip6tables then %> -<ul class="cbi-tabmenu"> - <li class="cbi-tab<%= mode ~= 4 and "-disabled" %>"><a href="<%=luci.dispatcher.build_url("admin/status/iptables/4")%>"><%:IPv4 Firewall%></a></li> - <li class="cbi-tab<%= mode ~= 6 and "-disabled" %>"><a href="<%=luci.dispatcher.build_url("admin/status/iptables/6")%>"><%:IPv6 Firewall%></a></li> -</ul> -<% end %> - -<form method="post" action="<%=REQUEST_URI%>"> - <div class="cbi-map"> - <fieldset class="cbi-section"> - <h3><%:Actions%></h3> - <ul> - <li><a href="<%=REQUEST_URI%>?zero=<%=mode%>"><%:Reset Counters%></a></li> - <li><a href="<%=REQUEST_URI%>?restart=1"><%:Restart Firewall%></a></li> - </ul> - <br /><br /> - - <% for _, tbl in ipairs(tables) do chaincnt = 0 %> - <h3><%:Table%>: <%=tbl%></h3> - <table class="cbi-section-table" style="font-size:90%"> - <% for _, chain in ipairs(ipt:chains(tbl)) do - rowcnt = 0 - chaincnt = chaincnt + 1 - chaininfo = ipt:chain(tbl, chain) - %> - <tr class="cbi-section-table-titles cbi-rowstyle-<%=rowstyle()%>"> - <th class="cbi-section-table-cell" style="text-align:left" colspan="11"> - <br /><span id="rule_<%=tbl:lower()%>_<%=chain%>"> - <%:Chain%> <em><%=chain%></em> - (<%- if chaininfo.policy then -%> - <%:Policy%>: <em><%=chaininfo.policy%></em>, <%:Packets%>: <%=chaininfo.packets%>, <%:Traffic%>: <%=wba.byte_format(chaininfo.bytes)-%> - <%- else -%> - <%:References%>: <%=chaininfo.references-%> - <%- end -%>)</span> - </th> - </tr> - <tr class="cbi-section-table-descr"> - <th class="cbi-section-table-cell"><%:Rule #%></th> - <th class="cbi-section-table-cell"><%:Pkts.%></th> - <th class="cbi-section-table-cell"><%:Traffic%></th> - <th class="cbi-section-table-cell"><%:Target%></th> - <th class="cbi-section-table-cell"><%:Prot.%></th> - <th class="cbi-section-table-cell"><%:Flags%></th> - <th class="cbi-section-table-cell"><%:In%></th> - <th class="cbi-section-table-cell"><%:Out%></th> - <th class="cbi-section-table-cell"><%:Source%></th> - <th class="cbi-section-table-cell"><%:Destination%></th> - <th class="cbi-section-table-cell" style="width:30%"><%:Options%></th> - </tr> - - <% for _, rule in ipairs(ipt:find({table=tbl, chain=chain})) do %> - <tr class="cbi-section-table-row cbi-rowstyle-<%=rowstyle()%>"> - <td><%=rule.index%></td> - <td><%=rule.packets%></td> - <td><%=wba.byte_format(rule.bytes)%></td> - <td><%=rule.target and link_target(tbl, rule.target) or "-"%></td> - <td><%=rule.protocol%></td> - <td><%=rule.flags%></td> - <td><%=link_iface(rule.inputif)%></td> - <td><%=link_iface(rule.outputif)%></td> - <td><%=rule.source%></td> - <td><%=rule.destination%></td> - <td style="width:30%"><small><%=#rule.options > 0 and luci.util.pcdata(table.concat(rule.options, " ")) or "-"%></small></td> - </tr> - <% end %> - - <% if rowcnt == 1 then %> - <tr class="cbi-section-table-titles cbi-rowstyle-<%=rowstyle()%>"> - <td colspan="11"><em><%:No rules in this chain%></em></td> - </tr> - <% end %> - <% end %> - - <% if chaincnt == 0 then %> - <tr class="cbi-section-table-titles cbi-rowstyle-<%=rowstyle()%>"> - <td colspan="11"><em><%:No chains in this table%></em></td> - </tr> - <% end %> - </table> - <br /><br /> - <% end %> - </fieldset> - </div> -</form> - -<%+footer%> diff --git a/modules/admin-full/luasrc/view/admin_status/load.htm b/modules/admin-full/luasrc/view/admin_status/load.htm deleted file mode 100644 index a002715ec8..0000000000 --- a/modules/admin-full/luasrc/view/admin_status/load.htm +++ /dev/null @@ -1,291 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2010 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - --%> - -<%+header%> - -<script type="text/javascript" src="<%=resource%>/cbi.js"></script> -<script type="text/javascript">//<![CDATA[ - var bwxhr = new XHR(); - - var G; - var TIME = 0; - var L01 = 1; - var L05 = 2; - var L15 = 3; - - var width = 760; - var height = 300; - var step = 5; - - var data_wanted = Math.floor(width / step); - var data_fill = 0; - var data_stamp = 0; - - var data_01 = [ ]; - var data_05 = [ ]; - var data_15 = [ ]; - - var line_01; - var line_05; - var line_15; - - var label_25; - var label_050; - var label_75; - - var label_01_cur; - var label_01_avg; - var label_01_peak; - - var label_05_cur; - var label_05_avg; - var label_05_peak; - - var label_15_cur; - var label_15_avg; - var label_15_peak; - - var label_scale; - - - /* wait for SVG */ - window.setTimeout( - function() { - var svg = document.getElementById('bwsvg'); - - try { - G = svg.getSVGDocument - ? svg.getSVGDocument() : svg.contentDocument; - } - catch(e) { - G = document.embeds['bwsvg'].getSVGDocument(); - } - - if (!G) - { - window.setTimeout(arguments.callee, 1000); - } - else - { - /* find sizes */ - width = svg.offsetWidth - 2; - height = svg.offsetHeight - 2; - data_wanted = Math.ceil(width / step); - - /* prefill datasets */ - for (var i = 0; i < data_wanted; i++) - { - data_01[i] = 0; - data_05[i] = 0; - data_15[i] = 0; - } - - /* find svg elements */ - line_01 = G.getElementById('load01'); - line_05 = G.getElementById('load05'); - line_15 = G.getElementById('load15'); - - label_25 = G.getElementById('label_25'); - label_50 = G.getElementById('label_50'); - label_75 = G.getElementById('label_75'); - - label_01_cur = document.getElementById('lb_load01_cur'); - label_01_avg = document.getElementById('lb_load01_avg'); - label_01_peak = document.getElementById('lb_load01_peak'); - - label_05_cur = document.getElementById('lb_load05_cur'); - label_05_avg = document.getElementById('lb_load05_avg'); - label_05_peak = document.getElementById('lb_load05_peak'); - - label_15_cur = document.getElementById('lb_load15_cur'); - label_15_avg = document.getElementById('lb_load15_avg'); - label_15_peak = document.getElementById('lb_load15_peak'); - - label_scale = document.getElementById('scale'); - - - /* plot horizontal time interval lines */ - for (var i = width % (step * 60); i < width; i += step * 60) - { - var line = G.createElementNS('http://www.w3.org/2000/svg', 'line'); - line.setAttribute('x1', i); - line.setAttribute('y1', 0); - line.setAttribute('x2', i); - line.setAttribute('y2', '100%'); - line.setAttribute('style', 'stroke:black;stroke-width:0.1'); - - 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.appendChild(G.createTextNode(Math.round((width - i) / step / 60) + 'm')); - - label_25.parentNode.appendChild(line); - label_25.parentNode.appendChild(text); - } - - label_scale.innerHTML = String.format('<%:(%d minute window, %d second interval)%>', data_wanted / 60, 3); - - /* render datasets, start update interval */ - XHR.poll(3, '<%=build_url("admin/status/realtime/load_status")%>', null, - function(x, data) - { - var data_max = 0; - var data_scale = 0; - - var data_01_avg = 0; - var data_05_avg = 0; - var data_15_avg = 0; - - var data_01_peak = 0; - var data_05_peak = 0; - var data_15_peak = 0; - - for (var i = data_stamp ? 0 : 1; i < data.length; i++) - { - /* skip overlapping entries */ - if (data[i][TIME] <= data_stamp) - continue; - - data_01.push(data[i][L01]); - data_05.push(data[i][L05]); - data_15.push(data[i][L15]); - } - - /* cut off outdated entries */ - data_01 = data_01.slice(data_01.length - data_wanted, data_01.length); - data_05 = data_05.slice(data_05.length - data_wanted, data_05.length); - data_15 = data_15.slice(data_15.length - data_wanted, data_15.length); - - /* find peak */ - for (var i = 0; i < data_01.length; i++) - { - data_max = Math.max(data_max, data_01[i]); - data_max = Math.max(data_max, data_05[i]); - data_max = Math.max(data_max, data_15[i]); - - data_01_peak = Math.max(data_01_peak, data_01[i]); - data_05_peak = Math.max(data_05_peak, data_05[i]); - data_15_peak = Math.max(data_15_peak, data_15[i]); - - if (i > 0) - { - data_01_avg = (data_01_avg + data_01[i]) / 2; - data_05_avg = (data_05_avg + data_05[i]) / 2; - data_15_avg = (data_15_avg + data_15[i]) / 2; - } - else - { - data_01_avg = data_01[i]; - data_05_avg = data_05[i]; - data_15_avg = data_15[i]; - } - } - - /* remember current timestamp, calculate horizontal scale */ - data_stamp = data[data.length-1][TIME]; - data_scale = height / (data_max * 1.1); - - - /* plot data */ - var pt_01 = '0,' + height; - var pt_05 = '0,' + height; - var pt_15 = '0,' + height; - - var y_01 = 0; - var y_05 = 0; - var y_15 = 0; - - for (var i = 0; i < data_01.length; i++) - { - var x = i * step; - - y_01 = height - Math.floor(data_01[i] * data_scale); - y_05 = height - Math.floor(data_05[i] * data_scale); - y_15 = height - Math.floor(data_15[i] * data_scale); - - pt_01 += ' ' + x + ',' + y_01; - pt_05 += ' ' + x + ',' + y_05; - pt_15 += ' ' + x + ',' + y_15; - } - - pt_01 += ' ' + width + ',' + y_01 + ' ' + width + ',' + height; - pt_05 += ' ' + width + ',' + y_05 + ' ' + width + ',' + height; - pt_15 += ' ' + width + ',' + y_15 + ' ' + width + ',' + height; - - - line_01.setAttribute('points', pt_01); - line_05.setAttribute('points', pt_05); - line_15.setAttribute('points', pt_15); - - label_25.firstChild.data = (1.1 * 0.25 * data_max / 100).toFixed(2); - label_50.firstChild.data = (1.1 * 0.50 * data_max / 100).toFixed(2); - label_75.firstChild.data = (1.1 * 0.75 * data_max / 100).toFixed(2); - - label_01_cur.innerHTML = (data_01[data_01.length-1] / 100).toFixed(2); - label_05_cur.innerHTML = (data_05[data_05.length-1] / 100).toFixed(2); - label_15_cur.innerHTML = (data_15[data_15.length-1] / 100).toFixed(2); - - label_01_avg.innerHTML = (data_01_avg / 100).toFixed(2); - label_05_avg.innerHTML = (data_05_avg / 100).toFixed(2); - label_15_avg.innerHTML = (data_15_avg / 100).toFixed(2); - - label_01_peak.innerHTML = (data_01_peak / 100).toFixed(2); - label_05_peak.innerHTML = (data_05_peak / 100).toFixed(2); - label_15_peak.innerHTML = (data_15_peak / 100).toFixed(2); - } - ); - } - }, 1000 - ); -//]]></script> - -<h2><a id="content" name="content"><%:Realtime Load%></a></h2> - -<embed id="bwsvg" style="width:100%; height:300px; border:1px solid #000000; background-color:#FFFFFF" src="<%=resource%>/load.svg" /> -<div style="text-align:right"><small id="scale">-</small></div> -<br /> - -<table style="width:100%; table-layout:fixed" cellspacing="5"> - <tr> - <td style="text-align:right; vertical-align:top"><strong style="border-bottom:2px solid #ff0000; white-space:nowrap"><%:1 Minute Load:%></strong></td> - <td id="lb_load01_cur">0</td> - - <td style="text-align:right; vertical-align:top"><strong><%:Average:%></strong></td> - <td id="lb_load01_avg">0</td> - - <td style="text-align:right; vertical-align:top"><strong><%:Peak:%></strong></td> - <td id="lb_load01_peak">0</td> - </tr> - <tr> - <td style="text-align:right; vertical-align:top"><strong style="border-bottom:2px solid #ff6600; white-space:nowrap"><%:5 Minute Load:%></strong></td> - <td id="lb_load05_cur">0</td> - - <td style="text-align:right; vertical-align:top"><strong><%:Average:%></strong></td> - <td id="lb_load05_avg">0</td> - - <td style="text-align:right; vertical-align:top"><strong><%:Peak:%></strong></td> - <td id="lb_load05_peak">0</td> - </tr> - <tr> - <td style="text-align:right; vertical-align:top"><strong style="border-bottom:2px solid #ffaa00; white-space:nowrap"><%:15 Minute Load:%></strong></td> - <td id="lb_load15_cur">0</td> - - <td style="text-align:right; vertical-align:top"><strong><%:Average:%></strong></td> - <td id="lb_load15_avg">0</td> - - <td style="text-align:right; vertical-align:top"><strong><%:Peak:%></strong></td> - <td id="lb_load15_peak">0</td> - </tr> -</table> - -<%+footer%> diff --git a/modules/admin-full/luasrc/view/admin_status/routes.htm b/modules/admin-full/luasrc/view/admin_status/routes.htm deleted file mode 100644 index 4e7287b705..0000000000 --- a/modules/admin-full/luasrc/view/admin_status/routes.htm +++ /dev/null @@ -1,107 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2008-2009 Steven Barth <steven@midlink.org> -Copyright 2008-2009 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ - --%> - -<%- - require "bit" - require "luci.sys" - require "luci.tools.webadmin" - require "nixio.fs" - - local style = true --%> - -<%+header%> - -<div class="cbi-map" id="cbi-network"> - <h2><a id="content" name="content"><%:Routes%></a></h2> - <div class="cbi-map-descr"><%:The following rules are currently active on this system.%></div> - - <fieldset class="cbi-section" id="cbi-table-table"> - <legend>ARP</legend> - <div class="cbi-section-node"> - <table class="cbi-section-table"> - <tr class="cbi-section-table-titles"> - <th class="cbi-section-table-cell"><%_<abbr title="Internet Protocol Version 4">IPv4</abbr>-Address%></th> - <th class="cbi-section-table-cell"><%_<abbr title="Media Access Control">MAC</abbr>-Address%></th> - <th class="cbi-section-table-cell"><%:Interface%></th> - </tr> - - <% luci.sys.net.arptable(function(e) %> - <tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>"> - <td class="cbi-value-field"><%=e["IP address"]%></td> - <td class="cbi-value-field"><%=e["HW address"]%></td> - <td class="cbi-value-field"><%=e["Device"]%></td> - </tr> - <% style = not style; end) %> - </table> - </div> - </fieldset> - <br /> - - <fieldset class="cbi-section" id="cbi-table-table"> - <legend><%_Active <abbr title="Internet Protocol Version 4">IPv4</abbr>-Routes%></legend> - - <div class="cbi-section-node"> - <table class="cbi-section-table"> - <tr class="cbi-section-table-titles"> - <th class="cbi-section-table-cell"><%:Network%></th> - <th class="cbi-section-table-cell"><%:Target%></th> - <th class="cbi-section-table-cell"><%_<abbr title="Internet Protocol Version 4">IPv4</abbr>-Gateway%></th> - <th class="cbi-section-table-cell"><%:Metric%></th> - </tr> - <% luci.sys.net.routes(function(rt) %> - <tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>"> - <td class="cbi-value-field"><%=luci.tools.webadmin.iface_get_network(rt.device) or rt.device%></td> - <td class="cbi-value-field"><%=rt.dest:string()%></td> - <td class="cbi-value-field"><%=rt.gateway:string()%></td> - <td class="cbi-value-field"><%=rt.metric%></td> - </tr> - <% style = not style; end) %> - </table> - </div> - </fieldset> - <br /> - - <% if nixio.fs.access("/proc/net/ipv6_route") then - style = true - fe80 = luci.ip.IPv6("fe80::/10") - %> - <fieldset class="cbi-section" id="cbi-table-table"> - <legend><%_Active <abbr title="Internet Protocol Version 6">IPv6</abbr>-Routes%></legend> - - <div class="cbi-section-node"> - <table class="cbi-section-table"> - <tr class="cbi-section-table-titles"> - <th class="cbi-section-table-cell"><%:Network%></th> - <th class="cbi-section-table-cell"><%:Target%></th> - <th class="cbi-section-table-cell"><%_<abbr title="Internet Protocol Version 6">IPv6</abbr>-Gateway%></th> - <th class="cbi-section-table-cell"><%:Metric%></th> - </tr> - <% luci.sys.net.routes6(function(rt) if fe80:contains(rt.dest) then return end %> - <tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>"> - <td class="cbi-value-field"><%=luci.tools.webadmin.iface_get_network(rt.device) or '(' .. rt.device .. ')'%></td> - <td class="cbi-value-field"><%=rt.dest:string()%></td> - <td class="cbi-value-field"><%=rt.source:string()%></td> - <td class="cbi-value-field"><%=rt.metric_raw:upper()%></td> - </tr> - <% style = not style; end) %> - </table> - </div> - </fieldset> - <br /> - <% end %> -</div> - -<%+footer%> diff --git a/modules/admin-full/luasrc/view/admin_status/syslog.htm b/modules/admin-full/luasrc/view/admin_status/syslog.htm deleted file mode 100644 index 06aeeb01a6..0000000000 --- a/modules/admin-full/luasrc/view/admin_status/syslog.htm +++ /dev/null @@ -1,20 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ - --%> -<%+header%> -<h2><a id="content" name="content"><%:System Log%></a></h2> -<div id="content_syslog"> -<textarea readonly="readonly" wrap="off" rows="<%=syslog:cmatch("\n")+2%>" id="syslog"><%=syslog:pcdata()%></textarea> -</div> -<%+footer%> diff --git a/modules/admin-full/luasrc/view/admin_status/wireless.htm b/modules/admin-full/luasrc/view/admin_status/wireless.htm deleted file mode 100644 index 465143ebce..0000000000 --- a/modules/admin-full/luasrc/view/admin_status/wireless.htm +++ /dev/null @@ -1,378 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2011 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - --%> - -<%- - local ntm = require "luci.model.network".init() - - local dev - local devices = { } - for _, dev in luci.util.vspairs(luci.sys.net.devices()) do - if dev:match("^wlan%d") or dev:match("^ath%d") or dev:match("^wl%d") then - devices[#devices+1] = dev - end - end - - local curdev = luci.dispatcher.context.requestpath - curdev = curdev[#curdev] ~= "wireless" and curdev[#curdev] or devices[1] --%> - -<%+header%> - -<script type="text/javascript" src="<%=resource%>/cbi.js"></script> -<script type="text/javascript">//<![CDATA[ - var bwxhr = new XHR(); - - var G, G2; - var TIME = 0; - var RATE = 1; - var RSSI = 2; - var NOISE = 3; - - var width = 760; - var height = 300; - var step = 5; - - var data_wanted = Math.floor(width / step); - var data_fill = 0; - var data_stamp = 0; - - var data_rssi = [ ]; - var data_noise = [ ]; - var data_rate = [ ]; - - var line_rssi; - var line_noise; - var line_rate; - - var label_25, label_25_2; - var label_50, label_50_2; - var label_75, label_75_2; - - var label_rssi_cur; - var label_rssi_avg; - var label_rssi_peak; - - var label_noise_cur; - var label_noise_avg; - var label_noise_peak; - - var label_rate_cur; - var label_rate_avg; - var label_rate_peak; - - var label_scale; - - - /* wait for SVG */ - window.setTimeout( - function() { - var svg = document.getElementById('iwsvg'); - var svg2 = document.getElementById('iwsvg2'); - - try { - G = svg.getSVGDocument - ? svg.getSVGDocument() : svg.contentDocument; - G2 = svg2.getSVGDocument - ? svg2.getSVGDocument() : svg2.contentDocument; - } - catch(e) { - G = document.embeds['iwsvg'].getSVGDocument(); - G2 = document.embeds['iwsvg2'].getSVGDocument(); - } - - if (!G || !G2) - { - window.setTimeout(arguments.callee, 1000); - } - else - { - /* find sizes */ - width = svg.offsetWidth - 2; - height = svg.offsetHeight - 2; - data_wanted = Math.ceil(width / step); - - /* prefill datasets */ - for (var i = 0; i < data_wanted; i++) - { - data_rssi[i] = 0; - data_noise[i] = 0; - data_rate[i] = 0; - } - - /* find svg elements */ - line_rssi = G.getElementById('rssi'); - line_noise = G.getElementById('noise'); - line_rate = G2.getElementById('rate'); - - label_25 = G.getElementById('label_25'); - label_50 = G.getElementById('label_50'); - label_75 = G.getElementById('label_75'); - label_25_2 = G2.getElementById('label_25'); - label_50_2 = G2.getElementById('label_50'); - label_75_2 = G2.getElementById('label_75'); - - label_rssi_cur = document.getElementById('rssi_bw_cur'); - label_rssi_avg = document.getElementById('rssi_bw_avg'); - label_rssi_peak = document.getElementById('rssi_bw_peak'); - - label_noise_cur = document.getElementById('noise_bw_cur'); - label_noise_avg = document.getElementById('noise_bw_avg'); - label_noise_peak = document.getElementById('noise_bw_peak'); - - label_rate_cur = document.getElementById('rate_bw_cur'); - label_rate_avg = document.getElementById('rate_bw_avg'); - label_rate_peak = document.getElementById('rate_bw_peak'); - - label_scale = document.getElementById('scale'); - label_scale_2 = document.getElementById('scale2'); - - - /* plot horizontal time interval lines */ - for (var i = width % (step * 60); i < width; i += step * 60) - { - var line = G.createElementNS('http://www.w3.org/2000/svg', 'line'); - line.setAttribute('x1', i); - line.setAttribute('y1', 0); - line.setAttribute('x2', i); - line.setAttribute('y2', '100%'); - line.setAttribute('style', 'stroke:black;stroke-width:0.1'); - - 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.appendChild(G.createTextNode(Math.round((width - i) / step / 60) + 'm')); - - label_25.parentNode.appendChild(line); - label_25.parentNode.appendChild(text); - - - var line2 = G2.createElementNS('http://www.w3.org/2000/svg', 'line'); - line2.setAttribute('x1', i); - line2.setAttribute('y1', 0); - line2.setAttribute('x2', i); - line2.setAttribute('y2', '100%'); - line2.setAttribute('style', 'stroke:black;stroke-width:0.1'); - - 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.appendChild(G.createTextNode(Math.round((width - i) / step / 60) + 'm')); - - label_25_2.parentNode.appendChild(line2); - label_25_2.parentNode.appendChild(text2); - } - - label_scale.innerHTML = String.format('<%:(%d minute window, %d second interval)%>', data_wanted / 60, 3); - label_scale_2.innerHTML = String.format('<%:(%d minute window, %d second interval)%>', data_wanted / 60, 3); - - /* render datasets, start update interval */ - XHR.poll(3, '<%=build_url("admin/status/realtime/wireless_status", curdev)%>', null, - function(x, data) - { - var noise_floor = 255; - var rate_floor = 60000; - - for (var i = 0; i < data.length; i++) { - noise_floor = Math.min(noise_floor, data[i][NOISE]); - rate_floor = Math.min(rate_floor, data[i][RATE]); - } - - noise_floor -= 5; - - var data_max = 0; - var data_scale = 0; - var data_max_2 = 0; - var data_scale_2 = 0; - - var data_rssi_avg = 0; - var data_noise_avg = 0; - var data_rate_avg = 0; - - var data_rssi_peak = 0; - var data_noise_peak = 0; - var data_rate_peak = 0; - - for (var i = data_stamp ? 0 : 1; i < data.length; i++) - { - /* skip overlapping entries */ - if (data[i][TIME] <= data_stamp) - continue; - - data_rssi.push(data[i][RSSI] - noise_floor); - data_noise.push(data[i][NOISE] - noise_floor); - data_rate.push(Math.floor(data[i][RATE] / 1000)); - } - - /* cut off outdated entries */ - data_rssi = data_rssi.slice(data_rssi.length - data_wanted, data_rssi.length); - data_noise = data_noise.slice(data_noise.length - data_wanted, data_noise.length); - data_rate = data_rate.slice(data_rate.length - data_wanted, data_rate.length); - - /* find peak */ - for (var i = 0; i < data_rssi.length; i++) - { - data_max = Math.max(data_max, data_rssi[i]); - data_max_2 = Math.max(data_max_2, data_rate[i]); - - data_rssi_peak = Math.max(data_rssi_peak, data_rssi[i]); - data_noise_peak = Math.max(data_noise_peak, data_noise[i]); - data_rate_peak = Math.max(data_rate_peak, data_rate[i]); - - if (i > 0) - { - data_rssi_avg = (data_rssi_avg + data_rssi[i]) / 2; - data_noise_avg = (data_noise_avg + data_noise[i]) / 2; - data_rate_avg = (data_rate_avg + data_rate[i]) / 2; - } - else - { - data_rssi_avg = data_rssi[i]; - data_noise_avg = data_noise[i]; - data_rate_avg = data_rate[i]; - } - } - - /* remember current timestamp, calculate horizontal scale */ - data_stamp = data[data.length-1][TIME]; - data_scale = (height / (data_max * 1.1)).toFixed(1); - data_scale_2 = (height / (data_max_2 * 1.1)).toFixed(1); - - /* plot data */ - var pt_rssi = '0,' + height; - var pt_noise = '0,' + height; - var pt_rate = '0,' + height; - - var y_rssi = 0; - var y_noise = 0; - var y_rate = 0; - - for (var i = 0; i < data_rssi.length; i++) - { - var x = i * step; - - y_rssi = height - Math.floor(data_rssi[i] * data_scale); - y_noise = height - Math.floor(data_noise[i] * data_scale); - y_rate = height - Math.floor(data_rate[i] * data_scale_2); - - y_rssi -= Math.floor(y_rssi % (1/data_scale)); - y_noise -= Math.floor(y_noise % (1/data_scale)); - - pt_rssi += ' ' + x + ',' + y_rssi; - pt_noise += ' ' + x + ',' + y_noise; - pt_rate += ' ' + x + ',' + y_rate; - } - - pt_rssi += ' ' + width + ',' + y_rssi + ' ' + width + ',' + height; - pt_noise += ' ' + width + ',' + y_noise + ' ' + width + ',' + height; - pt_rate += ' ' + width + ',' + y_rate + ' ' + width + ',' + height; - - line_rssi.setAttribute('points', pt_rssi); - line_noise.setAttribute('points', pt_noise); - line_rate.setAttribute('points', pt_rate); - - function wireless_label(dbm, noise) - { - if (noise) - return String.format("%d <%:dBm%> (SNR %d <%:dBm%>)", noise_floor + dbm - 255, dbm - noise); - else - return String.format("%d <%:dBm%>", noise_floor + dbm - 255); - } - - function rate_label(mbit) - { - return String.format("%d <%:Mbit/s%>", mbit); - } - - label_25.firstChild.data = wireless_label(1.1 * 0.25 * data_max); - label_50.firstChild.data = wireless_label(1.1 * 0.50 * data_max); - label_75.firstChild.data = wireless_label(1.1 * 0.75 * data_max); - - label_25_2.firstChild.data = rate_label(1.1 * 0.25 * data_max_2); - label_50_2.firstChild.data = rate_label(1.1 * 0.50 * data_max_2); - label_75_2.firstChild.data = rate_label(1.1 * 0.75 * data_max_2); - - label_rssi_cur.innerHTML = wireless_label(data_rssi[data_rssi.length-1], data_noise[data_noise.length-1]).nobr(); - label_noise_cur.innerHTML = wireless_label(data_noise[data_noise.length-1]).nobr(); - - label_rssi_avg.innerHTML = wireless_label(data_rssi_avg, data_noise_avg).nobr(); - label_noise_avg.innerHTML = wireless_label(data_noise_avg).nobr(); - - label_rssi_peak.innerHTML = wireless_label(data_rssi_peak, data_noise_peak).nobr(); - label_noise_peak.innerHTML = wireless_label(data_noise_peak).nobr(); - - label_rate_cur.innerHTML = rate_label(data_rate[data_rate.length-1]); - label_rate_avg.innerHTML = rate_label(data_rate_avg); - label_rate_peak.innerHTML = rate_label(data_rate_peak); - } - ); - } - }, 1000 - ); -//]]></script> - -<h2><a id="content" name="content"><%:Realtime Wireless%></a></h2> - -<ul class="cbi-tabmenu"> - <% for _, dev in ipairs(devices) do %> - <li class="cbi-tab<%= dev == curdev and "" or "-disabled" %>"><a href="<%=pcdata(dev)%>"><%=pcdata(dev)%></a></li> - <% end %> -</ul> - -<embed id="iwsvg" style="width:100%; height:300px; border:1px solid #000000; background-color:#FFFFFF" src="<%=resource%>/wireless.svg" /> -<div style="text-align:right"><small id="scale">-</small></div> -<br /> - -<table style="width:100%; table-layout:fixed" cellspacing="5"> - <tr> - <td style="text-align:right; vertical-align:top"><strong style="border-bottom:2px solid blue"><%:Signal:%></strong></td> - <td id="rssi_bw_cur">0 <%:dBm%></td> - - <td style="text-align:right; vertical-align:top"><strong><%:Average:%></strong></td> - <td id="rssi_bw_avg">0 <%:dBm%></td> - - <td style="text-align:right; vertical-align:top"><strong><%:Peak:%></strong></td> - <td id="rssi_bw_peak">0 <%:dBm%></td> - </tr> - <tr> - <td style="text-align:right; vertical-align:top"><strong style="border-bottom:2px solid red"><%:Noise:%></strong></td> - <td id="noise_bw_cur">0 <%:dBm%></td> - - <td style="text-align:right; vertical-align:top"><strong><%:Average:%></strong></td> - <td id="noise_bw_avg">0 <%:dBm%></td> - - <td style="text-align:right; vertical-align:top"><strong><%:Peak:%></strong></td> - <td id="noise_bw_peak">0 <%:dBm%></td> - </tr> -</table> - -<br /> - -<embed id="iwsvg2" style="width:100%; height:300px; border:1px solid #000000; background-color:#FFFFFF" src="<%=resource%>/wifirate.svg" /> -<div style="text-align:right"><small id="scale2">-</small></div> -<br /> - -<table style="width:100%; table-layout:fixed" cellspacing="5"> - <tr> - <td style="text-align:right; vertical-align:top"><strong style="border-bottom:2px solid green"><%:Phy Rate:%></strong></td> - <td id="rate_bw_cur">0 MBit/s</td> - - <td style="text-align:right; vertical-align:top"><strong><%:Average:%></strong></td> - <td id="rate_bw_avg">0 MBit/s</td> - - <td style="text-align:right; vertical-align:top"><strong><%:Peak:%></strong></td> - <td id="rate_bw_peak">0 MBit/s</td> - </tr> -</table> - -<%+footer%> diff --git a/modules/admin-full/luasrc/view/admin_system/applyreboot.htm b/modules/admin-full/luasrc/view/admin_system/applyreboot.htm deleted file mode 100644 index 56721a6104..0000000000 --- a/modules/admin-full/luasrc/view/admin_system/applyreboot.htm +++ /dev/null @@ -1,50 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ - --%> - -<html> - <head> - <title><%=luci.sys.hostname()%> - <% if title then %><%=title%><% else %><%:Rebooting...%><% end %></title> - <link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/cascade.css" /> - <script type="text/javascript" src="<%=resource%>/xhr.js"></script> - <script type="text/javascript">//<![CDATA[ - var interval = window.setInterval(function() { - var img = new Image(); - - img.onload = function() { - window.clearInterval(interval); - location.href = ('https:' == document.location.protocol ? 'https://' : 'http://') + '<%=addr or luci.http.getenv("SERVER_NAME")%>/'; - }; - - img.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + '<%=addr or luci.http.getenv("SERVER_NAME")%><%=resource%>/icons/loading.gif?' + Math.random(); - }, 5000); - //]]></script> - </head> - <body> - <div id="maincontainer"> - <div id="maincontent"> - <h2><a id="content" name="content"><%:System%> - <% if title then %><%=title%><% else %><%:Rebooting...%><% end %></a></h2> - <fieldset class="cbi-section"> - <p> - <% if msg then %><%=msg%><% else %><%:Changes applied.%><% end %> - </p> - <p> - <img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> - <%:Waiting for changes to be applied...%> - </p> - </fieldset> - </div> - </div> - </body> -</html> diff --git a/modules/admin-full/luasrc/view/admin_system/backupfiles.htm b/modules/admin-full/luasrc/view/admin_system/backupfiles.htm deleted file mode 100644 index 38b5f03a14..0000000000 --- a/modules/admin-full/luasrc/view/admin_system/backupfiles.htm +++ /dev/null @@ -1,19 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ - --%> - -<ul class="cbi-tabmenu"> - <li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/system/flashops")%>"><%:Actions%></a></li> - <li class="cbi-tab"><a href="#"><%:Configuration%></a></li> -</ul> diff --git a/modules/admin-full/luasrc/view/admin_system/clock_status.htm b/modules/admin-full/luasrc/view/admin_system/clock_status.htm deleted file mode 100644 index 84e151075f..0000000000 --- a/modules/admin-full/luasrc/view/admin_system/clock_status.htm +++ /dev/null @@ -1,36 +0,0 @@ -<%+cbi/valueheader%> - -<script type="text/javascript">//<![CDATA[ - XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "system", "clock_status")%>', null, - function(x, rv) - { - var s = document.getElementById('<%=self.option%>-clock-status'); - if (s) - { - s.innerHTML = rv.timestring || '?'; - } - } - ); - - function sync_clock(btn) - { - btn.disabled = true; - btn.value = '<%:Synchronizing...%>'; - - XHR.get('<%=luci.dispatcher.build_url("admin", "system", "clock_status")%>', - { set: Math.floor((new Date()).getTime() / 1000) }, - function() - { - btn.disabled = false; - btn.value = '<%:Sync with browser%>'; - } - ); - - return false; - } -//]]></script> - -<span id="<%=self.option%>-clock-status"><em><%:Collecting data...%></em></span> -<input type="button" class="cbi-button cbi-button-apply" value="<%:Sync with browser%>" onclick="return sync_clock(this)" /> - -<%+cbi/valuefooter%> diff --git a/modules/admin-full/luasrc/view/admin_system/flashops.htm b/modules/admin-full/luasrc/view/admin_system/flashops.htm deleted file mode 100644 index debc796e89..0000000000 --- a/modules/admin-full/luasrc/view/admin_system/flashops.htm +++ /dev/null @@ -1,94 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ - --%> - -<%+header%> - -<h2><a id="content" name="content"><%:Flash operations%></a></h2> - -<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> -</ul> - -<fieldset class="cbi-section"> - - <fieldset class="cbi-section"> - <legend><%:Backup / Restore%></legend> - <form method="post" action="<%=REQUEST_URI%>" enctype="multipart/form-data"> - <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> - <div class="cbi-section-node"> - <div class="cbi-value<% if not reset_avail then %> cbi-value-last<% end %>"> - <label class="cbi-value-title" for="image"><%:Download backup%>:</label> - <div class="cbi-value-field"> - <input class="cbi-button cbi-button-apply" type="submit" name="backup" value="<%:Generate archive%>" /> - </div> - </div> - <% if reset_avail then %> - <div class="cbi-value cbi-value-last"> - <label class="cbi-value-title"><%:Reset to defaults%>:</label> - <div class="cbi-value-field"> - <input onclick="return confirm('<%:Really reset all changes?%>')" class="cbi-button cbi-button-reset" type="submit" name="reset" value="<%:Perform reset%>" /> - </div> - </div> - <% end %> - </div> - <br /> - <div class="cbi-section-descr"><%:To restore configuration files, you can upload a previously generated backup archive here.%></div> - <div class="cbi-section-node"> - <div class="cbi-value cbi-value-last"> - <label class="cbi-value-title" for="archive"><%:Restore backup%>:</label> - <div class="cbi-value-field"> - <input type="file" name="archive" id="archive" /> - <input type="submit" class="cbi-button cbi-input-apply" name="restore" value="<%:Upload archive...%>" /> - </div> - </div> - </div> - </form> - </fieldset> - - <br /> - - <fieldset class="cbi-section"> - <legend><%:Flash new firmware image%></legend> - <% if upgrade_avail then %> - <form method="post" action="<%=REQUEST_URI%>" enctype="multipart/form-data"> - <div class="cbi-section-descr"><%:Upload a sysupgrade-compatible image here to replace the running firmware. Check "Keep settings" to retain the current configuration (requires an OpenWrt compatible firmware image).%></div> - <div class="cbi-section-node"> - <div class="cbi-value"> - <label class="cbi-value-title" for="keep"><%:Keep settings%>:</label> - <div class="cbi-value-field"> - <input type="checkbox" name="keep" id="keep" checked="checked" /> - </div> - </div> - <div class="cbi-value cbi-value-last<% if image_invalid then %> cbi-value-error<% end %>"> - <label class="cbi-value-title" for="image"><%:Image%>:</label> - <div class="cbi-value-field"> - <input type="file" name="image" id="image" /> - <input type="submit" class="cbi-button cbi-input-apply" value="<%:Flash image...%>" /> - </div> - </div> - </div> - <% if image_invalid then %> - <div class="cbi-section-error"><%:The uploaded image file does not contain a supported format. Make sure that you choose the generic image format for your platform. %></div> - <% end %> - </form> - <% else %> - <div class="cbi-section-descr"><%:Sorry, there is no sysupgrade support present; a new firmware image must be flashed manually. Please refer to the OpenWrt wiki for device specific install instructions.%></div> - <% end %> - </fieldset> - -</fieldset> - -<%+footer%> diff --git a/modules/admin-full/luasrc/view/admin_system/ipkg.htm b/modules/admin-full/luasrc/view/admin_system/ipkg.htm deleted file mode 100644 index 7f0956cfde..0000000000 --- a/modules/admin-full/luasrc/view/admin_system/ipkg.htm +++ /dev/null @@ -1,19 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ - --%> - -<ul class="cbi-tabmenu"> - <li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/system/packages")%>"><%:Actions%></a></li> - <li class="cbi-tab"><a href="#"><%:Configuration%></a></li> -</ul> diff --git a/modules/admin-full/luasrc/view/admin_system/packages.htm b/modules/admin-full/luasrc/view/admin_system/packages.htm deleted file mode 100644 index 00b4be4868..0000000000 --- a/modules/admin-full/luasrc/view/admin_system/packages.htm +++ /dev/null @@ -1,200 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2008-2010 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - --%> -<%- -local bit = require "bit" -local opkg = require "luci.model.ipkg" -local fs = require "nixio.fs" -local wa = require "luci.tools.webadmin" -local rowcnt = 1 - -function rowstyle() - rowcnt = rowcnt + 1 - return (rowcnt % 2) + 1 -end - -local fstat = fs.statvfs(opkg.overlay_root()) -local space_total = fstat and fstat.blocks or 0 -local space_free = fstat and fstat.bfree or 0 -local space_used = space_total - space_free - -local used_perc = math.floor(0.5 + ((space_total > 0) and ((100 / space_total) * space_used) or 100)) -local free_byte = space_free * fstat.frsize - -local filter = { } - - -local opkg_list = luci.model.ipkg.list_all -local querypat -if query and #query > 0 then - querypat = '*%s*' % query - opkg_list = luci.model.ipkg.find -end - -local letterpat -if letter == 35 then - letterpat = "[^a-z]*" -else - letterpat = string.char(letter, 42) -- 'A' '*' -end - --%> - -<%+header%> - -<h2><a id="content" name="content"><%:Software%></a></h2> - -<form method="post" action="<%=REQUEST_URI%>"> - <div class="cbi-map"> - - <ul class="cbi-tabmenu"> - <li class="cbi-tab"><a href="#"><%:Actions%></a></li> - <li class="cbi-tab-disabled"><a href="<%=REQUEST_URI%>/ipkg"><%:Configuration%></a></li> - </ul> - - <fieldset class="cbi-section"> - - - <fieldset class="cbi-section-node"> - <% if (install and next(install)) or (remove and next(remove)) or update or upgrade then %> - <div class="cbi-value"> - <% if #stdout > 0 then %><pre><%=pcdata(stdout)%></pre><% end %> - <% if #stderr > 0 then %><pre class="error"><%=pcdata(stderr)%></pre><% end %> - </div> - <% end %> - - <% if querypat then %> - <div class="cbi-value"> - <%:Displaying only packages containing%> <strong>"<%=pcdata(query)%>"</strong> - <input type="button" onclick="location.href='?display=<%=pcdata(display)%>'" href="#" class="cbi-button cbi-button-reset" style="margin-left:1em" value="<%:Reset%>" /> - <br style="clear:both" /> - </div> - <% end %> - - <% if no_lists or old_lists then %> - <div class="cbi-value"> - <% if old_lists then %> - <%:Package lists are older than 24 hours%> - <% else %> - <%:No package lists available%> - <% end %> - <input type="button" onclick="location.href='?update=1'" href="#" class="cbi-button cbi-button-apply" style="margin-left:3em" value="<%:Update lists%>" /> - </div> - <% end %> - - <div class="cbi-value cbi-value-last"> - <%:Free space%>: <strong><%=(100-used_perc)%>%</strong> (<strong><%=wa.byte_format(free_byte)%></strong>) - <div style="margin:3px 0; width:300px; height:10px; border:1px solid #000000; background-color:#80C080"> - <div style="background-color:#F08080; border-right:1px solid #000000; height:100%; width:<%=used_perc%>%"> </div> - </div> - </div> - </fieldset> - - <br /> - - <fieldset class="cbi-section-node"> - <input type="hidden" name="display" value="<%=pcdata(display)%>" /> - - <div class="cbi-value"> - <label class="cbi-value-title"><%:Download and install package%>:</label> - <div class="cbi-value-field"> - <input type="text" name="url" size="30" value="" /> - <input class="cbi-button cbi-input-save" type="submit" name="submit" value="<%:OK%>" /> - </div> - </div> - - <div class="cbi-value cbi-value-last"> - <label class="cbi-value-title"><%:Filter%>:</label> - <div class="cbi-value-field"> - <input type="text" name="query" size="20" value="<%=pcdata(query)%>" /> - <input type="submit" class="cbi-button cbi-input-find" name="search" value="<%:Find package%>" /> - </div> - </div> - </fieldset> - </fieldset> - <br /> - - <h3><%:Status%></h3> - - - <ul class="cbi-tabmenu"> - <li class="cbi-tab<% if display ~= "installed" then %>-disabled<% end %>"><a href="?display=installed&query=<%=pcdata(query)%>"><%:Installed packages%><% if query then %> (<%=pcdata(query)%>)<% end %></a></li> - <li class="cbi-tab<% if display ~= "available" then %>-disabled<% end %>"><a href="?display=available&query=<%=pcdata(query)%>"><%:Available packages%><% if query then %> (<%=pcdata(query)%>)<% end %></a></li> - </ul> - - <% if display ~= "available" then %> - <fieldset class="cbi-section"> - <table class="cbi-section-table" style="width:100%"> - <tr class="cbi-section-table-titles"> - <th class="cbi-section-table-cell" style="text-align:left"> </th> - <th class="cbi-section-table-cell" style="text-align:left"><%:Package name%></th> - <th class="cbi-section-table-cell" style="text-align:left"><%:Version%></th> - </tr> - <% local empty = true; luci.model.ipkg.list_installed(querypat, function(n, v, d) empty = false; filter[n] = true %> - <tr class="cbi-section-table-row cbi-rowstyle-<%=rowstyle()%>"> - <td style="text-align:left; width:10%"><a onclick="return window.confirm('<%:Remove%> "<%=luci.util.pcdata(n)%>" ?')" href="<%=REQUEST_URI%>?submit=1&remove=<%=luci.util.pcdata(n)%>"><%:Remove%></a></td> - <td style="text-align:left"><%=luci.util.pcdata(n)%></td> - <td style="text-align:left"><%=luci.util.pcdata(v)%></td> - </tr> - <% end) %> - <% if empty then %> - <tr class="cbi-section-table-row"> - <td style="text-align:left"> </td> - <td style="text-align:left"><em><%:none%></em></td> - <td style="text-align:left"><em><%:none%></em></td> - </tr> - <% end %> - </table> - </fieldset> - <% else %> - <fieldset class="cbi-section"> - <% if not querypat then %> - <ul class="cbi-tabmenu"> - <% local i; for i = 65, 90 do %> - <li class="cbi-tab<% if letter ~= i then %>-disabled<% end %>"><a href="?display=available&letter=<%=string.char(i)%>"><%=string.char(i)%></a></li> - <% end %> - <li class="cbi-tab<% if letter ~= 35 then %>-disabled<% end %>"><a href="?display=available&letter=%23">#</a></li> - </ul> - <div class="cbi-section-node"> - <% end %> - <table class="cbi-section-table" style="width:100%"> - <tr class="cbi-section-table-titles"> - <th class="cbi-section-table-cell" style="text-align:left"> </th> - <th class="cbi-section-table-cell" style="text-align:left"><%:Package name%></th> - <th class="cbi-section-table-cell" style="text-align:left"><%:Version%></th> - <th class="cbi-section-table-cell" style="text-align:left"><%:Description%></th> - </tr> - <% local empty = true; opkg_list(querypat or letterpat, function(n, v, d) if filter[n] then return end; empty = false %> - <tr class="cbi-section-table-row cbi-rowstyle-<%=rowstyle()%>"> - <td style="text-align:left; width:10%"><a onclick="return window.confirm('<%:Install%> "<%=luci.util.pcdata(n)%>" ?')" href="<%=REQUEST_URI%>?submit=1&install=<%=luci.util.pcdata(n)%>"><%:Install%></a></td> - <td style="text-align:left"><%=luci.util.pcdata(n)%></td> - <td style="text-align:left"><%=luci.util.pcdata(v)%></td> - <td style="text-align:left"><%=luci.util.pcdata(d)%></td> - </tr> - <% end) %> - <% if empty then %> - <tr class="cbi-section-table-row"> - <td style="text-align:left"> </td> - <td style="text-align:left"><em><%:none%></em></td> - <td style="text-align:left"><em><%:none%></em></td> - <td style="text-align:left"><em><%:none%></em></td> - </tr> - <% end %> - </table> - <% if not querypat then %> - </div> - <% end %> - </fieldset> - <% end %> - </div> -</form> -<%+footer%> diff --git a/modules/admin-full/luasrc/view/admin_system/reboot.htm b/modules/admin-full/luasrc/view/admin_system/reboot.htm deleted file mode 100644 index 5f2912d925..0000000000 --- a/modules/admin-full/luasrc/view/admin_system/reboot.htm +++ /dev/null @@ -1,33 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ - --%> -<%+header%> -<h2><a id="content" name="content"><%:System%></a></h2> -<h3><%:Reboot%></h3> -<p><%:Reboots the operating system of your device%></p> -<%- -local c = require("luci.model.uci").cursor():changes() -if c and next(c) then --%> - <p class="warning"><%:Warning: There are unsaved changes that will be lost while rebooting!%></p> -<%- -end -if not reboot then --%> -<p><a href="<%=controller%>/admin/system/reboot?reboot=1"><%:Perform reboot%></a></p> -<%- else -%> -<p><%:Please wait: Device rebooting...%></p> -<script type="text/javascript">setTimeout("location='<%=controller%>/admin'", 60000)</script> -<%- end -%> -<%+footer%>
\ No newline at end of file diff --git a/modules/admin-full/luasrc/view/admin_system/upgrade.htm b/modules/admin-full/luasrc/view/admin_system/upgrade.htm deleted file mode 100644 index ce285332eb..0000000000 --- a/modules/admin-full/luasrc/view/admin_system/upgrade.htm +++ /dev/null @@ -1,67 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2008-2009 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ - --%> - -<%+header%> - -<h2><a id="content" name="content"><%:Flash Firmware%> - <%:Verify%></a></h2> -<p> - <%_ The flash image was uploaded. - Below is the checksum and file size listed, - compare them with the original file to ensure data integrity.<br /> - Click "Proceed" below to start the flash procedure. %> - - <% if storage > 0 and size > storage then %> - <br /><br /> - <div class="error"><%:It appears that you are trying to - flash an image that does not fit into the flash memory, please verify - the image file! %></div> - <% end %> - -</p> - -<fieldset class="cbi-section"> - <ul> - <li><%:Checksum%>: <code><%=checksum%></code></li> - <li><%:Size%>: <% - local w = require "luci.tools.webadmin" - write(w.byte_format(size)) - - if storage > 0 then - write(luci.i18n.translatef( - " (%s available)", - w.byte_format(storage) - )) - end - %></li> - <li><% if keep then %> - <%:Configuration files will be kept.%> - <% else %> - <%:Note: Configuration files will be erased.%> - <% end %></li> - </ul> -</fieldset> - -<div class="cbi-page-actions right"> - <form style="display:inline" action="<%=REQUEST_URI%>" method="post"> - <input class="cbi-button cbi-button-reset" type="submit" value="<%:Cancel%>" /> - </form> - <form style="display:inline" action="<%=REQUEST_URI%>" method="post"> - <input type="hidden" name="step" value="2" /> - <input type="hidden" name="keep" value="<%=keep and "1" or ""%>" /> - <input class="cbi-button cbi-button-apply" type="submit" value="<%:Proceed%>" /> - </form> -</div> - -<%+footer%> diff --git a/modules/admin-full/luasrc/view/admin_uci/apply.htm b/modules/admin-full/luasrc/view/admin_uci/apply.htm deleted file mode 100644 index f6a68126de..0000000000 --- a/modules/admin-full/luasrc/view/admin_uci/apply.htm +++ /dev/null @@ -1,32 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ - --%> - -<%+header%> - -<h2><a id="content" name="content"><%:Configuration%> / <%:Apply%></a></h2> - -<% if changes then %> - <%+cbi/apply_xhr%> - <%+admin_uci/changelog%> - - <%- cbi_apply_xhr('uci-apply', configs) -%> - - <p><strong><%:The following changes have been committed%>:</strong></p> - <%- uci_changelog(changes) -%> -<% else %> - <p><strong><%:There are no pending changes to apply!%></strong></p> -<% end %> - -<%+footer%> diff --git a/modules/admin-full/luasrc/view/admin_uci/changelog.htm b/modules/admin-full/luasrc/view/admin_uci/changelog.htm deleted file mode 100644 index e195befb3e..0000000000 --- a/modules/admin-full/luasrc/view/admin_uci/changelog.htm +++ /dev/null @@ -1,88 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2010 Jo-Philipp Wich <xm@subsignal.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ - --%> - -<% export("uci_changelog", function(changes) -%> -<fieldset class="cbi-section"> - <strong><%:Legend:%></strong> - <div class="uci-change-legend"> - <div class="uci-change-legend-label"><ins> </ins> <%:Section added%></div> - <div class="uci-change-legend-label"><del> </del> <%:Section removed%></div> - <div class="uci-change-legend-label"><var><ins> </ins></var> <%:Option changed%></div> - <div class="uci-change-legend-label"><var><del> </del></var> <%:Option removed%></div> - <br style="clear:both" /> - </div> - <br /> - - <div class="uci-change-list"><% - local util = luci.util - local ret = { } - - for r, tbl in pairs(changes) do - for s, os in pairs(tbl) do - -- section add - if os['.type'] and os['.type'] ~= "" then - ret[#ret+1] = "<ins>%s.%s=<strong>%s</strong>" %{ r, s, os['.type'] } - for o, v in util.kspairs(os) do - if o:sub(1,1) ~= "." then - if type(v) == "table" then - local i - for i = 1, #v do - ret[#ret+1] = "<br />%s.%s.%s+=<strong>%s</strong>" - %{ r, s, o, util.pcdata(v[i]) } - end - else - ret[#ret+1] = "<br />%s.%s.%s=<strong>%s</strong>" - %{ r, s, o, util.pcdata(v) } - end - end - end - ret[#ret+1] = "</ins><br />" - - -- section delete - elseif os['.type'] and os['.type'] == "" then - ret[#ret+1] = "<del>%s.<strong>%s</strong></del><br />" %{ r, s } - - -- modifications - else - ret[#ret+1] = "<var>%s.%s<br />" %{ r, s } - for o, v in util.kspairs(os) do - if o:sub(1,1) ~= "." then - if v and #v > 0 then - ret[#ret+1] = "<ins>" - if type(v) == "table" then - local i - for i = 1, #v do - ret[#ret+1] = "%s.%s.%s+=<strong>%s</strong><br />" - %{ r, s, o, util.pcdata(v[i]) } - end - - else - ret[#ret+1] = "%s.%s.%s=<strong>%s</strong><br />" - %{ r, s, o, util.pcdata(v) } - end - ret[#ret+1] = "</ins>" - else - ret[#ret+1] = "<del>%s.%s.<strong>%s</strong><br /></del>" %{ r, s, o } - end - end - end - ret[#ret+1] = "</var><br />" - end - end - end - - write(table.concat(ret)) - %></div> -</fieldset> -<%- end) %> diff --git a/modules/admin-full/luasrc/view/admin_uci/changes.htm b/modules/admin-full/luasrc/view/admin_uci/changes.htm deleted file mode 100644 index 2415de316f..0000000000 --- a/modules/admin-full/luasrc/view/admin_uci/changes.htm +++ /dev/null @@ -1,52 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ - --%> - -<%+header%> - -<h2><a id="content" name="content"><%:Configuration%> / <%:Changes%></a></h2> - -<% if changes then %> - <%+admin_uci/changelog%> - <%- uci_changelog(changes) -%> -<% else %> - <p><strong><%:There are no pending changes!%></strong></p> -<% end %> - -<div class="cbi-page-actions"> - <% local r = luci.http.formvalue("redir"); if r and #r > 0 then %> - <div style="float:left"> - <form class="inline" method="get" action="<%=luci.util.pcdata(r)%>"> - <input class="cbi-button cbi-button-link" style="float:left; margin:0" type="submit" value="<%:Back%>" /> - </form> - </div> - <% end %> - - <div style="text-align:right"> - <form class="inline" method="get" action="<%=controller%>/admin/uci/apply"> - <input type="hidden" name="redir" value="<%=pcdata(luci.http.formvalue("redir"))%>" /> - <input class="cbi-button cbi-button-apply" type="submit" value="<%:Apply%>" /> - </form> - <form class="inline" method="get" action="<%=controller%>/admin/uci/saveapply"> - <input type="hidden" name="redir" value="<%=pcdata(luci.http.formvalue("redir"))%>" /> - <input class="cbi-button cbi-button-save" type="submit" value="<%:Save & Apply%>" /> - </form> - <form class="inline" method="get" action="<%=controller%>/admin/uci/revert"> - <input type="hidden" name="redir" value="<%=pcdata(luci.http.formvalue("redir"))%>" /> - <input class="cbi-button cbi-button-reset" type="submit" value="<%:Revert%>" /> - </form> - </div> -</div> - -<%+footer%> diff --git a/modules/admin-full/luasrc/view/admin_uci/revert.htm b/modules/admin-full/luasrc/view/admin_uci/revert.htm deleted file mode 100644 index 739b752046..0000000000 --- a/modules/admin-full/luasrc/view/admin_uci/revert.htm +++ /dev/null @@ -1,36 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ - --%> - -<%+header%> - -<h2><a id="content" name="content"><%:Configuration%> / <%:Revert%></a></h2> - -<% if changes then %> - <%+cbi/apply_xhr%> - <%+admin_uci/changelog%> - - <p><strong><%:The following changes have been reverted%>:</strong></p> - <%- uci_changelog(changes) -%> -<% else %> - <p><strong><%:There are no pending changes to revert!%></strong></p> -<% end %> - -<div class="cbi-page-actions"> - <form class="inline" method="get" action="<%=luci.util.pcdata(luci.http.formvalue("redir"))%>"> - <input class="cbi-button cbi-button-link" style="margin:0" type="submit" value="<%:Back%>" /> - </form> -</div> - -<%+footer%> diff --git a/modules/admin-full/luasrc/view/cbi/wireless_modefreq.htm b/modules/admin-full/luasrc/view/cbi/wireless_modefreq.htm deleted file mode 100644 index ac14593e79..0000000000 --- a/modules/admin-full/luasrc/view/cbi/wireless_modefreq.htm +++ /dev/null @@ -1,167 +0,0 @@ -<%+cbi/valueheader%> - -<script type="text/javascript">//<![CDATA[ - var freqlist = <%= luci.http.write_json(self.freqlist) %>; - var hwmodes = <%= luci.http.write_json(self.hwmodes) %>; - - var channels = { - '11g': [ - 'auto', 'auto', true - ], - '11a': [ - 'auto', 'auto', true - ] - }; - - for (var i = 0; i < freqlist.length; i++) - channels[(freqlist[i].mhz > 2484) ? '11a' : '11g'].push( - freqlist[i].channel, - '%d (%d MHz)'.format(freqlist[i].channel, freqlist[i].mhz), - !freqlist[i].restricted - ); - - var modes = [ - '', 'Legacy', true, - 'n', 'N', hwmodes.n, - 'ac', 'AC', hwmodes.ac - ]; - - var htmodes = { - '': [ - '', '-', true - ], - 'n': [ - 'HT20', '20 MHz', true, - 'HT40', '40 MHz', true - ], - 'ac': [ - 'VHT20', '20 MHz', true, - 'VHT40', '40 MHz', true, - 'VHT80', '80 MHz', true, - 'VHT160', '160 MHz', true - ] - }; - - var bands = { - '': [ - '11g', '2.4 GHz', (channels['11g'].length > 3), - '11a', '5 GHz', (channels['11a'].length > 3) - ], - 'n': [ - '11g', '2.4 GHz', (channels['11g'].length > 3), - '11a', '5 GHz', (channels['11a'].length > 3) - ], - 'ac': [ - '11a', '5 GHz', true - ] - }; - - function cbi_set_values(sel, vals) - { - if (sel.vals) - sel.vals.selected = sel.selectedIndex; - - while (sel.options[0]) - sel.remove(0); - - for (var i = 0; vals && i < vals.length; i += 3) - { - if (!vals[i+2]) - continue; - - var opt = document.createElement('option'); - opt.value = vals[i+0]; - opt.text = vals[i+1]; - - sel.add(opt); - } - - if (!isNaN(vals.selected)) - sel.selectedIndex = vals.selected; - - sel.parentNode.style.display = (sel.options.length <= 1) ? 'none' : ''; - sel.vals = vals; - } - - function cbi_toggle_wifi_mode(id) - { - cbi_toggle_wifi_htmode(id); - cbi_toggle_wifi_band(id); - } - - function cbi_toggle_wifi_htmode(id) - { - var mode = document.getElementById(id + '.mode'); - var bwdt = document.getElementById(id + '.htmode'); - - cbi_set_values(bwdt, htmodes[mode.value]); - } - - function cbi_toggle_wifi_band(id) - { - var mode = document.getElementById(id + '.mode'); - var band = document.getElementById(id + '.band'); - - cbi_set_values(band, bands[mode.value]); - cbi_toggle_wifi_channel(id); - } - - function cbi_toggle_wifi_channel(id) - { - var band = document.getElementById(id + '.band'); - var chan = document.getElementById(id + '.channel'); - - cbi_set_values(chan, channels[band.value]); - } - - function cbi_init_wifi(id) - { - var mode = document.getElementById(id + '.mode'); - var band = document.getElementById(id + '.band'); - var chan = document.getElementById(id + '.channel'); - var bwdt = document.getElementById(id + '.htmode'); - - cbi_set_values(mode, modes); - - if (/VHT20|VHT40|VHT80|VHT160/.test(<%= luci.http.write_json(self.map:get(section, "htmode")) %>)) - mode.value = 'ac'; - else if (/HT20|HT40/.test(<%= luci.http.write_json(self.map:get(section, "htmode")) %>)) - mode.value = 'n'; - else - mode.value = ''; - - cbi_toggle_wifi_mode(id); - - if (/a/.test(<%= luci.http.write_json(self.map:get(section, "hwmode")) %>)) - band.value = '11a'; - else - band.value = '11g'; - - cbi_toggle_wifi_band(id); - - bwdt.value = <%= luci.http.write_json(self.map:get(section, "htmode")) %>; - chan.value = <%= luci.http.write_json(self.map:get(section, "channel")) %>; - } -//]]></script> - -<label style="float:left; margin-right:3px"> - <%:Mode%><br /> - <select style="width:auto" id="<%= cbid %>.mode" name="<%= cbid %>.mode" onchange="cbi_toggle_wifi_mode('<%= cbid %>')"></select> -</label> -<label style="float:left; margin-right:3px"> - <%:Band%><br /> - <select style="width:auto" id="<%= cbid %>.band" name="<%= cbid %>.band" onchange="cbi_toggle_wifi_band('<%= cbid %>')"></select> -</label> -<label style="float:left; margin-right:3px"> - <%:Channel%><br /> - <select style="width:auto" id="<%= cbid %>.channel" name="<%= cbid %>.channel"></select> -</label> -<label style="float:left; margin-right:3px"> - <%:Width%><br /> - <select style="width:auto" id="<%= cbid %>.htmode" name="<%= cbid %>.htmode"></select> -</label> -<br style="clear:left" /> - -<script type="text/javascript">cbi_init_wifi('<%= cbid %>');</script> - -<%+cbi/valuefooter%> |