gluon/package/gluon-web-private-wifi/luasrc/lib/gluon/config-mode/model/admin/privatewifi.lua
Matthias Schiffer b1aa5390a7
gluon-config-mode-core: move gluon-web base path to /lib/gluon/config-mode
- CGI script and index.html are moved from gluon-web to
  gluon-config-mode-core, the script is renamed to 'config'
- gluon-web and gluon-web-model base views and i18n files are symlinked
  into the new path
- gluon-web-theme is renamed to gluon-config-mode-theme and installs
  directly into the new path
- all gluon-web-* models, controllers and views are moved into the new
  path
2018-02-26 00:07:13 +01:00

56 lines
1.7 KiB
Lua

local uci = require("simple-uci").cursor()
local util = require 'gluon.util'
-- where to read the configuration from
local primary_iface = 'wan_radio0'
local f = Form(translate("Private WLAN"))
local s = f:section(Section, nil, translate(
'Your node can additionally extend your private network by bridging the WAN interface '
.. 'with a separate WLAN. This feature is completely independent of the mesh functionality. '
.. 'Please note that the private WLAN and meshing on the WAN interface should not be enabled '
.. 'at the same time.'
))
local enabled = s:option(Flag, "enabled", translate("Enabled"))
enabled.default = uci:get('wireless', primary_iface) and not uci:get_bool('wireless', primary_iface, "disabled")
local ssid = s:option(Value, "ssid", translate("Name (SSID)"))
ssid:depends(enabled, true)
ssid.datatype = "maxlength(32)"
ssid.default = uci:get('wireless', primary_iface, "ssid")
local key = s:option(Value, "key", translate("Key"), translate("8-63 characters"))
key:depends(enabled, true)
key.datatype = "wpakey"
key.default = uci:get('wireless', primary_iface, "key")
function f:write()
util.foreach_radio(uci, function(radio, index)
local radio_name = radio['.name']
local name = "wan_" .. radio_name
if enabled.data then
local macaddr = util.get_wlan_mac(uci, radio, index, 4)
uci:section('wireless', "wifi-iface", name, {
device = radio_name,
network = "wan",
mode = 'ap',
encryption = 'psk2',
ssid = ssid.data,
key = key.data,
macaddr = macaddr,
disabled = false,
})
else
uci:set('wireless', name, "disabled", true)
end
end)
uci:commit('wireless')
end
return f