How to use the pycares.QUERY_TYPE_CNAME function in pycares

To help you get started, we’ve selected a few pycares examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github saghul / pycares / tests / tests.py View on Github external
def test_query_cname(self):
        self.result, self.errorno = None, None
        def cb(result, errorno):
            self.result, self.errorno = result, errorno
        self.channel.query('www.amazon.com', pycares.QUERY_TYPE_CNAME, cb)
        self.wait()
        self.assertNoError(self.errorno)
        self.assertEqual(type(self.result), pycares.ares_query_cname_result)
github Q2h1Cg / dnsbrute / lib / dns.py View on Github external
if parent_domain not in _black_list:
        # 生成泛解析黑名单
        thread = threading.Thread(target=_query_pan_dns, args=(parent_domain,))
        thread.start()
        thread.join()

    record = None
    for query_type in ("A", "CNAME"):
        try:
            with async_timeout.timeout(_Timeout):
                records = await _resolver.query(domain, query_type)
        except:
            pass
        else:
            if query_type == "CNAME":
                record = Record(domain, QUERY_TYPE_CNAME, records.ttl if records.ttl else -1, [records.cname])
            elif query_type == "A" and records:
                record = Record(domain, QUERY_TYPE_A, records[0].ttl, [record_.host for record_ in records])
            if record:
                break

    if record:
        return None if _is_pan_dns(record) else record
github saghul / aiodns / aiodns / __init__.py View on Github external
from . import error


__version__ = '2.0.0'

__all__ = ('DNSResolver', 'error')


READ = 1
WRITE = 2

query_type_map = {'A'     : pycares.QUERY_TYPE_A,
                  'AAAA'  : pycares.QUERY_TYPE_AAAA,
                  'ANY'   : pycares.QUERY_TYPE_ANY,
                  'CNAME' : pycares.QUERY_TYPE_CNAME,
                  'MX'    : pycares.QUERY_TYPE_MX,
                  'NAPTR' : pycares.QUERY_TYPE_NAPTR,
                  'NS'    : pycares.QUERY_TYPE_NS,
                  'PTR'   : pycares.QUERY_TYPE_PTR,
                  'SOA'   : pycares.QUERY_TYPE_SOA,
                  'SRV'   : pycares.QUERY_TYPE_SRV,
                  'TXT'   : pycares.QUERY_TYPE_TXT
        }


class DNSResolver:
    def __init__(self, nameservers: Optional[List[str]] = None, loop: Optional[asyncio.AbstractEventLoop] = None,
                 **kwargs: Any) -> None:
        self.loop = loop or asyncio.get_event_loop()
        assert self.loop is not None
        kwargs.pop('sock_state_cb', None)