fix: udp panic when udpConn is not net.PacketConn

This commit is contained in:
mzz2017 2023-02-11 21:10:34 +08:00
parent f2d5ed34fb
commit d67fe075a3

View File

@ -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() {