mirror of
				https://github.com/Ysurac/openmptcprouter-feeds.git
				synced 2025-03-09 15:40:03 +00:00 
			
		
		
		
	Add check for duplicate mac
This commit is contained in:
		
							parent
							
								
									7c2fd8f2ad
								
							
						
					
					
						commit
						a254d4aaed
					
				
					 2 changed files with 34 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -455,6 +455,7 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm
 | 
			
		|||
					var multipath_available = mArray.wans[i].multipath_available;
 | 
			
		||||
					var multipath_state = mArray.wans[i].multipath_state;
 | 
			
		||||
					var duplicateif = mArray.wans[i].duplicateif;
 | 
			
		||||
					var duplicatemac = mArray.wans[i].duplicatemac;
 | 
			
		||||
					// Generate template
 | 
			
		||||
					if(mArray.openmptcprouter.remote_from_lease == true && mArray.wans.length == 1)
 | 
			
		||||
					{
 | 
			
		||||
| 
						 | 
				
			
			@ -547,12 +548,12 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm
 | 
			
		|||
					if(gateway == '' && gateway6 == '')
 | 
			
		||||
					{
 | 
			
		||||
						statusMessage += '<%:No gateway defined%>' + '<br />';
 | 
			
		||||
					} else if(gw_ping == 'DOWN')
 | 
			
		||||
					} else if(gateway != '' && gw_ping == 'DOWN')
 | 
			
		||||
					{
 | 
			
		||||
						statusMessage += '<%:Gateway DOWN%>' + '<br />';
 | 
			
		||||
					} else if(gw_ping6 == 'DOWN')
 | 
			
		||||
					} else if(gateway6 != '' && gw_ping6 == 'DOWN')
 | 
			
		||||
					{
 | 
			
		||||
						statusMessage += '<%:Gateway DOWN%>' + '<br />';
 | 
			
		||||
						statusMessage += '<%:Gateway IPv6 DOWN%>' + '<br />';
 | 
			
		||||
					} else if(multipath_available == 'ERROR')
 | 
			
		||||
					{
 | 
			
		||||
						statusMessage += '<%:Multipath seems to be blocked on the connection%>' + '<br />';
 | 
			
		||||
| 
						 | 
				
			
			@ -566,7 +567,7 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm
 | 
			
		|||
						statusMessage += '<%:Wan IP and gateway are identical%>' + '<br />';
 | 
			
		||||
						statusMessageClass = "error";
 | 
			
		||||
					}
 | 
			
		||||
					if (stat == 'Offline' && ip6addr != '' && ipaddr == mArray.wans[i].gateway6)
 | 
			
		||||
					if (stat == 'Offline' && ip6addr != '' && ip6addr == mArray.wans[i].gateway6)
 | 
			
		||||
					{
 | 
			
		||||
						statusMessage += '<%:Wan IP and gateway are identical%>' + '<br />';
 | 
			
		||||
						statusMessageClass = "error";
 | 
			
		||||
| 
						 | 
				
			
			@ -595,6 +596,11 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm
 | 
			
		|||
						statusMessage += '<%:Network interface duplicated%>' + '<br />';
 | 
			
		||||
						statusMessageClass = "error";
 | 
			
		||||
					}
 | 
			
		||||
					if(duplicatemac)
 | 
			
		||||
					{
 | 
			
		||||
						statusMessage += '<%:Network interface MAC address duplicated%>' + '<br />';
 | 
			
		||||
						statusMessageClass = "error";
 | 
			
		||||
					}
 | 
			
		||||
					if(ipv6_discover == 'DETECTED')
 | 
			
		||||
					{
 | 
			
		||||
						statusMessage += '<%:IPv6 route received%>' + '<br />'
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1105,6 +1105,7 @@ function interfaces_status()
 | 
			
		|||
	mArray.wans = {}
 | 
			
		||||
	mArray.tunnels = {}
 | 
			
		||||
	allintf = {}
 | 
			
		||||
	allmac = {}
 | 
			
		||||
 | 
			
		||||
	uci:foreach("network", "interface", function (section)
 | 
			
		||||
	    local interface = section[".name"]
 | 
			
		||||
| 
						 | 
				
			
			@ -1117,6 +1118,7 @@ function interfaces_status()
 | 
			
		|||
	    local enabled = section["auto"]
 | 
			
		||||
	    local proto = section["proto"] or ""
 | 
			
		||||
	    local ipv6 = section["ipv6"] or "0"
 | 
			
		||||
	    local mac = section ["macaddr"] or ""
 | 
			
		||||
 | 
			
		||||
	    --if not ipaddr or not gateway then return end
 | 
			
		||||
	    -- Don't show if0 in the overview
 | 
			
		||||
| 
						 | 
				
			
			@ -1140,6 +1142,16 @@ function interfaces_status()
 | 
			
		|||
		end
 | 
			
		||||
	    end
 | 
			
		||||
 | 
			
		||||
	    duplicatemac = false
 | 
			
		||||
	    if mac ~= "" and mac ~= nil and not (section["ifname"] ~= nil and section["ifname"]:match("^@.*")) then
 | 
			
		||||
		if allmac[mac] then
 | 
			
		||||
		    connectivity = "ERROR"
 | 
			
		||||
		    duplicatemac = true
 | 
			
		||||
		else
 | 
			
		||||
		    allmac[mac] = true
 | 
			
		||||
		end
 | 
			
		||||
	    end
 | 
			
		||||
 | 
			
		||||
	    --if multipath == "off" and not ifname:match("^tun.*") then return end
 | 
			
		||||
	    if multipath == "off" then return end
 | 
			
		||||
	    
 | 
			
		||||
| 
						 | 
				
			
			@ -1237,7 +1249,7 @@ function interfaces_status()
 | 
			
		|||
			    if gateway ~= "" then
 | 
			
		||||
				    local gw_ping_test = ""
 | 
			
		||||
				    if ifname ~= "" and ifname ~= nil then
 | 
			
		||||
					    gw_ping_test = ut.trim(sys.exec("ping -w 1 -c 1 -I " .. ifname .. " " .. gateway .. " | grep '100% packet loss'"))
 | 
			
		||||
					    gw_ping_test = ut.trim(sys.exec("ping -w 1 -c 1 -B -I " .. ifname .. " " .. gateway .. " | grep '100% packet loss'"))
 | 
			
		||||
				    else
 | 
			
		||||
					    gw_ping_test = ut.trim(sys.exec("ping -w 1 -c 1 " .. gateway .. " | grep '100% packet loss'"))
 | 
			
		||||
				    end
 | 
			
		||||
| 
						 | 
				
			
			@ -1247,11 +1259,13 @@ function interfaces_status()
 | 
			
		|||
						    connectivity = "WARNING"
 | 
			
		||||
					    end
 | 
			
		||||
				    end
 | 
			
		||||
			    else
 | 
			
		||||
				gw_ping = "DOWN"
 | 
			
		||||
			    end
 | 
			
		||||
			    if gateway6 ~= "" then
 | 
			
		||||
				    local gw_ping6_test = ""
 | 
			
		||||
				    if ifname ~= "" and ifname ~= nil then
 | 
			
		||||
					    gw_ping6_test = ut.trim(sys.exec("ping -w 1 -c 1 -I " .. ifname .. " " .. gateway6 .. " | grep '100% packet loss'"))
 | 
			
		||||
					    gw_ping6_test = ut.trim(sys.exec("ping -w 1 -c 1 -B -I " .. ifname .. " " .. gateway6 .. " | grep '100% packet loss'"))
 | 
			
		||||
				    else
 | 
			
		||||
					    gw_ping6_test = ut.trim(sys.exec("ping -w 1 -c 1 " .. gateway6 .. " | grep '100% packet loss'"))
 | 
			
		||||
				    end
 | 
			
		||||
| 
						 | 
				
			
			@ -1261,6 +1275,8 @@ function interfaces_status()
 | 
			
		|||
						    connectivity = "WARNING"
 | 
			
		||||
					    end
 | 
			
		||||
				    end
 | 
			
		||||
			    else
 | 
			
		||||
				gw_ping6 = "DOWN"
 | 
			
		||||
			    end
 | 
			
		||||
		    end
 | 
			
		||||
		    if uci:get("openmptcprouter", interface, "manufacturer") == "huawei" then
 | 
			
		||||
| 
						 | 
				
			
			@ -1346,6 +1362,10 @@ function interfaces_status()
 | 
			
		|||
		    multipath_available = "NO CHECK"
 | 
			
		||||
	    end
 | 
			
		||||
 | 
			
		||||
	    local zonewan = "NO"
 | 
			
		||||
	    if ut.trim(sys.exec("uci -q get firewall.zone_wan.networks | grep '" .. interface .. "'")) ~= "" then
 | 
			
		||||
		    zonewan = "OK"
 | 
			
		||||
	    end
 | 
			
		||||
	    
 | 
			
		||||
	    -- Detect if WAN get an IPv6
 | 
			
		||||
	    local ipv6_discover = "NONE"
 | 
			
		||||
| 
						 | 
				
			
			@ -1449,6 +1469,7 @@ function interfaces_status()
 | 
			
		|||
		multipath_available = multipath_available,
 | 
			
		||||
		multipath_state = current_multipath_state,
 | 
			
		||||
		duplicateif = duplicateif,
 | 
			
		||||
		duplicatemac = duplicatemac,
 | 
			
		||||
		signal = signal,
 | 
			
		||||
		operator = operator,
 | 
			
		||||
		phonenumber = phonenumber,
 | 
			
		||||
| 
						 | 
				
			
			@ -1457,6 +1478,7 @@ function interfaces_status()
 | 
			
		|||
		proto = proto,
 | 
			
		||||
		rx = rx,
 | 
			
		||||
		tx = tx,
 | 
			
		||||
		zonewan = zonewan,
 | 
			
		||||
	    }
 | 
			
		||||
	    if ifname ~= nil and ifname:match("^tun.*") then
 | 
			
		||||
		    table.insert(mArray.tunnels, data);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue