mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +00:00
device_tracker.asuswrt: Ignore unreachable ip neigh entries (#12201)
This commit is contained in:
parent
eaa2791539
commit
ebe4418afe
@ -63,6 +63,7 @@ _IP_NEIGH_REGEX = re.compile(
|
|||||||
r'\w+\s'
|
r'\w+\s'
|
||||||
r'(\w+\s(?P<mac>(([0-9a-f]{2}[:-]){5}([0-9a-f]{2}))))?\s'
|
r'(\w+\s(?P<mac>(([0-9a-f]{2}[:-]){5}([0-9a-f]{2}))))?\s'
|
||||||
r'\s?(router)?'
|
r'\s?(router)?'
|
||||||
|
r'\s?(nud)?'
|
||||||
r'(?P<status>(\w+))')
|
r'(?P<status>(\w+))')
|
||||||
|
|
||||||
_ARP_CMD = 'arp -n'
|
_ARP_CMD = 'arp -n'
|
||||||
@ -211,6 +212,9 @@ class AsusWrtDeviceScanner(DeviceScanner):
|
|||||||
result = _parse_lines(lines, _IP_NEIGH_REGEX)
|
result = _parse_lines(lines, _IP_NEIGH_REGEX)
|
||||||
devices = {}
|
devices = {}
|
||||||
for device in result:
|
for device in result:
|
||||||
|
status = device['status']
|
||||||
|
if status is None or status.upper() != 'REACHABLE':
|
||||||
|
continue
|
||||||
if device['mac'] is not None:
|
if device['mac'] is not None:
|
||||||
mac = device['mac'].upper()
|
mac = device['mac'].upper()
|
||||||
old_device = cur_devices.get(mac)
|
old_device = cur_devices.get(mac)
|
||||||
@ -225,7 +229,7 @@ class AsusWrtDeviceScanner(DeviceScanner):
|
|||||||
result = _parse_lines(lines, _ARP_REGEX)
|
result = _parse_lines(lines, _ARP_REGEX)
|
||||||
devices = {}
|
devices = {}
|
||||||
for device in result:
|
for device in result:
|
||||||
if device['mac']:
|
if device['mac'] is not None:
|
||||||
mac = device['mac'].upper()
|
mac = device['mac'].upper()
|
||||||
devices[mac] = Device(mac, device['ip'], None)
|
devices[mac] = Device(mac, device['ip'], None)
|
||||||
return devices
|
return devices
|
||||||
|
@ -52,8 +52,8 @@ WL_DEVICES = {
|
|||||||
|
|
||||||
ARP_DATA = [
|
ARP_DATA = [
|
||||||
'? (123.123.123.125) at 01:02:03:04:06:08 [ether] on eth0\r',
|
'? (123.123.123.125) at 01:02:03:04:06:08 [ether] on eth0\r',
|
||||||
'? (123.123.123.126) at 08:09:10:11:12:14 [ether] on br0\r'
|
'? (123.123.123.126) at 08:09:10:11:12:14 [ether] on br0\r',
|
||||||
'? (123.123.123.127) at <incomplete> on br0\r'
|
'? (123.123.123.127) at <incomplete> on br0\r',
|
||||||
]
|
]
|
||||||
|
|
||||||
ARP_DEVICES = {
|
ARP_DEVICES = {
|
||||||
@ -65,8 +65,10 @@ ARP_DEVICES = {
|
|||||||
|
|
||||||
NEIGH_DATA = [
|
NEIGH_DATA = [
|
||||||
'123.123.123.125 dev eth0 lladdr 01:02:03:04:06:08 REACHABLE\r',
|
'123.123.123.125 dev eth0 lladdr 01:02:03:04:06:08 REACHABLE\r',
|
||||||
'123.123.123.126 dev br0 lladdr 08:09:10:11:12:14 STALE\r'
|
'123.123.123.126 dev br0 lladdr 08:09:10:11:12:14 REACHABLE\r',
|
||||||
'123.123.123.127 dev br0 FAILED\r'
|
'123.123.123.127 dev br0 FAILED\r',
|
||||||
|
'123.123.123.128 dev br0 lladdr 08:09:15:15:15:15 DELAY\r',
|
||||||
|
'fe80::feff:a6ff:feff:12ff dev br0 lladdr fc:ff:a6:ff:12:ff STALE\r',
|
||||||
]
|
]
|
||||||
|
|
||||||
NEIGH_DEVICES = {
|
NEIGH_DEVICES = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user