fix a bug in cmdkey generation

pull/73/head
Darien Raymond 9 years ago
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
}

@ -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…
Cancel
Save