From 63e8e689a89ce3a446486df212608dfadf173ee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Wed, 20 Aug 2025 11:39:44 +0000 Subject: [PATCH] and httpin --- proxy/http/server.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/proxy/http/server.go b/proxy/http/server.go index 3721dd47..beeb4427 100644 --- a/proxy/http/server.go +++ b/proxy/http/server.go @@ -95,6 +95,9 @@ func (s *Server) ProcessWithFirstbyte(ctx context.Context, network net.Network, inbound.User = &protocol.MemoryUser{ Level: s.config.UserLevel, } + if isTransportConn(conn) { + inbound.CanSpliceCopy = 3 + } var reader *bufio.Reader if len(firstbyte) > 0 { readerWithoutFirstbyte := bufio.NewReaderSize(readerOnly{conn}, buf.Size) @@ -207,7 +210,9 @@ func (s *Server) handleConnect(ctx context.Context, _ *http.Request, reader *buf } responseDone := func() error { - inbound.CanSpliceCopy = 1 + if inbound.CanSpliceCopy == 2 { + inbound.CanSpliceCopy = 1 + } defer timer.SetTimeout(plcy.Timeouts.UplinkOnly) v2writer := buf.NewWriter(conn) @@ -370,6 +375,20 @@ func readResponseAndHandle100Continue(r *bufio.Reader, req *http.Request, writer return http.ReadResponse(r, req) } +// isTransportConn return false if the conn is a raw tcp conn without transport or tls, can process splice copy +func isTransportConn(conn stat.Connection) bool { + if conn != nil { + statConn, ok := conn.(*stat.CounterConnection) + if ok { + conn = statConn.Connection + } + if _, ok := conn.(*net.TCPConn); ok { + return false + } + } + return true +} + func init() { common.Must(common.RegisterConfig((*ServerConfig)(nil), func(ctx context.Context, config interface{}) (interface{}, error) { return NewServer(ctx, config.(*ServerConfig))