Skip to content

Commit ef90099

Browse files
committed
increase the default UDP buffer
1 parent 10ee7b1 commit ef90099

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

server.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ const defaultReadTimeout = 2 * time.Second
1818
// then we start using defaultTCPIdleTimeout
1919
const defaultTCPIdleTimeout = 8 * time.Second
2020

21+
// defaultUDPSize is the size of the UDP read buffer. Using 1252 by default,
22+
// see here: https://github.com/AdguardTeam/AdGuardDNS/issues/188
23+
const defaultUDPSize = 1252
24+
2125
// helper struct that is used in several SetReadDeadline calls
2226
var longTimeAgo = time.Unix(1, 0)
2327

@@ -49,7 +53,7 @@ type Server struct {
4953
ResolverCert *Cert
5054

5155
// UDPSize is the default buffer size to use to read incoming UDP messages.
52-
// If not set it defaults to dns.MinMsgSize (512 B).
56+
// If not set it defaults to defaultUDPSize (1252 B).
5357
UDPSize int
5458

5559
// Handler to invoke. If nil, uses DefaultHandler.
@@ -154,7 +158,7 @@ func (s *Server) init() {
154158
s.tcpListeners = map[net.Listener]struct{}{}
155159

156160
if s.UDPSize == 0 {
157-
s.UDPSize = dns.MinMsgSize
161+
s.UDPSize = defaultUDPSize
158162
}
159163
}
160164

0 commit comments

Comments
 (0)