luci-app-wman3: add license header to all files
[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 dsp = require "luci.dispatcher"
6 arg[1] = arg[1] or ""
7
8
9 m5 = Map("mwan3", translatef("MWAN Rule Configuration - %s", arg[1]))
10 m5.redirect = dsp.build_url("admin", "network", "mwan", "rule")
11
12 mwan_rule = m5:section(NamedSection, arg[1], "rule", "")
13 mwan_rule.addremove = false
14 mwan_rule.dynamic = false
15
16 src_ip = mwan_rule:option(Value, "src_ip", translate("Source address"),
17         translate("Supports CIDR notation (eg \"192.168.100.0/24\") without quotes"))
18 src_ip.datatype = ipaddr
19
20 src_port = mwan_rule:option(Value, "src_port", translate("Source port"),
21         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"))
22
23 dest_ip = mwan_rule:option(Value, "dest_ip", translate("Destination address"),
24         translate("Supports CIDR notation (eg \"192.168.100.0/24\") without quotes"))
25 dest_ip.datatype = ipaddr
26
27 dest_port = mwan_rule:option(Value, "dest_port", translate("Destination port"),
28         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"))
29
30 proto = mwan_rule:option(Value, "proto", translate("Protocol"),
31         translate("View the content of /etc/protocols for protocol description"))
32 proto.default = "all"
33 proto.rmempty = false
34 proto:value("all")
35 proto:value("tcp")
36 proto:value("udp")
37 proto:value("icmp")
38 proto:value("esp")
39
40 sticky = mwan_rule:option(ListValue, "sticky", translate("Sticky"),
41         translate("Traffic from the same source IP address that previously matched this rule within the sticky timeout period will use the same WAN interface"))
42 sticky.default = "0"
43 sticky:value("1", translate("Yes"))
44 sticky:value("0", translate("No"))
45
46 timeout = mwan_rule:option(Value, "timeout", translate("Sticky timeout"),
47         translate("Seconds. Acceptable values: 1-1000000. Defaults to 600 if not set"))
48 timeout.datatype = "range(1, 1000000)"
49
50 ipset = mwan_rule:option(Value, "ipset", translate("IPset"),
51         translate("Name of IPset rule. Requires IPset rule in /etc/dnsmasq.conf (eg \"ipset=/youtube.com/youtube\")"))
52
53 policy = mwan_rule:option(Value, "use_policy", translate("Policy assigned"))
54 m5.uci:foreach("mwan3", "policy",
55         function(s)
56                 policy:value(s['.name'], s['.name'])
57         end
58 )
59 policy:value("unreachable", translate("unreachable (reject)"))
60 policy:value("blackhole", translate("blackhole (drop)"))
61 policy:value("default", translate("default (use main routing table)"))
62
63 return m5