mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-28 19:41:27 +00:00
Go back to first fix (revet d21e9b0abd
)
Xtls is magic, don't play with it ;) A knowledged guess is the timing to switch to splice is very sensitive. Now both Xtls and Freedom outound do the switching when pipe just finished one buffer
This commit is contained in:
parent
09656bd5d1
commit
a15334b395
|
@ -224,6 +224,15 @@ func XtlsWrite(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdate
|
||||||
var ct stats.Counter
|
var ct stats.Counter
|
||||||
for {
|
for {
|
||||||
buffer, err := reader.ReadMultiBuffer()
|
buffer, err := reader.ReadMultiBuffer()
|
||||||
|
if trafficState.WriterSwitchToDirectCopy {
|
||||||
|
if inbound := session.InboundFromContext(ctx); inbound != nil && inbound.CanSpliceCopy == 2 {
|
||||||
|
inbound.CanSpliceCopy = 1 // force the value to 1, don't use setter
|
||||||
|
}
|
||||||
|
rawConn, _, writerCounter := proxy.UnwrapRawConn(conn)
|
||||||
|
writer = buf.NewWriter(rawConn)
|
||||||
|
ct = writerCounter
|
||||||
|
trafficState.WriterSwitchToDirectCopy = false
|
||||||
|
}
|
||||||
if !buffer.IsEmpty() {
|
if !buffer.IsEmpty() {
|
||||||
if ct != nil {
|
if ct != nil {
|
||||||
ct.Add(int64(buffer.Len()))
|
ct.Add(int64(buffer.Len()))
|
||||||
|
@ -232,15 +241,6 @@ func XtlsWrite(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdate
|
||||||
if werr := writer.WriteMultiBuffer(buffer); werr != nil {
|
if werr := writer.WriteMultiBuffer(buffer); werr != nil {
|
||||||
return werr
|
return werr
|
||||||
}
|
}
|
||||||
if trafficState.WriterSwitchToDirectCopy {
|
|
||||||
rawConn, _, writerCounter := proxy.UnwrapRawConn(conn)
|
|
||||||
writer = buf.NewWriter(rawConn)
|
|
||||||
ct = writerCounter
|
|
||||||
trafficState.WriterSwitchToDirectCopy = false
|
|
||||||
if inbound := session.InboundFromContext(ctx); inbound != nil && inbound.CanSpliceCopy == 2 {
|
|
||||||
inbound.CanSpliceCopy = 1 // force the value to 1, don't use setter
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue