Skip to main content

Reverse DNS lookup engine

Project description

Code style: black PyPI - Python Version PyPI - Wheel PyPI piwheels

rdns-reaper: Reverse DNS lookup Engine

rdns-reaper is a multi-threaded lookup engine for Python v3 to resolve DNS names from IP addresses. IP addresses can be added to the custom class by a calling program individually or in batches, after which point the client triggers the resolver to execute on all IP addresses. Once the lookup completes, the calling program can retrieve the data in a variety of ways.

The library currently runs on IPv4 addresses and IPv6 address. Entries can be cached to disk to prevent excessive querying. Limited filtering exists to restrict lookups to RFC1918 IPv4 space as an option.

rdns-reaper is currently tested with Python 3.6-3.11

Installation and Usage

PyPI

$ pip install rdns-reaper

#For a specific version (e.g. 0.0.10)
$ pip install rdns-reaper==0.0.10

Github with PIP

#Latest Full Release
$ pip install git+https://github.com/mullaneywt/rdns_reaper/@releases

#Latest Release Candidate
$ pip install git+https://github.com/mullaneywt/rdns_reaper/

#Specific Release Version (e.g. 0.0.10)
$ pip install git+https://github.com/mullaneywt/rdns_reaper/@0.0.10

Usage

>>> from rdns_reaper import rdns_reaper
>>> rdr = rdns_reaper(limit_to_rfc1918=False, concurrent=20, unresolvable=r"N\A")

>>> iplist = ["8.8.8.8", "1.1.1.1", "8.8.4.4"]
>>> rdr.add_ip_list(iplist)
>>> rdr.resolve_all()

>>> rdr["1.1.1.1"]
one.one.one.one

>>> for address in rdr:
>>>   print(address)
{
	('8.8.8.8', 'dns.google')
	('1.1.1.1', 'one.one.one.one')
	('8.8.4.4', 'dns.google')
}

Supported parameters

The following parameters are supported when an instance of rdns_reaper is created:

parameter type description default
limit_to_rfc1918 boolean Limits checking to only IPv4 RFC1918 address space (IPv6 entirely disabled) False
concurrent integer Number of concurrent resolver threads to use 5
unresolvable string Value to populate if resolving fails None
filemode ["r"|"w"] read only or read-write disk cache None
filename string Path and filename for YAML formatted disk cache None

Note that entries with None as a value will be reprocessed in subsequent resolver runs, while entries with any other value from the unresolveable parameter will not be processed again without manual intervention

Supported operands

  • +, which can add two rdns_reaper objects, a string with a single IP address, or a set/list with one or more IP addresses
  • +=, which can add two rdns_reaper objects, a string with a single IP address, or a set/list with one or more IP addresses

Supported magic methods

  • contains() - checks if a given string containing an IP address exists in the resolver instance
  • del() - takes a string containing an IP address and removes it from the resolver instance
  • getitem() - returns the resolved name for given string containing an IP address
  • iter() - will provider an iterator that returns address/name tuples
  • len() - number of unique IP addresses in a resolver instance

Supported custom methods

  • add_ip(IP) - adds an IP address (provided as a string)
  • add_ip_list(IP_LIST) - adds IP addresses (provided as a list of strings)
  • clear_all_hostnames() - resets all names to None across entire instance
  • clearname(IP) - resets a name to None
  • get_dict() - returns a dictionary with addresses as keys and names as values
  • keys() - returns a list of all IP addresses in the instance
  • loadfile() - forces a load of the YAML based disk cache
  • remove_ip(IP) - removes an IP address (provided as a string)
  • resolve_all() - launches a threaded resolver process
  • resolve_all_serial() - launches a singular serial resolver process
  • savefile() - forces a save of the YAML based disk cache
  • setname(IP, NAME) - forces the name for a value (provided as strings)
  • values() - returns a list of all DNS names

License

This project currently is not licensed for use by third parties and all rights are retained by the creator. Plans for adoption of a common open source license are in the works.

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

rdns_reaper-0.0.11.tar.gz (6.8 kB view hashes)

Uploaded Source

Built Distribution

rdns_reaper-0.0.11-py3-none-any.whl (6.4 kB view hashes)

Uploaded 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