applications/luci-multiwan: Changed no value, to "auto" instead.
[project/luci.git] / applications / luci-multiwan / luasrc / model / cbi / multiwan / multiwan.lua
1 require("luci.tools.webadmin")
2
3 m = Map("multiwan", translate("Multi-WAN"),
4         translate("Multi-WAN allows for the use of multiple uplinks for load balancing and failover."))
5
6 s = m:section(NamedSection, "config", "multiwan", "")
7 e = s:option(Flag, "enabled", translate("Enable"))
8 e.rmempty = false
9
10 function e.write(self, section, value)
11         local cmd = (value == "1") and "enable" or "disable"
12         if value ~= "1" then
13                 os.execute("/etc/init.d/multiwan stop")
14         end
15         os.execute("/etc/init.d/multiwan " .. cmd)
16 end
17
18 function e.cfgvalue(self, section)
19         return (os.execute("/etc/init.d/multiwan enabled") == 0) and "1" or "0"
20 end
21
22 default_route = s:option(ListValue, "default_route", translate("Default Route"))
23 luci.tools.webadmin.cbi_add_networks(default_route)
24 default_route:value("balancer", translate("Load Balancer"))
25 default_route.default = "balancer"
26 default_route.optional = false
27 default_route.rmempty = false
28
29 s = m:section(TypedSection, "interface", translate("WAN Interfaces"),
30         translate("Health Monitor detects and corrects network changes and failed connections."))
31 s.addremove = true
32
33 weight = s:option(ListValue, "weight", translate("Load Balancer Distribution"))
34 weight:value("10", "10")
35 weight:value("9", "9")
36 weight:value("8", "8")
37 weight:value("7", "7")
38 weight:value("6", "6")
39 weight:value("5", "5")
40 weight:value("4", "4")
41 weight:value("3", "3")
42 weight:value("2", "2")
43 weight:value("1", "1")
44 weight:value("disable", translate("None"))
45 weight.default = "10"
46 weight.optional = false
47 weight.rmempty = false
48
49 interval = s:option(ListValue, "health_interval", translate("Health Monitor Interval"))
50 interval:value("disable", translate("Disable"))
51 interval:value("5", "5 sec.")
52 interval:value("10", "10 sec.")
53 interval:value("20", "20 sec.")
54 interval:value("30", "30 sec.")
55 interval:value("60", "60 sec.")
56 interval:value("120", "120 sec.")
57 interval.default = "10"
58 interval.optional = false
59 interval.rmempty = false
60
61 icmp_hosts = s:option(Value, "icmp_hosts", translate("Health Monitor ICMP Host(s)"))
62 icmp_hosts:value("disable", translate("Disable"))
63 icmp_hosts:value("dns", "DNS Server(s)")
64 icmp_hosts:value("gateway", "WAN Gateway")
65 icmp_hosts.default = "dns"
66 icmp_hosts.optional = false
67 icmp_hosts.rmempty = false
68
69 timeout = s:option(ListValue, "timeout", translate("Health Monitor ICMP Timeout"))
70 timeout:value("1", "1 sec.")
71 timeout:value("2", "2 sec.")
72 timeout:value("3", "3 sec.")
73 timeout:value("4", "4 sec.")
74 timeout:value("5", "5 sec.")
75 timeout:value("10", "10 sec.")
76 timeout.default = "3"
77 timeout.optional = false
78 timeout.rmempty = false
79
80 fail = s:option(ListValue, "health_fail_retries", translate("Attempts Before WAN Failover"))
81 fail:value("1", "1")
82 fail:value("3", "3")
83 fail:value("5", "5")
84 fail:value("10", "10")
85 fail:value("15", "15")
86 fail:value("20", "20")
87 fail.default = "3"
88 fail.optional = false
89 fail.rmempty = false
90
91 recovery = s:option(ListValue, "health_recovery_retries", translate("Attempts Before WAN Recovery"))
92 recovery:value("1", "1")
93 recovery:value("3", "3")
94 recovery:value("5", "5")
95 recovery:value("10", "10")
96 recovery:value("15", "15")
97 recovery:value("20", "20")
98 recovery.default = "5"
99 recovery.optional = false
100 recovery.rmempty = false
101
102 failover_to = s:option(ListValue, "failover_to", translate("Failover Traffic Destination"))
103 failover_to:value("disable", translate("None"))
104 luci.tools.webadmin.cbi_add_networks(failover_to)
105 failover_to:value("balancer", translate("Load Balancer"))
106 failover_to.default = "balancer"
107 failover_to.optional = false
108 failover_to.rmempty = false
109
110 dns = s:option(Value, "dns", translate("DNS Server(s)"))
111 dns:value("auto", translate("Auto"))
112 dns.default = "auto"
113 dns.optional = false
114 dns.rmempty = true
115
116 s = m:section(TypedSection, "mwanfw", translate("Multi-WAN Traffic Rules"),
117         translate("Configure rules for directing outbound traffic through specified WAN Uplinks."))
118 s.template = "cbi/tblsection"
119 s.anonymous = true
120 s.addremove = true
121
122 src = s:option(Value, "src", translate("Source Address"))
123 src.rmempty = true
124 src:value("", translate("all"))
125 luci.tools.webadmin.cbi_add_knownips(src)
126
127 dst = s:option(Value, "dst", translate("Destination Address"))
128 dst.rmempty = true
129 dst:value("", translate("all"))
130 luci.tools.webadmin.cbi_add_knownips(dst)
131
132 proto = s:option(ListValue, "proto", translate("Protocol"))
133 proto:value("", translate("all"))
134 proto:value("tcp", "TCP")
135 proto:value("udp", "UDP")
136 proto:value("icmp", "ICMP")
137 proto.rmempty = true
138
139 ports = s:option(Value, "ports", translate("Ports"))
140 ports.rmempty = true
141 ports:value("", translate("all", translate("all")))
142
143 wanrule = s:option(ListValue, "wanrule", translate("WAN Uplink"))
144 luci.tools.webadmin.cbi_add_networks(wanrule)
145 wanrule:value("balancer", translate("Load Balancer"))
146 wanrule.default = "balancer"
147 wanrule.optional = false
148 wanrule.rmempty = false
149
150 return m