network_utils.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:pyimc 作者: oysstu 项目源码 文件源码
def get_interfaces(ignore_local=True):
    """
    Retrieves the address of all external interfaces (lo 127.0.0.1 ignored)
    :return: List of tuples (interface, addr)
    """
    interfaces = netifaces.interfaces()
    if_ext = []
    for i in interfaces:
        if i == 'lo' and ignore_local:
            continue
        iface = netifaces.ifaddresses(i).get(netifaces.AF_INET)
        if iface:
            for j in iface:
                if_ext.append((i, j['addr'], j['netmask']))

    return if_ext
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号