From e0f746fa3ded1a4d8ba12eb4d88fe00d65a0a2b7 Mon Sep 17 00:00:00 2001 From: nadoo <287492+nadoo@users.noreply.github.com> Date: Sat, 14 Jul 2018 12:18:52 +0800 Subject: [PATCH] vmess: set rand.Seed only 1 time in NewClient --- proxy/vmess/client.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/proxy/vmess/client.go b/proxy/vmess/client.go index dcbcda8..9815fac 100644 --- a/proxy/vmess/client.go +++ b/proxy/vmess/client.go @@ -99,6 +99,9 @@ func NewClient(uuidStr, security string, alterID int) (*Client, error) { return nil, errors.New("unknown security type: " + security) } + // NOTE: give rand a new seed to avoid the same sequence of values + rand.Seed(time.Now().UnixNano()) + return c, nil } @@ -114,7 +117,6 @@ func (c *Client) NewConn(rc net.Conn, target string) (*Conn, error) { } randBytes := make([]byte, 33) - rand.Seed(time.Now().UnixNano()) rand.Read(randBytes) copy(conn.reqBodyIV[:], randBytes[:16])