mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-10-20 00:04:26 +00:00
XTLS Vision: Compatible with Go 1.27.3+ (#7176)
https://github.com/XTLS/Xray-core/pull/7176#issuecomment-6229087350 Fixes https://github.com/XTLS/Xray-core/issues/7162#issuecomment-6210430747 --------- Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user