diff --git a/proxy/trojan/server.go b/proxy/trojan/server.go index 618fbe10..6309bbc6 100644 --- a/proxy/trojan/server.go +++ b/proxy/trojan/server.go @@ -155,9 +155,8 @@ func (s *Server) Process(ctx context.Context, network net.Network, conn stat.Con return newError("unable to set read deadline").Base(err).AtWarning() } - first := buf.New() - defer first.Release() - + first := buf.FromBytes(make([]byte, buf.Size)) + first.Clear() firstLen, err := first.ReadFrom(conn) if err != nil { return newError("failed to read first request").Base(err) diff --git a/proxy/vless/inbound/inbound.go b/proxy/vless/inbound/inbound.go index b623fe6e..86b09e04 100644 --- a/proxy/vless/inbound/inbound.go +++ b/proxy/vless/inbound/inbound.go @@ -188,9 +188,8 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s return newError("unable to set read deadline").Base(err).AtWarning() } - first := buf.New() - defer first.Release() - + first := buf.FromBytes(make([]byte, buf.Size)) + first.Clear() firstLen, _ := first.ReadFrom(connection) newError("firstLen = ", firstLen).AtInfo().WriteToLog(sid)