mirror of
https://github.com/v2fly/v2ray-core
synced 2024-02-27 03:18:06 +00:00
function to compare byte array
This commit is contained in:
@@ -56,7 +56,7 @@ func NewID(uuid uuid.UUID) *ID {
|
||||
return id
|
||||
}
|
||||
|
||||
func nextId(u *uuid.UUID) uuid.UUID {
|
||||
func nextID(u *uuid.UUID) uuid.UUID {
|
||||
md5hash := md5.New()
|
||||
common.Must2(md5hash.Write(u.Bytes()))
|
||||
common.Must2(md5hash.Write([]byte("16167dc8-16b6-4e6d-b8bb-65dd68113a81")))
|
||||
@@ -74,8 +74,7 @@ func NewAlterIDs(primary *ID, alterIDCount uint16) []*ID {
|
||||
alterIDs := make([]*ID, alterIDCount)
|
||||
prevID := primary.UUID()
|
||||
for idx := range alterIDs {
|
||||
newid := nextId(&prevID)
|
||||
// TODO: check duplicates
|
||||
newid := nextID(&prevID)
|
||||
alterIDs[idx] = NewID(newid)
|
||||
prevID = newid
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package protocol_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"v2ray.com/core/common/predicate"
|
||||
"v2ray.com/core/common/compare"
|
||||
. "v2ray.com/core/common/protocol"
|
||||
"v2ray.com/core/common/uuid"
|
||||
. "v2ray.com/ext/assert"
|
||||
@@ -13,7 +13,7 @@ func TestCmdKey(t *testing.T) {
|
||||
assert := With(t)
|
||||
|
||||
id := NewID(uuid.New())
|
||||
assert(predicate.BytesAll(id.CmdKey(), 0), IsFalse)
|
||||
assert(compare.BytesAll(id.CmdKey(), 0), IsFalse)
|
||||
}
|
||||
|
||||
func TestIdEquals(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user