Merge pull request #1476 from dibdot/travelmate
luci-app-travelmate: sync with travelmate 1.0.0
This commit is contained in:
commit
68cfa21274
4 changed files with 45 additions and 30 deletions
|
@ -4,8 +4,10 @@
|
||||||
local fs = require("nixio.fs")
|
local fs = require("nixio.fs")
|
||||||
local uci = require("luci.model.uci").cursor()
|
local uci = require("luci.model.uci").cursor()
|
||||||
local json = require("luci.jsonc")
|
local json = require("luci.jsonc")
|
||||||
|
local util = require("luci.util")
|
||||||
local nw = require("luci.model.network").init()
|
local nw = require("luci.model.network").init()
|
||||||
local fw = require("luci.model.firewall").init()
|
local fw = require("luci.model.firewall").init()
|
||||||
|
local dump = util.ubus("network.interface", "dump", {})
|
||||||
local trmiface = uci.get("travelmate", "global", "trm_iface") or "trm_wwan"
|
local trmiface = uci.get("travelmate", "global", "trm_iface") or "trm_wwan"
|
||||||
local trminput = uci.get("travelmate", "global", "trm_rtfile") or "/tmp/trm_runtime.json"
|
local trminput = uci.get("travelmate", "global", "trm_rtfile") or "/tmp/trm_runtime.json"
|
||||||
local uplink = uci.get("network", trmiface) or ""
|
local uplink = uci.get("network", trmiface) or ""
|
||||||
|
@ -38,7 +40,8 @@ if uplink == "" then
|
||||||
btn.inputtitle = translate("Add Interface")
|
btn.inputtitle = translate("Add Interface")
|
||||||
btn.inputstyle = "apply"
|
btn.inputstyle = "apply"
|
||||||
btn.disabled = false
|
btn.disabled = false
|
||||||
function btn.write(self, section, value)
|
|
||||||
|
function btn.write(self, section)
|
||||||
local iface = o:formvalue(section)
|
local iface = o:formvalue(section)
|
||||||
if iface then
|
if iface then
|
||||||
uci:set("travelmate", section, "trm_iface", iface)
|
uci:set("travelmate", section, "trm_iface", iface)
|
||||||
|
@ -75,19 +78,16 @@ o2 = s:option(Flag, "trm_automatic", translate("Enable 'automatic' mode"),
|
||||||
o2.default = o2.enabled
|
o2.default = o2.enabled
|
||||||
o2.rmempty = false
|
o2.rmempty = false
|
||||||
|
|
||||||
btn = s:option(Button, "", translate("Manual Rescan"))
|
o3 = s:option(ListValue, "trm_iface", translate("Uplink / Trigger interface"),
|
||||||
btn:depends("trm_automatic", "")
|
translate("Name of the used uplink interface."))
|
||||||
btn.inputtitle = translate("Rescan")
|
if dump then
|
||||||
btn.inputstyle = "find"
|
local i, v
|
||||||
btn.disabled = false
|
for i, v in ipairs(dump.interface) do
|
||||||
function btn.write()
|
if v.interface ~= "loopback" and v.interface ~= "lan" then
|
||||||
luci.sys.call("env -i /etc/init.d/travelmate start >/dev/null 2>&1")
|
o3:value(v.interface)
|
||||||
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "travelmate"))
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
o3 = s:option(Value, "trm_iface", translate("Uplink / Trigger interface"),
|
|
||||||
translate("Name of the uplink interface that triggers travelmate processing in 'manual' mode."))
|
|
||||||
o3.datatype = "and(uciname,rangelength(3,15))"
|
|
||||||
o3.default = trmiface
|
o3.default = trmiface
|
||||||
o3.rmempty = false
|
o3.rmempty = false
|
||||||
|
|
||||||
|
@ -97,6 +97,18 @@ o4.default = 2
|
||||||
o4.datatype = "range(1,90)"
|
o4.datatype = "range(1,90)"
|
||||||
o4.rmempty = false
|
o4.rmempty = false
|
||||||
|
|
||||||
|
btn = s:option(Button, "", translate("Manual Rescan"),
|
||||||
|
translate("Force a manual uplink rescan / reconnect in 'trigger' mode."))
|
||||||
|
btn:depends("trm_automatic", "")
|
||||||
|
btn.inputtitle = translate("Rescan")
|
||||||
|
btn.inputstyle = "find"
|
||||||
|
btn.disabled = false
|
||||||
|
|
||||||
|
function btn.write()
|
||||||
|
luci.sys.call("env -i /etc/init.d/travelmate start >/dev/null 2>&1")
|
||||||
|
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "travelmate"))
|
||||||
|
end
|
||||||
|
|
||||||
-- Runtime information
|
-- Runtime information
|
||||||
|
|
||||||
ds = m:section(NamedSection, "global", "travelmate", translate("Runtime Information"))
|
ds = m:section(NamedSection, "global", "travelmate", translate("Runtime Information"))
|
||||||
|
|
|
@ -5,6 +5,8 @@ local fs = require("nixio.fs")
|
||||||
local uci = require("luci.model.uci").cursor()
|
local uci = require("luci.model.uci").cursor()
|
||||||
local http = require("luci.http")
|
local http = require("luci.http")
|
||||||
local trmiface = uci.get("travelmate", "global", "trm_iface") or "trm_wwan"
|
local trmiface = uci.get("travelmate", "global", "trm_iface") or "trm_wwan"
|
||||||
|
local encr_psk = {"psk", "psk2", "psk-mixed"}
|
||||||
|
local encr_wpa = {"wpa", "wpa2", "wpa-mixed"}
|
||||||
|
|
||||||
m = SimpleForm("add", translate("Add Wireless Uplink Configuration"))
|
m = SimpleForm("add", translate("Add Wireless Uplink Configuration"))
|
||||||
m.submit = translate("Save")
|
m.submit = translate("Save")
|
||||||
|
@ -53,7 +55,7 @@ elseif (tonumber(m.hidden.wpa_version) or 0) > 0 then
|
||||||
encr:value("psk", "WPA PSK")
|
encr:value("psk", "WPA PSK")
|
||||||
encr:value("psk-mixed", "WPA/WPA2 mixed")
|
encr:value("psk-mixed", "WPA/WPA2 mixed")
|
||||||
encr:value("psk2", "WPA2 PSK")
|
encr:value("psk2", "WPA2 PSK")
|
||||||
encr.default = "psk2"
|
encr.default = encr_psk[tonumber(m.hidden.wpa_version)] or "psk2"
|
||||||
|
|
||||||
ciph = m:field(ListValue, "cipher", translate("Cipher"))
|
ciph = m:field(ListValue, "cipher", translate("Cipher"))
|
||||||
ciph:value("auto", translate("Automatic"))
|
ciph:value("auto", translate("Automatic"))
|
||||||
|
@ -70,7 +72,7 @@ elseif (tonumber(m.hidden.wpa_version) or 0) > 0 then
|
||||||
encr:value("wpa", "WPA Enterprise")
|
encr:value("wpa", "WPA Enterprise")
|
||||||
encr:value("wpa-mixed", "WPA/WPA2 Enterprise mixed")
|
encr:value("wpa-mixed", "WPA/WPA2 Enterprise mixed")
|
||||||
encr:value("wpa2", "WPA2 Enterprise")
|
encr:value("wpa2", "WPA2 Enterprise")
|
||||||
encr.default = "wpa2"
|
encr.default = encr_wpa[tonumber(m.hidden.wpa_version)] or "wpa2"
|
||||||
|
|
||||||
ciph = m:field(ListValue, "cipher", translate("Cipher"))
|
ciph = m:field(ListValue, "cipher", translate("Cipher"))
|
||||||
ciph:value("auto", translate("Automatic"))
|
ciph:value("auto", translate("Automatic"))
|
||||||
|
|
|
@ -22,17 +22,17 @@ local s = uci:get_all("wireless", m.hidden.cfg)
|
||||||
if s ~= nil then
|
if s ~= nil then
|
||||||
wssid = m:field(Value, "ssid", translate("SSID"))
|
wssid = m:field(Value, "ssid", translate("SSID"))
|
||||||
wssid.datatype = "rangelength(1,32)"
|
wssid.datatype = "rangelength(1,32)"
|
||||||
wssid.default = s.ssid
|
wssid.default = s.ssid or ""
|
||||||
|
|
||||||
bssid = m:field(Value, "bssid", translate("BSSID"))
|
bssid = m:field(Value, "bssid", translate("BSSID"))
|
||||||
bssid.datatype = "macaddr"
|
bssid.datatype = "macaddr"
|
||||||
bssid.default = s.bssid
|
bssid.default = s.bssid or ""
|
||||||
|
|
||||||
|
s.cipher = "auto"
|
||||||
if string.match(s.encryption, '\+') and not string.match(s.encryption, '^wep') then
|
if string.match(s.encryption, '\+') and not string.match(s.encryption, '^wep') then
|
||||||
s.pos = string.find(s.encryption, '\+')
|
s.pos = string.find(s.encryption, '\+')
|
||||||
s.cipher = string.sub(s.encryption, s.pos + 1)
|
s.cipher = string.sub(s.encryption, s.pos + 1)
|
||||||
s.encryption = string.sub(s.encryption, 0, s.pos - 1)
|
s.encryption = string.sub(s.encryption, 0, s.pos - 1)
|
||||||
else
|
|
||||||
s.cipher = "auto"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if s.encryption and s.encryption ~= "none" then
|
if s.encryption and s.encryption ~= "none" then
|
||||||
|
|
|
@ -8,6 +8,7 @@ This is free software, licensed under the Apache License, Version 2.0
|
||||||
local utl = require("luci.util")
|
local utl = require("luci.util")
|
||||||
local dev = luci.http.formvalue("device")
|
local dev = luci.http.formvalue("device")
|
||||||
local iw = luci.sys.wifi.getiwinfo(dev)
|
local iw = luci.sys.wifi.getiwinfo(dev)
|
||||||
|
local wpa_label = {translate("WPA"), translate("WPA2"), translate("WPA/WPA2")}
|
||||||
|
|
||||||
if not iw then
|
if not iw then
|
||||||
luci.http.redirect(luci.dispatcher.build_url("admin/services/travelmate/stations"))
|
luci.http.redirect(luci.dispatcher.build_url("admin/services/travelmate/stations"))
|
||||||
|
@ -17,7 +18,7 @@ This is free software, licensed under the Apache License, Version 2.0
|
||||||
if info.wep == true then
|
if info.wep == true then
|
||||||
return translate("WEP")
|
return translate("WEP")
|
||||||
elseif info.wpa > 0 then
|
elseif info.wpa > 0 then
|
||||||
return translatef("%s (%s/%s)", (info.wpa == 3) and translate("WPA/WPA2") or (info.wpa == 2 and "WPA2" or "WPA"), table.concat(info.auth_suites), table.concat(info.group_ciphers))
|
return "%s (%s/%s)" %{wpa_label[info.wpa], table.concat(info.auth_suites), table.concat(info.group_ciphers)}
|
||||||
elseif info.enabled then
|
elseif info.enabled then
|
||||||
return translate("Unknown")
|
return translate("Unknown")
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue