fix new tls lib issue

This commit is contained in:
Fangliding
2026-10-16 16:03:44 +08:00
parent 206a24a9f0
commit 969e5b6c11
4 changed files with 43 additions and 38 deletions
+21
View File
@@ -5,7 +5,28 @@
// clients with 'socks' for proxying.
package vless
import (
"bytes"
"net"
"reflect"
"github.com/xtls/xray-core/common/utils"
)
const (
None = "none"
XRV = "xtls-rprx-vision"
)
// Old TLS lib holds bytes.Buffer, but new TLS lib holds *bytes.Buffer
// Since Xray has 3 TLS libraries (std, utls, REALITY server)
// we detect the type of rawInput and return the appropriate pointer
func AccessTLSBuffers(conn net.Conn) (*bytes.Reader, **bytes.Buffer) {
input := utils.AccessField[bytes.Reader](conn, "input")
field := reflect.ValueOf(conn).Elem().FieldByName("rawInput")
if field.Kind() == reflect.Pointer {
return input, utils.AccessField[*bytes.Buffer](conn, "rawInput")
}
raw := utils.AccessField[bytes.Buffer](conn, "rawInput")
return input, &raw
}