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