VMess: Returns clearer error in AuthIDDecoderHolder (#5090)

pull/5102/merge
风扇滑翔翼 2025-09-08 22:19:17 +08:00 committed by GitHub
parent 2b82366148
commit a0c63ba1cf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 4 deletions

View File

@ -17,8 +17,10 @@ import (
)
var (
ErrNotFound = errors.New("user do not exist")
ErrReplay = errors.New("replayed request")
ErrNotFound = errors.New("user do not exist")
ErrNeagtiveTime = errors.New("timestamp is negative")
ErrInvalidTime = errors.New("invalid timestamp, perhaps unsynchronized time")
ErrReplay = errors.New("replayed request")
)
func CreateAuthID(cmdKey []byte, time int64) [16]byte {
@ -102,11 +104,11 @@ func (a *AuthIDDecoderHolder) Match(authID [16]byte) (interface{}, error) {
}
if t < 0 {
continue
return nil, ErrNeagtiveTime
}
if math.Abs(math.Abs(float64(t))-float64(time.Now().Unix())) > 120 {
continue
return nil, ErrInvalidTime
}
if !a.filter.Check(authID[:]) {