From bcb11ad45f4cbb8122b100a673feaf232260c75d 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, 11 Jul 2025 14:14:00 +0000 Subject: [PATCH] Refine unsafe usage --- main/commands/all/tls/ping.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/main/commands/all/tls/ping.go b/main/commands/all/tls/ping.go index 4c652e46..f4be3fba 100644 --- a/main/commands/all/tls/ping.go +++ b/main/commands/all/tls/ping.go @@ -129,10 +129,9 @@ func printTLSConnDetail(tlsConn *gotls.Conn) { tlsVersion = "TLS 1.2" } fmt.Println("TLS Version:", tlsVersion) - p, _ := reflect.TypeOf(tlsConn).Elem().FieldByName("curveID") - curveID := (*gotls.CurveID)(unsafe.Pointer(uintptr(unsafe.Pointer(tlsConn)) + p.Offset)) - if curveID != nil { - PostQuantum := (*curveID == gotls.X25519MLKEM768) + curveID := *(*gotls.CurveID)(unsafe.Pointer(reflect.ValueOf(tlsConn).Elem().FieldByName("curveID").UnsafeAddr())) + if curveID != 0 { + PostQuantum := (curveID == gotls.X25519MLKEM768) fmt.Println("Post-Quantum key exchange:", PostQuantum, "("+curveID.String()+")") } else { fmt.Println("Post-Quantum key exchange: false (RSA Exchange)")