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
diff options
context:
space:
mode:
authormhsanaei <ho3ein.sanaei@gmail.com>2024-07-09 00:08:00 +0300
committermhsanaei <ho3ein.sanaei@gmail.com>2024-07-09 00:47:49 +0300
commitf1500a5d313aac35121981046327396d237a4946 (patch)
tree04cecd968ccac48aa12a8769c28d62a0bc2672ff /web/service/xray.go
parentc9a218d0604876dbbd5adf076750b3fb8fa3811c (diff)
improved - message logs
Diffstat (limited to 'web/service/xray.go')
-rw-r--r--web/service/xray.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/web/service/xray.go b/web/service/xray.go
index 6074216d..d37c963a 100644
--- a/web/service/xray.go
+++ b/web/service/xray.go
@@ -97,7 +97,7 @@ func (s *XrayService) GetXrayConfig() (*xray.Config, error) {
if !clientTraffic.Enable {
clients = RemoveIndex(clients, index-indexDecrease)
indexDecrease++
- logger.Info("Remove Inbound User ", c["email"], " due the expire or traffic limit")
+ logger.Infof("Remove Inbound User %s due to expiration or traffic limit", c["email"])
}
}
}
@@ -165,11 +165,20 @@ func (s *XrayService) GetXrayConfig() (*xray.Config, error) {
func (s *XrayService) GetXrayTraffic() ([]*xray.Traffic, []*xray.ClientTraffic, error) {
if !s.IsXrayRunning() {
- return nil, nil, errors.New("xray is not running")
+ err := errors.New("xray is not running")
+ logger.Debug("Attempted to fetch Xray traffic, but Xray is not running:", err)
+ return nil, nil, err
}
- s.xrayAPI.Init(p.GetAPIPort())
+ apiPort := p.GetAPIPort()
+ s.xrayAPI.Init(apiPort)
defer s.xrayAPI.Close()
- return s.xrayAPI.GetTraffic(true)
+
+ traffic, clientTraffic, err := s.xrayAPI.GetTraffic(true)
+ if err != nil {
+ logger.Debug("Failed to fetch Xray traffic:", err)
+ return nil, nil, err
+ }
+ return traffic, clientTraffic, nil
}
func (s *XrayService) RestartXray(isForce bool) error {
@@ -202,7 +211,7 @@ func (s *XrayService) RestartXray(isForce bool) error {
func (s *XrayService) StopXray() error {
lock.Lock()
defer lock.Unlock()
- logger.Debug("stop xray")
+ logger.Debug("Attempting to stop Xray...")
if s.IsXrayRunning() {
return p.Stop()
}