Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorMHSanaei <ho3ein.sanaei@gmail.com>2024-03-11 11:22:28 +0300
committerMHSanaei <ho3ein.sanaei@gmail.com>2024-03-11 11:22:28 +0300
commit5f3c2f781e3f782d43967859d01a16b23bef73df (patch)
tree4c0d7551ae64862628b821a38465d2f40224d01f /web
parent6c73791cab6d430e1c061c8c515280c01d2fe95d (diff)
avoid empty client id
Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
Diffstat (limited to 'web')
-rw-r--r--web/service/inbound.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/web/service/inbound.go b/web/service/inbound.go
index d71057b1..fdafe05a 100644
--- a/web/service/inbound.go
+++ b/web/service/inbound.go
@@ -573,15 +573,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
@@ -590,6 +594,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 {
@@ -682,7 +691,7 @@ func (s *InboundService) UpdateInboundClient(data *model.Inbound, clientId strin
return needRestart, tx.Save(oldInbound).Error
}
-func (s *InboundService) AddTraffic(traffics []*xray.Traffic, clientTraffics []*xray.ClientTraffic) (error, bool) {
+func (s *InboundService) AddTraffic(inboundTraffics []*xray.Traffic, clientTraffics []*xray.ClientTraffic) (error, bool) {
var err error
db := database.GetDB()
tx := db.Begin()
@@ -694,7 +703,7 @@ func (s *InboundService) AddTraffic(traffics []*xray.Traffic, clientTraffics []*
tx.Commit()
}
}()
- err = s.addInboundTraffic(tx, traffics)
+ err = s.addInboundTraffic(tx, inboundTraffics)
if err != nil {
return err, false
}