mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-22 12:49:20 +02:00
Fix user download stats with splice
This commit is contained in:
parent
d7434e8e36
commit
9b5c3f417e
|
@ -16,6 +16,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pires/go-proxyproto"
|
"github.com/pires/go-proxyproto"
|
||||||
|
"github.com/xtls/xray-core/app/dispatcher"
|
||||||
"github.com/xtls/xray-core/common/buf"
|
"github.com/xtls/xray-core/common/buf"
|
||||||
"github.com/xtls/xray-core/common/errors"
|
"github.com/xtls/xray-core/common/errors"
|
||||||
"github.com/xtls/xray-core/common/net"
|
"github.com/xtls/xray-core/common/net"
|
||||||
|
@ -478,14 +479,18 @@ func CopyRawConnIfExist(ctx context.Context, readerConn net.Conn, writerConn net
|
||||||
for inbound.CanSpliceCopy != 3 {
|
for inbound.CanSpliceCopy != 3 {
|
||||||
if inbound.CanSpliceCopy == 1 {
|
if inbound.CanSpliceCopy == 1 {
|
||||||
newError("CopyRawConn splice").WriteToLog(session.ExportIDToError(ctx))
|
newError("CopyRawConn splice").WriteToLog(session.ExportIDToError(ctx))
|
||||||
|
statWriter, _ := writer.(*dispatcher.SizeStatWriter)
|
||||||
//runtime.Gosched() // necessary
|
//runtime.Gosched() // necessary
|
||||||
time.Sleep(time.Millisecond) // without this, there will be a rare ssl error for freedom splice
|
time.Sleep(time.Millisecond) // without this, there will be a rare ssl error for freedom splice
|
||||||
w, err := tc.ReadFrom(readerConn)
|
w, err := tc.ReadFrom(readerConn)
|
||||||
if readCounter != nil {
|
if readCounter != nil {
|
||||||
readCounter.Add(w)
|
readCounter.Add(w) // outbound stats
|
||||||
}
|
}
|
||||||
if writeCounter != nil {
|
if writeCounter != nil {
|
||||||
writeCounter.Add(w)
|
writeCounter.Add(w) // inbound stats
|
||||||
|
}
|
||||||
|
if statWriter != nil {
|
||||||
|
statWriter.Counter.Add(w) // user stats
|
||||||
}
|
}
|
||||||
if err != nil && errors.Cause(err) != io.EOF {
|
if err != nil && errors.Cause(err) != io.EOF {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue