mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 01:08:33 +00:00
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:
parent
94c7970fd6
commit
22c50a70c6
3 changed files with 43 additions and 37 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue