Skip to main content

Checks wildcard domain names

Project description

Wildhost

CircleCI PyPI pyversions PyPI version fury.io

Checks wildcard domain names.

Install

pip install wildhost

Usage

Import the module

>>> import wildhost

Pass a hostname to the check function.

>>> wildhost.check('foo.bar.domain.tld')

If none of the levels of the name are wildcards, None will be returned.

>>> wildhost.check('mail.google.com')

This returns None as neither google.com nor mail.google.com are wildcards.

For a wildcard name, the lowest level wildcard name will be returned.

>>> wildhost.check('foo.bar.spam.grok.sharefile.com')
'sharefile.com'

Performance

The module caches the wildcard results and uses them in further checks. For example:

>>> wildhost.check('foo.bar.spam.grok.sharefile.com')  # this will be a fresh check
'sharefile.com'
>>> wildhost.check('boom.blast.sharefile.com')  # this will use the cache
'sharefile.com'

Once sharefile.com is known to be a wildcard, any further subdomains of sharefile.com will be evaluated as wildcards as well. This is determined from a static check and therefore very fast.

However, there is a caveat. In an unlikely scenario, api.sharefile.com will be missed, if it happens to be a valid subdomain.

In such cases, when in doubt, use the wildcard.check_fresh function to ignore the cache.

>>> wildcard.check_fresh('api.sharefile.com')

This will return None if it is, in fact, not a wildcard.

check_fresh needs to make network requests, where as check caches the results and is very fast. Choose one that is suitable for the problem at hand.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wildhost-0.0.4.tar.gz (4.2 kB view hashes)

Uploaded Source

Built Distribution

wildhost-0.0.4-py2.py3-none-any.whl (3.1 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page