python类AI_V4MAPPED的实例源码

greendns_test.py 文件源码 项目:deb-python-eventlet 作者: openstack 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_v4mapped(self):
        greendns.resolve = _make_mock_resolve()
        greendns.resolve.add('example.com', '1.2.3.4')
        res = greendns.getaddrinfo('example.com', 80,
                                   socket.AF_INET6, 0, 0, socket.AI_V4MAPPED)
        addrs = set(ai[-1] for ai in res)
        assert addrs == set([('::ffff:1.2.3.4', 80, 0, 0)])
greendns_test.py 文件源码 项目:deb-python-eventlet 作者: openstack 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_v4mapped_all(self):
        greendns.resolve = _make_mock_resolve()
        greendns.resolve.add('example.com', '1.2.3.4')
        greendns.resolve.add('example.com', 'dead:beef::1')
        res = greendns.getaddrinfo('example.com', 80, socket.AF_INET6, 0, 0,
                                   socket.AI_V4MAPPED | socket.AI_ALL)
        addrs = set(ai[-1] for ai in res)
        for addr in addrs:
            assert addr in [('::ffff:1.2.3.4', 80, 0, 0),
                            ('dead:beef::1', 80, 0, 0)]


问题


面经


文章

微信
公众号

扫码关注公众号