Parcourir la source

Merge pull request #381 from arfett/master

mwan-luci: update to 1.3-2
sbyx il y a 10 ans
Parent
révision
56c5187af1

+ 5
- 4
net/mwan3-luci/Makefile Voir le fichier

@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
9 9
 
10 10
 PKG_NAME:=luci-app-mwan3
11 11
 PKG_VERSION:=1.3
12
-PKG_RELEASE:=1
12
+PKG_RELEASE:=2
13 13
 PKG_MAINTAINER:=Aedan Renner <chipdankly@gmail.com>
14 14
 PKG_LICENSE:=GPLv2
15 15
 
@@ -20,14 +20,15 @@ define Package/luci-app-mwan3
20 20
   CATEGORY:=LuCI
21 21
   SUBMENU:=3. Applications
22 22
   TITLE:=LuCI support for the MWAN3 multiwan hotplug script
23
-  DEPENDS:=+mwan3
23
+  DEPENDS:=+mwan3 +luci-mod-admin-full +luci-lib-nixio
24 24
   PKGARCH:=all
25 25
   MAINTAINER:=Aedan Renner <chipdankly@gmail.com>
26 26
 endef
27 27
 
28 28
 define Package/luci-app-mwan3/description
29
-Hotplug script which makes configuration of multiple WAN interfaces simple and manageable
30
-With loadbalancing/failover support for up to 250 WAN interfaces, connection tracking and an easy to manage traffic ruleset
29
+Hotplug script which makes configuration of multiple WAN interfaces simple and
30
+manageable with loadbalancing/failover support for up to 250 physical or logical
31
+WAN interfaces, connection tracking and an easy to manage traffic ruleset
31 32
 endef
32 33
 
33 34
 define Build/Compile

+ 5
- 6
net/mwan3-luci/files/etc/hotplug.d/iface/16-mwan3custombak Voir le fichier

@@ -1,22 +1,21 @@
1 1
 #!/bin/sh
2 2
 
3 3
 # to enable this script uncomment the case loop at the bottom
4
-# to report MWAN3 status on interface up/down events modify the lines in the send_reportdata function
4
+# to report mwan3 status on interface hotplug ifup/ifdown events modify the lines in the send_alert function
5 5
 
6 6
 send_alert()
7 7
 {
8
-	# $1 stores the mwan3 status information
9
-	# insert your code here to send the contents of $1
10
-	echo "$1"
8
+	# variable "$1" stores the mwan3 status information
9
+	# insert your code here to send the contents of "$1"
11 10
 }
12 11
 
13 12
 gather_event_info()
