diff options
Diffstat (limited to 'web/service/xray.go')
| -rw-r--r-- | web/service/xray.go | 13 |
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 { |
