Skip to content
Snippets Groups Projects
Select Git revision
  • 818c31afdd80b1f6ed58e07290875b49450c905b
  • v2018.2.x default
  • experimental
  • master
  • v2021.1.2-ffs
  • v2021.1.1-ffs
  • nrb/gluon-master-cpe510
  • v2021.1-ffs
  • v2020.2.3-ffs
  • nrbffs/fastd-remove-delay
  • v2020.2.2-ffs
  • v2020.2.1-ffs
  • v2020.2-ffs
  • v2020.2.x
  • v2020.1.3-ffs
  • v2020.1.1-ffs
  • v2020.1-ffs
  • v2019.1.2-ffs
  • v2019.1.1-ffs
  • nrb/test-radv-filter
  • v2019.1-ffs
  • nrbffs/netgear-ex6120
  • v2021.1.2-ffs0.2
  • v2021.1.2-ffs0.1
  • v2021.1.1-ffs0.4
  • v2021.1.1-ffs0.3
  • v2021.1.1-ffs0.2
  • v2021.1.1-ffs0.1
  • v2021.1-ffs0.1
  • v2020.2.3-ffs0.3
  • v2020.2.3-ffs0.2
  • v2020.2.3-ffs0.1
  • v2020.2.2-ffs0.1
  • v2020.2.1-ffs0.1
  • v2020.2-ffs0.1
  • v2020.2
  • v2020.2.x-ffs0.1
  • v2020.1.3-ffs0.1
  • v2020.1.1-ffs0.1
  • v2020.1-ffs0.1
  • v2019.1.2-ffs0.1
  • v2019.1.1-ffs0.1
42 results

0300-mesh-vpn.lua

Blame
  • Forked from firmware / FFS Gluon
    2592 commits behind the upstream repository.
    user avatar
    Matthias Schiffer authored
    We now keep the VPN enable state, bandwidth limit enable and actual limits
    in the core config to avoid having to recover "user intent" from different
    config files when the used VPN packages change.
    
    Fixes #1736
    818c31af
    History
    0300-mesh-vpn.lua 2.00 KiB
    local unistd = require 'posix.unistd'
    
    local has_fastd = unistd.access('/lib/gluon/mesh-vpn/fastd')
    local has_tunneldigger = unistd.access('/lib/gluon/mesh-vpn/tunneldigger')
    
    return function(form, uci)
    	if not (has_fastd or has_tunneldigger) then
    		return
    	end
    
    	local pkg_i18n = i18n 'gluon-config-mode-mesh-vpn'
    
    	local msg = pkg_i18n.translate(
    		'Your internet connection can be used to establish a ' ..
    	        'VPN connection with other nodes. ' ..
    	        'Enable this option if there are no other nodes reachable ' ..
    	        'over WLAN in your vicinity or you want to make a part of ' ..
    	        'your connection\'s bandwidth available for the network. You can limit how ' ..
    	        'much bandwidth the node will use at most.'
    	)
    
    	local s = form:section(Section, nil, msg)
    
    	local o
    
    	local meshvpn = s:option(Flag, "meshvpn", pkg_i18n.translate("Use internet connection (mesh VPN)"))
    	meshvpn.default = uci:get_bool("gluon", "mesh_vpn", "enabled")
    	function meshvpn:write(data)
    		uci:set("gluon", "mesh_vpn", "enabled", data)
    	end
    
    	local limit = s:option(Flag, "limit_enabled", pkg_i18n.translate("Limit bandwidth"))
    	limit:depends(meshvpn, true)
    	limit.default = uci:get_bool("gluon", "mesh_vpn", "limit_enabled")
    	function limit:write(data)
    		uci:set("gluon", "mesh_vpn", "limit_enabled", data)
    	end
    
    	o = s:option(Value, "limit_ingress", pkg_i18n.translate("Downstream (kbit/s)"))
    	o:depends(limit, true)
    	o.default = uci:get("gluon", "mesh_vpn", "limit_ingress")
    	o.datatype = "uinteger"
    	function o:write(data)
    		uci:set("gluon", "mesh_vpn", "limit_ingress", data)
    	end
    
    	o = s:option(Value, "limit_egress", pkg_i18n.translate("Upstream (kbit/s)"))
    	o:depends(limit, true)
    	o.default = uci:get("gluon", "mesh_vpn", "limit_egress")
    	o.datatype = "uinteger"
    	function o:write(data)
    		uci:set("gluon", "mesh_vpn", "limit_egress", data)
    	end
    
    	function s:handle()
    		Section.handle(s)
    		uci:save('gluon')
    		os.execute('exec /lib/gluon/mesh-vpn/update-config')
    	end
    
    	return {'gluon', 'fastd', 'tunneldigger', 'simple-tc'}
    end