vmess: set rand.Seed only 1 time in NewClient

This commit is contained in:
nadoo 2018-07-14 12:18:52 +08:00
parent 7a7b25f173
commit e0f746fa3d

View File

@ -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])