14 13
 {
15 14
 	# create event information message
16
-	local EVENT_INFO="Interface [ "$INTERFACE" ($DEVICE) ] on router [ "$(uci get -p /var/state system.@system[0].hostname)" ] has triggered an [ "$ACTION" ] hotplug event on "$(date)""
15
+	local EVENT_INFO="Interface [ "$INTERFACE" ($DEVICE) ] on router [ "$(uci get -p /var/state system.@system[0].hostname)" ] has triggered a hotplug [ "$ACTION" ] event on "$(date +"%a %b %d %Y %T %Z")""
17 16
 
18 17
 	# get current interface, policy and rule status
19
-	local CURRENT_STATUS="$(mwan3 status)"
18
+	local CURRENT_STATUS="$(/usr/sbin/mwan3 status)"
20 19
 
21 20
 	# get last 50 mwan3 systemlog messages
22 21
 	local MWAN3_LOG="$(echo -e "Last 50 MWAN3 systemlog entries. Newest entries sorted at the top:\n$(logread | grep mwan3 | tail -n 50 | sed 'x;1!H;$!d;x')")"

+ 0
- 14
net/mwan3-luci/files/etc/uci-defaults/mwan3 Voir le fichier

@@ -1,14 +0,0 @@
1
-#!/bin/sh
2
-
3
-# delete existing mwan3 ucitrack entry and add new entry
4
-uci -q batch <<-EOF >/dev/null
5
-	del ucitrack.@mwan3[-1]
6
-	add ucitrack mwan3
7
-	set ucitrack.@mwan3[-1].exec="/etc/init.d/mwan3 restart"
8
-	commit ucitrack
9
-EOF
10
-
11
-# make controller file addition take effect without system restart
12
-rm -rf /tmp/luci-indexcache /tmp/luci-modulecache
13
-
14
-exit 0

+ 14
- 0
net/mwan3-luci/files/etc/uci-defaults/mwan3-luci Voir le fichier

@@ -0,0 +1,14 @@
1
+#!/bin/sh
2
+
3
+# replace existing mwan3-luci ucitrack entry
4
+uci -q batch <<-EOF >/dev/null
5
+	del ucitrack.@mwan3[-1]
6
+	add ucitrack mwan3
7
+	set ucitrack.@mwan3[-1].exec="/usr/sbin/mwan3 restart"
8
+	commit ucitrack
9
+EOF
10
+
11
+# remove LuCI cache
12
+rm -rf /tmp/luci-indexcache /tmp/luci-modulecache
13
+
14
+exit 0

+ 6
- 6
net/mwan3-luci/files/usr/lib/lua/luci/controller/mwan3.lua Voir le fichier

@@ -168,7 +168,7 @@ function mwan3_diag_data(iface, tool, alt)
168 168
 		local ifdev = ut.trim(sys.exec("uci get -p /var/state network." .. iface .. ".ifname"))
169 169
 		if ifdev ~= "" then
170 170
 			if tool == "ping" then
171
-				local gateway = ut.trim(sys.exec("route -n | awk -F' ' '{ if ($8 == \"" .. ifdev .. "\" && $1 == \"0.0.0.0\") print $2 }'"))
171
+				local gateway = ut.trim(sys.exec("route -n | awk '{ if ($8 == \"" .. ifdev .. "\" && $1 == \"0.0.0.0\" && $3 == \"0.0.0.0\") print $2 }'"))
172 172
 				if gateway ~= "" then
173 173
 					if alt == "gateway" then
174 174
 						local cmd = "ping -c 3 -W 2 -I " .. ifdev .. " " .. gateway
@@ -247,17 +247,17 @@ function mwan3_tshoot_data()
247 247
 		else
248 248
 			lucirelease = "\nLuCI - unknown"
249 249
 		end
250
-	local mwan3version = ut.trim(sys.exec("opkg info mwan3 | grep Version | awk -F' ' '{ print $2 }'"))
250
+	local mwan3version = ut.trim(sys.exec("opkg info mwan3 | grep Version | awk '{ print $2 }'"))
251 251
 		if mwan3version ~= "" then
252 252
 			mwan3version = "\n\nmwan3 - " .. mwan3version
253 253
 		else
254 254
 			mwan3version = "\nmwan3 - unknown"
255 255
 		end
256
-	local mwan3lversion = ut.trim(sys.exec("opkg info luci-app-mwan3 | grep Version | awk -F' ' '{ print $2 }'"))
256
+	local mwan3lversion = ut.trim(sys.exec("opkg info luci-app-mwan3 | grep Version | awk '{ print $2 }'"))
257 257
 		if mwan3lversion ~= "" then
258
-			mwan3lversion = "\nluci-app-mwan3 - " .. mwan3lversion
258
+			mwan3lversion = "\nmwan3-luci - " .. mwan3lversion
259 259
 		else
260
-			mwan3lversion = "\nluci-app-mwan3 - unknown"
260
+			mwan3lversion = "\nmwan3-luci - unknown"
261 261
 		end
262 262
 	local softrev = wrtrelease .. lucirelease .. mwan3version .. mwan3lversion
263 263
 	rv.mw3ver = { }
@@ -316,7 +316,7 @@ function mwan3_tshoot_data()
316 316
 	rv.iprule[ipruleid[ipr]] = { rule = ipr }
317 317
 
318 318
 	-- ip route list table 1-250
319
-	local routelisting, rlstr = ut.trim(sys.exec("ip rule | sed 's/://g' | awk -F' ' '$1>=2001 && $1<=2250' | awk -F' ' '{ print $NF }'")), ""
319
+	local routelisting, rlstr = ut.trim(sys.exec("ip rule | sed 's/://g' | awk '$1>=2001 && $1<=2250' | awk '{ print $NF }'")), ""
320 320
 		if routelisting ~= "" then
321 321
 			for line in routelisting:gmatch("[^\r\n]+") do
322 322
 				rlstr = rlstr .. line .. "\n" .. sys.exec("ip route list table " .. line)

+ 3
- 3
net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan3/mwan3_interface.lua Voir le fichier

@@ -30,7 +30,7 @@ function iface_check() -- find issues with too many interfaces, reliability and
30 30
 					err_netcfg_list = err_netcfg_list .. ifname .. " "
31 31
 					err_route_list = err_route_list .. ifname .. " "
32 32
 				else
33
-					local rtcheck = ut.trim(sys.exec("route -n | awk -F' ' '{ if ($8 == \"" .. ifdev .. "\" && $1 == \"0.0.0.0\") print $1 }'"))
33
+					local rtcheck = ut.trim(sys.exec("route -n | awk '{ if ($8 == \"" .. ifdev .. "\" && $1 == \"0.0.0.0\" && $3 == \"0.0.0.0\") print $1 }'"))
34 34
 					if rtcheck == "" then
35 35
 						err_found = 1
36 36
 						err_route_list = err_route_list .. ifname .. " "
@@ -44,12 +44,12 @@ function iface_check() -- find issues with too many interfaces, reliability and
44 44
 		end
45 45
 	)
