mesh_vpn_fastd.lua 813 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. local uci = require("simple-uci").cursor()
  2. local util = gluon.web.util
  3. local f = Form(translate('Mesh VPN'))
  4. local s = f:section(Section)
  5. local mode = s:option(Value, 'mode')
  6. mode.package = "gluon-web-mesh-vpn-fastd"
  7. mode.template = "gluon/model/mesh-vpn-fastd"
  8. local methods = uci:get('fastd', 'mesh_vpn', 'method')
  9. if util.contains(methods, 'null') then
  10. mode.default = 'performance'
  11. else
  12. mode.default = 'security'
  13. end
  14. function mode:write(data)
  15. local site = require 'gluon.site'
  16. local methods = {}
  17. if data == 'performance' then
  18. table.insert(methods, 'null')
  19. end
  20. for _, method in ipairs(site.mesh_vpn.fastd.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. return f