Skip to content

Commit 88ebc6b

Browse files
dyhkwongnekohasekai
authored andcommitted
Fix UUID of all zeros
1 parent 253ca98 commit 88ebc6b

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ type Client struct {
3434
}
3535

3636
func NewClient(userId string, security string, alterId int, options ...ClientOption) (*Client, error) {
37-
user := uuid.FromStringOrNil(userId)
38-
if user == uuid.Nil {
39-
user = uuid.NewV5(user, userId)
37+
user, err := uuid.FromString(userId)
38+
if err != nil {
39+
user = uuid.NewV5(uuid.Nil, userId)
4040
}
4141

4242
var rawSecurity byte

service.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ func (s *Service[U]) UpdateUsers(userList []U, userIdList []string, alterIdList
8181
userAlterIds := make(map[U][][16]byte)
8282
for i, user := range userList {
8383
userId := userIdList[i]
84-
userUUID := uuid.FromStringOrNil(userId)
85-
if userUUID == uuid.Nil {
86-
userUUID = uuid.NewV5(userUUID, userId)
84+
userUUID, err := uuid.FromString(userId)
85+
if err != nil {
86+
userUUID = uuid.NewV5(uuid.Nil, userId)
8787
}
8888
userCmdKey := Key(userUUID)
8989
userKeyMap[user] = userCmdKey

vless/client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ type Client struct {
2525
}
2626

2727
func NewClient(userId string, flow string, logger logger.Logger) (*Client, error) {
28-
user := uuid.FromStringOrNil(userId)
29-
if user == uuid.Nil {
30-
user = uuid.NewV5(user, userId)
28+
user, err := uuid.FromString(userId)
29+
if err != nil {
30+
user = uuid.NewV5(uuid.Nil, userId)
3131
}
3232
switch flow {
3333
case "", "xtls-rprx-vision":

vless/service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ func (s *Service[T]) UpdateUsers(userList []T, userUUIDList []string, userFlowLi
4141
userMap := make(map[[16]byte]T)
4242
userFlowMap := make(map[T]string)
4343
for i, userName := range userList {
44-
userID := uuid.FromStringOrNil(userUUIDList[i])
45-
if userID == uuid.Nil {
44+
userID, err := uuid.FromString(userUUIDList[i])
45+
if err != nil {
4646
userID = uuid.NewV5(uuid.Nil, userUUIDList[i])
4747
}
4848
userMap[userID] = userName

0 commit comments

Comments
 (0)