hookdns
HookDNS is a library which allow you to modify a name resolution in your Python script without any modification in your hosts file or by using a fake DNS resolver.
import requests
from hookdns import hosts
with hosts({"example.org": "127.0.0.1"}):
...
r = requests.get("http://example.org") # the request is sent to your local server
...
Installation
pip install hookdns
Usage
Custom DNS resolutions are describe by a dictionnary where the keys are hostnames and the values the expected corresponding addresses.
{
"hostname1": "addr1",
"hostname2": "addr2"
}
hostname and addr could be a domain name or a string representation of an IPv4/IPV6.
Example using the patch as a decorator
import requests
from hookdns import hosts
@hosts({"example.org": "127.0.0.1"})
def myfunc():
...
r = requests.get("http://example.org") # the request is sent to your local server
...
Example using the patch as a context manager
import requests
from hookdns import hosts
with hosts({"example.org": "localhost"}):
...
r = requests.get("http://example.org") # the request is sent to your local server
...
Metadata
Release files for hookdns 3.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hookdns-3.0.0.tar.gz | 9.8 kB | With provenance | Details for hookdns-3.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hookdns-3.0.0-py3-none-any.whl | Python 3 | none | any | Details for hookdns-3.0.0-py3-none-any.whl |
Total release size: 19.2 kB
Release files / hookdns-3.0.0.tar.gz
| Download URL | hookdns-3.0.0.tar.gz |
|---|---|
| Size | 9.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e82abaa885f1a502d8db340b6e6e5d9454deea6febbf2949bbf2ab6beb37c1bf
|
|
BLAKE2b-256 checksum How to use checksums |
5039f92f2407b0c5ddcd7599c1ab432051472c5b8867b81d350858f685103f5f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.
Transparency logRelease files / hookdns-3.0.0-py3-none-any.whl
| Download URL | hookdns-3.0.0-py3-none-any.whl |
|---|---|
| Size | 9.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cf370762a2e64aabe8d2f72507a9fb8eed34861ba7b4ff05be6cca20390d7c56
|
|
BLAKE2b-256 checksum How to use checksums |
0b9cb4eb01800a360fab9d226799f16ca77bce3ea6b97c018cef66be41322031
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.
Transparency logSecurity for hookdns 3.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for hookdns-3.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.