mirror of
https://github.com/alireza0/x-ui.git
synced 2026-03-21 08:15:48 +00:00
0.3.0
- 增加到期时间限制 - 新增配置面板 https 访问后,http 自动跳转 https(同端口) - 降低获取系统连接数的 cpu 使用率 - 优化界面 - VMess 协议 alterId 默认改为 0 - 修复旧版本 iOS 系统白屏问题 - 修复重启面板后 xray 没有启动的问题
This commit is contained in:
@@ -3,6 +3,7 @@ package service
|
||||
import (
|
||||
"fmt"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
"x-ui/database"
|
||||
"x-ui/database/model"
|
||||
"x-ui/util/common"
|
||||
@@ -166,8 +167,9 @@ func (s *InboundService) AddTraffic(traffics []*xray.Traffic) (err error) {
|
||||
|
||||
func (s *InboundService) DisableInvalidInbounds() (int64, error) {
|
||||
db := database.GetDB()
|
||||
now := time.Now()
|
||||
result := db.Model(model.Inbound{}).
|
||||
Where("up + down >= total and total > 0 and enable = ?", true).
|
||||
Where("((total > 0 and up + down >= total) or (expiry_time > 0 and expiry_time <= ?)) and enable = ?", now, true).
|
||||
Update("enable", false)
|
||||
err := result.Error
|
||||
count := result.RowsAffected
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
"runtime"
|
||||
"time"
|
||||
"x-ui/logger"
|
||||
"x-ui/util/sys"
|
||||
"x-ui/xray"
|
||||
)
|
||||
|
||||
@@ -142,18 +143,14 @@ func (s *ServerService) GetStatus(lastStatus *Status) *Status {
|
||||
logger.Warning("can not find io counters")
|
||||
}
|
||||
|
||||
tcpConnStats, err := net.Connections("tcp")
|
||||
status.TcpCount, err = sys.GetTCPCount()
|
||||
if err != nil {
|
||||
logger.Warning("get connections failed:", err)
|
||||
} else {
|
||||
status.TcpCount = len(tcpConnStats)
|
||||
logger.Warning("get tcp connections failed:", err)
|
||||
}
|
||||
|
||||
udpConnStats, err := net.Connections("udp")
|
||||
status.UdpCount, err = sys.GetUDPCount()
|
||||
if err != nil {
|
||||
logger.Warning("get connections failed:", err)
|
||||
} else {
|
||||
status.UdpCount = len(udpConnStats)
|
||||
logger.Warning("get udp connections failed:", err)
|
||||
}
|
||||
|
||||
if s.xrayService.IsXrayRunning() {
|
||||
@@ -265,7 +262,7 @@ func (s *ServerService) UpdateXray(version string) error {
|
||||
|
||||
s.xrayService.StopXray()
|
||||
defer func() {
|
||||
err := s.xrayService.RestartXray()
|
||||
err := s.xrayService.RestartXray(true)
|
||||
if err != nil {
|
||||
logger.Error("start xray failed:", err)
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ func (s *XrayService) GetXrayTraffic() ([]*xray.Traffic, error) {
|
||||
return p.GetTraffic(true)
|
||||
}
|
||||
|
||||
func (s *XrayService) RestartXray() error {
|
||||
func (s *XrayService) RestartXray(isForce bool) error {
|
||||
lock.Lock()
|
||||
defer lock.Unlock()
|
||||
logger.Debug("restart xray")
|
||||
@@ -94,8 +94,9 @@ func (s *XrayService) RestartXray() error {
|
||||
return err
|
||||
}
|
||||
|
||||
if p != nil {
|
||||
if p.GetConfig().Equals(xrayConfig) {
|
||||
if p != nil && p.IsRunning() {
|
||||
if !isForce && p.GetConfig().Equals(xrayConfig) {
|
||||
logger.Debug("not need to restart xray")
|
||||
return nil
|
||||
}
|
||||
p.Stop()
|
||||
|
||||
Reference in New Issue
Block a user