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"
6 local util = require("luci.util")
12 local ipsets = util.split(util.trim(util.exec("ipset -n -L 2>/dev/null | grep -v mwan3_ | sort")), "\n", nil, true) or {}
14 m = Map("mwan3", translatef("MWAN Rule Configuration - %s", arg[1]))
15 m.redirect = dsp.build_url("admin", "network", "mwan", "rule")
17 s = m:section(NamedSection, arg[1], "rule", "")
21 o = s:option(Value, "src_ip", translate("Source address"),
22 translate("Supports CIDR notation (eg \"192.168.100.0/24\") without quotes"))
25 o = s:option(Value, "src_port", translate("Source port"),
26 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"))
28 o = s:option(Value, "dest_ip", translate("Destination address"),
29 translate("Supports CIDR notation (eg \"192.168.100.0/24\") without quotes"))
32 o = s:option(Value, "dest_port", translate("Destination port"),
33 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"))
35 o = s:option(Value, "proto", translate("Protocol"),
36 translate("View the content of /etc/protocols for protocol description"))
45 o = s:option(ListValue, "sticky", translate("Sticky"),
46 translate("Traffic from the same source IP address that previously matched this rule within the sticky timeout period will use the same WAN interface"))
48 o:value("1", translate("Yes"))
49 o:value("0", translate("No"))
51 o = s:option(Value, "timeout", translate("Sticky timeout"),
52 translate("Seconds. Acceptable values: 1-1000000. Defaults to 600 if not set"))
53 o.datatype = "range(1, 1000000)"
55 o = s:option(Value, "ipset", translate("IPset"),
56 translate("Name of IPset rule. Requires IPset rule in /etc/dnsmasq.conf (eg \"ipset=/youtube.com/youtube\")"))
57 o:value("", translate("-- Please choose --"))
58 for _, z in ipairs(ipsets) do
62 o = s:option(Flag, "logging", translate("Logging"),
63 translate("Enables firewall rule logging (global mwan3 logging must also be enabled)"))
65 o = s:option(Value, "use_policy", translate("Policy assigned"))
66 m.uci:foreach("mwan3", "policy",
68 o:value(s['.name'], s['.name'])
71 o:value("unreachable", translate("unreachable (reject)"))
72 o:value("blackhole", translate("blackhole (drop)"))
73 o:value("default", translate("default (use main routing table)"))