From 9ac1cf2d68df75d25b0c83efe6fa8fda563dd63d Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Wed, 12 Feb 2020 13:12:07 +0800 Subject: [PATCH] Fix: vmessUDPConn should return a correctly address --- adapters/outbound/vmess.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/adapters/outbound/vmess.go b/adapters/outbound/vmess.go index a7a5016d..401f3b87 100644 --- a/adapters/outbound/vmess.go +++ b/adapters/outbound/vmess.go @@ -54,7 +54,7 @@ func (v *Vmess) DialUDP(metadata *C.Metadata) (C.PacketConn, error) { if err != nil { return nil, fmt.Errorf("new vmess client error: %v", err) } - return newPacketConn(&vmessUDPConn{Conn: c}, v), nil + return newPacketConn(&vmessUDPConn{Conn: c, rAddr: metadata.UDPAddr()}, v), nil } func NewVmess(option VmessOption) (*Vmess, error) { @@ -117,6 +117,7 @@ func parseVmessAddr(metadata *C.Metadata) *vmess.DstAddr { type vmessUDPConn struct { net.Conn + rAddr net.Addr } func (uc *vmessUDPConn) WriteTo(b []byte, addr net.Addr) (int, error) { @@ -125,5 +126,5 @@ func (uc *vmessUDPConn) WriteTo(b []byte, addr net.Addr) (int, error) { func (uc *vmessUDPConn) ReadFrom(b []byte) (int, net.Addr, error) { n, err := uc.Conn.Read(b) - return n, uc.RemoteAddr(), err + return n, uc.rAddr, err }