root/luci/trunk/applications/luci-multiwan/luasrc/model/cbi/multiwan/multiwan.lua @ 8333

Revision 8333, 4.9 KB (checked in by jow, 15 months ago)

applications/luci-multiwan: use new uci disable option instead of disabling the init script

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