Work around non tabular headers in BSD netstat

netstat outputs some headers in BSD (that the Linux version does not)
that are not tabular and were breaking our 'split line into columns
and get nth column' logic. We now skip such headers.

Should fix #141.
This commit is contained in:
vieira 2017-04-04 22:30:38 +00:00 committed by Brian May
parent af9ebd0f4b
commit ef83a5c573

View File

@ -67,6 +67,8 @@ def _shl(n, bits):
def _route_netstat(line): def _route_netstat(line):
cols = line.split(None) cols = line.split(None)
if len(cols) < 3:
return None, None
ipw = _ipmatch(cols[0]) ipw = _ipmatch(cols[0])
maskw = _ipmatch(cols[2]) # linux only maskw = _ipmatch(cols[2]) # linux only
mask = _maskbits(maskw) # returns 32 if maskw is null mask = _maskbits(maskw) # returns 32 if maskw is null