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


Python client.getResolver方法代码示例

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


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

示例1: test_interface

# 需要导入模块: from twisted.names import client [as 别名]
# 或者: from twisted.names.client import getResolver [as 别名]
def test_interface(self):
        """
        L{client.getResolver} returns an object providing L{IResolver}.
        """
        with AlternateReactor(Clock()):
            resolver = client.getResolver()
        self.assertTrue(verifyObject(IResolver, resolver)) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:9,代码来源:test_client.py

示例2: test_idempotent

# 需要导入模块: from twisted.names import client [as 别名]
# 或者: from twisted.names.client import getResolver [as 别名]
def test_idempotent(self):
        """
        Multiple calls to L{client.getResolver} return the same L{IResolver}
        implementation.
        """
        with AlternateReactor(Clock()):
            a = client.getResolver()
            b = client.getResolver()
        self.assertIs(a, b) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:11,代码来源:test_client.py

示例3: _initResolver

# 需要导入模块: from twisted.names import client [as 别名]
# 或者: from twisted.names.client import getResolver [as 别名]
def _initResolver():
    global DebugResolver
    if DebugResolver is None:
        if config.Scheduling.iSchedule.DNSDebug:
            DebugResolver = FakeBindAuthority(config.Scheduling.iSchedule.DNSDebug)
        else:
            DebugResolver = getResolver() 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:9,代码来源:utils.py

示例4: __init__

# 需要导入模块: from twisted.names import client [as 别名]
# 或者: from twisted.names.client import getResolver [as 别名]
def __init__(self):
        self.recs = {}
        
        self.resolver = client.getResolver() 
开发者ID:calston,项目名称:tensor,代码行数:6,代码来源:utils.py

示例5: reverseResolve

# 需要导入模块: from twisted.names import client [as 别名]
# 或者: from twisted.names.client import getResolver [as 别名]
def reverseResolve(
    ip: MaybeIPAddress, resolver: IResolver = None
) -> Optional[List[str]]:
    """Using the specified IResolver, reverse-resolves the specifed `ip`.

    :return: a sorted list of resolved hostnames (which the specified IP
        address reverse-resolves to). If the DNS lookup appeared to succeed,
        but no hostnames were found, returns an empty list. If the DNS lookup
        timed out or an error occurred, returns None.
    """
    if resolver is None:
        resolver = getResolver()
    ip = IPAddress(ip)
    try:
        data = yield resolver.lookupPointer(
            ip.reverse_dns, timeout=REVERSE_RESOLVE_RETRIES
        )
        # I love the concise way in which I can ask the Twisted data structure
        # what the list of hostnames is. This is great.
        results = sorted(
            (rr.payload.name.name.decode("idna") for rr in data[0]),
            key=preferred_hostnames_sort_key,
        )
    except AuthoritativeDomainError:
        # "Failed to reverse-resolve '%s': authoritative failure." % ip
        # This means the name didn't resolve, so return an empty list.
        return []
    except DomainError:
        # "Failed to reverse-resolve '%s': no records found." % ip
        # This means the name didn't resolve, so return an empty list.
        return []
    except DNSQueryTimeoutError:
        # "Failed to reverse-resolve '%s': timed out." % ip
        # Don't return an empty list since this implies a temporary failure.
        pass
    except ResolverError:
        # "Failed to reverse-resolve '%s': rejected by local resolver." % ip
        # Don't return an empty list since this could be temporary (unclear).
        pass
    else:
        return results
    return None 
开发者ID:maas,项目名称:maas,代码行数:44,代码来源:network.py


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