From d0663277dc519f93082358d844dfdddf3b7713c6 Mon Sep 17 00:00:00 2001 From: rookisbusy Date: Thu, 30 Mar 2023 14:17:25 +0800 Subject: [PATCH] safe dns buff size --- listener/sing_tun/dns.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/listener/sing_tun/dns.go b/listener/sing_tun/dns.go index 21dee43c..f2daaf0c 100644 --- a/listener/sing_tun/dns.go +++ b/listener/sing_tun/dns.go @@ -110,7 +110,10 @@ func (h *ListenerHandler) NewPacketConnection(ctx context.Context, conn network. conn2 = nil }() for { - buff := buf.NewPacket() + // safe size which is 1232 from https://dnsflagday.net/2020/. + // so 2048 is enough + buff := buf.NewSize(2 * 1024) + _ = conn.SetReadDeadline(time.Now().Add(DefaultDnsReadTimeout)) dest, err := conn.ReadPacket(buff) if err != nil { buff.Release()