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