From c90affe7dbed973af3e789881d246e3ab9506d8e Mon Sep 17 00:00:00 2001 From: yu <1758031883@qq.com> Date: Mon, 9 Sep 2024 23:44:22 +0800 Subject: [PATCH] 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 --- proxy/vmess/validator.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/proxy/vmess/validator.go b/proxy/vmess/validator.go index 00e49ae2..43ced006 100644 --- a/proxy/vmess/validator.go +++ b/proxy/vmess/validator.go @@ -39,7 +39,10 @@ func (v *TimedUserValidator) Add(u *protocol.MemoryUser) error { 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 { hashkdf := hmac.New(sha256.New, []byte("VMESSBSKDF")) hashkdf.Write(account.ID.Bytes())