gluon/package/gluon-mesh-vpn-fastd/check_site.lua
lemoer b3c9ac8bce scripts: check_site_lib: need_table() now merges all keys before calling subcheck(...)
This also introduces an api change to the subcheck()!

Before:
-> subcheck(key, value, conf_name)

After:
-> subcheck(key, conf_name)

The idea is, that it's hard to submit a value, which should be then checked
again. It's wouldn't be clear (after merging) from which config the value
is, and so an helpful error message would be impossible.
2017-12-28 19:59:38 +01:00

31 lines
1017 B
Lua

local fastd_methods = {'salsa2012+gmac', 'salsa2012+umac', 'null+salsa2012+gmac', 'null+salsa2012+umac', 'null'}
need_array_of('mesh_vpn.fastd.methods', fastd_methods)
need_boolean(in_site('mesh_vpn.fastd.configurable'), false)
need_one_of(in_site('mesh_vpn.fastd.syslog_level'), {'error', 'warn', 'info', 'verbose', 'debug', 'debug2'}, false)
local function check_peer(prefix)
return function(k, conf_name)
assert_uci_name(k, conf_name)
local table = string.format('%s[%q].', prefix, k)
need_string_match(table .. 'key', '^%x+$')
need_string_array(in_domain(table .. 'remotes'))
end
end
local function check_group(prefix)
return function(k, conf_name)
assert_uci_name(k, conf_name)
local table = string.format('%s[%q].', prefix, k)
need_number(table .. 'limit', false)
need_table(table .. 'peers', check_peer(table .. 'peers'), false)
need_table(table .. 'groups', check_group(table .. 'groups'), false)
end
end
need_table('mesh_vpn.fastd.groups', check_group('mesh_vpn.fastd.groups'))