1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-25 17:05:23 +00:00

fix a bug in cmdkey generation

This commit is contained in:
Darien Raymond 2016-01-20 16:45:50 +00:00
parent baaef1dad5
commit 23b6b987ca
3 changed files with 28 additions and 1 deletions

View File

@ -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
}

View File

@ -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
View 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()
}