gluon-core, gluon-client-bridge: use new gluon.site library in gluon.util
In particular, this affects users of gluon.util.iterate_radios.
This commit is contained in:
parent
53b6065500
commit
293a45456b
@ -7,14 +7,11 @@ local uci = require('simple-uci').cursor()
|
||||
|
||||
|
||||
local function is_disabled(config, name)
|
||||
local disabled
|
||||
if uci:get('wireless', name) then
|
||||
disabled = uci:get_bool('wireless', name, 'disabled')
|
||||
else
|
||||
disabled = config and config.disabled
|
||||
return uci:get_bool('wireless', name, 'disabled')
|
||||
end
|
||||
|
||||
return disabled
|
||||
return config.disabled(false)
|
||||
end
|
||||
|
||||
local function configure_client(config, radio, index, suffix)
|
||||
@ -23,7 +20,7 @@ local function configure_client(config, radio, index, suffix)
|
||||
|
||||
uci:delete('wireless', name)
|
||||
|
||||
if not config then
|
||||
if not config() then
|
||||
return
|
||||
end
|
||||
|
||||
@ -36,7 +33,7 @@ local function configure_client(config, radio, index, suffix)
|
||||
device = radio,
|
||||
network = 'client',
|
||||
mode = 'ap',
|
||||
ssid = config.ssid,
|
||||
ssid = config.ssid(),
|
||||
macaddr = macaddr,
|
||||
ifname = suffix and 'client' .. suffix,
|
||||
disabled = disabled or false,
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
local util = require 'gluon.util'
|
||||
local site = require 'gluon.site_config'
|
||||
local site = require 'gluon.site'
|
||||
local sysconfig = require 'gluon.sysconfig'
|
||||
|
||||
local uci = require('simple-uci').cursor()
|
||||
@ -12,11 +12,12 @@ if not sysconfig.gluon_version then
|
||||
end
|
||||
|
||||
local function get_channel(radio, config)
|
||||
local channel
|
||||
if uci:get_first('gluon-core', 'wireless', 'preserve_channels') then
|
||||
return uci:get('wireless', radio, 'channel') or config.channel
|
||||
else
|
||||
return config.channel
|
||||
channel = uci:get('wireless', radio, 'channel')
|
||||
end
|
||||
|
||||
return channel or config.channel()
|
||||
end
|
||||
|
||||
local function is_disabled(name)
|
||||
@ -134,7 +135,7 @@ local function fixup_wan(radio, index)
|
||||
end
|
||||
|
||||
local function configure_radio(radio, index, config)
|
||||
if not config then
|
||||
if not config() then
|
||||
return
|
||||
end
|
||||
|
||||
@ -149,29 +150,27 @@ local function configure_radio(radio, index, config)
|
||||
|
||||
uci:set('wireless', radio, 'channel', channel)
|
||||
uci:set('wireless', radio, 'htmode', 'HT20')
|
||||
uci:set('wireless', radio, 'country', site.regdom)
|
||||
uci:set('wireless', radio, 'country', site.regdom())
|
||||
|
||||
uci:set_list('wireless', radio, 'supported_rates', config.supported_rates)
|
||||
uci:set_list('wireless', radio, 'basic_rate', config.basic_rate)
|
||||
uci:set_list('wireless', radio, 'supported_rates', config.supported_rates())
|
||||
uci:set_list('wireless', radio, 'basic_rate', config.basic_rate())
|
||||
|
||||
|
||||
local ibss_disabled = is_disabled('ibss_' .. radio)
|
||||
local mesh_disabled = is_disabled('mesh_' .. radio)
|
||||
|
||||
configure_ibss(config.ibss, radio, index, suffix,
|
||||
configure_ibss(config.ibss(), radio, index, suffix,
|
||||
first_non_nil(
|
||||
ibss_disabled,
|
||||
mesh_disabled,
|
||||
(config.ibss or {}).disabled, -- will be nil if config.ibss or config.ibss.disabled is unset
|
||||
false
|
||||
config.ibss.disabled(false)
|
||||
)
|
||||
)
|
||||
configure_mesh(config.mesh, radio, index, suffix,
|
||||
configure_mesh(config.mesh(), radio, index, suffix,
|
||||
first_non_nil(
|
||||
mesh_disabled,
|
||||
ibss_disabled,
|
||||
(config.mesh or {}).disabled, -- will be nil if config.mesh or config.mesh.disabled is unset
|
||||
false
|
||||
config.mesh.disabled(false)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -35,7 +35,7 @@ local table = table
|
||||
local nixio = require 'nixio'
|
||||
local hash = require 'hash'
|
||||
local sysconfig = require 'gluon.sysconfig'
|
||||
local site = require 'gluon.site_config'
|
||||
local site = require 'gluon.site'
|
||||
local fs = require 'nixio.fs'
|
||||
|
||||
|
||||
@ -131,7 +131,7 @@ function site_seed_bytes(key, length)
|
||||
-- cryptographic strength
|
||||
while ret:len() < 2*length do
|
||||
i = i + 1
|
||||
v = hash.md5(v .. key .. site.site_seed:lower() .. i)
|
||||
v = hash.md5(v .. key .. site.site_seed():lower() .. i)
|
||||
ret = ret .. v
|
||||
end
|
||||
|
||||
@ -253,11 +253,9 @@ end
|
||||
function iterate_radios(uci, f)
|
||||
local radios = {}
|
||||
|
||||
uci:foreach('wireless', 'wifi-device',
|
||||
function(s)
|
||||
uci:foreach('wireless', 'wifi-device', function(s)
|
||||
table.insert(radios, s['.name'])
|
||||
end
|
||||
)
|
||||
end)
|
||||
|
||||
for index, radio in ipairs(radios) do
|
||||
local hwmode = uci:get('wireless', radio, 'hwmode')
|
||||
|
Loading…
Reference in New Issue
Block a user