From 0d772cd800553a5fccabc977362286e2c9bb954e Mon Sep 17 00:00:00 2001 From: RPRX <63339210+rprx@users.noreply.github.com> Date: Fri, 4 Dec 2020 11:51:12 +0000 Subject: [PATCH] Adjust Splice panic strategy --- app/proxyman/inbound/worker.go | 17 ++++++++++------- proxy/vless/encoding/encoding.go | 4 ++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/proxyman/inbound/worker.go b/app/proxyman/inbound/worker.go index 94df0ddd..0d4ae494 100644 --- a/app/proxyman/inbound/worker.go +++ b/app/proxyman/inbound/worker.go @@ -423,24 +423,27 @@ func (w *dsWorker) callback(conn internet.Connection) { sid := session.NewID() ctx = session.ContextWithID(ctx, sid) + if w.uplinkCounter != nil || w.downlinkCounter != nil { + conn = &internet.StatCouterConnection{ + Connection: conn, + ReadCounter: w.uplinkCounter, + WriteCounter: w.downlinkCounter, + } + } ctx = session.ContextWithInbound(ctx, &session.Inbound{ Source: net.DestinationFromAddr(conn.RemoteAddr()), Gateway: net.UnixDestination(w.address), Tag: w.tag, + Conn: conn, }) + content := new(session.Content) if w.sniffingConfig != nil { content.SniffingRequest.Enabled = w.sniffingConfig.Enabled content.SniffingRequest.OverrideDestinationForProtocol = w.sniffingConfig.DestinationOverride } ctx = session.ContextWithContent(ctx, content) - if w.uplinkCounter != nil || w.downlinkCounter != nil { - conn = &internet.StatCouterConnection{ - Connection: conn, - ReadCounter: w.uplinkCounter, - WriteCounter: w.downlinkCounter, - } - } + if err := w.proxy.Process(ctx, net.Network_UNIX, conn, w.dispatcher); err != nil { newError("connection ends").Base(err).WriteToLog(session.ExportIDToError(ctx)) } diff --git a/proxy/vless/encoding/encoding.go b/proxy/vless/encoding/encoding.go index 04b84955..cfa3914d 100644 --- a/proxy/vless/encoding/encoding.go +++ b/proxy/vless/encoding/encoding.go @@ -185,7 +185,7 @@ func ReadV(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater, c if conn.DirectIn { conn.DirectIn = false if sctx != nil { - if inbound := session.InboundFromContext(sctx); inbound != nil { + if inbound := session.InboundFromContext(sctx); inbound != nil && inbound.Conn != nil { iConn := inbound.Conn statConn, ok := iConn.(*internet.StatCouterConnection) if ok { @@ -208,7 +208,7 @@ func ReadV(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater, c panic("XTLS Splice: not TCP inbound") } } else { - panic("XTLS Splice: nil inbound") + //panic("XTLS Splice: nil inbound or nil inbound.Conn") } } reader = buf.NewReadVReader(conn.Connection, rawConn)