ruleconfig.lua 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. -- Copyright 2014 Aedan Renner <chipdankly@gmail.com>
  2. -- Copyright 2018 Florian Eckert <fe@dev.tdt.de>
  3. -- Licensed to the public under the GNU General Public License v2.
  4. dsp = require "luci.dispatcher"
  5. arg[1] = arg[1] or ""
  6. m5 = Map("mwan3", translatef("MWAN Rule Configuration - %s", arg[1]))
  7. m5.redirect = dsp.build_url("admin", "network", "mwan", "rule")
  8. mwan_rule = m5:section(NamedSection, arg[1], "rule", "")
  9. mwan_rule.addremove = false
  10. mwan_rule.dynamic = false
  11. src_ip = mwan_rule:option(Value, "src_ip", translate("Source address"),
  12. translate("Supports CIDR notation (eg \"192.168.100.0/24\") without quotes"))
  13. src_ip.datatype = ipaddr
  14. src_port = mwan_rule:option(Value, "src_port", translate("Source port"),
  15. translate("May be entered as a single or multiple port(s) (eg \"22\" or \"80,443\") or as a portrange (eg \"1024:2048\") without quotes"))
  16. dest_ip = mwan_rule:option(Value, "dest_ip", translate("Destination address"),
  17. translate("Supports CIDR notation (eg \"192.168.100.0/24\") without quotes"))
  18. dest_ip.datatype = ipaddr
  19. dest_port = mwan_rule:option(Value, "dest_port", translate("Destination port"),
  20. translate("May be entered as a single or multiple port(s) (eg \"22\" or \"80,443\") or as a portrange (eg \"1024:2048\") without quotes"))
  21. proto = mwan_rule:option(Value, "proto", translate("Protocol"),
  22. translate("View the content of /etc/protocols for protocol description"))
  23. proto.default = "all"
  24. proto.rmempty = false
  25. proto:value("all")
  26. proto:value("tcp")
  27. proto:value("udp")
  28. proto:value("icmp")
  29. proto:value("esp")
  30. sticky = mwan_rule:option(ListValue, "sticky", translate("Sticky"),
  31. translate("Traffic from the same source IP address that previously matched this rule within the sticky timeout period will use the same WAN interface"))
  32. sticky.default = "0"
  33. sticky:value("1", translate("Yes"))
  34. sticky:value("0", translate("No"))
  35. timeout = mwan_rule:option(Value, "timeout", translate("Sticky timeout"),
  36. translate("Seconds. Acceptable values: 1-1000000. Defaults to 600 if not set"))
  37. timeout.datatype = "range(1, 1000000)"
  38. ipset = mwan_rule:option(Value, "ipset", translate("IPset"),
  39. translate("Name of IPset rule. Requires IPset rule in /etc/dnsmasq.conf (eg \"ipset=/youtube.com/youtube\")"))
  40. policy = mwan_rule:option(Value, "use_policy", translate("Policy assigned"))
  41. m5.uci:foreach("mwan3", "policy",
  42. function(s)
  43. policy:value(s['.name'], s['.name'])
  44. end
  45. )
  46. policy:value("unreachable", translate("unreachable (reject)"))
  47. policy:value("blackhole", translate("blackhole (drop)"))
  48. policy:value("default", translate("default (use main routing table)"))
  49. return m5