models.py 文件源码

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

项目:nat64check 作者: sjm-steffann 项目源码 文件源码
def get_addresses(hostname) -> List[Union[IPv4Address, IPv6Address]]:
    # Get DNS info
    try:
        a_records = subprocess.check_output(args=['dig', '+short', 'a', hostname],
                                            stderr=subprocess.DEVNULL)
        aaaa_records = subprocess.check_output(args=['dig', '+short', 'aaaa', hostname],
                                               stderr=subprocess.DEVNULL)
        dns_records = a_records + aaaa_records

        dns_results = []
        for line in dns_records.decode('utf-8').strip().split():
            try:
                dns_results.append(str(ip_address(line)))
            except ValueError:
                pass
    except subprocess.CalledProcessError:
        dns_results = []

    return dns_results
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号