Fix: RPC call causes xray panic problem using wrong account type (#3744)

* fix:RPC call causes xray panic problem. Problem details: add a VMess protocol user in an inbound proxy. If inTag: "VMess-xxx", but the developer carelessly calls the add user method of vless or other protocols, such as xrayCtl.AddVlessUser(user), causing xray panic

* fix:use xray log system return error

---------

Co-authored-by: chengtao@snqu.com <chengtao@snqu.com>
This commit is contained in:
yu 2024-09-09 23:44:22 +08:00 committed by GitHub
parent 3d0feae462
commit c90affe7db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -39,7 +39,10 @@ func (v *TimedUserValidator) Add(u *protocol.MemoryUser) error {
v.users = append(v.users, u) v.users = append(v.users, u)
account := u.Account.(*MemoryAccount) account, ok := u.Account.(*MemoryAccount)
if !ok {
return errors.New("account type is incorrect")
}
if !v.behaviorFused { if !v.behaviorFused {
hashkdf := hmac.New(sha256.New, []byte("VMESSBSKDF")) hashkdf := hmac.New(sha256.New, []byte("VMESSBSKDF"))
hashkdf.Write(account.ID.Bytes()) hashkdf.Write(account.ID.Bytes())