Merge pull request #2442 from TDT-AG/pr/20190109-luci-mod-system-pollinterval
[project/luci.git] / applications / luci-app-mwan3 / luasrc / model / cbi / mwan / ruleconfig.lua
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
5 local dsp = require "luci.dispatcher"
6
7 local m, mwan_rule, src_ip, src_port, dest_ip, dest_port, proto, sticky
8 local timeout, ipset, policy
9
10 arg[1] = arg[1] or ""
11
12 m = Map("mwan3", translatef("MWAN Rule Configuration - %s", arg[1]))
13 m.redirect = dsp.build_url("admin", "network", "mwan", "rule")
14
15 mwan_rule = m:section(NamedSection, arg[1], "rule", "")
16 mwan_rule.addremove = false
17 mwan_rule.dynamic = false
18
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
22
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"))
25
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
29
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"))
32
33 proto = mwan_rule:option(Value, "proto", translate("Protocol"),
34 translate("View the content of /etc/protocols for protocol description"))
35 proto.default = "all"
36 proto.rmempty = false
37 proto:value("all")
38 proto:value("tcp")
39 proto:value("udp")
40 proto:value("icmp")
41 proto:value("esp")
42
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"))
45 sticky.default = "0"
46 sticky:value("1", translate("Yes"))
47 sticky:value("0", translate("No"))
48
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)"
52
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\")"))
55
56 policy = mwan_rule:option(Value, "use_policy", translate("Policy assigned"))
57 m.uci:foreach("mwan3", "policy",
58 function(s)
59 policy:value(s['.name'], s['.name'])
60 end
61 )
62 policy:value("unreachable", translate("unreachable (reject)"))
63 policy:value("blackhole", translate("blackhole (drop)"))
64 policy:value("default", translate("default (use main routing table)"))
65
66 return m