gluon-{,web-}mesh-vpn-fastd: add support for null@l2tp method

THe "null" and "null@l2tp" methods are considered equivalent and always
added and removed together when the method list is "configurable".
"null@l2tp" is added before "null", so it is preferred when the peer
supports both.
This commit is contained in:
Matthias Schiffer 2021-03-07 20:13:41 +01:00
parent 487d312d25
commit 15eeb86f42
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C
3 changed files with 10 additions and 7 deletions

View File

@ -1,4 +1,4 @@
local fastd_methods = {'salsa2012+umac', 'null+salsa2012+umac', 'null'}
local fastd_methods = {'salsa2012+umac', 'null+salsa2012+umac', 'null@l2tp', 'null'}
need_array_of({'mesh_vpn', 'fastd', 'methods'}, fastd_methods)
need_boolean(in_site({'mesh_vpn', 'fastd', 'configurable'}), false)

View File

@ -17,20 +17,22 @@ end
local methods
if site.mesh_vpn.fastd.configurable(false) then
local has_null = util.contains(site.mesh_vpn.fastd.methods(), 'null')
local site_methods = site.mesh_vpn.fastd.methods()
local has_null = util.contains(site_methods, 'null@l2tp') or util.contains(site_methods, 'null')
local old_methods = uci:get('fastd', 'mesh_vpn', 'method')
if old_methods then
has_null = util.contains(old_methods, 'null')
has_null = util.contains(old_methods, 'null@l2tp') or util.contains(old_methods, 'null')
end
methods = {}
if has_null then
table.insert(methods, 'null@l2tp')
table.insert(methods, 'null')
end
for _, method in ipairs(site.mesh_vpn.fastd.methods()) do
if method ~= 'null' then
for _, method in ipairs(site_methods) do
if method ~= 'null@l2tp' and method ~= 'null' then
table.insert(methods, method)
end
end

View File

@ -10,7 +10,7 @@ mode.package = "gluon-web-mesh-vpn-fastd"
mode.template = "mesh-vpn-fastd"
local methods = uci:get('fastd', 'mesh_vpn', 'method')
if util.contains(methods, 'null') then
if util.contains(methods, 'null@l2tp') or util.contains(methods, 'null') then
-- performance mode will only be used as default, if it is present in site.mesh_vpn.fastd.methods
mode.default = 'performance'
else
@ -24,11 +24,12 @@ function mode:write(data)
-- if performance mode was selected, and the method 'null' was not present in the original table, it will be added
local site_methods = {}
if data == 'performance' then
table.insert(site_methods, 'null@l2tp')
table.insert(site_methods, 'null')
end
for _, method in ipairs(site.mesh_vpn.fastd.methods()) do
if method ~= 'null' then
if method ~= 'null@l2tp' and method ~= 'null' then
table.insert(site_methods, method)
end
end