Closed wen-long closed 4 years ago
From https://tools.ietf.org/html/draft-ietf-dnsind-udp-size-02 The DNS data portion of DNS UDP packets is currently limited to 512 bytes. The standard states that if the data required to be in the response to a UDP request does not fit in 512 bytes, a truncation flag bit is set in the response and the resolver must try again using TCP with TCP's substantially higher set up and tear down overhead..
I suppose add a custom config for udp package size (512 for default) or just fall back to tcp when the truncate occurs would be a better choice.
Reference:
@shawn1m you are right,this is just a quick and straight fix,while at least it works fine.
dnsmasq have a option --edns-packet-max which defaults to 2048
https://github.com/guns/dnsmasq/blob/fe3d87f8ccd942f4478efdfbc3a7ca5aeedcc0d9/src/config.h#L21
but I dont think this is a problem overture needs to worry about. DNS's staff should be done right by upstream https://github.com/miekg/dns this is just a api problem,miekg/dns needs some buffer for io,and let user determine the size. maybe some other dns library allocate a big enough memory itself, thus this kind of problem will not exist. or at latest dns library should return an error when buffer is too small,or force to use a bigger buffer size(by some calucate)
Merged. I'll add configuration for this and change the default value later if necessary.
解决 https://github.com/shawn1m/overture/issues/174
调试信息: github.com/miekg/dns@v1.1.8/client.go:237 内部读取 go udp conn,返回的数据截断且没有报错