From d67fe075a3dd37056c31e05bc1a5b2667b7a14cf Mon Sep 17 00:00:00 2001 From: mzz2017 <2017@duck.com> Date: Sat, 11 Feb 2023 21:10:34 +0800 Subject: [PATCH] fix: udp panic when udpConn is not net.PacketConn --- control/udp_endpoint.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/control/udp_endpoint.go b/control/udp_endpoint.go index f8d8dea..8cec636 100644 --- a/control/udp_endpoint.go +++ b/control/udp_endpoint.go @@ -124,6 +124,9 @@ func (p *UdpEndpointPool) GetOrCreate(lAddr netip.AddrPort, createOption *UdpEnd if err != nil { return nil, true, err } + if _, ok = udpConn.(net.PacketConn); !ok { + return nil, true, fmt.Errorf("protocol does not support udp") + } ue = &UdpEndpoint{ conn: udpConn.(net.PacketConn), deadlineTimer: time.AfterFunc(createOption.NatTimeout, func() {