vpnbypass.lua 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. readmeURL = "https://github.com/openwrt/packages/blob/master/net/vpnbypass/files/README.md"
  2. m = Map("vpnbypass", translate("VPN Bypass Settings"))
  3. s = m:section(NamedSection, "config", "vpnbypass")
  4. -- General options
  5. e = s:option(Flag, "enabled", translate("Enable/start service"))
  6. e.rmempty = false
  7. function e.cfgvalue(self, section)
  8. return self.map:get(section, "enabled") == "1" and luci.sys.init.enabled("vpnbypass") and self.enabled or self.disabled
  9. end
  10. function e.write(self, section, value)
  11. if value == "1" then
  12. luci.sys.call("/etc/init.d/vpnbypass enable >/dev/null")
  13. luci.sys.call("/etc/init.d/vpnbypass start >/dev/null")
  14. else
  15. luci.sys.call("/etc/init.d/vpnbypass stop >/dev/null")
  16. end
  17. return Flag.write(self, section, value)
  18. end
  19. -- Local Ports
  20. p1 = s:option(DynamicList, "localport", translate("Local Ports to Bypass"), translate("Local ports to trigger VPN Bypass"))
  21. p1.datatype = "portrange"
  22. -- p1.placeholder = "0-65535"
  23. p1.addremove = false
  24. p1.optional = false
  25. -- Remote Ports
  26. p2 = s:option(DynamicList, "remoteport", translate("Remote Ports to Bypass"), translate("Remote ports to trigger VPN Bypass"))
  27. p2.datatype = "portrange"
  28. -- p2.placeholder = "0-65535"
  29. p2.addremove = false
  30. p2.optional = false
  31. -- Local Subnets
  32. r1 = s:option(DynamicList, "localsubnet", translate("Local IP Addresses to Bypass"), translate("Local IP addresses or subnets with direct internet access (outside of the VPN tunnel)"))
  33. r1.datatype = "ip4addr"
  34. -- r1.placeholder = luci.ip.new(uci.cursor():get("network", "lan", "ipaddr") .. "/" .. uci.cursor():get("network", "lan", "netmask"))
  35. r1.addremove = false
  36. r1.optional = false
  37. -- Remote Subnets
  38. r2 = s:option(DynamicList, "remotesubnet", translate("Remote IP Addresses to Bypass"), translate("Remote IP addresses or subnets which will be accessed directly (outside of the VPN tunnel)"))
  39. r2.datatype = "ip4addr"
  40. -- r2.placeholder = "0.0.0.0/0"
  41. r2.addremove = false
  42. r2.optional = false
  43. -- Domains
  44. d = Map("dhcp")
  45. s4 = d:section(TypedSection, "dnsmasq")
  46. s4.anonymous = true
  47. di = s4:option(DynamicList, "ipset", translate("Domains to Bypass"),
  48. translate("Domains to be accessed directly (outside of the VPN tunnel), see ")
  49. .. [[<a href="]] .. readmeURL .. [[#bypass-domains-formatsyntax" target="_blank">]]
  50. .. translate("README") .. [[</a>]] .. translate(" for syntax"))
  51. return m, d