diff --git a/core/server/config.go b/core/server/config.go index 19aae53bd0..a01f478f4d 100644 --- a/core/server/config.go +++ b/core/server/config.go @@ -7,10 +7,9 @@ import ( "sync/atomic" "time" - "github.com/apernet/hysteria/core/v2/internal/utils" - "github.com/apernet/hysteria/core/v2/errors" "github.com/apernet/hysteria/core/v2/internal/pmtud" + "github.com/apernet/hysteria/core/v2/internal/utils" "github.com/apernet/quic-go" ) diff --git a/core/server/copy.go b/core/server/copy.go index 2f99ae42cf..7123fc89ea 100644 --- a/core/server/copy.go +++ b/core/server/copy.go @@ -32,7 +32,7 @@ func copyBufferLog(dst io.Writer, src io.Reader, log func(n uint64) bool) error } } -func copyTwoWayWithLogger(id string, serverRw, remoteRw io.ReadWriter, l TrafficLogger, stats *StreamStats) error { +func copyTwoWayEx(id string, serverRw, remoteRw io.ReadWriter, l TrafficLogger, stats *StreamStats) error { errChan := make(chan error, 2) go func() { errChan <- copyBufferLog(serverRw, remoteRw, func(n uint64) bool { @@ -52,7 +52,7 @@ func copyTwoWayWithLogger(id string, serverRw, remoteRw io.ReadWriter, l Traffic return <-errChan } -// copyTwoWay is the "fast-path" version of copyTwoWayWithLogger that does not log traffic. +// copyTwoWay is the "fast-path" version of copyTwoWayEx that does not log traffic or update stream stats. // It uses the built-in io.Copy instead of our own copyBufferLog. func copyTwoWay(serverRw, remoteRw io.ReadWriter) error { errChan := make(chan error, 2) diff --git a/core/server/server.go b/core/server/server.go index f7ad957f81..696f1d0956 100644 --- a/core/server/server.go +++ b/core/server/server.go @@ -280,7 +280,7 @@ func (h *h3sHandler) handleTCPRequest(stream quic.Stream) { } // Start proxying if trafficLogger != nil { - err = copyTwoWayWithLogger(h.authID, stream, tConn, trafficLogger, streamStats) + err = copyTwoWayEx(h.authID, stream, tConn, trafficLogger, streamStats) } else { // Use the fast path if no traffic logger is set err = copyTwoWay(stream, tConn) diff --git a/extras/trafficlogger/http.go b/extras/trafficlogger/http.go index 87eb919f14..d8e6ebd4f1 100644 --- a/extras/trafficlogger/http.go +++ b/extras/trafficlogger/http.go @@ -11,9 +11,8 @@ import ( "sync" "time" - "github.com/apernet/quic-go" - "github.com/apernet/hysteria/core/v2/server" + "github.com/apernet/quic-go" ) const (