From d87c4b521b2e891155241c01b98a7ac90a8883b9 Mon Sep 17 00:00:00 2001 From: Felix Kaechele Date: Thu, 26 Jul 2018 01:26:00 +0200 Subject: [PATCH] gluon-mesh-vpn: support ingress bandwidth shaping with tunneldigger (#1460) Signed-off-by: Felix Kaechele --- .../gluon/config-mode/wizard/0300-mesh-vpn.lua | 15 +++++++++++++-- .../luasrc/lib/gluon/upgrade/500-mesh-vpn | 5 +++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/package/gluon-config-mode-mesh-vpn/luasrc/lib/gluon/config-mode/wizard/0300-mesh-vpn.lua b/package/gluon-config-mode-mesh-vpn/luasrc/lib/gluon/config-mode/wizard/0300-mesh-vpn.lua index 98f27048..0fd6432b 100644 --- a/package/gluon-config-mode-mesh-vpn/luasrc/lib/gluon/config-mode/wizard/0300-mesh-vpn.lua +++ b/package/gluon-config-mode-mesh-vpn/luasrc/lib/gluon/config-mode/wizard/0300-mesh-vpn.lua @@ -41,14 +41,25 @@ return function(form, uci) uci:set("simple-tc", "mesh_vpn", "interface") uci:set("simple-tc", "mesh_vpn", "enabled", data) uci:set("simple-tc", "mesh_vpn", "ifname", "mesh-vpn") + if not data and has_tunneldigger then + uci:delete("tunneldigger", "mesh_vpn", "limit_bw_down") + end end o = s:option(Value, "limit_ingress", pkg_i18n.translate("Downstream (kbit/s)")) o:depends(limit, true) - o.default = uci:get("simple-tc", "mesh_vpn", "limit_ingress") + if has_tunneldigger then + o.default = uci:get("tunneldigger", "mesh_vpn", "limit_bw_down") + else + o.default = uci:get("simple-tc", "mesh_vpn", "limit_ingress") + end o.datatype = "uinteger" function o:write(data) - uci:set("simple-tc", "mesh_vpn", "limit_ingress", data) + if has_tunneldigger then + uci:set("tunneldigger", "mesh_vpn", "limit_bw_down", data) + else + uci:set("simple-tc", "mesh_vpn", "limit_ingress", data) + end end o = s:option(Value, "limit_egress", pkg_i18n.translate("Upstream (kbit/s)")) diff --git a/package/gluon-mesh-vpn-core/luasrc/lib/gluon/upgrade/500-mesh-vpn b/package/gluon-mesh-vpn-core/luasrc/lib/gluon/upgrade/500-mesh-vpn index 78045030..00764588 100755 --- a/package/gluon-mesh-vpn-core/luasrc/lib/gluon/upgrade/500-mesh-vpn +++ b/package/gluon-mesh-vpn-core/luasrc/lib/gluon/upgrade/500-mesh-vpn @@ -79,6 +79,11 @@ uci:save('fastd') if has_tunneldigger then uci:set('tunneldigger', 'mesh_vpn', 'enabled', enabled) + if site.mesh_vpn.bandwidth_limit.enabled(false) then + uci:set('tunneldigger', 'mesh_vpn', 'limit_bw_down', site.mesh_vpn.bandwidth_limit.ingress()) + uci:set('simple-tc', 'mesh_vpn', 'limit_ingress', 0) + uci:save('simple-tc') + end else uci:delete('tunneldigger', 'mesh_vpn') end