From 629d0da33c3f70d6bb2d3fd4a0adee95576bd4be Mon Sep 17 00:00:00 2001 From: Alireza Ahmadi Date: Sun, 10 Mar 2024 16:02:31 +0100 Subject: [PATCH] avoid empty client id #1072 --- web/service/inbound.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/web/service/inbound.go b/web/service/inbound.go index c9e27051..2e55609f 100644 --- a/web/service/inbound.go +++ b/web/service/inbound.go @@ -553,15 +553,19 @@ func (s *InboundService) UpdateInboundClient(data *model.Inbound, clientId strin } oldEmail := "" + newClientId := "" clientIndex := 0 for index, oldClient := range oldClients { oldClientId := "" if oldInbound.Protocol == "trojan" { oldClientId = oldClient.Password + newClientId = clients[0].Password } else if oldInbound.Protocol == "shadowsocks" { oldClientId = oldClient.Email + newClientId = clients[0].Email } else { oldClientId = oldClient.ID + newClientId = clients[0].ID } if clientId == oldClientId { oldEmail = oldClient.Email @@ -570,6 +574,11 @@ func (s *InboundService) UpdateInboundClient(data *model.Inbound, clientId strin } } + // Validate new client ID + if newClientId == "" { + return false, common.NewError("empty client ID") + } + if len(clients[0].Email) > 0 && clients[0].Email != oldEmail { existEmail, err := s.checkEmailsExistForClients(clients) if err != nil {