46 46
 	-- check if any interfaces have duplicate metrics
47
-	local metric_dupnums = sys.exec("echo '" .. metric_list .. "' | awk -F' ' '{ print $2 }' | uniq -d")
47
+	local metric_dupnums = sys.exec("echo '" .. metric_list .. "' | awk '{ print $2 }' | uniq -d")
48 48
 	if metric_dupnums ~= "" then
49 49
 		err_found = 1
50 50
 		local metric_dupes = ""
51 51
 		for line in metric_dupnums:gmatch("[^\r\n]+") do
52
-			metric_dupes = sys.exec("echo '" .. metric_list .. "' | grep '" .. line .. "' | awk -F' ' '{ print $1 }'")
52
+			metric_dupes = sys.exec("echo '" .. metric_list .. "' | grep '" .. line .. "' | awk '{ print $1 }'")
53 53
 			err_dupmet_list = err_dupmet_list .. metric_dupes
54 54
 		end
55 55
 		err_dupmet_list = sys.exec("echo '" .. err_dupmet_list .. "' | tr '\n' ' '")

+ 3
- 3
net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan3/mwan3_interfaceconfig.lua Voir le fichier

@@ -12,9 +12,9 @@ function iface_check()
12 12
 			end
13 13
 		)
14 14
 		-- compare metric against list
15
-		local metric_dupnums, metric_dupes = sys.exec("echo '" .. metric_list .. "' | awk -F' ' '{ print $2 }' | uniq -d"), ""
15
+		local metric_dupnums, metric_dupes = sys.exec("echo '" .. metric_list .. "' | awk '{ print $2 }' | uniq -d"), ""
16 16
 		for line in metric_dupnums:gmatch("[^\r\n]+") do
17
-			metric_dupes = sys.exec("echo '" .. metric_list .. "' | grep '" .. line .. "' | awk -F' ' '{ print $1 }'")
17
+			metric_dupes = sys.exec("echo '" .. metric_list .. "' | grep '" .. line .. "' | awk '{ print $1 }'")
18 18
 			err_dupmet_list = err_dupmet_list .. metric_dupes
19 19
 		end
20 20
 		if sys.exec("echo '" .. err_dupmet_list .. "' | grep -w " .. arg[1]) ~= "" then
@@ -36,7 +36,7 @@ function iface_check()
36 36
 			err_netcfg = 1
37 37
 			err_route = 1
38 38
 		else
39
-			local rtcheck = ut.trim(sys.exec("route -n | awk -F' ' '{ if ($8 == \"" .. ifdev .. "\" && $1 == \"0.0.0.0\") print $1 }'"))
39
+			local rtcheck = ut.trim(sys.exec("route -n | awk '{ if ($8 == \"" .. ifdev .. "\" && $1 == \"0.0.0.0\" && $3 == \"0.0.0.0\") print $1 }'"))
40 40
 			if rtcheck == "" then
41 41
 				err_route = 1
42 42
 			end

+ 13
- 0
net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan3/mwan3_policy.lua Voir le fichier

