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): ...@@ -51,18 +51,15 @@ class ARP(object):
subprocess.check_call(['/usr/sbin/arp', '-an'], stdout=output_stream, stderr=subprocess.STDOUT) subprocess.check_call(['/usr/sbin/arp', '-an'], stdout=output_stream, stderr=subprocess.STDOUT)
output_stream.seek(0) output_stream.seek(0)
for line in output_stream.read().split('\n'): for line in output_stream.read().split('\n'):
if line.find('(') > -1 and line.find(')') > -1: line_parts = line.split()
if line.find('expires in') > -1: if len(line_parts) > 10 and len(line_parts[1]) > 2:
expires = line.split('expires in')[1:][0].strip().split(' ')[0] if line_parts[8].isdigit():
if expires.isdigit(): expires = int(line_parts[8])
expires = int(expires)
else: else:
expires = -1 expires = -1
else: address = line_parts[1][1:-1]
expires = -1 mac = line_parts[3]
address = line.split(')')[0].split('(')[-1] physical_intf = line_parts[5]
mac = line.split('at')[-1].split('on')[0].strip()
physical_intf = line.split('on')[-1].strip().split(' ')[0]
if address in self._arp_table: if address in self._arp_table:
self._arp_table[address]['intf'].append(physical_intf) self._arp_table[address]['intf'].append(physical_intf)
elif mac.find('incomplete') == -1: 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