- 增加到期时间限制
 - 新增配置面板 https 访问后,http 自动跳转 https(同端口)
 - 降低获取系统连接数的 cpu 使用率
 - 优化界面
 - VMess 协议 alterId 默认改为 0
 - 修复旧版本 iOS 系统白屏问题
 - 修复重启面板后 xray 没有启动的问题
This commit is contained in:
sprov
2021-07-26 13:29:29 +08:00
parent f1057b1142
commit 292d5b89d4
22 changed files with 474 additions and 147 deletions

View File

@@ -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

View File

@@ -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)
}

View File

@@ -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()