module("luci.controller.admin.network", package.seeall)
function index()
- require("luci.i18n")
local uci = require("luci.model.uci").cursor()
local net = require "luci.model.network".init(uci)
- local i18n = luci.i18n.translate
local has_wifi = nixio.fs.stat("/etc/config/wireless")
local has_switch = false
page = node("admin", "network")
page.target = alias("admin", "network", "network")
- page.title = i18n("Network")
+ page.title = _("Network")
page.order = 50
page.index = true
if has_switch then
page = node("admin", "network", "vlan")
page.target = cbi("admin_network/vlan")
- page.title = i18n("Switch")
+ page.title = _("Switch")
page.order = 20
end
if has_wifi and has_wifi.size > 0 then
- page = entry({"admin", "network", "wireless"}, arcombine(template("admin_network/wifi_overview"), cbi("admin_network/wifi")), i18n("Wifi"), 15)
+ page = entry({"admin", "network", "wireless"}, arcombine(template("admin_network/wifi_overview"), cbi("admin_network/wifi")), _("Wifi"), 15)
page.leaf = true
page.subindex = true
end
end
- page = entry({"admin", "network", "network"}, arcombine(cbi("admin_network/network"), cbi("admin_network/ifaces")), i18n("Interfaces"), 10)
+ page = entry({"admin", "network", "network"}, arcombine(cbi("admin_network/network"), cbi("admin_network/ifaces")), _("Interfaces"), 10)
page.leaf = true
page.subindex = true
)
if nixio.fs.access("/etc/config/dhcp") then
- page = node("admin", "network", "dhcpleases")
- page.target = cbi("admin_network/dhcpleases")
- page.title = i18n("DHCP Leases")
+ 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 = node("admin", "network", "hosts")
page.target = cbi("admin_network/hosts")
- page.title = i18n("Hostnames")
+ page.title = _("Hostnames")
page.order = 40
end
page = node("admin", "network", "routes")
page.target = cbi("admin_network/routes")
- page.title = i18n("Static Routes")
+ page.title = _("Static Routes")
page.order = 50
page = node("admin", "network", "diagnostics")
page.target = template("admin_network/diagnostics")
- page.title = i18n("Diagnostics")
+ page.title = _("Diagnostics")
page.order = 60
page = entry({"admin", "network", "diag_ping"}, call("diag_ping"), nil)
local rv = { }
local iface
- for iface in path[#path]:gmatch("[%w%.%-]+") do
+ for iface in path[#path]:gmatch("[%w%.%-_]+") do
local net = netm:get_network(iface)
if net then
local info
luci.http.status(404, "No such device")
end
+function wifi_reconnect()
+ local path = luci.dispatcher.context.requestpath
+ local mode = path[#path-1]
+ local wnet = path[#path]
+ 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", (mode == "wireless_shutdown") and 1 or nil)
+ netmd:commit("wireless")
+
+ luci.sys.call("(env -i /sbin/wifi down; env -i /sbin/wifi up) >/dev/null 2>/dev/null")
+ luci.http.status(200, (mode == "wireless_shutdown") and "Shutdown" or "Reconnected")
+
+ return
+ end
+
+ luci.http.status(404, "No such radio")
+end
+
function lease_status()
local s = require "luci.tools.status"