mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-05-08 14:13:22 +00:00
This commit is contained in:
@@ -77,25 +77,25 @@ func (w *tcpWorker) callback(conn stat.Connection) {
|
|||||||
case internet.SocketConfig_TProxy:
|
case internet.SocketConfig_TProxy:
|
||||||
dest = net.DestinationFromAddr(conn.LocalAddr())
|
dest = net.DestinationFromAddr(conn.LocalAddr())
|
||||||
}
|
}
|
||||||
// Check if try to connect to this inbound itself (can cause loopback)
|
|
||||||
var isLoopBack bool
|
|
||||||
if w.address == net.AnyIP || w.address == net.AnyIPv6 {
|
|
||||||
if dest.Port.Value() == w.port.Value() && IsLocal(dest.Address.IP()) {
|
|
||||||
isLoopBack = true
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if w.hub.Addr().String() == dest.NetAddr() {
|
|
||||||
isLoopBack = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if isLoopBack {
|
|
||||||
cancel()
|
|
||||||
conn.Close()
|
|
||||||
errors.LogError(ctx, errors.New("loopback connection detected"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if dest.IsValid() {
|
if dest.IsValid() {
|
||||||
|
// Check if try to connect to this inbound itself (can cause loopback)
|
||||||
|
var isLoopBack bool
|
||||||
|
if w.address == net.AnyIP || w.address == net.AnyIPv6 {
|
||||||
|
if dest.Port.Value() == w.port.Value() && IsLocal(dest.Address.IP()) {
|
||||||
|
isLoopBack = true
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if w.hub.Addr().String() == dest.NetAddr() {
|
||||||
|
isLoopBack = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if isLoopBack {
|
||||||
|
cancel()
|
||||||
|
conn.Close()
|
||||||
|
errors.LogError(ctx, errors.New("loopback connection detected"))
|
||||||
|
return
|
||||||
|
}
|
||||||
outbounds[0].Target = dest
|
outbounds[0].Target = dest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user