From 1d7c40d7287545cdad368d43f563811a6ac088bc Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sun, 4 Dec 2022 18:24:46 -0500 Subject: [PATCH] Enable Xtls Vision (Direct not Splice) for any inbound connection Before this change, Vision client need a pure inbound like socks or http. After this change, it will support any inbound. This is useful in traffic forwarder use case inside China. --- proxy/vless/encoding/encoding.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/proxy/vless/encoding/encoding.go b/proxy/vless/encoding/encoding.go index 1817fa27..bbe3b1e7 100644 --- a/proxy/vless/encoding/encoding.go +++ b/proxy/vless/encoding/encoding.go @@ -260,8 +260,8 @@ func XtlsRead(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater for { if shouldSwitchToDirectCopy { shouldSwitchToDirectCopy = false - if runtime.GOOS == "linux" || runtime.GOOS == "android" { - if inbound := session.InboundFromContext(ctx); inbound != nil && inbound.Conn != nil { + if inbound := session.InboundFromContext(ctx); inbound != nil && inbound.Conn != nil && (runtime.GOOS == "linux" || runtime.GOOS == "android") { + if _, ok := inbound.User.Account.(*vless.MemoryAccount); inbound.User.Account == nil || ok { iConn := inbound.Conn statConn, ok := iConn.(*stat.CounterConnection) if ok { @@ -281,11 +281,7 @@ func XtlsRead(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater statConn.WriteCounter.Add(w) } return err - } else { - panic("XTLS Splice: not TCP inbound") } - } else { - // panic("XTLS Splice: nil inbound or nil inbound.Conn") } } reader = buf.NewReadVReader(conn, rawConn, nil)