From b9eea8ec7c18c516032460882d2a7feba0f6aac9 Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Fri, 9 Feb 2024 13:54:37 -0800 Subject: [PATCH] The DoHNameserver now supports using GET instead of POST if desired, and passes source and source_port to the underlying query methods. --- dns/nameserver.py | 8 ++++++++ doc/whatsnew.rst | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/dns/nameserver.py b/dns/nameserver.py index 0c494c18..030057b6 100644 --- a/dns/nameserver.py +++ b/dns/nameserver.py @@ -165,11 +165,13 @@ class DoHNameserver(Nameserver): 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" @@ -203,10 +205,13 @@ class DoHNameserver(Nameserver): 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( @@ -224,10 +229,13 @@ class DoHNameserver(Nameserver): 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), ) diff --git a/doc/whatsnew.rst b/doc/whatsnew.rst index e588d5ce..861cc1a7 100644 --- a/doc/whatsnew.rst +++ b/doc/whatsnew.rst @@ -27,6 +27,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 ----- -- 2.47.3