diff options
author | Dirk Brenken <dev@brenken.org> | 2019-10-18 12:44:54 +0200 |
---|---|---|
committer | Dirk Brenken <dev@brenken.org> | 2019-10-18 12:44:54 +0200 |
commit | 1cb904323ccedf5d4606e62ed358cc587ff5ed29 (patch) | |
tree | f3dace43aa6722bb56b8d786922e0e79e0382925 /applications | |
parent | 36887747d5a20388bc3abf929f419cf5ca925387 (diff) |
luci-app-travelmate: sync with update 1.5.0
* mainly adds WPA3 support
Signed-off-by: Dirk Brenken <dev@brenken.org>
Diffstat (limited to 'applications')
4 files changed, 117 insertions, 98 deletions
diff --git a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_add.lua b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_add.lua index c0c873d76c..406e17e42b 100644 --- a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_add.lua +++ b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_add.lua @@ -7,7 +7,7 @@ local http = require("luci.http") local util = require("luci.util") local scripts = util.split(util.trim(util.exec("ls /etc/travelmate/*.login 2>/dev/null")), "\n", nil, true) or {} local trmiface = uci:get("travelmate", "global", "trm_iface") or "trm_wwan" -local encr_psk = {"psk", "psk2", "psk-mixed"} +local encr_psk = {"psk", "psk2", "psk-mixed", "sae", "owe", "sae-mixed"} local encr_wpa = {"wpa", "wpa2", "wpa-mixed"} m = SimpleForm("add", translate("Add Wireless Uplink Configuration")) @@ -23,11 +23,18 @@ m.hidden = { device = http.formvalue("device"), ssid = http.formvalue("ssid"), bssid = http.formvalue("bssid"), - wep = http.formvalue("wep"), + description = http.formvalue("description"), + wep = tonumber(http.formvalue("wep")) or 0, wpa_suites = http.formvalue("wpa_suites"), - wpa_version = http.formvalue("wpa_version") + wpa_version = tonumber(http.formvalue("wpa_version")) or 0 } +if m.hidden.wpa_version == 4 then + if string.find(m.hidden.description, "OWE") then + m.hidden.wpa_version = 5 + end +end + if m.hidden.ssid == "" then wssid = m:field(Value, "ssid", translate("SSID (hidden)")) else @@ -49,7 +56,7 @@ bssid:depends("no_bssid", 0) bssid.datatype = "macaddr" bssid.default = m.hidden.bssid or "" -if (tonumber(m.hidden.wep) or 0) == 1 then +if m.hidden.wep == 1 then encr = m:field(ListValue, "encryption", translate("Encryption")) encr:value("wep", "WEP") encr:value("wep+open", "WEP Open System") @@ -60,30 +67,13 @@ if (tonumber(m.hidden.wep) or 0) == 1 then wkey = m:field(Value, "key", translate("WEP-Passphrase")) wkey.password = true wkey.datatype = "wepkey" -elseif (tonumber(m.hidden.wpa_version) or 0) > 0 then - if m.hidden.wpa_suites == "PSK" or m.hidden.wpa_suites == "PSK2" then - encr = m:field(ListValue, "encryption", translate("Encryption")) - encr:value("psk", "WPA PSK") - encr:value("psk-mixed", "WPA/WPA2 mixed") - encr:value("psk2", "WPA2 PSK") - encr.default = encr_psk[tonumber(m.hidden.wpa_version)] or "psk2" - - ciph = m:field(ListValue, "cipher", translate("Cipher")) - ciph:value("auto", translate("Automatic")) - ciph:value("ccmp", translate("Force CCMP (AES)")) - ciph:value("tkip", translate("Force TKIP")) - ciph:value("tkip+ccmp", translate("Force TKIP and CCMP (AES)")) - ciph.default = "auto" - - wkey = m:field(Value, "key", translate("WPA-Passphrase")) - wkey.password = true - wkey.datatype = "wpakey" - elseif m.hidden.wpa_suites == "802.1X" then +elseif m.hidden.wpa_version > 0 then + if m.hidden.wpa_suites == "802.1X" then encr = m:field(ListValue, "encryption", translate("Encryption")) encr:value("wpa", "WPA Enterprise") encr:value("wpa-mixed", "WPA/WPA2 Enterprise mixed") encr:value("wpa2", "WPA2 Enterprise") - encr.default = encr_wpa[tonumber(m.hidden.wpa_version)] or "wpa2" + encr.default = encr_wpa[m.hidden.wpa_version] or "wpa2" ciph = m:field(ListValue, "cipher", translate("Cipher")) ciph:value("auto", translate("Automatic")) @@ -134,6 +124,34 @@ elseif (tonumber(m.hidden.wpa_version) or 0) > 0 then privkeypwd.datatype = "wpakey" privkeypwd.password = true privkeypwd.rmempty = true + else + encr = m:field(ListValue, "encryption", translate("Encryption")) + encr:value("psk", "WPA-PSK") + encr:value("psk2", "WPA2-PSK") + encr:value("psk-mixed", "WPA/WPA2 mixed") + encr:value("sae", "WPA3-SAE") + encr:value("owe", "OWE (open network)") + encr:value("sae-mixed", "WPA2/WPA3 mixed") + encr.default = encr_psk[m.hidden.wpa_version] or "psk2" + + ciph = m:field(ListValue, "cipher", translate("Cipher")) + ciph:value("auto", translate("Automatic")) + ciph:value("ccmp", translate("Force CCMP (AES)")) + ciph:value("tkip", translate("Force TKIP")) + ciph:value("tkip+ccmp", translate("Force TKIP and CCMP (AES)")) + ciph:depends("encryption", "psk") + ciph:depends("encryption", "psk2") + ciph:depends("encryption", "psk-mixed") + ciph.default = "auto" + + wkey = m:field(Value, "key", translate("WPA-Passphrase")) + wkey.password = true + wkey.datatype = "wpakey" + wkey:depends("encryption", "psk") + wkey:depends("encryption", "psk2") + wkey:depends("encryption", "psk-mixed") + wkey:depends("encryption", "sae") + wkey:depends("encryption", "sae-mixed") end end @@ -144,7 +162,7 @@ local cmd_args_default = uci:get("travelmate", login_section, "command_args") cmd_list = m:field(ListValue, "cmdlist", translate("Auto Login Script"), translate("External script reference which will be called for automated captive portal logins.")) cmd_args = m:field(Value, "cmdargs", translate("Optional Arguments"), - translate("Space separated list of additional optional arguments passed to the Auto Login Script, i.e. username and password")) + translate("Space separated list of additional arguments passed to the Auto Login Script, i.e. username and password")) for _, z in ipairs(scripts) do cmd_list:value(z) cmd_args:depends("cmdlist", z) @@ -154,7 +172,7 @@ cmd_list.default = cmd or "none" cmd_args.default = cmd_args_default function wssid.write(self, section, value) - newsection = uci:section("wireless", "wifi-iface", nil, { + newsection = uci:section("wireless", "wifi-iface", "trm_" .. login_section, { mode = "sta", network = trmiface, device = m.hidden.device, @@ -163,23 +181,11 @@ function wssid.write(self, section, value) disabled = "1" }) - if (tonumber(m.hidden.wep) or 0) == 1 then - uci:set("wireless", newsection, "encryption", encr:formvalue(section)) - uci:set("wireless", newsection, "key", wkey:formvalue(section) or "") - elseif (tonumber(m.hidden.wpa_version) or 0) > 0 then - if m.hidden.wpa_suites == "PSK" or m.hidden.wpa_suites == "PSK2" then - if ciph:formvalue(section) ~= "auto" then - uci:set("wireless", newsection, "encryption", encr:formvalue(section) .. "+" .. ciph:formvalue(section)) - else - uci:set("wireless", newsection, "encryption", encr:formvalue(section)) - end + if encr:formvalue(section) then + if string.find(encr:formvalue(section), '^wep') then + uci:set("wireless", newsection, "encryption", encr:formvalue(section)) uci:set("wireless", newsection, "key", wkey:formvalue(section) or "") - elseif m.hidden.wpa_suites == "802.1X" then - if ciph:formvalue(section) ~= "auto" then - uci:set("wireless", newsection, "encryption", encr:formvalue(section) .. "+" .. ciph:formvalue(section)) - else - uci:set("wireless", newsection, "encryption", encr:formvalue(section)) - end + elseif string.find(encr:formvalue(section), '^wpa') then uci:set("wireless", newsection, "eap_type", eaptype:formvalue(section)) uci:set("wireless", newsection, "auth", authentication:formvalue(section)) uci:set("wireless", newsection, "identity", ident:formvalue(section) or "") @@ -188,10 +194,18 @@ function wssid.write(self, section, value) uci:set("wireless", newsection, "client_cert", clientcert:formvalue(section) or "") uci:set("wireless", newsection, "priv_key", privkey:formvalue(section) or "") uci:set("wireless", newsection, "priv_key_pwd", privkeypwd:formvalue(section) or "") + elseif encr:formvalue(section) ~= "owe" then + uci:set("wireless", newsection, "key", wkey:formvalue(section) or "") + end + if ciph:formvalue(section) and ciph:formvalue(section) ~= "auto" then + uci:set("wireless", newsection, "encryption", encr:formvalue(section) .. "+" .. ciph:formvalue(section)) + else + uci:set("wireless", newsection, "encryption", encr:formvalue(section)) end else uci:set("wireless", newsection, "encryption", "none") end + local login_section = (wssid:formvalue(section) or "") .. (bssid:formvalue(section) or "") login_section = login_section:gsub("[^%w_]", "_") if not uci:get("travelmate", login_section) and cmd_list:formvalue(section) ~= "none" then diff --git a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_edit.lua b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_edit.lua index ab0b924549..725bd59770 100644 --- a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_edit.lua +++ b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_edit.lua @@ -31,7 +31,6 @@ if s ~= nil then bssid.datatype = "macaddr" bssid.default = s.bssid or "" - s.cipher = "auto" if string.match(s.encryption, '%+') and not string.match(s.encryption, '^wep') then s.pos = string.find(s.encryption, '%+') s.cipher = string.sub(s.encryption, s.pos + 1) @@ -49,22 +48,6 @@ if s ~= nil then wkey = m:field(Value, "key", translate("Passphrase")) wkey.datatype = "wepkey" - elseif string.match(s.encryption, '^psk') then - encr = m:field(ListValue, "encryption", translate("Encryption")) - encr:value("psk", "WPA PSK") - encr:value("psk-mixed", "WPA/WPA2 mixed") - encr:value("psk2", "WPA2 PSK") - encr.default = s.encryption - - ciph = m:field(ListValue, "cipher", translate("Cipher")) - ciph:value("auto", translate("Automatic")) - ciph:value("ccmp", translate("Force CCMP (AES)")) - ciph:value("tkip", translate("Force TKIP")) - ciph:value("tkip+ccmp", translate("Force TKIP and CCMP (AES)")) - ciph.default = s.cipher - - wkey = m:field(Value, "key", translate("Passphrase")) - wkey.datatype = "wpakey" elseif string.match(s.encryption, '^wpa') then encr = m:field(ListValue, "encryption", translate("Encryption")) encr:value("wpa", "WPA Enterprise") @@ -104,6 +87,8 @@ if s ~= nil then wkey = m:field(Value, "password", translate("Passphrase")) wkey.datatype = "wpakey" + wkey.password = true + wkey.default = s.password cacert = m:field(Value, "ca_cert", translate("Path to CA-Certificate")) cacert.rmempty = true @@ -125,9 +110,36 @@ if s ~= nil then privkeypwd.password = true privkeypwd.rmempty = true privkeypwd.default = s.priv_key_pwd or "" + else + encr = m:field(ListValue, "encryption", translate("Encryption")) + encr:value("psk", "WPA-PSK") + encr:value("psk2", "WPA2-PSK") + encr:value("psk-mixed", "WPA/WPA2 mixed") + encr:value("sae", "WPA3-SAE") + encr:value("owe", "OWE (open network)") + encr:value("sae-mixed", "WPA2/WPA3 mixed") + encr.default = s.encryption + + ciph = m:field(ListValue, "cipher", translate("Cipher")) + ciph:value("auto", translate("Automatic")) + ciph:value("ccmp", translate("Force CCMP (AES)")) + ciph:value("tkip", translate("Force TKIP")) + ciph:value("tkip+ccmp", translate("Force TKIP and CCMP (AES)")) + ciph:depends("encryption", "psk") + ciph:depends("encryption", "psk2") + ciph:depends("encryption", "psk-mixed") + ciph.default = s.cipher or "auto" + + wkey = m:field(Value, "key", translate("Passphrase")) + wkey.datatype = "wpakey" + wkey.password = true + wkey:depends("encryption", "psk") + wkey:depends("encryption", "psk2") + wkey:depends("encryption", "psk-mixed") + wkey:depends("encryption", "sae") + wkey:depends("encryption", "sae-mixed") + wkey.default = s.key end - wkey.password = true - wkey.default = s.key or s.password end local login_section = (s.ssid or "") .. (s.bssid or "") @@ -137,7 +149,7 @@ if s ~= nil then cmd_list = m:field(ListValue, "cmdlist", translate("Auto Login Script"), translate("External script reference which will be called for automated captive portal logins.")) cmd_args = m:field(Value, "cmdargs", translate("Optional Arguments"), - translate("Space separated list of additional optional arguments passed to the Auto Login Script, i.e. username and password")) + translate("Space separated list of additional arguments passed to the Auto Login Script, i.e. username and password")) for _, z in ipairs(scripts) do cmd_list:value(z) cmd_args:depends("cmdlist", z) @@ -152,23 +164,11 @@ end function wssid.write(self, section, value) uci:set("wireless", m.hidden.cfg, "ssid", wssid:formvalue(section)) uci:set("wireless", m.hidden.cfg, "bssid", bssid:formvalue(section)) - if s.encryption and s.encryption ~= "none" then - if string.match(s.encryption, '^wep') then + if encr:formvalue(section) then + if string.find(encr:formvalue(section), '^wep') then uci:set("wireless", m.hidden.cfg, "encryption", encr:formvalue(section)) uci:set("wireless", m.hidden.cfg, "key", wkey:formvalue(section) or "") - elseif string.match(s.encryption, '^psk') then - if ciph:formvalue(section) ~= "auto" then - uci:set("wireless", m.hidden.cfg, "encryption", encr:formvalue(section) .. "+" .. ciph:formvalue(section)) - else - uci:set("wireless", m.hidden.cfg, "encryption", encr:formvalue(section)) - end - uci:set("wireless", m.hidden.cfg, "key", wkey:formvalue(section) or "") - elseif string.match(s.encryption, '^wpa') then - if ciph:formvalue(section) ~= "auto" then - uci:set("wireless", m.hidden.cfg, "encryption", encr:formvalue(section) .. "+" .. ciph:formvalue(section)) - else - uci:set("wireless", m.hidden.cfg, "encryption", encr:formvalue(section)) - end + elseif string.find(encr:formvalue(section), '^wpa') then uci:set("wireless", m.hidden.cfg, "eap_type", eaptype:formvalue(section)) uci:set("wireless", m.hidden.cfg, "auth", authentication:formvalue(section)) uci:set("wireless", m.hidden.cfg, "identity", ident:formvalue(section) or "") @@ -178,6 +178,14 @@ function wssid.write(self, section, value) uci:set("wireless", m.hidden.cfg, "priv_key", privkey:formvalue(section) or "") uci:set("wireless", m.hidden.cfg, "priv_key_pwd", privkeypwd:formvalue(section) or "") end + if encr:formvalue(section) ~= "owe" then + uci:set("wireless", m.hidden.cfg, "key", wkey:formvalue(section) or "") + end + if ciph:formvalue(section) and ciph:formvalue(section) ~= "auto" then + uci:set("wireless", m.hidden.cfg, "encryption", encr:formvalue(section) .. "+" .. ciph:formvalue(section)) + else + uci:set("wireless", m.hidden.cfg, "encryption", encr:formvalue(section)) + end end local login_section = (wssid:formvalue(section) or "") .. (bssid:formvalue(section) or "") login_section = login_section:gsub("[^%w_]", "_") diff --git a/applications/luci-app-travelmate/luasrc/view/travelmate/runtime.htm b/applications/luci-app-travelmate/luasrc/view/travelmate/runtime.htm index 90c3e2b779..2284799664 100644 --- a/applications/luci-app-travelmate/luasrc/view/travelmate/runtime.htm +++ b/applications/luci-app-travelmate/luasrc/view/travelmate/runtime.htm @@ -1,5 +1,5 @@ <%# -Copyright 2017-2018 Dirk Brenken (dev@brenken.org) +Copyright 2017-2019 Dirk Brenken (dev@brenken.org) This is free software, licensed under the Apache License, Version 2.0 -%> @@ -28,6 +28,9 @@ This is free software, licensed under the Apache License, Version 2.0 input = json.data.faulty_stations; view.innerHTML = input || "-"; view = document.getElementById("value_6"); + input = json.data.wpa_capabilities; + view.innerHTML = input || "-"; + view = document.getElementById("value_7"); input = json.data.last_rundate; view.innerHTML = input || "-"; } @@ -128,11 +131,17 @@ This is free software, licensed under the Apache License, Version 2.0 </div> </div> <div class="cbi-value" id="status_6"> - <label class="cbi-value-title" for="status_6"><%:Last Run%></label> + <label class="cbi-value-title" for="status_6"><%:WPA Capabilities%></label> <div class="cbi-value-field"> <span class="runtime" id="value_6">-</span> </div> </div> +<div class="cbi-value" id="status_7"> + <label class="cbi-value-title" for="status_7"><%:Last Run%></label> + <div class="cbi-value-field"> + <span class="runtime" id="value_7">-</span> + </div> +</div> <hr /> <div class="cbi-value" id="button_1"> <label class="cbi-value-title" for="button_1"><%:Restart Travelmate%></label> diff --git a/applications/luci-app-travelmate/luasrc/view/travelmate/wifi_scan.htm b/applications/luci-app-travelmate/luasrc/view/travelmate/wifi_scan.htm index 86846a5710..6bb60795ad 100644 --- a/applications/luci-app-travelmate/luasrc/view/travelmate/wifi_scan.htm +++ b/applications/luci-app-travelmate/luasrc/view/travelmate/wifi_scan.htm @@ -1,31 +1,18 @@ <%# -Copyright 2017-2018 Dirk Brenken (dev@brenken.org) +Copyright 2017-2019 Dirk Brenken (dev@brenken.org) This is free software, licensed under the Apache License, Version 2.0 -%> <%- - local sys = require("luci.sys") - local utl = require("luci.util") - local dev = luci.http.formvalue("device") - local iw = luci.sys.wifi.getiwinfo(dev) - local label = {translate("WPA"), translate("WPA2"), translate("WPA/WPA2")} + local sys = require("luci.sys") + local utl = require("luci.util") + 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/services/travelmate/stations")) end - function format_wifi_encryption(info) - if info.wep == true then - return translate("WEP") - elseif info.wpa > 0 then - return "%s (%s/%s)" %{label[info.wpa] or translate("Unknown"), table.concat(info.auth_suites), table.concat(info.group_ciphers)} - elseif info.enabled then - return translate("Unknown") - else - return translate("Open") - end - end - function percent_wifi_signal(info) local qc = info.quality or 0 local qm = info.quality_max or 0 @@ -59,7 +46,7 @@ This is free software, licensed under the Apache License, Version 2.0 <%=net.bssid and utl.pcdata(net.bssid)%> </div> <div class="td left" style="text-align: left !important"> - <%=format_wifi_encryption(net.encryption)%> + <%=net.encryption.description%> </div> <div class="td left" style="text-align: left !important"> <%=percent_wifi_signal(net)%> % @@ -70,6 +57,7 @@ This is free software, licensed under the Apache License, Version 2.0 <input type="hidden" name="device" value="<%=utl.pcdata(dev)%>"/> <input type="hidden" name="ssid" value="<%=utl.pcdata(net.ssid)%>"/> <input type="hidden" name="bssid" value="<%=utl.pcdata(net.bssid)%>"/> + <input type="hidden" name="description" value="<%=net.encryption.description%>"/> <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%>"/> |