def _get_eth_info(self):
eth_info = {
'inner': [],
'outer': [],
'lo': []
}
info = psutil.net_if_addrs()
for eth, net in info.iteritems():
ip = None
for n in net:
if n.family == 2 and n.address:
ip = n.address
break
else:
continue
if ip is None:
continue
ip_type = self._get_ip_type(ip)
eth_info[ip_type].append(eth)
return eth_info
评论列表
文章目录