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.
5 local dsp = require "luci.dispatcher"
7 local m, mwan_rule, src_ip, src_port, dest_ip, dest_port, proto, sticky
8 local timeout, ipset, policy
12 m = Map("mwan3", translatef("MWAN Rule Configuration - %s", arg[1]))
13 m.redirect = dsp.build_url("admin", "network", "mwan", "rule")
15 mwan_rule = m:section(NamedSection, arg[1], "rule", "")
16 mwan_rule.addremove = false
17 mwan_rule.dynamic = false
19 src_ip = mwan_rule:option(Value, "src_ip", translate("Source address"),
20 translate("Supports CIDR notation (eg \"192.168.100.0/24\") without quotes"))
21 src_ip.datatype = ipaddr
23 src_port = mwan_rule:option(Value, "src_port", translate("Source port"),
24 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"))
26 dest_ip = mwan_rule:option(Value, "dest_ip", translate("Destination address"),
27 translate("Supports CIDR notation (eg \"192.168.100.0/24\") without quotes"))
28 dest_ip.datatype = ipaddr
30 dest_port = mwan_rule:option(Value, "dest_port", translate("Destination port"),
31 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"))
33 proto = mwan_rule:option(Value, "proto", translate("Protocol"),
34 translate("View the content of /etc/protocols for protocol description"))
43 sticky = mwan_rule:option(ListValue, "sticky", translate("Sticky"),
44 translate("Traffic from the same source IP address that previously matched this rule within the sticky timeout period will use the same WAN interface"))
46 sticky:value("1", translate("Yes"))
47 sticky:value("0", translate("No"))
49 timeout = mwan_rule:option(Value, "timeout", translate("Sticky timeout"),
50 translate("Seconds. Acceptable values: 1-1000000. Defaults to 600 if not set"))
51 timeout.datatype = "range(1, 1000000)"
53 ipset = mwan_rule:option(Value, "ipset", translate("IPset"),
54 translate("Name of IPset rule. Requires IPset rule in /etc/dnsmasq.conf (eg \"ipset=/youtube.com/youtube\")"))
56 policy = mwan_rule:option(Value, "use_policy", translate("Policy assigned"))
57 m.uci:foreach("mwan3", "policy",
59 policy:value(s['.name'], s['.name'])
62 policy:value("unreachable", translate("unreachable (reject)"))
63 policy:value("blackhole", translate("blackhole (drop)"))
64 policy:value("default", translate("default (use main routing table)"))