0300-mesh-vpn.lua 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. return function(form, uci)
  2. local msg = translate(
  3. 'Your internet connection can be used to establish an ' ..
  4. 'encrypted connection with other nodes. ' ..
  5. 'Enable this option if there are no other nodes reachable ' ..
  6. 'over WLAN in your vicinity or you want to make a part of ' ..
  7. 'your connection\'s bandwidth available for the network. You can limit how ' ..
  8. 'much bandwidth the node will use at most.'
  9. )
  10. local s = form:section(Section, nil, msg)
  11. local o
  12. local meshvpn = s:option(Flag, "meshvpn", translate("Use internet connection (mesh VPN)"))
  13. meshvpn.default = uci:get_bool("fastd", "mesh_vpn", "enabled")
  14. function meshvpn:write(data)
  15. uci:set("fastd", "mesh_vpn", "enabled", data)
  16. end
  17. local limit = s:option(Flag, "limit_enabled", translate("Limit bandwidth"))
  18. limit:depends(meshvpn, true)
  19. limit.default = uci:get_bool("simple-tc", "mesh_vpn", "enabled")
  20. function limit:write(data)
  21. uci:set("simple-tc", "mesh_vpn", "interface")
  22. uci:set("simple-tc", "mesh_vpn", "enabled", data)
  23. uci:set("simple-tc", "mesh_vpn", "ifname", "mesh-vpn")
  24. end
  25. o = s:option(Value, "limit_ingress", translate("Downstream (kbit/s)"))
  26. o:depends(limit, true)
  27. o.default = uci:get("simple-tc", "mesh_vpn", "limit_ingress")
  28. o.datatype = "uinteger"
  29. function o:write(data)
  30. uci:set("simple-tc", "mesh_vpn", "limit_ingress", data)
  31. end
  32. o = s:option(Value, "limit_egress", translate("Upstream (kbit/s)"))
  33. o:depends(limit, true)
  34. o.default = uci:get("simple-tc", "mesh_vpn", "limit_egress")
  35. o.datatype = "uinteger"
  36. function o:write(data)
  37. uci:set("simple-tc", "mesh_vpn", "limit_egress", data)
  38. end
  39. return {'fastd', 'simple-tc'}
  40. end