From dc217653e24f67b6f2d69687c073a2c97d78ed30 Mon Sep 17 00:00:00 2001 From: "Craig M. Coffee" Date: Fri, 14 May 2010 12:52:44 +0000 Subject: [PATCH] [applications]: multiwan: Added Fast Balancer Option, added mini menu --- .../luasrc/controller/multiwan.lua | 5 ++ .../luasrc/model/cbi/multiwan/multiwan.lua | 5 +- .../model/cbi/multiwan/multiwanmini.lua | 65 +++++++++++++++++++ po/en/multiwan.po | 5 ++ po/templates/multiwan.pot | 3 + 5 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 applications/luci-multiwan/luasrc/model/cbi/multiwan/multiwanmini.lua diff --git a/applications/luci-multiwan/luasrc/controller/multiwan.lua b/applications/luci-multiwan/luasrc/controller/multiwan.lua index 1cbcf9e27..561747b0f 100644 --- a/applications/luci-multiwan/luasrc/controller/multiwan.lua +++ b/applications/luci-multiwan/luasrc/controller/multiwan.lua @@ -10,4 +10,9 @@ function index() page.i18n = "multiwan" page.dependent = true + local page = entry({"mini", "network", "multiwan"}, cbi("multiwan/multiwanmini", {autoapply=true}), "Multi-WAN") + page.i18n = "multiwan" + page.dependent = true + + end diff --git a/applications/luci-multiwan/luasrc/model/cbi/multiwan/multiwan.lua b/applications/luci-multiwan/luasrc/model/cbi/multiwan/multiwan.lua index 9ccb819b3..3494ac74a 100644 --- a/applications/luci-multiwan/luasrc/model/cbi/multiwan/multiwan.lua +++ b/applications/luci-multiwan/luasrc/model/cbi/multiwan/multiwan.lua @@ -21,6 +21,7 @@ end default_route = s:option(ListValue, "default_route", translate("Default Route")) luci.tools.webadmin.cbi_add_networks(default_route) +default_route:value("fastbalancer", translate("Fast Balancer")) default_route:value("balancer", translate("Load Balancer")) default_route.default = "balancer" default_route.optional = false @@ -102,6 +103,7 @@ recovery.rmempty = false failover_to = s:option(ListValue, "failover_to", translate("Failover Traffic Destination")) failover_to:value("disable", translate("None")) luci.tools.webadmin.cbi_add_networks(failover_to) +failover_to:value("fastbalancer", translate("Fast Balancer")) failover_to:value("balancer", translate("Load Balancer")) failover_to.default = "balancer" failover_to.optional = false @@ -142,8 +144,9 @@ ports:value("", translate("all", translate("all"))) wanrule = s:option(ListValue, "wanrule", translate("WAN Uplink")) luci.tools.webadmin.cbi_add_networks(wanrule) +wanrule:value("fastbalancer", translate("Fast Balancer")) wanrule:value("balancer", translate("Load Balancer")) -wanrule.default = "balancer" +wanrule.default = "fastbalancer" wanrule.optional = false wanrule.rmempty = false diff --git a/applications/luci-multiwan/luasrc/model/cbi/multiwan/multiwanmini.lua b/applications/luci-multiwan/luasrc/model/cbi/multiwan/multiwanmini.lua new file mode 100644 index 000000000..829ecda45 --- /dev/null +++ b/applications/luci-multiwan/luasrc/model/cbi/multiwan/multiwanmini.lua @@ -0,0 +1,65 @@ +require("luci.tools.webadmin") + +m = Map("multiwan", translate("Multi-WAN"), + translate("Multi-WAN allows for the use of multiple uplinks for load balancing and failover.")) + +s = m:section(NamedSection, "config", "multiwan", "") +e = s:option(Flag, "enabled", translate("Enable")) +e.rmempty = false + +function e.write(self, section, value) + local cmd = (value == "1") and "enable" or "disable" + if value ~= "1" then + os.execute("/etc/init.d/multiwan stop") + end + os.execute("/etc/init.d/multiwan " .. cmd) +end + +function e.cfgvalue(self, section) + return (os.execute("/etc/init.d/multiwan enabled") == 0) and "1" or "0" +end + +default_route = s:option(ListValue, "default_route", translate("Default Route")) +luci.tools.webadmin.cbi_add_networks(default_route) +default_route:value("fastbalancer", translate("Fast Balancer")) +default_route:value("balancer", translate("Load Balancer")) +default_route.default = "balancer" +default_route.optional = false +default_route.rmempty = false + +s = m:section(TypedSection, "mwanfw", translate("Multi-WAN Traffic Rules"), + translate("Configure rules for directing outbound traffic through specified WAN Uplinks.")) +s.template = "cbi/tblsection" +s.anonymous = true +s.addremove = true + +src = s:option(Value, "src", translate("Source Address")) +src.rmempty = true +src:value("", translate("all")) +luci.tools.webadmin.cbi_add_knownips(src) + +dst = s:option(Value, "dst", translate("Destination Address")) +dst.rmempty = true +dst:value("", translate("all")) +luci.tools.webadmin.cbi_add_knownips(dst) + +proto = s:option(ListValue, "proto", translate("Protocol")) +proto:value("", translate("all")) +proto:value("tcp", "TCP") +proto:value("udp", "UDP") +proto:value("icmp", "ICMP") +proto.rmempty = true + +ports = s:option(Value, "ports", translate("Ports")) +ports.rmempty = true +ports:value("", translate("all", translate("all"))) + +wanrule = s:option(ListValue, "wanrule", translate("WAN Uplink")) +luci.tools.webadmin.cbi_add_networks(wanrule) +wanrule:value("fastbalancer", translate("Fast Balancer")) +wanrule:value("balancer", translate("Load Balancer")) +wanrule.default = "fastbalancer" +wanrule.optional = false +wanrule.rmempty = false + +return m diff --git a/po/en/multiwan.po b/po/en/multiwan.po index b17fbffba..a0ed72ae5 100644 --- a/po/en/multiwan.po +++ b/po/en/multiwan.po @@ -119,3 +119,8 @@ msgstr "DNS Server(s)" msgid "Enable" msgstr "Enable" +#: /tmp/i18n/luasrc/i18n/multiwan.en.lua:24 +#. Fast Balancer +msgid "Fast Balancer" +msgstr "Fast Balancer" + diff --git a/po/templates/multiwan.pot b/po/templates/multiwan.pot index 0df9a88c7..ccfe9bf94 100644 --- a/po/templates/multiwan.pot +++ b/po/templates/multiwan.pot @@ -32,6 +32,9 @@ msgstr "" msgid "Failover Traffic Destination" msgstr "" +msgid "Fast Balancer" +msgstr "" + msgid "Health Monitor ICMP Host(s)" msgstr "" -- 2.25.1