Adjust Splice panic strategy

This commit is contained in:
RPRX 2020-12-04 11:51:12 +00:00 committed by GitHub
parent d7ff78c688
commit 0d772cd800
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 13 deletions

View File

@ -423,17 +423,6 @@ func (w *dsWorker) callback(conn internet.Connection) {
sid := session.NewID() sid := session.NewID()
ctx = session.ContextWithID(ctx, sid) ctx = session.ContextWithID(ctx, sid)
ctx = session.ContextWithInbound(ctx, &session.Inbound{
Source: net.DestinationFromAddr(conn.RemoteAddr()),
Gateway: net.UnixDestination(w.address),
Tag: w.tag,
})
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 { if w.uplinkCounter != nil || w.downlinkCounter != nil {
conn = &internet.StatCouterConnection{ conn = &internet.StatCouterConnection{
Connection: conn, Connection: conn,
@ -441,6 +430,20 @@ func (w *dsWorker) callback(conn internet.Connection) {
WriteCounter: w.downlinkCounter, 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 err := w.proxy.Process(ctx, net.Network_UNIX, conn, w.dispatcher); err != nil { if err := w.proxy.Process(ctx, net.Network_UNIX, conn, w.dispatcher); err != nil {
newError("connection ends").Base(err).WriteToLog(session.ExportIDToError(ctx)) newError("connection ends").Base(err).WriteToLog(session.ExportIDToError(ctx))
} }

View File

@ -185,7 +185,7 @@ func ReadV(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater, c
if conn.DirectIn { if conn.DirectIn {
conn.DirectIn = false conn.DirectIn = false
if sctx != nil { if sctx != nil {
if inbound := session.InboundFromContext(sctx); inbound != nil { if inbound := session.InboundFromContext(sctx); inbound != nil && inbound.Conn != nil {
iConn := inbound.Conn iConn := inbound.Conn
statConn, ok := iConn.(*internet.StatCouterConnection) statConn, ok := iConn.(*internet.StatCouterConnection)
if ok { if ok {
@ -208,7 +208,7 @@ func ReadV(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater, c
panic("XTLS Splice: not TCP inbound") panic("XTLS Splice: not TCP inbound")
} }
} else { } else {
panic("XTLS Splice: nil inbound") //panic("XTLS Splice: nil inbound or nil inbound.Conn")
} }
} }
reader = buf.NewReadVReader(conn.Connection, rawConn) reader = buf.NewReadVReader(conn.Connection, rawConn)