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>2023-06-05 00:02:19 +0300
committerMHSanaei <ho3ein.sanaei@gmail.com>2023-06-05 00:02:19 +0300
commit70f250dfe1e24249a4cc8102e3fef65959dfb15a (patch)
tree9fdc990d656267abf6facafd851ab7b4835be977 /web/service/xray.go
parent1030bcf321f15ada665ca3c55436d7c2449b5faf (diff)
[feature] using xray api and more
Improve DB performance [api] backward compatibility: add client by update Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
Diffstat (limited to 'web/service/xray.go')
-rw-r--r--web/service/xray.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/web/service/xray.go b/web/service/xray.go
index bcc886fe..5475891f 100644
--- a/web/service/xray.go
+++ b/web/service/xray.go
@@ -18,6 +18,7 @@ var result string
type XrayService struct {
inboundService InboundService
settingService SettingService
+ xrayAPI xray.XrayAPI
}
func (s *XrayService) IsXrayRunning() bool {
@@ -143,7 +144,9 @@ func (s *XrayService) GetXrayTraffic() ([]*xray.Traffic, []*xray.ClientTraffic,
if !s.IsXrayRunning() {
return nil, nil, errors.New("xray is not running")
}
- return p.GetTraffic(true)
+ s.xrayAPI.Init(p.GetAPIPort())
+ defer s.xrayAPI.Close()
+ return s.xrayAPI.GetTraffic(true)
}
func (s *XrayService) RestartXray(isForce bool) error {
@@ -158,7 +161,7 @@ func (s *XrayService) RestartXray(isForce bool) error {
if p != nil && p.IsRunning() {
if !isForce && p.GetConfig().Equals(xrayConfig) {
- logger.Debug("not need to restart xray")
+ logger.Debug("It does not need to restart xray")
return nil
}
p.Stop()
@@ -166,7 +169,11 @@ func (s *XrayService) RestartXray(isForce bool) error {
p = xray.NewProcess(xrayConfig)
result = ""
- return p.Start()
+ err = p.Start()
+ if err != nil {
+ return err
+ }
+ return nil
}
func (s *XrayService) StopXray() error {