From f6f339049074cf0634b0b8886de52bf6c89ffecf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Wed, 3 Aug 2022 17:49:04 +0800 Subject: [PATCH] Update WriteToUDPAddrPort usage since fixed by go1.18.5 --- common/dialer/resolve_conn.go | 4 ++-- inbound/default.go | 5 ----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/common/dialer/resolve_conn.go b/common/dialer/resolve_conn.go index b6084971..7fe011ff 100644 --- a/common/dialer/resolve_conn.go +++ b/common/dialer/resolve_conn.go @@ -43,9 +43,9 @@ func (w *ResolveUDPConn) WritePacket(buffer *buf.Buffer, destination M.Socksaddr if err != nil { return err } - return common.Error(w.UDPConn.WriteTo(buffer.Bytes(), M.SocksaddrFrom(addresses[0], destination.Port).UDPAddr())) + return common.Error(w.UDPConn.WriteToUDPAddrPort(buffer.Bytes(), M.SocksaddrFrom(addresses[0], destination.Port).AddrPort())) } - return common.Error(w.UDPConn.WriteToUDP(buffer.Bytes(), destination.UDPAddr())) + return common.Error(w.UDPConn.WriteToUDPAddrPort(buffer.Bytes(), destination.AddrPort())) } func (w *ResolveUDPConn) Upstream() any { diff --git a/inbound/default.go b/inbound/default.go index dd73a6c4..fb567e9d 100644 --- a/inbound/default.go +++ b/inbound/default.go @@ -46,7 +46,6 @@ type myInboundAdapter struct { tcpListener *net.TCPListener udpConn *net.UDPConn - packetForce6 bool packetAccess sync.RWMutex packetOutboundClosed chan struct{} packetOutbound chan *myInboundPacket @@ -83,7 +82,6 @@ func (a *myInboundAdapter) Start() error { return err } a.udpConn = udpConn - a.packetForce6 = M.SocksaddrFromNet(udpConn.LocalAddr()).Addr.Is6() a.packetOutboundClosed = make(chan struct{}) a.packetOutbound = make(chan *myInboundPacket) if a.oobPacketHandler != nil { @@ -340,9 +338,6 @@ func (a *myInboundAdapter) writePacket(buffer *buf.Buffer, destination M.Socksad } return common.Error(a.udpConn.WriteTo(buffer.Bytes(), udpAddr)) } - if a.packetForce6 && destination.Addr.Is4() { - destination.Addr = netip.AddrFrom16(destination.Addr.As16()) - } return common.Error(a.udpConn.WriteToUDPAddrPort(buffer.Bytes(), destination.AddrPort())) }