فهرست منبع

Revise the Code per XTLS#1515 (#1536)

* Use buf.FromBytes(make([]byte, 0, buf.Size)) to create `first`

Fixes https://github.com/XTLS/Xray-core/issues/1515

* Update server.go

* Update inbound.go

Co-authored-by: RPRX <[email protected]>
MP 2 سال پیش
والد
کامیت
77d2f9edd7
2فایلهای تغییر یافته به همراه4 افزوده شده و 6 حذف شده
  1. 2 3
      proxy/trojan/server.go
  2. 2 3
      proxy/vless/inbound/inbound.go

+ 2 - 3
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)

+ 2 - 3
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)