mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-05-27 07:13:59 +00:00
Only get network interfaces that are up.
This commit is contained in:
parent
6a135dd79c
commit
241205e5b0
2 changed files with 5 additions and 3 deletions
|
|
@ -393,8 +393,8 @@ class Resolver(object):
|
|||
return []
|
||||
from linkcheck.network import IfConfig
|
||||
ifc = IfConfig()
|
||||
return [ifc.getAddr(iface) for iface in ifc.getInterfaceList() \
|
||||
if ifc.isUp(iface)]
|
||||
return [ifc.getAddr(iface)
|
||||
for iface in ifc.getInterfaceList(flags=IfConfig.IFF_UP)]
|
||||
|
||||
def add_addrinfo (self, host, interface=False):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class IfConfig (object):
|
|||
return None
|
||||
return socket.inet_ntoa(result[20:24])
|
||||
|
||||
def getInterfaceList (self):
|
||||
def getInterfaceList (self, flags=0):
|
||||
"""Get all interface names in a list."""
|
||||
if sys.platform == 'darwin':
|
||||
command = ['ifconfig', '-l']
|
||||
|
|
@ -100,6 +100,8 @@ class IfConfig (object):
|
|||
name = struct.unpack("16s%ds" % (self.ifr_size-16), ifconf)[0]
|
||||
name = name.split('\0', 1)[0]
|
||||
if name:
|
||||
if flags and not (self.getFlags(name) & flags):
|
||||
continue
|
||||
iflist.append(name)
|
||||
i += self.ifr_size
|
||||
return iflist
|
||||
|
|
|
|||
Loading…
Reference in a new issue