Use dns.DefaultMsgSize instead of magic number 4096

This commit is contained in:
Star Brilliant
2018-04-25 03:04:31 +08:00
parent dc14a70e9d
commit 874a3613e4
5 changed files with 5 additions and 5 deletions

View File

@@ -72,7 +72,7 @@ func NewClient(conf *config) (c *Client, err error) {
Addr: addr,
Net: "udp",
Handler: udpHandler,
UDPSize: 4096,
UDPSize: dns.DefaultMsgSize,
})
c.tcpServers = append(c.tcpServers, &dns.Server{
Addr: addr,

View File

@@ -73,7 +73,7 @@ func (c *Client) generateRequestIETF(w dns.ResponseWriter, r *dns.Msg, isTCP boo
opt = new(dns.OPT)
opt.Hdr.Name = "."
opt.Hdr.Rrtype = dns.TypeOPT
opt.SetUDPSize(4096)
opt.SetUDPSize(dns.DefaultMsgSize)
opt.SetDo(false)
r.Extra = append(r.Extra, opt)
} else {

View File

@@ -150,7 +150,7 @@ func (s *Server) parseRequestGoogle(w http.ResponseWriter, r *http.Request) *DNS
opt := new(dns.OPT)
opt.Hdr.Name = "."
opt.Hdr.Rrtype = dns.TypeOPT
opt.SetUDPSize(4096)
opt.SetUDPSize(dns.DefaultMsgSize)
opt.SetDo(true)
if ednsClientAddress != nil {
edns0Subnet := new(dns.EDNS0_SUBNET)

View File

@@ -93,7 +93,7 @@ func (s *Server) parseRequestIETF(w http.ResponseWriter, r *http.Request) *DNSRe
opt = new(dns.OPT)
opt.Hdr.Name = "."
opt.Hdr.Rrtype = dns.TypeOPT
opt.SetUDPSize(4096)
opt.SetUDPSize(dns.DefaultMsgSize)
opt.SetDo(false)
msg.Extra = append(msg.Extra, opt)
}

View File

@@ -58,7 +58,7 @@ func NewServer(conf *config) (s *Server) {
conf: conf,
udpClient: &dns.Client{
Net: "udp",
UDPSize: 4096,
UDPSize: dns.DefaultMsgSize,
Timeout: time.Duration(conf.Timeout) * time.Second,
},
tcpClient: &dns.Client{