gera2ld / async_dns

DNS library based on asyncio
MIT License
70 stars 17 forks source link

Flags loss fix #19

Closed RomaLash closed 3 years ago

RomaLash commented 3 years ago

I want to find out is nameserver has AA flag for requested domain.

I wrote this code: resolver = ProxyResolver(proxies=['ns1.google.com.']) res = await resolver.query('www.google.com', types.ANY, timeout=2) print("AA: ", res.aa) But AA is 0 (incorrect).

It happend because "self.result" variable in query.py didnt get flags from "inter_res"

gera2ld commented 3 years ago

If I understand the RFC correctly AA should be 0 because the proxy server is not authoritative and it returns a cached result. IMHO the other props should not be overridden by the upstream response.

It seems to be a defect that this library didn't expose a pure resolver without cache.

RomaLash commented 3 years ago

because the proxy server is not authoritative

response from "dig"

; <<>> DiG 9.10.3-P4-Ubuntu <<>> @ns1.google.com ns www.google.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 41011
;; flags: qr aa rd; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1
;; WARNING: recursion requested but not available

As u can see, i used "ns1.google.com" as nameserver and get AA = 1.

oh..I see - cache mechanism doesnt save nameserver. If I make query as above and than make another ( e.g. with 8.8.8.8 as nameserver) I still get AA = 1 (because I save it from first query for this domain).

gera2ld commented 3 years ago

There is a client to get the raw response from remote server now. See readme for more detail.