mirror of
				https://github.com/Ysurac/openmptcprouter-feeds.git
				synced 2025-03-09 15:40:03 +00:00 
			
		
		
		
	Fix MPTCP bandwidth graph in some case
This commit is contained in:
		
							parent
							
								
									1400f7b0aa
								
							
						
					
					
						commit
						495d658f29
					
				
					 2 changed files with 26 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -40,6 +40,9 @@ function multipath_bandwidth()
 | 
			
		|||
 | 
			
		||||
	uci:foreach("network", "interface", function(s)
 | 
			
		||||
		local dev = s["ifname"] or ""
 | 
			
		||||
		if dev == "" then
 | 
			
		||||
			dev = get_device(s["ifname"])
 | 
			
		||||
		end
 | 
			
		||||
		if dev ~= "lo" and dev ~= "" then
 | 
			
		||||
			local multipath = s["multipath"] or "off"
 | 
			
		||||
			if multipath == "on" or multipath == "master" or multipath == "backup" or multipath == "handover" then
 | 
			
		||||
| 
						 | 
				
			
			@ -59,7 +62,11 @@ end
 | 
			
		|||
 | 
			
		||||
function get_device(interface)
 | 
			
		||||
	local dump = require("luci.util").ubus("network.interface.%s" % interface, "status", {})
 | 
			
		||||
	return dump['l3_device']
 | 
			
		||||
	if dump then
 | 
			
		||||
		return dump['l3_device']
 | 
			
		||||
	else
 | 
			
		||||
		return ""
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function mptcp_check_trace(iface)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,6 +24,15 @@
 | 
			
		|||
	local ntm = require "luci.model.network".init()
 | 
			
		||||
	local uci = require "luci.model.uci".cursor()
 | 
			
		||||
 | 
			
		||||
	function get_device(interface)
 | 
			
		||||
		local dump = require("luci.util").ubus("network.interface.%s" % interface, "status", {})
 | 
			
		||||
		if dump and dump['l3_device'] ~= "" then
 | 
			
		||||
			return dump['l3_device']
 | 
			
		||||
		else
 | 
			
		||||
			return interface
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	local dev
 | 
			
		||||
	local devices = { "all" }
 | 
			
		||||
	for _, dev in ipairs(ntm:get_networks()) do
 | 
			
		||||
| 
						 | 
				
			
			@ -35,7 +44,7 @@
 | 
			
		|||
		--end
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	local curdev = luci.http.formvalue("dev") or "all"
 | 
			
		||||
	local curifname = luci.http.formvalue("dev") or "all"
 | 
			
		||||
-%>
 | 
			
		||||
 | 
			
		||||
<%+header%>
 | 
			
		||||
| 
						 | 
				
			
			@ -96,7 +105,7 @@
 | 
			
		|||
		);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
<% if curdev == "all" then %>
 | 
			
		||||
<% if curifname == "all" then %>
 | 
			
		||||
	var all = true;
 | 
			
		||||
	var bwxhr = new XHR();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -652,7 +661,7 @@
 | 
			
		|||
				label_scale.innerHTML = String.format('<%:(%d minute window, %d second interval)%>', data_wanted / 60, 3);
 | 
			
		||||
 | 
			
		||||
				/* render datasets, start update interval */
 | 
			
		||||
				XHR.poll(3, '<%=build_url("admin/network/mptcp/interface_bandwidth", curdev)%>', null,
 | 
			
		||||
				XHR.poll(3, '<%=build_url("admin/network/mptcp/interface_bandwidth", curifname)%>', null,
 | 
			
		||||
					function(x, data)
 | 
			
		||||
					{
 | 
			
		||||
						var data_max   = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -762,12 +771,15 @@
 | 
			
		|||
<h2><a id="content" name="content"><%:Realtime Traffic%></a></h2>
 | 
			
		||||
 | 
			
		||||
<ul class="cbi-tabmenu">
 | 
			
		||||
	<% for _, dev in ipairs(devices) do %>
 | 
			
		||||
		<li class="cbi-tab<%= dev == curdev and "" or "-disabled" %>"><a href="?dev=<%=pcdata(dev)%>"><%=pcdata(dev)%></a></li>
 | 
			
		||||
	<% for _, dev in ipairs(devices) do 
 | 
			
		||||
		local ifname = get_device(dev)
 | 
			
		||||
	%>
 | 
			
		||||
		
 | 
			
		||||
		<li class="cbi-tab<%= ifname == curifname and "" or "-disabled" %>"><a href="?dev=<%=pcdata(get_device(dev))%>"><%=pcdata(dev)%></a></li>
 | 
			
		||||
	<% end %>
 | 
			
		||||
</ul>
 | 
			
		||||
 | 
			
		||||
<% if curdev == "all" then %>
 | 
			
		||||
<% if curifname == "all" then %>
 | 
			
		||||
 | 
			
		||||
<strong><%:Download:%></strong>
 | 
			
		||||
<embed id="dnsvg" style="width:100%; height:300px; border:1px solid #000000; background-color:#FFFFFF" src="<%=resource%>/bandwidth.svg" />
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue