当前位置: 首页>>代码示例>>Python>>正文


Python IPAddress.is_ipv4_mapped方法代码示例

本文整理汇总了Python中netaddr.IPAddress.is_ipv4_mapped方法的典型用法代码示例。如果您正苦于以下问题:Python IPAddress.is_ipv4_mapped方法的具体用法?Python IPAddress.is_ipv4_mapped怎么用?Python IPAddress.is_ipv4_mapped使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在netaddr.IPAddress的用法示例。


在下文中一共展示了IPAddress.is_ipv4_mapped方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _normalize_ip_address

# 需要导入模块: from netaddr import IPAddress [as 别名]
# 或者: from netaddr.IPAddress import is_ipv4_mapped [as 别名]
    def _normalize_ip_address(addr):
        """
        When we used mapped ipv4 (starting with ::FFFF/96) we need to
        normalize it to ipv4 in order to compare it with value used
        in commonName in the certificate.
        """
        ip = IPAddress(addr)
        if ip.is_ipv4_mapped():
            addr = str(ip.ipv4())

        return addr
开发者ID:EdDev,项目名称:vdsm,代码行数:13,代码来源:sslutils.py

示例2: get_version

# 需要导入模块: from netaddr import IPAddress [as 别名]
# 或者: from netaddr.IPAddress import is_ipv4_mapped [as 别名]
def get_version(request):
    func = request.GET.get('func', '')
    remote_addr = IPAddress(request.remote_addr)
    data = {
        'address': remote_addr.format(),
        'version': remote_addr.version,
        'ipv4_mapped': remote_addr.is_ipv4_mapped(),
    }
    return Response(
            body='%s(%s);' % (func, json.dumps(data)),
            content_type='text/javascript')
开发者ID:yosida95,项目名称:ipv4-ipv6.yosida95-com,代码行数:13,代码来源:views.py

示例3: normalize_mapped_address

# 需要导入模块: from netaddr import IPAddress [as 别名]
# 或者: from netaddr.IPAddress import is_ipv4_mapped [as 别名]
def normalize_mapped_address(ipaddr):
    """
    Converts a IPv4-mapped IPv6 address into a IPv4 address. Handles both the
    ::ffff:192.0.2.128 format as well as the deprecated ::192.0.2.128 format.

    :param ipaddr: IP address [str]
    :return: normalized IP address [str]
    """
    ipaddr = IPAddress(ipaddr)
    if ipaddr.is_ipv4_compat() or ipaddr.is_ipv4_mapped():
        ipaddr = ipaddr.ipv4()
    return str(ipaddr)
开发者ID:FreeMinded,项目名称:nsupdate.info,代码行数:14,代码来源:iptools.py

示例4: test_ip_v4_to_ipv6_mapped

# 需要导入模块: from netaddr import IPAddress [as 别名]
# 或者: from netaddr.IPAddress import is_ipv4_mapped [as 别名]
def test_ip_v4_to_ipv6_mapped():
    ip = IPAddress('192.0.2.15').ipv6()
    assert ip == IPAddress('::ffff:192.0.2.15')
    assert ip.is_ipv4_mapped()
    assert not ip.is_ipv4_compat()
开发者ID:drkjam,项目名称:netaddr,代码行数:7,代码来源:test_ip_v4_v6_conversions.py


注:本文中的netaddr.IPAddress.is_ipv4_mapped方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。