Skip to content

Conversation

@xtlsee
Copy link
Contributor

@xtlsee xtlsee commented Dec 15, 2025

No description provided.

@RPRX
Copy link
Member

RPRX commented Dec 16, 2025

// ParseBytes converts a UUID in byte form to object.
func ParseBytes(b []byte) (UUID, error) {
var uuid UUID
if len(b) != 16 {
return uuid, errors.New("invalid UUID: ", b)
}
copy(uuid[:], b)
return uuid, nil
}

这个 16 字节转成 UUID 不会出错,ParseBytes() 只检查了 length

@RPRX
Copy link
Member

RPRX commented Dec 16, 2025

直接包上 common.Must2() 吧

@xtlsee
Copy link
Contributor Author

xtlsee commented Dec 16, 2025

如果不报错,是否可以考虑这样写:

		if request.User = validator.Get(id); request.User == nil {
			u := uuid.UUID(id)
			return nil, nil, nil, isfb, errors.New(fmt.Sprintf("invalid request user id: %s", u.String()))
		}

@Fangliding
Copy link
Member

本来就该这样 ParseBytes还多转道切片

@xtlsee
Copy link
Contributor Author

xtlsee commented Dec 16, 2025

@RPRX
Copy link
Member

RPRX commented Dec 16, 2025

好久没写这块都忘了,那直接 uuid.UUID(id).String() 就行了

@xtlsee
Copy link
Contributor Author

xtlsee commented Dec 17, 2025

uuid.UUID(id).String()

会报错:

Cannot call a pointer method on 'uuid.UUID(id)'

@RPRX RPRX changed the title Improve user_id validation and error messaging VLESS inbound: Print invalid UUID string Dec 23, 2025
@RPRX RPRX merged commit dd757ca into XTLS:main Dec 23, 2025
@RPRX
Copy link
Member

RPRX commented Dec 23, 2025

操作太快发现那个 %s 忘删了,等之后的 commit 顺便删一下吧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants