30 lines
792 B
Lua
Executable File
30 lines
792 B
Lua
Executable File
#!/usr/bin/lua
|
|
|
|
local uci = require('simple-uci').cursor()
|
|
local vpn_name, vpn = require('gluon.mesh-vpn').get_active_provider()
|
|
|
|
local vpn_config = {
|
|
enabled = uci:get_bool('gluon', 'mesh_vpn', 'enabled'),
|
|
limit_enabled = uci:get_bool('gluon', 'mesh_vpn', 'limit_enabled'),
|
|
limit_egress = uci:get('gluon', 'mesh_vpn', 'limit_egress'),
|
|
limit_ingress = uci:get('gluon', 'mesh_vpn', 'limit_ingress'),
|
|
}
|
|
|
|
if vpn_name ~= 'fastd' then
|
|
uci:set('fastd', 'mesh_vpn', 'enabled', false)
|
|
uci:save('fastd')
|
|
end
|
|
|
|
if vpn_name ~= 'tunneldigger' then
|
|
uci:set('tunneldigger', 'mesh_vpn', 'enabled', false)
|
|
uci:save('tunneldigger')
|
|
end
|
|
|
|
vpn.enable(vpn_config.enabled)
|
|
if vpn_config.limit_enabled then
|
|
vpn.set_limit(vpn_config.limit_ingress, vpn_config.limit_egress)
|
|
else
|
|
vpn.set_limit(nil, nil)
|
|
end
|
|
|