mirror of
https://github.com/alireza0/x-ui.git
synced 2026-03-19 23:35:48 +00:00
0.1.0
- 改进 ui 界面 - 修复流量超出后账号不自动失效问题 - 修复vless生成的链接不正确问题 - 修复网页端重启面板功能问题
This commit is contained in:
@@ -102,12 +102,12 @@ func (s *InboundService) AddTraffic(traffics []*xray.Traffic) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (s *InboundService) DisableInvalidInbounds() (bool, error) {
|
||||
func (s *InboundService) DisableInvalidInbounds() (int64, error) {
|
||||
db := database.GetDB()
|
||||
result := db.Model(model.Inbound{}).
|
||||
Where("up + down >= total and total > 0 and enable = ?", true).
|
||||
Update("enable", false)
|
||||
err := result.Error
|
||||
count := result.RowsAffected
|
||||
return count > 0, err
|
||||
return count, err
|
||||
}
|
||||
|
||||
@@ -5,18 +5,18 @@ import (
|
||||
"errors"
|
||||
"go.uber.org/atomic"
|
||||
"sync"
|
||||
"x-ui/logger"
|
||||
"x-ui/xray"
|
||||
)
|
||||
|
||||
var p *xray.Process
|
||||
var lock sync.Mutex
|
||||
var isNeedXrayRestart atomic.Bool
|
||||
var result string
|
||||
|
||||
type XrayService struct {
|
||||
inboundService InboundService
|
||||
settingService SettingService
|
||||
|
||||
isNeedXrayRestart atomic.Bool
|
||||
}
|
||||
|
||||
func (s *XrayService) IsXrayRunning() bool {
|
||||
@@ -87,6 +87,7 @@ func (s *XrayService) GetXrayTraffic() ([]*xray.Traffic, error) {
|
||||
func (s *XrayService) RestartXray() error {
|
||||
lock.Lock()
|
||||
defer lock.Unlock()
|
||||
logger.Debug("restart xray")
|
||||
|
||||
xrayConfig, err := s.GetXrayConfig()
|
||||
if err != nil {
|
||||
@@ -108,16 +109,17 @@ func (s *XrayService) RestartXray() error {
|
||||
func (s *XrayService) StopXray() error {
|
||||
lock.Lock()
|
||||
defer lock.Unlock()
|
||||
logger.Debug("stop xray")
|
||||
if s.IsXrayRunning() {
|
||||
return p.Stop()
|
||||
}
|
||||
return errors.New("xray is not running")
|
||||
}
|
||||
|
||||
func (s *XrayService) SetIsNeedRestart(needRestart bool) {
|
||||
s.isNeedXrayRestart.Store(needRestart)
|
||||
func (s *XrayService) SetToNeedRestart() {
|
||||
isNeedXrayRestart.Store(true)
|
||||
}
|
||||
|
||||
func (s *XrayService) IsNeedRestart() bool {
|
||||
return s.isNeedXrayRestart.Load()
|
||||
func (s *XrayService) IsNeedRestartAndSetFalse() bool {
|
||||
return isNeedXrayRestart.CAS(true, false)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user