Skip to content

Commit 1a581c7

Browse files
committed
The DoHNameserver now supports using GET instead of POST
if desired, and passes source and source_port to the underlying query methods. (cherry picked from commit b9eea8e)
1 parent 742fddb commit 1a581c7

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

dns/nameserver.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,13 @@ def __init__(
165165
url: str,
166166
bootstrap_address: Optional[str] = None,
167167
verify: Union[bool, str] = True,
168+
want_get: bool = False,
168169
):
169170
super().__init__()
170171
self.url = url
171172
self.bootstrap_address = bootstrap_address
172173
self.verify = verify
174+
self.want_get = want_get
173175

174176
def kind(self):
175177
return "DoH"
@@ -203,10 +205,13 @@ def query(
203205
request,
204206
self.url,
205207
timeout=timeout,
208+
source=source,
209+
source_port=source_port,
206210
bootstrap_address=self.bootstrap_address,
207211
one_rr_per_rrset=one_rr_per_rrset,
208212
ignore_trailing=ignore_trailing,
209213
verify=self.verify,
214+
post=(not self.want_get),
210215
)
211216

212217
async def async_query(
@@ -224,10 +229,13 @@ async def async_query(
224229
request,
225230
self.url,
226231
timeout=timeout,
232+
source=source,
233+
source_port=source_port,
227234
bootstrap_address=self.bootstrap_address,
228235
one_rr_per_rrset=one_rr_per_rrset,
229236
ignore_trailing=ignore_trailing,
230237
verify=self.verify,
238+
post=(not self.want_get),
231239
)
232240

233241

doc/whatsnew.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ What's New in dnspython
2222
feature like DoH is not desired in dnspython, but an old httpx is installed
2323
along with dnspython for some other purpose.
2424

25+
* The DoHNameserver class now allows GET to be used instead of the default POST,
26+
and also passes source and source_port correctly to the underlying query
27+
methods.
28+
2529
2.5.0
2630
-----
2731

0 commit comments

Comments
 (0)