fix logs in api

Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
This commit is contained in:
MHSanaei 2023-07-31 19:52:28 +03:30
parent dd3bbbc4af
commit c46ced0c4c

View file

@ -316,13 +316,9 @@ func (s *InboundService) UpdateInbound(inbound *model.Inbound) (*model.Inbound,
needRestart := false needRestart := false
s.xrayApi.Init(p.GetAPIPort()) s.xrayApi.Init(p.GetAPIPort())
err1 := s.xrayApi.DelInbound(tag) if s.xrayApi.DelInbound(tag) == nil {
if err1 != nil {
logger.Debug("Unable to delete old inbound by api:", err1)
needRestart = true
} else {
logger.Debug("Old inbound deleted by api:", tag) logger.Debug("Old inbound deleted by api:", tag)
}
if inbound.Enable { if inbound.Enable {
inboundJson, err2 := json.MarshalIndent(oldInbound.GenXrayInboundConfig(), "", " ") inboundJson, err2 := json.MarshalIndent(oldInbound.GenXrayInboundConfig(), "", " ")
if err2 != nil { if err2 != nil {
@ -338,7 +334,6 @@ func (s *InboundService) UpdateInbound(inbound *model.Inbound) (*model.Inbound,
} }
} }
} }
}
s.xrayApi.Close() s.xrayApi.Close()
db := database.GetDB() db := database.GetDB()
@ -662,7 +657,9 @@ func (s *InboundService) UpdateInboundClient(data *model.Inbound, clientId strin
needRestart := false needRestart := false
if len(oldEmail) > 0 { if len(oldEmail) > 0 {
s.xrayApi.Init(p.GetAPIPort()) s.xrayApi.Init(p.GetAPIPort())
s.xrayApi.RemoveUser(oldInbound.Tag, oldEmail) if s.xrayApi.RemoveUser(oldInbound.Tag, oldEmail) == nil {
logger.Debug("Old client deleted by api:", clients[0].Email)
}
if clients[0].Enable { if clients[0].Enable {
cipher := "" cipher := ""
if oldInbound.Protocol == "shadowsocks" { if oldInbound.Protocol == "shadowsocks" {
@ -681,8 +678,6 @@ func (s *InboundService) UpdateInboundClient(data *model.Inbound, clientId strin
logger.Debug("Error in adding client by api:", err1) logger.Debug("Error in adding client by api:", err1)
needRestart = true needRestart = true
} }
} else {
logger.Debug("Client disabled by api:", clients[0].Email)
} }
s.xrayApi.Close() s.xrayApi.Close()
} else { } else {