UDS: Make all remote addr 0.0.0.0 (#4390)

https://github.com/XTLS/Xray-core/pull/4389#issuecomment-2656360673

---------

Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com>
This commit is contained in:
风扇滑翔翼 2025-02-13 22:01:33 +08:00 committed by GitHub
parent 94c7970fd6
commit 22c50a70c6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 43 additions and 37 deletions

View file

@ -2,7 +2,6 @@ package inbound
import (
"context"
"strings"
"sync"
"sync/atomic"
"time"
@ -464,19 +463,8 @@ func (w *dsWorker) callback(conn stat.Connection) {
WriteCounter: w.downlinkCounter,
}
}
// For most of time, unix obviously have no source addr. But if we leave it empty, it will cause panic.
// So we use gateway as source for log.
// However, there are some special situations where a valid source address might be available.
// Such as the source address parsed from X-Forwarded-For in websocket.
// In that case, we keep it.
var source net.Destination
if !strings.Contains(conn.RemoteAddr().String(), "unix") {
source = net.DestinationFromAddr(conn.RemoteAddr())
} else {
source = net.UnixDestination(w.address)
}
ctx = session.ContextWithInbound(ctx, &session.Inbound{
Source: source,
Source: net.DestinationFromAddr(conn.RemoteAddr()),
Gateway: net.UnixDestination(w.address),
Tag: w.tag,
Conn: conn,