1
0

multiwanmini.lua 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. require("luci.tools.webadmin")
  2. m = Map("multiwan", translate("Multi-WAN"),
  3. translate("Multi-WAN allows for the use of multiple uplinks for load balancing and failover."))
  4. s = m:section(NamedSection, "config", "multiwan", "")
  5. e = s:option(Flag, "enabled", translate("Enable"))
  6. e.rmempty = false
  7. e.default = "1"
  8. function e.write(self, section, value)
  9. if value == "0" then
  10. os.execute("/etc/init.d/multiwan stop")
  11. else
  12. os.execute("/etc/init.d/multiwan enable")
  13. end
  14. Flag.write(self, section, value)
  15. end
  16. s = m:section(TypedSection, "mwanfw", translate("Multi-WAN Traffic Rules"),
  17. translate("Configure rules for directing outbound traffic through specified WAN Uplinks."))
  18. s.template = "cbi/tblsection"
  19. s.anonymous = true
  20. s.addremove = true
  21. src = s:option(Value, "src", translate("Source Address"))
  22. src.rmempty = true
  23. src:value("", translate("all"))
  24. luci.tools.webadmin.cbi_add_knownips(src)
  25. dst = s:option(Value, "dst", translate("Destination Address"))
  26. dst.rmempty = true
  27. dst:value("", translate("all"))
  28. luci.tools.webadmin.cbi_add_knownips(dst)
  29. proto = s:option(Value, "proto", translate("Protocol"))
  30. proto:value("", translate("all"))
  31. proto:value("tcp", "TCP")
  32. proto:value("udp", "UDP")
  33. proto:value("icmp", "ICMP")
  34. proto.rmempty = true
  35. ports = s:option(Value, "ports", translate("Ports"))
  36. ports.rmempty = true
  37. ports:value("", translate("all", translate("all")))
  38. wanrule = s:option(ListValue, "wanrule", translate("WAN Uplink"))
  39. luci.tools.webadmin.cbi_add_networks(wanrule)
  40. wanrule:value("fastbalancer", translate("Load Balancer(Performance)"))
  41. wanrule:value("balancer", translate("Load Balancer(Compatibility)"))
  42. wanrule.default = "fastbalancer"
  43. wanrule.optional = false
  44. wanrule.rmempty = false
  45. s = m:section(NamedSection, "config", "", "")
  46. s.addremove = false
  47. default_route = s:option(ListValue, "default_route", translate("Default Route"))
  48. luci.tools.webadmin.cbi_add_networks(default_route)
  49. default_route:value("fastbalancer", translate("Load Balancer(Performance)"))
  50. default_route:value("balancer", translate("Load Balancer(Compatibility)"))
  51. default_route.default = "balancer"
  52. default_route.optional = false
  53. default_route.rmempty = false
  54. return m