From 5a8e9c25a44c97fe23374b079c650be2b6bdb257 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: Fri, 15 Aug 2025 22:50:35 +0800 Subject: [PATCH] Chore: Migrate to Go 1.25 (#5024) * Try to update to go1.25 * Remove unsafe usage --- go.mod | 2 +- main/commands/all/tls/ping.go | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 6408d162..55f21962 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/xtls/xray-core -go 1.24 +go 1.25 require ( github.com/cloudflare/circl v1.6.1 diff --git a/main/commands/all/tls/ping.go b/main/commands/all/tls/ping.go index d289bc65..1e085094 100644 --- a/main/commands/all/tls/ping.go +++ b/main/commands/all/tls/ping.go @@ -6,9 +6,7 @@ import ( "encoding/base64" "fmt" "net" - "reflect" "strconv" - "unsafe" "github.com/xtls/xray-core/main/commands/base" . "github.com/xtls/xray-core/transport/internet/tls" @@ -139,14 +137,15 @@ func printCertificates(certs []*x509.Certificate) { } func printTLSConnDetail(tlsConn *gotls.Conn) { + connectionState := tlsConn.ConnectionState() var tlsVersion string - if tlsConn.ConnectionState().Version == gotls.VersionTLS13 { + if connectionState.Version == gotls.VersionTLS13 { tlsVersion = "TLS 1.3" - } else if tlsConn.ConnectionState().Version == gotls.VersionTLS12 { + } else if connectionState.Version == gotls.VersionTLS12 { tlsVersion = "TLS 1.2" } fmt.Println("TLS Version: ", tlsVersion) - curveID := *(*gotls.CurveID)(unsafe.Pointer(reflect.ValueOf(tlsConn).Elem().FieldByName("curveID").UnsafeAddr())) + curveID := connectionState.CurveID if curveID != 0 { PostQuantum := (curveID == gotls.X25519MLKEM768) fmt.Println("TLS Post-Quantum key exchange: ", PostQuantum, "("+curveID.String()+")")