@@ -95,6 +95,9 @@ func (s *Server) ProcessWithFirstbyte(ctx context.Context, network net.Network,
9595 inbound .User = & protocol.MemoryUser {
9696 Level : s .config .UserLevel ,
9797 }
98+ if isTransportConn (conn ) {
99+ inbound .CanSpliceCopy = 3
100+ }
98101 var reader * bufio.Reader
99102 if len (firstbyte ) > 0 {
100103 readerWithoutFirstbyte := bufio .NewReaderSize (readerOnly {conn }, buf .Size )
@@ -207,7 +210,9 @@ func (s *Server) handleConnect(ctx context.Context, _ *http.Request, reader *buf
207210 }
208211
209212 responseDone := func () error {
210- inbound .CanSpliceCopy = 1
213+ if inbound .CanSpliceCopy == 2 {
214+ inbound .CanSpliceCopy = 1
215+ }
211216 defer timer .SetTimeout (plcy .Timeouts .UplinkOnly )
212217
213218 v2writer := buf .NewWriter (conn )
@@ -370,6 +375,20 @@ func readResponseAndHandle100Continue(r *bufio.Reader, req *http.Request, writer
370375 return http .ReadResponse (r , req )
371376}
372377
378+ // isTransportConn return false if the conn is a raw tcp conn without transport or tls, can process splice copy
379+ func isTransportConn (conn stat.Connection ) bool {
380+ if conn != nil {
381+ statConn , ok := conn .(* stat.CounterConnection )
382+ if ok {
383+ conn = statConn .Connection
384+ }
385+ if _ , ok := conn .(* net.TCPConn ); ok {
386+ return false
387+ }
388+ }
389+ return true
390+ }
391+
373392func init () {
374393 common .Must (common .RegisterConfig ((* ServerConfig )(nil ), func (ctx context.Context , config interface {}) (interface {}, error ) {
375394 return NewServer (ctx , config .(* ServerConfig ))
0 commit comments