@@ -68,6 +68,19 @@ use_member = mwan_policy:option(DummyValue, "use_member", translate("Members ass
68 68
 		
69 69
 	end
70 70
 
71
+last_resort = mwan_policy:option(DummyValue, "last_resort", translate("Last resort"))
72
+	last_resort.rawhtml = true
73
+	function last_resort.cfgvalue(self, s)
74
+		local str = self.map:get(s, "last_resort")
75
+		if str == "unreachable" or str == "" or str == null then
76
+			return "unreachable (reject)"
77
+		elseif str == "blackhole" then
78
+			return "blackhole (drop)"
79
+		elseif str == "main" then
80
+			return "main (use main routing table)"
81
+		end
82
+	end
83
+
71 84
 errors = mwan_policy:option(DummyValue, "errors", translate("Errors"))
72 85
 	errors.rawhtml = true
73 86
 	function errors.cfgvalue(self, s)

+ 7
- 0
net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan3/mwan3_policyconfig.lua Voir le fichier

@@ -45,6 +45,13 @@ mwan_policy = m5:section(NamedSection, arg[1], "policy", "")
45 45
 use_member = mwan_policy:option(DynamicList, "use_member", translate("Member used"))
46 46
 	cbi_add_member(use_member)
47 47
 
48
+last_resort = mwan_policy:option(ListValue, "last_resort", translate("Last resort"),
49
+	translate("When all policy members are offline use this behavior for matched traffic"))
50
+	last_resort.default = "unreachable"
51
+	last_resort:value("unreachable", translate("unreachable (reject)"))
52
+	last_resort:value("blackhole", translate("blackhole (drop)"))
53
+	last_resort:value("main", translate("main (use main routing table)"))
54
+
48 55
 
49 56
 -- ------ currently configured members ------ --
50 57
 

+ 1
- 1
net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan3/mwan3_ruleconfig.lua Voir le fichier

@@ -28,7 +28,7 @@ function cbi_add_policy(field)
28 28
 end
29 29
 
30 30
 function cbi_add_protocol(field)
31
-	local protos = ut.trim(sys.exec("cat /etc/protocols | grep '	# ' | awk -F' ' '{print $1}' | grep -vw -e 'ip' -e 'tcp' -e 'udp' -e 'icmp' -e 'esp' | grep -v 'ipv6' | sort | tr '\n' ' '"))
31
+	local protos = ut.trim(sys.exec("cat /etc/protocols | grep '	# ' | awk '{print $1}' | grep -vw -e 'ip' -e 'tcp' -e 'udp' -e 'icmp' -e 'esp' | grep -v 'ipv6' | sort | tr '\n' ' '"))
32 32
 	for p in string.gmatch(protos, "%S+") do
33 33
 		field:value(p)
34 34
 	end

+ 1
- 4
net/mwan3-luci/files/usr/lib/lua/luci/view/mwan3/mwan3_adv_diagnostics.htm Voir le fichier

@@ -57,10 +57,7 @@
57 57
 				{
58 58
 					var temp = '';
59 59
 					var ncint = 'No diagnostic results returned';
60
-					temp = String.format(
61
-						'<pre id="diag_output_css"><strong>%s</strong></pre>',
62
-							ncint
63
-					);
60
+					temp = String.format('<pre id="diag_output_css"><strong>%s</strong></pre>', ncint);
64 61
 					output.innerHTML = temp;
65 62
 				}
66 63
 			}

+ 3
- 5
net/mwan3-luci/files/usr/lib/lua/luci/view/mwan3/mwan3_adv_troubleshoot.htm Voir le fichier

@@ -29,7 +29,7 @@
29 29
 
30 30
 				temp = String.format(
31 31
 					'<pre><span class="tsht">%s</span>%s<span class="tsht">%s</span>%s<span class="tsht">%s</span>%s<span class="tsht">%s</span>%s<span class="tsht">%s</span>%s<span class="tsht">%s</span>%s<span class="tsht">%s</span>%s<span class="tsht">%s</span>%s<span class="tsht">%s</span>%s</pre>',
32
-						mwanvers, st.mw3ver[0].mwan3v, mwan3cnfg, st.mwan3config[0].mwn3cfg, netcnfg, st.netconfig[0].netcfg, ifcnfg, st.ifconfig[0].ifcfg, iproute, st.rtshow[0].iprtshow, iprulesh, st.iprule[0].rule, routelisttbl, st.routelist[0].iprtlist, firewalldef, st.fidef[0].firedef, iptable, st.iptables[0].iptbls
32
+					mwanvers, st.mw3ver[0].mwan3v, mwan3cnfg, st.mwan3config[0].mwn3cfg, netcnfg, st.netconfig[0].netcfg, ifcnfg, st.ifconfig[0].ifcfg, iproute, st.rtshow[0].iprtshow, iprulesh, st.iprule[0].rule, routelisttbl, st.routelist[0].iprtlist, firewalldef, st.fidef[0].firedef, iptable, st.iptables[0].iptbls
33 33
 				);
34 34
 				tx.innerHTML = temp;
35 35
 			}
@@ -37,10 +37,7 @@
37 37
 			{
38 38
 				var temp = '';
39 39
 				var terror = 'Error collecting troubleshooting information';
40
-				temp = String.format(
41
-					'<strong>%s</strong>',
42
-						terror
43
-				);
40
+				temp = String.format('<strong>%s</strong>', terror);
44 41
 				tx.innerHTML = temp;
45 42
 			}
