Update WriteToUDPAddrPort usage since fixed by go1.18.5

This commit is contained in:
世界 2022-08-03 17:49:04 +08:00
parent d4cce1b5b9
commit f6f3390490
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
2 changed files with 2 additions and 7 deletions

View file

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

View file

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