mesh_vpn_fastd.lua 776 B

1234567891011121314151617181920212223242526272829303132333435363738
  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.template = "gluon/model/mesh-vpn-fastd"
  7. local methods = uci:get('fastd', 'mesh_vpn', 'method')
  8. if util.contains(methods, 'null') then
  9. mode.default = 'performance'
  10. else
  11. mode.default = 'security'
  12. end
  13. function mode:write(data)
  14. local site = require 'gluon.site_config'
  15. local methods = {}
  16. if data == 'performance' then
  17. table.insert(methods, 'null')
  18. end
  19. for _, method in ipairs(site.fastd_mesh_vpn.methods) do
  20. if method ~= 'null' then
  21. table.insert(methods, method)
  22. end
  23. end
  24. uci:set('fastd', 'mesh_vpn', 'method', methods)
  25. uci:save('fastd')
  26. uci:commit('fastd')
  27. end
  28. return f