[applications] luci-multiwan: Updated menu wording, and default for load balancer.
[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 resolv_conf = s:option(Value, "resolv_conf", translate("DNS Configuration File"),
30         translate("Writeable resolv file, dnsmasq defaults to /tmp/resolv.conf.auto"))
31 resolv_conf.default = "/tmp/resolv.conf.auto"
32 resolv_conf.optional = false
33 resolv_conf.rmempty = false
34
35 s = m:section(TypedSection, "interface", translate("WAN Interfaces"),
36         translate("Health Monitor detects and corrects network changes and failed connections."))
37 s.addremove = true
38
39 weight = s:option(ListValue, "weight", translate("Load Balancer Distribution"))
40 weight:value("10", "10")
41 weight:value("9", "9")
42 weight:value("8", "8")
43 weight:value("7", "7")
44 weight:value("6", "6")
45 weight:value("5", "5")
46 weight:value("4", "4")
47 weight:value("3", "3")
48 weight:value("2", "2")
49 weight:value("1", "1")
50 weight:value("disable", translate("None"))
51 weight.default = "10"
52 weight.optional = false
53 weight.rmempty = false
54
55 interval = s:option(ListValue, "health_interval", translate("Health Monitor Interval"))
56 interval:value("disable", translate("Disable"))
57 interval:value("5", "5 sec.")
58 interval:value("10", "10 sec.")
59 interval:value("20", "20 sec.")
60 interval:value("30", "30 sec.")
61 interval:value("60", "60 sec.")
62 interval:value("120", "120 sec.")
63 interval.default = "10"
64 interval.optional = false
65 interval.rmempty = false
66
67 icmp_hosts = s:option(Value, "icmp_hosts", translate("Health Monitor ICMP Host(s)"))
68 icmp_hosts:value("disable", translate("Disable"))
69 icmp_hosts:value("dns", "DNS Server(s)")
70 icmp_hosts:value("gateway", "WAN Gateway")
71 icmp_hosts.default = "dns"
72 icmp_hosts.optional = false
73 icmp_hosts.rmempty = false
74
75 timeout = s:option(ListValue, "timeout", translate("Health Monitor ICMP Timeout"))
76 timeout:value("1", "1 sec.")
77 timeout:value("2", "2 sec.")
78 timeout:value("3", "3 sec.")
79 timeout:value("4", "4 sec.")
80 timeout:value("5", "5 sec.")
81 timeout:value("10", "10 sec.")
82 timeout.default = "3"
83 timeout.optional = false
84 timeout.rmempty = false
85
86 fail = s:option(ListValue, "health_fail_retries", translate("Attempts Before WAN Failover"))
87 fail:value("1", "1")
88 fail:value("3", "3")
89 fail:value("5", "5")
90 fail:value("10", "10")
91 fail:value("15", "15")
92 fail:value("20", "20")
93 fail.default = "3"
94 fail.optional = false
95 fail.rmempty = false
96
97 recovery = s:option(ListValue, "health_recovery_retries", translate("Attempts Before WAN Recovery"))
98 recovery:value("1", "1")
99 recovery:value("3", "3")
100 recovery:value("5", "5")
101 recovery:value("10", "10")
102 recovery:value("15", "15")
103 recovery:value("20", "20")
104 recovery.default = "5"
105 recovery.optional = false
106 recovery.rmempty = false
107
108 failover_to = s:option(ListValue, "failover_to", translate("Failover Traffic Destination"))
109 failover_to:value("disable", translate("None"))
110 luci.tools.webadmin.cbi_add_networks(failover_to)
111 failover_to:value("balancer", translate("Load Balancer"))
112 failover_to.default = "balancer"
113 failover_to.optional = false
114 failover_to.rmempty = false
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