Skip to content

Commit

Permalink
The DoHNameserver now supports using GET instead of POST
Browse files Browse the repository at this point in the history
if desired, and passes source and source_port to the
underlying query methods.

(cherry picked from commit b9eea8e)
  • Loading branch information
rthalley committed Feb 9, 2024
1 parent 742fddb commit 1a581c7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions dns/nameserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,13 @@ def __init__(
url: str,
bootstrap_address: Optional[str] = None,
verify: Union[bool, str] = True,
want_get: bool = False,
):
super().__init__()
self.url = url
self.bootstrap_address = bootstrap_address
self.verify = verify
self.want_get = want_get

def kind(self):
return "DoH"
Expand Down Expand Up @@ -203,10 +205,13 @@ def query(
request,
self.url,
timeout=timeout,
source=source,
source_port=source_port,
bootstrap_address=self.bootstrap_address,
one_rr_per_rrset=one_rr_per_rrset,
ignore_trailing=ignore_trailing,
verify=self.verify,
post=(not self.want_get),
)

async def async_query(
Expand All @@ -224,10 +229,13 @@ async def async_query(
request,
self.url,
timeout=timeout,
source=source,
source_port=source_port,
bootstrap_address=self.bootstrap_address,
one_rr_per_rrset=one_rr_per_rrset,
ignore_trailing=ignore_trailing,
verify=self.verify,
post=(not self.want_get),
)


Expand Down
4 changes: 4 additions & 0 deletions doc/whatsnew.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ What's New in dnspython
feature like DoH is not desired in dnspython, but an old httpx is installed
along with dnspython for some other purpose.

* The DoHNameserver class now allows GET to be used instead of the default POST,
and also passes source and source_port correctly to the underlying query
methods.

2.5.0
-----

Expand Down

0 comments on commit 1a581c7

Please sign in to comment.