Git Product home page Git Product logo

vintagecircuit / doh-client-module Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 106 KB

This Python module performs reverse DNS lookups using DNS over HTTPS (DoH) specifically with IPv4 addresses. The project leverages the Quad9 DoH service and incorporates caching and logging functionalities for efficient and robust lookups.

License: MIT License

Python 100.00%
dns dnsoverhttps https network-tools python quad9 reverse-dns-lookup doh security

doh-client-module's Introduction

DoHClient Python Module

Description

The DoHClient module performs reverse DNS lookups for IPv4 addresses via DNS over HTTPS (DoH) using the Quad9 DoH endpoint. It includes caching and logging functionalities for efficiency and easier debugging.

Note: This module currently only supports IPv4 addresses.

Table of Contents

Features

  • IPv4 Support: Limited to IPv4 addresses.
  • Quad9 DoH Endpoint: Uses Quad9's secure DNS over HTTPS endpoint for domain resolution.
  • Caching: Incorporates a caching mechanism to reduce redundant queries.
  • IPv4 Validation: Validates IPv4 addresses.
  • Retries: Includes retries for failed requests.
  • Logging: Logs events and errors using the doh_logger custom module.

Dependencies

  • Python (>= 3.6)
  • requests
  • ipaddress

Note: doh_cache and doh_logger are custom modules; ensure they are included in your project directory.

Usage

Basic Usage

Here's a simple example of how to use the DoHClient module:

python from DoHClient import DoHClient

doh_client = DoHClient()
result = doh_client.reverse_lookup("8.8.8.8")
print(result)

Logging

Ensure the custom logging module, doh_logger, is set up before running the main module to capture all debug information.

Cache Duration

The caching duration is set to 5 minutes by default and can be modified by adjusting the CACHE_DURATION static variable in the DoHClient class.

Components

DoHClient

The DoHClient class is responsible for reverse DNS lookups for IPv4 addresses. It integrates a caching mechanism to reduce the number of network requests. For an in-depth understanding, refer to the code documentation.

Cache

The Cache class acts as an LRU (Least Recently Used) cache that retains DNS lookups for a specified timeframe. The cache has a size limit and autonomously evicts the oldest or stale entries based on size and duration.

  • Eviction Based on Time: Cache drops entries surpassing a certain age.
  • Eviction Based on Size: The cache keeps its size consistent by ousting the oldest entries when adding a new one, and it reaches its size cap.

Logging

The doh_logger module offers a configurable logging mechanism to monitor the application's behavior, track down errors, and comprehend its flow. Each log entry consists of a timestamp, logger's name, log level, and the message.

Contributing

Pull requests are welcome. For significant modifications, please initiate an issue first to discuss the intended changes.

License

MIT License.

doh-client-module's People

Contributors

vintagecircuit avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

nacy5806

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.