mesh_vpn_fastd.lua 877 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. local uci = require("simple-uci").cursor()
  2. local util = luci.util
  3. local f = SimpleForm('mesh_vpn', translate('Mesh VPN'))
  4. local s = f:section(SimpleSection)
  5. local o = s:option(Value, 'mode')
  6. o.template = "gluon/cbi/mesh-vpn-fastd-mode"
  7. local methods = uci:get('fastd', 'mesh_vpn', 'method')
  8. if util.contains(methods, 'null') then
  9. o.default = 'performance'
  10. else
  11. o.default = 'security'
  12. end
  13. function f.handle(self, state, data)
  14. if state == FORM_VALID then
  15. local site = require 'gluon.site_config'
  16. local methods = {}
  17. if data.mode == 'performance' then
  18. table.insert(methods, 'null')
  19. end
  20. for _, method in ipairs(site.fastd_mesh_vpn.methods) do
  21. if method ~= 'null' then
  22. table.insert(methods, method)
  23. end
  24. end
  25. uci:set('fastd', 'mesh_vpn', 'method', methods)
  26. uci:save('fastd')
  27. uci:commit('fastd')
  28. end
  29. end
  30. return f