fix: correct sing-tun's rAddr
This commit is contained in:
parent
f748e3632d
commit
66e5136ba0
1 changed files with 6 additions and 1 deletions
|
@ -29,6 +29,7 @@ type waitCloseConn struct {
|
||||||
net.Conn
|
net.Conn
|
||||||
wg *sync.WaitGroup
|
wg *sync.WaitGroup
|
||||||
close sync.Once
|
close sync.Once
|
||||||
|
rAddr net.Addr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *waitCloseConn) Close() error { // call from handleTCPConn(connCtx C.ConnContext)
|
func (c *waitCloseConn) Close() error { // call from handleTCPConn(connCtx C.ConnContext)
|
||||||
|
@ -38,6 +39,10 @@ func (c *waitCloseConn) Close() error { // call from handleTCPConn(connCtx C.Con
|
||||||
return c.Conn.Close()
|
return c.Conn.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *waitCloseConn) RemoteAddr() net.Addr {
|
||||||
|
return c.rAddr
|
||||||
|
}
|
||||||
|
|
||||||
func (h *ListenerHandler) NewConnection(ctx context.Context, conn net.Conn, metadata M.Metadata) error {
|
func (h *ListenerHandler) NewConnection(ctx context.Context, conn net.Conn, metadata M.Metadata) error {
|
||||||
switch metadata.Destination.Fqdn {
|
switch metadata.Destination.Fqdn {
|
||||||
case vmess.MuxDestination.Fqdn:
|
case vmess.MuxDestination.Fqdn:
|
||||||
|
@ -50,7 +55,7 @@ func (h *ListenerHandler) NewConnection(ctx context.Context, conn net.Conn, meta
|
||||||
wg := &sync.WaitGroup{}
|
wg := &sync.WaitGroup{}
|
||||||
defer wg.Wait() // this goroutine must exit after conn.Close()
|
defer wg.Wait() // this goroutine must exit after conn.Close()
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
h.TcpIn <- inbound.NewSocket(target, &waitCloseConn{Conn: conn, wg: wg}, h.Type)
|
h.TcpIn <- inbound.NewSocket(target, &waitCloseConn{Conn: conn, wg: wg, rAddr: metadata.Source.TCPAddr()}, h.Type)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue