From 6cc59a9b2d06513cb2fc25d88d657e24fe39e2ea Mon Sep 17 00:00:00 2001 From: hossinasaadi Date: Sat, 23 Dec 2023 11:38:43 +0400 Subject: [PATCH] fix ecdh crash in reality --- transport/internet/reality/reality.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/transport/internet/reality/reality.go b/transport/internet/reality/reality.go index de8a6ac60179..75a668c90913 100644 --- a/transport/internet/reality/reality.go +++ b/transport/internet/reality/reality.go @@ -136,7 +136,10 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati if config.Show { newError(fmt.Sprintf("REALITY localAddr: %v\thello.SessionId[:16]: %v\n", localAddr, hello.SessionId[:16])).WriteToLog(session.ExportIDToError(ctx)) } - publicKey, _ := ecdh.X25519().NewPublicKey(config.PublicKey) + publicKey, err := ecdh.X25519().NewPublicKey(config.PublicKey) + if err != nil { + return nil, errors.New("REALITY: publicKey == nil") + } uConn.AuthKey, _ = uConn.HandshakeState.State13.EcdheKey.ECDH(publicKey) if uConn.AuthKey == nil { return nil, errors.New("REALITY: SharedKey == nil")