46 43
 		}
@@ -53,6 +50,7 @@
53 50
 		<div id="mwan3_tshoot_text"><img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> Collecting data...</div>
54 51
 	</fieldset>
55 52
 </div>
53
+
56 54
 <style type="text/css">
57 55
   .container {  /*container for entire page. fixes bootstrap theme's ridiculously small page width*/
58 56
 	max-width: none;

+ 2
- 8
net/mwan3-luci/files/usr/lib/lua/luci/view/mwan3/mwan3_over_detail.htm Voir le fichier

@@ -14,20 +14,14 @@
14 14
 			if (st.mwan3dst)
15 15
 			{
16 16
 				var temp = '';
17
-				temp = String.format(
18
-					'<pre>%s</pre>',
19
-						st.mwan3dst[0].detailstat
20
-				);
17
+				temp = String.format('<pre>%s</pre>', st.mwan3dst[0].detailstat);
21 18
 				tx.innerHTML = temp;
22 19
 			}
23 20
 			else
24 21
 			{
25 22
 				var temp = '';
26 23
 				var nslg = 'No detailed status information available';
27
-				temp = String.format(
28
-					'<strong>%s</strong>',
29
-						nslg
30
-				);
24
+				temp = String.format('<strong>%s</strong>', nslg);
31 25
 				tx.innerHTML = temp;
32 26
 			}
33 27
 		}

+ 4
- 14
net/mwan3-luci/files/usr/lib/lua/luci/view/mwan3/mwan3_over_interface.htm Voir le fichier

@@ -45,7 +45,7 @@
45 45
 
46 46
 					temp += String.format(
47 47
 						'<span class="%s"><strong>%s (<a href="%q">%s</a>)</strong><br />%s</span>',
48
-							cssc, st.wans[i].name, st.wans[i].link, st.wans[i].ifname, stat
48
+						cssc, st.wans[i].name, st.wans[i].link, st.wans[i].ifname, stat
49 49
 					);
50 50
 				}
51 51
 				tx.innerHTML = temp;
@@ -54,10 +54,7 @@
54 54
 			{
55 55
 				var temp = '';
56 56
 				var ncint = 'No MWAN3 interfaces found';
57
-				temp = String.format(
58
-					'<strong>%s</strong>',
59
-						ncint
60
-				);
57
+				temp = String.format('<strong>%s</strong>', ncint);
61 58
 				tx.innerHTML = temp;
62 59
 			}
63 60
 
@@ -66,21 +63,14 @@
66 63
 			{
67 64
 				var temp = '';
68 65
 				var mwan3lg = 'Last 50 MWAN3 systemlog entries. Newest entries sorted at the top :';
69
-
70
-				temp = String.format(
71
-					'<pre>%s<br /><br />%s</pre>',
72
-						mwan3lg, st.mwan3log[0].mwanlog
73
-				);
66
+				temp = String.format('<pre>%s<br /><br />%s</pre>', mwan3lg, st.mwan3log[0].mwanlog);
74 67
 				tx.innerHTML = temp;
75 68
 			}
76 69
 			else
77 70
 			{
78 71
 				var temp = '';
79 72
 				var nslg = 'No MWAN3 systemlog history found';
80
-				temp = String.format(
81
-					'<strong>%s</strong>',
82
-						nslg
83
-				);
73
+				temp = String.format('<strong>%s</strong>', nslg);
84 74
 				tx.innerHTML = temp;
85 75
 			}
86 76
 		}

+ 2
- 5
net/mwan3-luci/files/usr/lib/lua/luci/view/mwan3/mwan3_status.htm Voir le fichier

@@ -37,7 +37,7 @@
37 37
 
38 38
 					temp += String.format(
39 39
 						'<span class="%s"><strong>%s (<a href="%q">%s</a>)</strong><br />%s</span>',
40
-							cssc, st.wans[i].name, st.wans[i].link, st.wans[i].ifname, stat
40
+						cssc, st.wans[i].name, st.wans[i].link, st.wans[i].ifname, stat
41 41
 					);
42 42
 				}
43 43
 				tx.innerHTML = temp;
@@ -46,10 +46,7 @@
46 46
 			{
47 47
 				var temp = '';
48 48
 				var ncint = 'No MWAN3 interfaces found';
49
-				temp += String.format(
50
-					'<strong>%s</strong>',
51
-						ncint
52
-				);
49
+				temp += String.format('<strong>%s</strong>', ncint );
53 50
 				tx.innerHTML = temp;
54 51
 			}
55 52
 		}