Fix: vmessUDPConn should return a correctly address
This commit is contained in:
parent
0c82ab8cdf
commit
9ac1cf2d68
1 changed files with 3 additions and 2 deletions
|
@ -54,7 +54,7 @@ func (v *Vmess) DialUDP(metadata *C.Metadata) (C.PacketConn, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("new vmess client error: %v", err)
|
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) {
|
func NewVmess(option VmessOption) (*Vmess, error) {
|
||||||
|
@ -117,6 +117,7 @@ func parseVmessAddr(metadata *C.Metadata) *vmess.DstAddr {
|
||||||
|
|
||||||
type vmessUDPConn struct {
|
type vmessUDPConn struct {
|
||||||
net.Conn
|
net.Conn
|
||||||
|
rAddr net.Addr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (uc *vmessUDPConn) WriteTo(b []byte, addr net.Addr) (int, error) {
|
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) {
|
func (uc *vmessUDPConn) ReadFrom(b []byte) (int, net.Addr, error) {
|
||||||
n, err := uc.Conn.Read(b)
|
n, err := uc.Conn.Read(b)
|
||||||
return n, uc.RemoteAddr(), err
|
return n, uc.rAddr, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue