An easy way to customize the dns resolution
Project description
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
...
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hookdns-2.0.2.tar.gz.
File metadata
- Download URL: hookdns-2.0.2.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9116f443d67ec2aacad162cab067d6f12200dcf72ca1bc194a5dbef77b7d513b
|
|
| MD5 |
7958159edbd41fd57e041daa74d4e6b3
|
|
| BLAKE2b-256 |
608dddae796c0dce333ab97b9a5a33aae666e3f1333fd4e601fd685eade8ebe3
|
Provenance
The following attestation bundles were made for hookdns-2.0.2.tar.gz:
Publisher:
build.yml on cle-b/hookdns
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hookdns-2.0.2.tar.gz -
Subject digest:
9116f443d67ec2aacad162cab067d6f12200dcf72ca1bc194a5dbef77b7d513b - Sigstore transparency entry: 1190949376
- Sigstore integration time:
-
Permalink:
cle-b/hookdns@778f2285e90e8d3e6ccb514afd4759df544f6537 -
Branch / Tag:
refs/tags/v2.0.2 - Owner: https://github.com/cle-b
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@778f2285e90e8d3e6ccb514afd4759df544f6537 -
Trigger Event:
push
-
Statement type:
File details
Details for the file hookdns-2.0.2-py3-none-any.whl.
File metadata
- Download URL: hookdns-2.0.2-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d4008e1b00a35a209644d61c31e8356703f53bd9a80062c02585cf48e430488
|
|
| MD5 |
ed77c6598b81d8aaa5366d4af67e8b94
|
|
| BLAKE2b-256 |
add184222d79e3dec52c419e412d43cad56d4d783cdd4ee41c2a4e786d636668
|
Provenance
The following attestation bundles were made for hookdns-2.0.2-py3-none-any.whl:
Publisher:
build.yml on cle-b/hookdns
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hookdns-2.0.2-py3-none-any.whl -
Subject digest:
9d4008e1b00a35a209644d61c31e8356703f53bd9a80062c02585cf48e430488 - Sigstore transparency entry: 1190949384
- Sigstore integration time:
-
Permalink:
cle-b/hookdns@778f2285e90e8d3e6ccb514afd4759df544f6537 -
Branch / Tag:
refs/tags/v2.0.2 - Owner: https://github.com/cle-b
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@778f2285e90e8d3e6ccb514afd4759df544f6537 -
Trigger Event:
push
-
Statement type: