mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-02 23:47:07 -05:00
fix a bug in cmdkey generation
This commit is contained in:
parent
baaef1dad5
commit
23b6b987ca
@ -25,3 +25,12 @@ func (this BytesLiteral) Int64Value() int64 {
|
||||
func (this BytesLiteral) String() string {
|
||||
return string(this.Value())
|
||||
}
|
||||
|
||||
func (this BytesLiteral) AllZero() bool {
|
||||
for _, b := range this {
|
||||
if b != 0 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
@ -46,6 +46,6 @@ func NewID(uuid *uuid.UUID) *ID {
|
||||
md5hash := md5.New()
|
||||
md5hash.Write(uuid.Bytes())
|
||||
md5hash.Write([]byte("c48619fe-8f02-49e0-b9e9-edf763e17e21"))
|
||||
md5.Sum(id.cmdKey[:0])
|
||||
md5hash.Sum(id.cmdKey[:0])
|
||||
return id
|
||||
}
|
||||
|
18
proxy/vmess/id_test.go
Normal file
18
proxy/vmess/id_test.go
Normal file
@ -0,0 +1,18 @@
|
||||
package vmess_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/v2ray/v2ray-core/common/uuid"
|
||||
"github.com/v2ray/v2ray-core/common/serial"
|
||||
. "github.com/v2ray/v2ray-core/proxy/vmess"
|
||||
v2testing "github.com/v2ray/v2ray-core/testing"
|
||||
"github.com/v2ray/v2ray-core/testing/assert"
|
||||
)
|
||||
|
||||
func TestCmdKey(t *testing.T) {
|
||||
v2testing.Current(t)
|
||||
|
||||
id := NewID(uuid.New())
|
||||
assert.Bool(serial.BytesLiteral(id.CmdKey()).AllZero()).IsFalse()
|
||||
}
|
Loading…
Reference in New Issue
Block a user