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/luci-app-travelmate/luasrc/model/cbi/travelmate | |
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/luci-app-travelmate/luasrc/model/cbi/travelmate')
-rw-r--r-- | applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_add.lua | 98 | ||||
-rw-r--r-- | applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_edit.lua | 78 |
2 files changed, 99 insertions, 77 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_]", "_") |