當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。