How to use the aiodns.DNSResolver function in aiodns

To help you get started, we’ve selected a few aiodns 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 c0rvax / project-black / black / workers / async_dns / test_async.py View on Github external
def start_dnscan(domain):
    resolver = aiodns.DNSResolver()
    loop = asyncio.get_event_loop()
    tasks = list()
    tasks.append(loop.create_task(resolve(domain_to_brute, 'NS')))
    tasks.append(loop.create_task(resolve(domain_to_brute, 'MX')))
    loop.run_until_complete(asyncio.wait(tasks))

    futures = list()

    for t in tasks:
        for domain_name in t.result():
            name = resolver.query(domain_name, 'A')
            name.add_done_callback(error_checker_callback)
            name.data = domain_name
        futures.append(name)

    result = loop.run_until_complete(asyncio.wait(futures))
github gmr / email-normalize / tests / test_normalizer.py View on Github external
def setUp(self) -> None:
        self.loop = asyncio.new_event_loop()
        asyncio.set_event_loop(self.loop)
        self.loop.set_debug(True)
        self.timeout = int(os.environ.get('ASYNC_TIMEOUT', '5'))
        self.timeout_handle = self.loop.call_later(
            self.timeout, self.on_timeout)
        self.normalizer = email_normalize.Normalizer()
        self.resolver = aiodns.DNSResolver(loop=self.loop)
        self.normalizer._resolver = self.resolver
github elektito / ih2torrent / ih2torrent.py View on Github external
print('Invalid infohash.')
        exit(1)

    nodes = SortedQueue(args.infohash)

    logger = logging.getLogger('ih2torrent')
    handler = StreamHandler(sys.stdout)
    handler.setLevel(logging.DEBUG)
    formatter = logging.Formatter('[%(asctime)s][%(levelname)s] %(message)s')
    handler.setFormatter(formatter)
    logger.setLevel(logging.DEBUG)
    logger.addHandler(handler)

    try:
        loop = asyncio.get_event_loop()
        resolver = aiodns.DNSResolver(loop=loop)
        loop.run_until_complete(ih2torrent(loop, args.infohash, args.file, args.bootstrap))
    except KeyboardInterrupt:
        print()
        print('Letting the remaining tasks finish before termination.')
    except Exception as e:
        print('Unexpected error:', e)

    pending = asyncio.Task.all_tasks()
    for task in pending:
        task.cancel()
    try:
        loop.run_until_complete(asyncio.gather(*pending))
    except CancelledError:
        pass

    loop.close()
github samuelcolvin / nosht / py / web / auth.py View on Github external
async def validate_email(email, loop):
    """
    check an email is likely to exist

    could do SMTP looks ups: https://gist.github.com/samuelcolvin/3652427c07fac775d0cdc8af127c0ed1
    but not really worth it
    """
    domain = email.split('@', 1)[1]
    resolver = aiodns.DNSResolver(loop=loop)
    try:
        with timeout(2, loop=loop):
            await resolver.query(domain, 'MX')
    except (aiodns.error.DNSError, ValueError, asyncio.TimeoutError) as e:
        logger.info('looking up "%s": error %s %s', email, e.__class__.__name__, e)
        return False
    else:
        return True
github kakshay21 / verify_email / verify_email / verify_email.py View on Github external
async def get_mx_ip(hostname):
    '''Get MX record by hostname.
    '''
    if hostname not in MX_DNS_CACHE:
        try:
            resolver = aiodns.DNSResolver()
            MX_DNS_CACHE[hostname] = await  resolver.query(hostname, 'MX')
        except aiodns.error.DNSError as e:
            MX_DNS_CACHE[hostname] = None
    return MX_DNS_CACHE[hostname]
github FeeiCN / ESD / ESD / __init__.py View on Github external
def dns_resolve(self):
        padding_domain = 'www.' + self.domain
        # loop = asyncio.get_event_loop()
        loop = asyncio.new_event_loop()
        asyncio.set_event_loop(loop)
        resolver = aiodns.DNSResolver(loop=loop)
        f = resolver.query(padding_domain, 'A')
        result = loop.run_until_complete(f)
        return result[0].host
github pinnaculum / galacteek / galacteek / core / schemes.py View on Github external
def __init__(self, loop):
        self.dnsResolver = aiodns.DNSResolver(loop=loop)
github constverum / ProxyBroker / proxybroker / resolver.py View on Github external
def __init__(self, timeout=5, loop=None):
        self._timeout = timeout
        self._loop = loop or asyncio.get_event_loop()
        self._resolver = aiodns.DNSResolver(loop=self._loop)
github SimplySecurity / simplydomain / simplydomain / src / static_modules / subdomain_raw_bruteforce.py View on Github external
}

        self.options = {
        }
        # ~ queue object
        self.word_count = int(self.json_entry['args'].raw_depth)
        self.word_list_queue = queue.Queue(maxsize=0)
        self.tasks = []
        self.domain = ''
        self.errors = []
        self.fqdn = []
        self.sub_gen_count = 0
        # disable uvloop until supports windows
        # asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
        self.loop = asyncio.get_event_loop()
        self.resolver = aiodns.DNSResolver(loop=self.loop, rotate=True)
        # TODO: make max tasks defined in config.json
        self.max_tasks = 1024
        # TODO: make total set from wordcount in config.json
        self.sem = asyncio.BoundedSemaphore(self.max_tasks)
        self.cs = core_scrub.Scrub()
        self.core_args = self.json_entry['args']
        self.core_resolvers = self.json_entry['resolvers']
        self.silent = self.json_entry['silent']

aiodns

Simple DNS resolver for asyncio

MIT
Latest version published 8 months ago

Package Health Score

89 / 100
Full package analysis

Similar packages