summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-mod-admin-full/luasrc/model/cbi
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2018-05-01 21:12:12 +0200
committerJo-Philipp Wich <jo@mein.io>2018-05-05 23:11:23 +0200
commitfd1ddcc41955d7f259c4142b7530063607dcddf4 (patch)
tree42056d5beae3d69644affdf6a52e1d60b672bcd4 /modules/luci-mod-admin-full/luasrc/model/cbi
parent8deb9495515b97898514e8ffb8f002c8afe3bfa7 (diff)
luci-mod-admin-full: rework wifi configuration
- localize variables - get rid of redirects breaking apply workflow - auto-adjust unusable channels when switching country - use apply/rollback workflow when enabling/disabling networks Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-mod-admin-full/luasrc/model/cbi')
-rw-r--r--modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi.lua119
1 files changed, 64 insertions, 55 deletions
diff --git a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi.lua b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi.lua
index a574d35979..a3e28fe589 100644
--- a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi.lua
+++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi.lua
@@ -7,6 +7,17 @@ local ut = require "luci.util"
local nt = require "luci.sys".net
local fs = require "nixio.fs"
+local acct_port, acct_secret, acct_server, anonymous_identity, ant1, ant2,
+ auth, auth_port, auth_secret, auth_server, bssid, cacert, cacert2,
+ cc, ch, cipher, clientcert, clientcert2, ea, eaptype, en, encr,
+ ft_protocol, ft_psk_generate_local, hidden, htmode, identity,
+ ieee80211r, ieee80211w, ifname, ifsection, isolate, key_retries,
+ legacyrates, max_timeout, meshfwd, meshid, ml, mobility_domain, mode,
+ mp, nasid, network, password, pmk_r1_push, privkey, privkey2, privkeypwd,
+ privkeypwd2, r0_key_lifetime, r0kh, r1_key_holder, r1kh,
+ reassociation_deadline, retry_timeout, ssid, st, tp, wepkey, wepslot,
+ wmm, wpakey, wps
+
arg[1] = arg[1] or ""
m = Map("wireless", "",
@@ -19,8 +30,6 @@ m:chain("network")
m:chain("firewall")
m.redirect = luci.dispatcher.build_url("admin/network/wireless")
-local ifsection
-
function m.on_commit(map)
local wnet = nw:get_wifinet(arg[1])
if ifsection and wnet then
@@ -40,38 +49,6 @@ if not wnet or not wdev then
return
end
--- wireless toggle was requested, commit and reload page
-function m.parse(map)
- local new_cc = m:formvalue("cbid.wireless.%s.country" % wdev:name())
- local old_cc = m:get(wdev:name(), "country")
-
- 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)
-
- if m:get(wdev:name(), "type") == "mac80211" and new_cc and new_cc ~= old_cc then
- luci.sys.call("iw reg set %s" % ut.shellquote(new_cc))
- luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless", arg[1]))
- return
- end
-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
@@ -112,6 +89,57 @@ 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)
+-- wireless toggle was requested, commit and reload page
+function m.parse(map)
+ local new_cc = m:formvalue("cbid.wireless.%s.country" % wdev:name())
+ local old_cc = m:get(wdev:name(), "country")
+
+ 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)
+ m.apply_needed = true
+ m.redirect = nil
+ end
+
+ Map.parse(map)
+
+ if m:get(wdev:name(), "type") == "mac80211" and new_cc and new_cc ~= old_cc then
+ luci.sys.call("iw reg set %s" % ut.shellquote(new_cc))
+
+ local old_ch = tonumber(m:formvalue("cbid.wireless.%s._mode_freq.channel" % wdev:name()) or "")
+ if old_ch then
+ local _, c, new_ch
+ for _, c in ipairs(iw.freqlist) do
+ if c.channel > old_ch or (old_ch <= 14 and c.channel > 14) then
+ break
+ end
+ new_ch = c.channel
+ end
+ if new_ch ~= old_ch then
+ wdev:set("channel", new_ch)
+ m.message = translatef("Channel %d is not available in the %s regulatory domain and has been auto-adjusted to %d.",
+ old_ch, new_cc, new_ch)
+ end
+ end
+ end
+
+ 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
+end
+
+m.title = luci.util.pcdata(wnet:get_i18n())
+
s = m:section(NamedSection, wdev:name(), "wifi-device", translate("Device Configuration"))
s.addremove = false
@@ -119,29 +147,12 @@ 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
@@ -170,9 +181,7 @@ if found_sta then
found_sta.channel or "(auto)", table.concat(found_sta.names, ", "))
else
ch = s:taboption("general", Value, "_mode_freq", '<br />'..translate("Operating frequency"))
- ch.hwmodes = hw_modes
- ch.htmodes = iw.htmodelist
- ch.freqlist = iw.freqlist
+ ch.iwinfo = iw
ch.template = "cbi/wireless_modefreq"
function ch.cfgvalue(self, section)
@@ -1049,7 +1058,7 @@ if hwtype == "mac80211" then
retry_timeout.rmempty = true
end
- local key_retries = s:taboption("encryption", Flag, "wpa_disable_eapol_key_retries",
+ key_retries = s:taboption("encryption", Flag, "wpa_disable_eapol_key_retries",
translate("Enable key reinstallation (KRACK) countermeasures"),
translate("Complicates key reinstallation attacks on the client side by disabling retransmission of EAPOL-Key frames that are used to install keys. This workaround might cause interoperability issues and reduced robustness of key negotiation especially in environments with heavy traffic load."))