Commit 2efbff6
fix(iroh-dns-server): inverted validation logic in DoH JSON response handler (#3737)
## Description
Fix inverted validation logic in the DNS-over-HTTPS (DoH) JSON response
handler. Previously, JSON DoH queries (`accept: application/dns-json`)
failed with a 500 error:
```json
{"status": "500", "detail": "Expected message type to be response"}
```
## Changes made
Corrected three ensure_any! validation checks from != to ==:
message_type() == Response
query_count() == queries().len()
answer_count() == answers().len()
## Testing
Tested locally with iroh-dns-server v0.95.1:
Before fix:
```sh
curl --header "accept: application/dns-json" \
"http://localhost:8080/dns-query?name=_iroh.<id>&type=TXT"
# {"status":"500","detail":"Expected message type to be response"}
```
After fix:
```sh
{
"Status": 0,
"Answer": [{
"name": "_iroh.nskwmm4rh...",
"type": 16,
"TTL": 30,
"data": "relay=https://..."
}]
}
```
## Notes
Only affects JSON DoH responses.
The binary POST format worked fine in my tests
Co-authored-by: Franz Heinzmann <[email protected]>1 parent dd280b8 commit 2efbff6
1 file changed
+3
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| |||
0 commit comments