Commit 3151c87e authored by Ad Schellevis's avatar Ad Schellevis

CP, refactor arp list, closes https://github.com/opnsense/core/issues/1344

parent e51bc802
......@@ -51,18 +51,15 @@ class ARP(object):
subprocess.check_call(['/usr/sbin/arp', '-an'], stdout=output_stream, stderr=subprocess.STDOUT)
output_stream.seek(0)
for line in output_stream.read().split('\n'):
if line.find('(') > -1 and line.find(')') > -1:
if line.find('expires in') > -1:
expires = line.split('expires in')[1:][0].strip().split(' ')[0]
if expires.isdigit():
expires = int(expires)
else:
expires = -1
line_parts = line.split()
if len(line_parts) > 10 and len(line_parts[1]) > 2:
if line_parts[8].isdigit():
expires = int(line_parts[8])
else:
expires = -1
address = line.split(')')[0].split('(')[-1]
mac = line.split('at')[-1].split('on')[0].strip()
physical_intf = line.split('on')[-1].strip().split(' ')[0]
address = line_parts[1][1:-1]
mac = line_parts[3]
physical_intf = line_parts[5]
if address in self._arp_table:
self._arp_table[address]['intf'].append(physical_intf)
elif mac.find('incomplete') == -1:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment