From ca1dc202f91c81b1de63c16c6d4eeb5e31c766de Mon Sep 17 00:00:00 2001 From: Oleksii Serdiuk Date: Wed, 25 Jan 2017 09:02:39 +0100 Subject: [PATCH] ASUSWRT: Add IPv6 support when parsing neighbors (#5536) * ASUSWRT: Add IPv6 support when parsing neighbors The regex for IPv6 should cover most cases, but it doesn't validate whether IP is correct. It also might fail for some edge cases. Also, ignore 'duid xx:xx:xx:xx:xx:xx:xx:xx:xx:xx' line in leases. Closes #2814 - ASUSWRT doesn't support ipv6 * Update asuswrt.py --- homeassistant/components/device_tracker/asuswrt.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/device_tracker/asuswrt.py b/homeassistant/components/device_tracker/asuswrt.py index be530abc9e2..512ccba0b74 100644 --- a/homeassistant/components/device_tracker/asuswrt.py +++ b/homeassistant/components/device_tracker/asuswrt.py @@ -71,10 +71,11 @@ _ARP_REGEX = re.compile( _IP_NEIGH_CMD = 'ip neigh' _IP_NEIGH_REGEX = re.compile( - r'(?P([0-9]{1,3}[\.]){3}[0-9]{1,3})\s' + - r'\w+\s' + - r'\w+\s' + - r'(\w+\s(?P(([0-9a-f]{2}[:-]){5}([0-9a-f]{2}))))?\s' + + r'(?P([0-9]{1,3}[\.]){3}[0-9]{1,3}|' + r'([0-9a-fA-F]{1,4}:){1,7}[0-9a-fA-F]{0,4}(:[0-9a-fA-F]{1,4}){1,7})\s' + r'\w+\s' + r'\w+\s' + r'(\w+\s(?P(([0-9a-f]{2}[:-]){5}([0-9a-f]{2}))))?\s' r'(?P(\w+))') _NVRAM_CMD = 'nvram get client_info_tmp' @@ -323,6 +324,8 @@ class AsusWrtDeviceScanner(DeviceScanner): else: for lease in result.leases: + if lease.startswith(b'duid '): + continue match = _LEASES_REGEX.search(lease.decode('utf-8')) if not match: