mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-10-27 02:24:40 +00:00
Compare commits
10 commits
0510c6d7b2
...
135f843b3e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
135f843b3e | ||
|
|
bc274d1e1f | ||
|
|
dc21f41932 | ||
|
|
f137b1af76 | ||
|
|
c4871ef8fe | ||
|
|
ecfffa882a | ||
|
|
3af5026abe | ||
|
|
1de7accd7c | ||
|
|
76afff2a6f | ||
|
|
9623e87511 |
39 changed files with 2373 additions and 1214 deletions
|
|
@ -34,8 +34,10 @@ type Inbound struct {
|
||||||
Total int64 `json:"total" form:"total"`
|
Total int64 `json:"total" form:"total"`
|
||||||
AllTime int64 `json:"allTime" form:"allTime" gorm:"default:0"`
|
AllTime int64 `json:"allTime" form:"allTime" gorm:"default:0"`
|
||||||
Remark string `json:"remark" form:"remark"`
|
Remark string `json:"remark" form:"remark"`
|
||||||
Enable bool `json:"enable" form:"enable"`
|
Enable bool `json:"enable" form:"enable" gorm:"index:idx_enable_traffic_reset,priority:1"`
|
||||||
ExpiryTime int64 `json:"expiryTime" form:"expiryTime"`
|
ExpiryTime int64 `json:"expiryTime" form:"expiryTime"`
|
||||||
|
TrafficReset string `json:"trafficReset" form:"trafficReset" gorm:"default:never;index:idx_enable_traffic_reset,priority:2"`
|
||||||
|
LastTrafficResetTime int64 `json:"lastTrafficResetTime" form:"lastTrafficResetTime" gorm:"default:0"`
|
||||||
ClientStats []xray.ClientTraffic `gorm:"foreignKey:InboundId;references:Id" json:"clientStats" form:"clientStats"`
|
ClientStats []xray.ClientTraffic `gorm:"foreignKey:InboundId;references:Id" json:"clientStats" form:"clientStats"`
|
||||||
|
|
||||||
// config part
|
// config part
|
||||||
|
|
|
||||||
2
go.mod
2
go.mod
|
|
@ -21,6 +21,7 @@ require (
|
||||||
github.com/xtls/xray-core v1.250911.0
|
github.com/xtls/xray-core v1.250911.0
|
||||||
go.uber.org/atomic v1.11.0
|
go.uber.org/atomic v1.11.0
|
||||||
golang.org/x/crypto v0.42.0
|
golang.org/x/crypto v0.42.0
|
||||||
|
golang.org/x/sys v0.36.0
|
||||||
golang.org/x/text v0.29.0
|
golang.org/x/text v0.29.0
|
||||||
google.golang.org/grpc v1.75.1
|
google.golang.org/grpc v1.75.1
|
||||||
gorm.io/driver/sqlite v1.6.0
|
gorm.io/driver/sqlite v1.6.0
|
||||||
|
|
@ -89,7 +90,6 @@ require (
|
||||||
golang.org/x/mod v0.28.0 // indirect
|
golang.org/x/mod v0.28.0 // indirect
|
||||||
golang.org/x/net v0.44.0 // indirect
|
golang.org/x/net v0.44.0 // indirect
|
||||||
golang.org/x/sync v0.17.0 // indirect
|
golang.org/x/sync v0.17.0 // indirect
|
||||||
golang.org/x/sys v0.36.0 // indirect
|
|
||||||
golang.org/x/time v0.13.0 // indirect
|
golang.org/x/time v0.13.0 // indirect
|
||||||
golang.org/x/tools v0.36.0 // indirect
|
golang.org/x/tools v0.36.0 // indirect
|
||||||
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect
|
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect
|
||||||
|
|
|
||||||
29
sub/sub.go
29
sub/sub.go
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"x-ui/logger"
|
"x-ui/logger"
|
||||||
"x-ui/util/common"
|
"x-ui/util/common"
|
||||||
|
|
@ -74,11 +75,6 @@ func (s *Server) initRouter() (*gin.Engine, error) {
|
||||||
engine.Use(middleware.DomainValidatorMiddleware(subDomain))
|
engine.Use(middleware.DomainValidatorMiddleware(subDomain))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Provide base_path in context for templates
|
|
||||||
engine.Use(func(c *gin.Context) {
|
|
||||||
c.Set("base_path", "/")
|
|
||||||
})
|
|
||||||
|
|
||||||
LinksPath, err := s.settingService.GetSubPath()
|
LinksPath, err := s.settingService.GetSubPath()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -89,6 +85,11 @@ func (s *Server) initRouter() (*gin.Engine, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set base_path based on LinksPath for template rendering
|
||||||
|
engine.Use(func(c *gin.Context) {
|
||||||
|
c.Set("base_path", LinksPath)
|
||||||
|
})
|
||||||
|
|
||||||
Encrypt, err := s.settingService.GetSubEncrypt()
|
Encrypt, err := s.settingService.GetSubEncrypt()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -154,11 +155,29 @@ func (s *Server) initRouter() (*gin.Engine, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assets: use disk if present, fallback to embedded
|
// Assets: use disk if present, fallback to embedded
|
||||||
|
// Serve under both root (/assets) and under the subscription path prefix (LinksPath + "assets")
|
||||||
|
// so reverse proxies with a URI prefix can load assets correctly.
|
||||||
|
// Determine LinksPath earlier to compute prefixed assets mount.
|
||||||
|
// Note: LinksPath always starts and ends with "/" (validated in settings).
|
||||||
|
var linksPathForAssets string
|
||||||
|
if LinksPath == "/" {
|
||||||
|
linksPathForAssets = "/assets"
|
||||||
|
} else {
|
||||||
|
// ensure single slash join
|
||||||
|
linksPathForAssets = strings.TrimRight(LinksPath, "/") + "/assets"
|
||||||
|
}
|
||||||
|
|
||||||
if _, err := os.Stat("web/assets"); err == nil {
|
if _, err := os.Stat("web/assets"); err == nil {
|
||||||
engine.StaticFS("/assets", http.FS(os.DirFS("web/assets")))
|
engine.StaticFS("/assets", http.FS(os.DirFS("web/assets")))
|
||||||
|
if linksPathForAssets != "/assets" {
|
||||||
|
engine.StaticFS(linksPathForAssets, http.FS(os.DirFS("web/assets")))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if subFS, err := fs.Sub(webpkg.EmbeddedAssets(), "assets"); err == nil {
|
if subFS, err := fs.Sub(webpkg.EmbeddedAssets(), "assets"); err == nil {
|
||||||
engine.StaticFS("/assets", http.FS(subFS))
|
engine.StaticFS("/assets", http.FS(subFS))
|
||||||
|
if linksPathForAssets != "/assets" {
|
||||||
|
engine.StaticFS(linksPathForAssets, http.FS(subFS))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.Error("sub: failed to mount embedded assets:", err)
|
logger.Error("sub: failed to mount embedded assets:", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -292,34 +292,25 @@ func (s *SubJsonService) realityData(rData map[string]any) map[string]any {
|
||||||
|
|
||||||
func (s *SubJsonService) genVnext(inbound *model.Inbound, streamSettings json_util.RawMessage, client model.Client, encryption string) json_util.RawMessage {
|
func (s *SubJsonService) genVnext(inbound *model.Inbound, streamSettings json_util.RawMessage, client model.Client, encryption string) json_util.RawMessage {
|
||||||
outbound := Outbound{}
|
outbound := Outbound{}
|
||||||
usersData := make([]UserVnext, 1)
|
|
||||||
|
|
||||||
usersData[0].ID = client.ID
|
|
||||||
usersData[0].Level = 8
|
|
||||||
if inbound.Protocol == model.VMESS {
|
|
||||||
usersData[0].Security = client.Security
|
|
||||||
}
|
|
||||||
if inbound.Protocol == model.VLESS {
|
|
||||||
usersData[0].Flow = client.Flow
|
|
||||||
usersData[0].Encryption = encryption
|
|
||||||
}
|
|
||||||
|
|
||||||
vnextData := make([]VnextSetting, 1)
|
|
||||||
vnextData[0] = VnextSetting{
|
|
||||||
Address: inbound.Listen,
|
|
||||||
Port: inbound.Port,
|
|
||||||
Users: usersData,
|
|
||||||
}
|
|
||||||
|
|
||||||
outbound.Protocol = string(inbound.Protocol)
|
outbound.Protocol = string(inbound.Protocol)
|
||||||
outbound.Tag = "proxy"
|
outbound.Tag = "proxy"
|
||||||
if s.mux != "" {
|
if s.mux != "" {
|
||||||
outbound.Mux = json_util.RawMessage(s.mux)
|
outbound.Mux = json_util.RawMessage(s.mux)
|
||||||
}
|
}
|
||||||
outbound.StreamSettings = streamSettings
|
outbound.StreamSettings = streamSettings
|
||||||
outbound.Settings = OutboundSettings{
|
// Emit flattened settings inside Settings to match new Xray format
|
||||||
Vnext: vnextData,
|
settings := make(map[string]any)
|
||||||
|
settings["address"] = inbound.Listen
|
||||||
|
settings["port"] = inbound.Port
|
||||||
|
settings["id"] = client.ID
|
||||||
|
if inbound.Protocol == model.VLESS {
|
||||||
|
settings["flow"] = client.Flow
|
||||||
|
settings["encryption"] = encryption
|
||||||
}
|
}
|
||||||
|
if inbound.Protocol == model.VMESS {
|
||||||
|
settings["security"] = client.Security
|
||||||
|
}
|
||||||
|
outbound.Settings = settings
|
||||||
|
|
||||||
result, _ := json.MarshalIndent(outbound, "", " ")
|
result, _ := json.MarshalIndent(outbound, "", " ")
|
||||||
return result
|
return result
|
||||||
|
|
@ -356,8 +347,8 @@ func (s *SubJsonService) genServer(inbound *model.Inbound, streamSettings json_u
|
||||||
outbound.Mux = json_util.RawMessage(s.mux)
|
outbound.Mux = json_util.RawMessage(s.mux)
|
||||||
}
|
}
|
||||||
outbound.StreamSettings = streamSettings
|
outbound.StreamSettings = streamSettings
|
||||||
outbound.Settings = OutboundSettings{
|
outbound.Settings = map[string]any{
|
||||||
Servers: serverData,
|
"servers": serverData,
|
||||||
}
|
}
|
||||||
|
|
||||||
result, _ := json.MarshalIndent(outbound, "", " ")
|
result, _ := json.MarshalIndent(outbound, "", " ")
|
||||||
|
|
@ -369,28 +360,10 @@ type Outbound struct {
|
||||||
Tag string `json:"tag"`
|
Tag string `json:"tag"`
|
||||||
StreamSettings json_util.RawMessage `json:"streamSettings"`
|
StreamSettings json_util.RawMessage `json:"streamSettings"`
|
||||||
Mux json_util.RawMessage `json:"mux,omitempty"`
|
Mux json_util.RawMessage `json:"mux,omitempty"`
|
||||||
ProxySettings map[string]any `json:"proxySettings,omitempty"`
|
Settings map[string]any `json:"settings,omitempty"`
|
||||||
Settings OutboundSettings `json:"settings,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type OutboundSettings struct {
|
// Legacy vnext-related structs removed for flattened schema
|
||||||
Vnext []VnextSetting `json:"vnext,omitempty"`
|
|
||||||
Servers []ServerSetting `json:"servers,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type VnextSetting struct {
|
|
||||||
Address string `json:"address"`
|
|
||||||
Port int `json:"port"`
|
|
||||||
Users []UserVnext `json:"users"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type UserVnext struct {
|
|
||||||
Encryption string `json:"encryption,omitempty"`
|
|
||||||
Flow string `json:"flow,omitempty"`
|
|
||||||
ID string `json:"id"`
|
|
||||||
Security string `json:"security,omitempty"`
|
|
||||||
Level int `json:"level"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ServerSetting struct {
|
type ServerSetting struct {
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -1110,7 +1109,7 @@ func (s *SubService) BuildPageData(subId string, hostHeader string, traffic xray
|
||||||
|
|
||||||
return PageData{
|
return PageData{
|
||||||
Host: hostHeader,
|
Host: hostHeader,
|
||||||
BasePath: "/",
|
BasePath: "/", // kept as "/"; templates now use context base_path injected from router
|
||||||
SId: subId,
|
SId: subId,
|
||||||
Download: download,
|
Download: download,
|
||||||
Upload: upload,
|
Upload: upload,
|
||||||
|
|
@ -1139,10 +1138,3 @@ func getHostFromXFH(s string) (string, error) {
|
||||||
}
|
}
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseInt64(s string) (int64, error) {
|
|
||||||
// handle potential quotes
|
|
||||||
s = strings.Trim(s, "\"'")
|
|
||||||
n, err := strconv.ParseInt(s, 10, 64)
|
|
||||||
return n, err
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,12 @@
|
||||||
package sys
|
package sys
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/binary"
|
||||||
|
"fmt"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v4/net"
|
"github.com/shirou/gopsutil/v4/net"
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetTCPCount() (int, error) {
|
func GetTCPCount() (int, error) {
|
||||||
|
|
@ -22,3 +27,69 @@ func GetUDPCount() (int, error) {
|
||||||
}
|
}
|
||||||
return len(stats), nil
|
return len(stats), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- CPU Utilization (macOS native) ---
|
||||||
|
|
||||||
|
// sysctl kern.cp_time returns an array of 5 longs: user, nice, sys, idle, intr.
|
||||||
|
// We compute utilization deltas without cgo.
|
||||||
|
var (
|
||||||
|
cpuMu sync.Mutex
|
||||||
|
lastTotals [5]uint64
|
||||||
|
hasLastCPUT bool
|
||||||
|
)
|
||||||
|
|
||||||
|
func CPUPercentRaw() (float64, error) {
|
||||||
|
raw, err := unix.SysctlRaw("kern.cp_time")
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
// Expect either 5*8 bytes (uint64) or 5*4 bytes (uint32)
|
||||||
|
var out [5]uint64
|
||||||
|
switch len(raw) {
|
||||||
|
case 5 * 8:
|
||||||
|
for i := 0; i < 5; i++ {
|
||||||
|
out[i] = binary.LittleEndian.Uint64(raw[i*8 : (i+1)*8])
|
||||||
|
}
|
||||||
|
case 5 * 4:
|
||||||
|
for i := 0; i < 5; i++ {
|
||||||
|
out[i] = uint64(binary.LittleEndian.Uint32(raw[i*4 : (i+1)*4]))
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return 0, fmt.Errorf("unexpected kern.cp_time size: %d", len(raw))
|
||||||
|
}
|
||||||
|
|
||||||
|
// user, nice, sys, idle, intr
|
||||||
|
user := out[0]
|
||||||
|
nice := out[1]
|
||||||
|
sysv := out[2]
|
||||||
|
idle := out[3]
|
||||||
|
intr := out[4]
|
||||||
|
|
||||||
|
cpuMu.Lock()
|
||||||
|
defer cpuMu.Unlock()
|
||||||
|
|
||||||
|
if !hasLastCPUT {
|
||||||
|
lastTotals = out
|
||||||
|
hasLastCPUT = true
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
dUser := user - lastTotals[0]
|
||||||
|
dNice := nice - lastTotals[1]
|
||||||
|
dSys := sysv - lastTotals[2]
|
||||||
|
dIdle := idle - lastTotals[3]
|
||||||
|
dIntr := intr - lastTotals[4]
|
||||||
|
|
||||||
|
lastTotals = out
|
||||||
|
|
||||||
|
totald := dUser + dNice + dSys + dIdle + dIntr
|
||||||
|
if totald == 0 {
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
busy := totald - dIdle
|
||||||
|
pct := float64(busy) / float64(totald) * 100.0
|
||||||
|
if pct > 100 {
|
||||||
|
pct = 100
|
||||||
|
}
|
||||||
|
return pct, nil
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,14 @@
|
||||||
package sys
|
package sys
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getLinesNum(filename string) (int, error) {
|
func getLinesNum(filename string) (int, error) {
|
||||||
|
|
@ -79,3 +83,99 @@ func safeGetLinesNum(path string) (int, error) {
|
||||||
}
|
}
|
||||||
return getLinesNum(path)
|
return getLinesNum(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- CPU Utilization (Linux native) ---
|
||||||
|
|
||||||
|
var (
|
||||||
|
cpuMu sync.Mutex
|
||||||
|
lastTotal uint64
|
||||||
|
lastIdleAll uint64
|
||||||
|
hasLast bool
|
||||||
|
)
|
||||||
|
|
||||||
|
// CPUPercentRaw returns instantaneous total CPU utilization by reading /proc/stat.
|
||||||
|
// First call initializes and returns 0; subsequent calls return busy/total * 100.
|
||||||
|
func CPUPercentRaw() (float64, error) {
|
||||||
|
f, err := os.Open("/proc/stat")
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
|
rd := bufio.NewReader(f)
|
||||||
|
line, err := rd.ReadString('\n')
|
||||||
|
if err != nil && err != io.EOF {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
// Expect line like: cpu user nice system idle iowait irq softirq steal guest guest_nice
|
||||||
|
fields := strings.Fields(line)
|
||||||
|
if len(fields) < 5 || fields[0] != "cpu" {
|
||||||
|
return 0, fmt.Errorf("unexpected /proc/stat format")
|
||||||
|
}
|
||||||
|
|
||||||
|
var nums []uint64
|
||||||
|
for i := 1; i < len(fields); i++ {
|
||||||
|
v, err := strconv.ParseUint(fields[i], 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
nums = append(nums, v)
|
||||||
|
}
|
||||||
|
if len(nums) < 4 { // need at least user,nice,system,idle
|
||||||
|
return 0, fmt.Errorf("insufficient cpu fields")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Conform with standard Linux CPU accounting
|
||||||
|
var user, nice, system, idle, iowait, irq, softirq, steal uint64
|
||||||
|
user = nums[0]
|
||||||
|
if len(nums) > 1 {
|
||||||
|
nice = nums[1]
|
||||||
|
}
|
||||||
|
if len(nums) > 2 {
|
||||||
|
system = nums[2]
|
||||||
|
}
|
||||||
|
if len(nums) > 3 {
|
||||||
|
idle = nums[3]
|
||||||
|
}
|
||||||
|
if len(nums) > 4 {
|
||||||
|
iowait = nums[4]
|
||||||
|
}
|
||||||
|
if len(nums) > 5 {
|
||||||
|
irq = nums[5]
|
||||||
|
}
|
||||||
|
if len(nums) > 6 {
|
||||||
|
softirq = nums[6]
|
||||||
|
}
|
||||||
|
if len(nums) > 7 {
|
||||||
|
steal = nums[7]
|
||||||
|
}
|
||||||
|
|
||||||
|
idleAll := idle + iowait
|
||||||
|
nonIdle := user + nice + system + irq + softirq + steal
|
||||||
|
total := idleAll + nonIdle
|
||||||
|
|
||||||
|
cpuMu.Lock()
|
||||||
|
defer cpuMu.Unlock()
|
||||||
|
|
||||||
|
if !hasLast {
|
||||||
|
lastTotal = total
|
||||||
|
lastIdleAll = idleAll
|
||||||
|
hasLast = true
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
totald := total - lastTotal
|
||||||
|
idled := idleAll - lastIdleAll
|
||||||
|
lastTotal = total
|
||||||
|
lastIdleAll = idleAll
|
||||||
|
|
||||||
|
if totald == 0 {
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
busy := totald - idled
|
||||||
|
pct := float64(busy) / float64(totald) * 100.0
|
||||||
|
if pct > 100 {
|
||||||
|
pct = 100
|
||||||
|
}
|
||||||
|
return pct, nil
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@ package sys
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"sync"
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v4/net"
|
"github.com/shirou/gopsutil/v4/net"
|
||||||
)
|
)
|
||||||
|
|
@ -28,3 +31,81 @@ func GetTCPCount() (int, error) {
|
||||||
func GetUDPCount() (int, error) {
|
func GetUDPCount() (int, error) {
|
||||||
return GetConnectionCount("udp")
|
return GetConnectionCount("udp")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- CPU Utilization (Windows native) ---
|
||||||
|
|
||||||
|
var (
|
||||||
|
modKernel32 = syscall.NewLazyDLL("kernel32.dll")
|
||||||
|
procGetSystemTimes = modKernel32.NewProc("GetSystemTimes")
|
||||||
|
|
||||||
|
cpuMu sync.Mutex
|
||||||
|
lastIdle uint64
|
||||||
|
lastKernel uint64
|
||||||
|
lastUser uint64
|
||||||
|
hasLast bool
|
||||||
|
)
|
||||||
|
|
||||||
|
type filetime struct {
|
||||||
|
LowDateTime uint32
|
||||||
|
HighDateTime uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
func ftToUint64(ft filetime) uint64 {
|
||||||
|
return (uint64(ft.HighDateTime) << 32) | uint64(ft.LowDateTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CPUPercentRaw returns the instantaneous total CPU utilization percentage using
|
||||||
|
// Windows GetSystemTimes across all logical processors. The first call returns 0
|
||||||
|
// as it initializes the baseline. Subsequent calls compute deltas.
|
||||||
|
func CPUPercentRaw() (float64, error) {
|
||||||
|
var idleFT, kernelFT, userFT filetime
|
||||||
|
r1, _, e1 := procGetSystemTimes.Call(
|
||||||
|
uintptr(unsafe.Pointer(&idleFT)),
|
||||||
|
uintptr(unsafe.Pointer(&kernelFT)),
|
||||||
|
uintptr(unsafe.Pointer(&userFT)),
|
||||||
|
)
|
||||||
|
if r1 == 0 { // failure
|
||||||
|
if e1 != nil {
|
||||||
|
return 0, e1
|
||||||
|
}
|
||||||
|
return 0, syscall.GetLastError()
|
||||||
|
}
|
||||||
|
|
||||||
|
idle := ftToUint64(idleFT)
|
||||||
|
kernel := ftToUint64(kernelFT)
|
||||||
|
user := ftToUint64(userFT)
|
||||||
|
|
||||||
|
cpuMu.Lock()
|
||||||
|
defer cpuMu.Unlock()
|
||||||
|
|
||||||
|
if !hasLast {
|
||||||
|
lastIdle = idle
|
||||||
|
lastKernel = kernel
|
||||||
|
lastUser = user
|
||||||
|
hasLast = true
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
idleDelta := idle - lastIdle
|
||||||
|
kernelDelta := kernel - lastKernel
|
||||||
|
userDelta := user - lastUser
|
||||||
|
|
||||||
|
// Update for next call
|
||||||
|
lastIdle = idle
|
||||||
|
lastKernel = kernel
|
||||||
|
lastUser = user
|
||||||
|
|
||||||
|
total := kernelDelta + userDelta
|
||||||
|
if total == 0 {
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
// On Windows, kernel time includes idle time; busy = total - idle
|
||||||
|
busy := total - idleDelta
|
||||||
|
|
||||||
|
pct := float64(busy) / float64(total) * 100.0
|
||||||
|
// lower bound not needed; ratios of uint64 are non-negative
|
||||||
|
if pct > 100 {
|
||||||
|
pct = 100
|
||||||
|
}
|
||||||
|
return pct, nil
|
||||||
|
}
|
||||||
|
|
|
||||||
2
web/assets/css/custom.min.css
vendored
2
web/assets/css/custom.min.css
vendored
File diff suppressed because one or more lines are too long
|
|
@ -10,6 +10,8 @@ class DBInbound {
|
||||||
this.remark = "";
|
this.remark = "";
|
||||||
this.enable = true;
|
this.enable = true;
|
||||||
this.expiryTime = 0;
|
this.expiryTime = 0;
|
||||||
|
this.trafficReset = "never";
|
||||||
|
this.lastTrafficResetTime = 0;
|
||||||
|
|
||||||
this.listen = "";
|
this.listen = "";
|
||||||
this.port = 0;
|
this.port = 0;
|
||||||
|
|
|
||||||
|
|
@ -647,10 +647,6 @@ class Outbound extends CommonClass {
|
||||||
].includes(this.protocol);
|
].includes(this.protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
hasVnext() {
|
|
||||||
return [Protocols.VMess, Protocols.VLESS].includes(this.protocol);
|
|
||||||
}
|
|
||||||
|
|
||||||
hasServers() {
|
hasServers() {
|
||||||
return [Protocols.Trojan, Protocols.Shadowsocks, Protocols.Socks, Protocols.HTTP].includes(this.protocol);
|
return [Protocols.Trojan, Protocols.Shadowsocks, Protocols.Socks, Protocols.HTTP].includes(this.protocol);
|
||||||
}
|
}
|
||||||
|
|
@ -690,13 +686,22 @@ class Outbound extends CommonClass {
|
||||||
if (this.stream?.sockopt)
|
if (this.stream?.sockopt)
|
||||||
stream = { sockopt: this.stream.sockopt.toJson() };
|
stream = { sockopt: this.stream.sockopt.toJson() };
|
||||||
}
|
}
|
||||||
|
// For VMess/VLESS, emit settings as a flat object
|
||||||
|
let settingsOut = this.settings instanceof CommonClass ? this.settings.toJson() : this.settings;
|
||||||
|
// Remove undefined/null keys
|
||||||
|
if (settingsOut && typeof settingsOut === 'object') {
|
||||||
|
Object.keys(settingsOut).forEach(k => {
|
||||||
|
if (settingsOut[k] === undefined || settingsOut[k] === null) delete settingsOut[k];
|
||||||
|
});
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
tag: this.tag == '' ? undefined : this.tag,
|
|
||||||
protocol: this.protocol,
|
protocol: this.protocol,
|
||||||
settings: this.settings instanceof CommonClass ? this.settings.toJson() : this.settings,
|
settings: settingsOut,
|
||||||
streamSettings: stream,
|
// Only include tag, streamSettings, sendThrough, mux if present and not empty
|
||||||
sendThrough: this.sendThrough != "" ? this.sendThrough : undefined,
|
...(this.tag ? { tag: this.tag } : {}),
|
||||||
mux: this.mux?.enabled ? this.mux : undefined,
|
...(stream ? { streamSettings: stream } : {}),
|
||||||
|
...(this.sendThrough ? { sendThrough: this.sendThrough } : {}),
|
||||||
|
...(this.mux?.enabled ? { mux: this.mux } : {}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1026,22 +1031,21 @@ Outbound.VmessSettings = class extends CommonClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
static fromJson(json = {}) {
|
static fromJson(json = {}) {
|
||||||
if (ObjectUtil.isArrEmpty(json.vnext)) return new Outbound.VmessSettings();
|
if (ObjectUtil.isEmpty(json.address) || ObjectUtil.isEmpty(json.port)) return new Outbound.VmessSettings();
|
||||||
return new Outbound.VmessSettings(
|
return new Outbound.VmessSettings(
|
||||||
json.vnext[0].address,
|
json.address,
|
||||||
json.vnext[0].port,
|
json.port,
|
||||||
json.vnext[0].users[0].id,
|
json.id,
|
||||||
json.vnext[0].users[0].security,
|
json.security,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
toJson() {
|
toJson() {
|
||||||
return {
|
return {
|
||||||
vnext: [{
|
|
||||||
address: this.address,
|
address: this.address,
|
||||||
port: this.port,
|
port: this.port,
|
||||||
users: [{ id: this.id, security: this.security }],
|
id: this.id,
|
||||||
}],
|
security: this.security,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -1056,23 +1060,23 @@ Outbound.VLESSSettings = class extends CommonClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
static fromJson(json = {}) {
|
static fromJson(json = {}) {
|
||||||
if (ObjectUtil.isArrEmpty(json.vnext)) return new Outbound.VLESSSettings();
|
if (ObjectUtil.isEmpty(json.address) || ObjectUtil.isEmpty(json.port)) return new Outbound.VLESSSettings();
|
||||||
return new Outbound.VLESSSettings(
|
return new Outbound.VLESSSettings(
|
||||||
json.vnext[0].address,
|
json.address,
|
||||||
json.vnext[0].port,
|
json.port,
|
||||||
json.vnext[0].users[0].id,
|
json.id,
|
||||||
json.vnext[0].users[0].flow,
|
json.flow,
|
||||||
json.vnext[0].users[0].encryption,
|
json.encryption
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
toJson() {
|
toJson() {
|
||||||
return {
|
return {
|
||||||
vnext: [{
|
|
||||||
address: this.address,
|
address: this.address,
|
||||||
port: this.port,
|
port: this.port,
|
||||||
users: [{ id: this.id, flow: this.flow, encryption: this.encryption }],
|
id: this.id,
|
||||||
}],
|
flow: this.flow,
|
||||||
|
encryption: this.encryption,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"x-ui/web/global"
|
"x-ui/web/global"
|
||||||
|
|
@ -39,6 +40,7 @@ func NewServerController(g *gin.RouterGroup) *ServerController {
|
||||||
func (a *ServerController) initRouter(g *gin.RouterGroup) {
|
func (a *ServerController) initRouter(g *gin.RouterGroup) {
|
||||||
|
|
||||||
g.GET("/status", a.status)
|
g.GET("/status", a.status)
|
||||||
|
g.GET("/cpuHistory", a.getCpuHistory)
|
||||||
g.GET("/getXrayVersion", a.getXrayVersion)
|
g.GET("/getXrayVersion", a.getXrayVersion)
|
||||||
g.GET("/getConfigJson", a.getConfigJson)
|
g.GET("/getConfigJson", a.getConfigJson)
|
||||||
g.GET("/getDb", a.getDb)
|
g.GET("/getDb", a.getDb)
|
||||||
|
|
@ -61,16 +63,18 @@ func (a *ServerController) initRouter(g *gin.RouterGroup) {
|
||||||
|
|
||||||
func (a *ServerController) refreshStatus() {
|
func (a *ServerController) refreshStatus() {
|
||||||
a.lastStatus = a.serverService.GetStatus(a.lastStatus)
|
a.lastStatus = a.serverService.GetStatus(a.lastStatus)
|
||||||
|
// collect cpu history when status is fresh
|
||||||
|
if a.lastStatus != nil {
|
||||||
|
a.serverService.AppendCpuSample(time.Now(), a.lastStatus.Cpu)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *ServerController) startTask() {
|
func (a *ServerController) startTask() {
|
||||||
webServer := global.GetWebServer()
|
webServer := global.GetWebServer()
|
||||||
c := webServer.GetCron()
|
c := webServer.GetCron()
|
||||||
c.AddFunc("@every 2s", func() {
|
c.AddFunc("@every 2s", func() {
|
||||||
now := time.Now()
|
// Always refresh to keep CPU history collected continuously.
|
||||||
if now.Sub(a.lastGetStatusTime) > time.Minute*3 {
|
// Sampling is lightweight and capped to ~6 hours in memory.
|
||||||
return
|
|
||||||
}
|
|
||||||
a.refreshStatus()
|
a.refreshStatus()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -81,6 +85,26 @@ func (a *ServerController) status(c *gin.Context) {
|
||||||
jsonObj(c, a.lastStatus, nil)
|
jsonObj(c, a.lastStatus, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getCpuHistory returns recent CPU utilization points.
|
||||||
|
// Query param q=minutes (int). Bounds: 1..360 (6 hours). Defaults to 60.
|
||||||
|
func (a *ServerController) getCpuHistory(c *gin.Context) {
|
||||||
|
minsStr := c.Query("q")
|
||||||
|
mins := 60
|
||||||
|
if minsStr != "" {
|
||||||
|
if v, err := strconv.Atoi(minsStr); err == nil {
|
||||||
|
mins = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if mins < 1 {
|
||||||
|
mins = 1
|
||||||
|
}
|
||||||
|
if mins > 360 {
|
||||||
|
mins = 360
|
||||||
|
}
|
||||||
|
res := a.serverService.GetCpuHistory(mins)
|
||||||
|
jsonObj(c, res, nil)
|
||||||
|
}
|
||||||
|
|
||||||
func (a *ServerController) getXrayVersion(c *gin.Context) {
|
func (a *ServerController) getXrayVersion(c *gin.Context) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
if now.Sub(a.lastGetVersionsTime) <= time.Minute {
|
if now.Sub(a.lastGetVersionsTime) <= time.Minute {
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
<template slot="content" >
|
<template slot="content" >
|
||||||
{{ i18n "lastOnline" }}: [[ formatLastOnline(client.email) ]]
|
{{ i18n "lastOnline" }}: [[ formatLastOnline(client.email) ]]
|
||||||
</template>
|
</template>
|
||||||
<template v-if="client.enable && isClientOnline(client.email)">
|
<template v-if="client.enable && isClientOnline(client.email) && !isClientDepleted">
|
||||||
<a-tag color="green">{{ i18n "online" }}</a-tag>
|
<a-tag color="green">{{ i18n "online" }}</a-tag>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
|
|
@ -49,9 +49,9 @@
|
||||||
<a-space direction="horizontal" :size="2">
|
<a-space direction="horizontal" :size="2">
|
||||||
<a-tooltip>
|
<a-tooltip>
|
||||||
<template slot="title">
|
<template slot="title">
|
||||||
<template v-if="!isClientEnabled(record, client.email)">{{ i18n "depleted" }}</template>
|
<template v-if="isClientDepleted">{{ i18n "depleted" }}</template>
|
||||||
<template v-else-if="!client.enable">{{ i18n "disabled" }}</template>
|
<template v-if="!isClientDepleted && !client.enable">{{ i18n "disabled" }}</template>
|
||||||
<template v-else-if="client.enable && isClientOnline(client.email)">{{ i18n "online" }}</template>
|
<template v-if="!isClientDepleted && client.enable && isClientOnline(client.email)">{{ i18n "online" }}</template>
|
||||||
</template>
|
</template>
|
||||||
<a-badge :class="isClientOnline(client.email)? 'online-animation' : ''" :color="client.enable ? statsExpColor(record, client.email) : themeSwitcher.isDarkTheme ? '#2c3950' : '#bcbcbc'"></a-badge>
|
<a-badge :class="isClientOnline(client.email)? 'online-animation' : ''" :color="client.enable ? statsExpColor(record, client.email) : themeSwitcher.isDarkTheme ? '#2c3950' : '#bcbcbc'"></a-badge>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,30 @@
|
||||||
<a-input-number v-model.number="dbInbound.totalGB" :min="0"></a-input-number>
|
<a-input-number v-model.number="dbInbound.totalGB" :min="0"></a-input-number>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item>
|
||||||
|
<template slot="label">
|
||||||
|
<a-tooltip>
|
||||||
|
<template slot="title">
|
||||||
|
<span>{{ i18n "pages.inbounds.periodicTrafficResetDesc" }}</span>
|
||||||
|
<br v-if="dbInbound.lastTrafficResetTime && dbInbound.lastTrafficResetTime > 0">
|
||||||
|
<span v-if="dbInbound.lastTrafficResetTime && dbInbound.lastTrafficResetTime > 0">
|
||||||
|
<strong>{{ i18n "pages.inbounds.lastReset" }}:</strong>
|
||||||
|
<span v-if="datepicker == 'gregorian'">[[ moment(dbInbound.lastTrafficResetTime).format('YYYY-MM-DD HH:mm:ss') ]]</span>
|
||||||
|
<span v-else>[[ DateUtil.convertToJalalian(moment(dbInbound.lastTrafficResetTime)) ]]</span>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
{{ i18n "pages.inbounds.periodicTrafficResetTitle" }}
|
||||||
|
<a-icon type="question-circle"></a-icon>
|
||||||
|
</a-tooltip>
|
||||||
|
</template>
|
||||||
|
<a-select v-model="dbInbound.trafficReset" :dropdown-class-name="themeSwitcher.currentTheme">
|
||||||
|
<a-select-option value="never">{{ i18n "pages.inbounds.periodicTrafficReset.never" }}</a-select-option>
|
||||||
|
<a-select-option value="daily">{{ i18n "pages.inbounds.periodicTrafficReset.daily" }}</a-select-option>
|
||||||
|
<a-select-option value="weekly">{{ i18n "pages.inbounds.periodicTrafficReset.weekly" }}</a-select-option>
|
||||||
|
<a-select-option value="monthly">{{ i18n "pages.inbounds.periodicTrafficReset.monthly" }}</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
<a-form-item>
|
<a-form-item>
|
||||||
<template slot="label">
|
<template slot="label">
|
||||||
<a-tooltip>
|
<a-tooltip>
|
||||||
|
|
|
||||||
|
|
@ -210,7 +210,7 @@
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- Vnext (vless/vmess) settings -->
|
<!-- VLESS/VMess user settings -->
|
||||||
<template v-if="[Protocols.VMess, Protocols.VLESS].includes(outbound.protocol)">
|
<template v-if="[Protocols.VMess, Protocols.VLESS].includes(outbound.protocol)">
|
||||||
<a-form-item label='ID'>
|
<a-form-item label='ID'>
|
||||||
<a-input v-model.trim="outbound.settings.id"></a-input>
|
<a-input v-model.trim="outbound.settings.id"></a-input>
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,10 @@
|
||||||
<a-input-number v-model.number="inbound.stream.reality.maxTimediff" :min="0"></a-input-number>
|
<a-input-number v-model.number="inbound.stream.reality.maxTimediff" :min="0"></a-input-number>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label='Min Client Ver'>
|
<a-form-item label='Min Client Ver'>
|
||||||
<a-input v-model.trim="inbound.stream.reality.minClientVer"></a-input>
|
<a-input v-model.trim="inbound.stream.reality.minClientVer" placeholder='25.9.11'></a-input>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label='Max Client Ver'>
|
<a-form-item label='Max Client Ver'>
|
||||||
<a-input v-model.trim="inbound.stream.reality.maxClientVer"></a-input>
|
<a-input v-model.trim="inbound.stream.reality.maxClientVer" placeholder='25.9.11'></a-input>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item>
|
<a-form-item>
|
||||||
<template slot="label">
|
<template slot="label">
|
||||||
|
|
|
||||||
|
|
@ -9,15 +9,13 @@
|
||||||
<a-spin :spinning="loadingStates.spinning" :delay="500" tip='{{ i18n "loading"}}'>
|
<a-spin :spinning="loadingStates.spinning" :delay="500" tip='{{ i18n "loading"}}'>
|
||||||
<transition name="list" appear>
|
<transition name="list" appear>
|
||||||
<a-alert type="error" v-if="showAlert && loadingStates.fetched" :style="{ marginBottom: '10px' }"
|
<a-alert type="error" v-if="showAlert && loadingStates.fetched" :style="{ marginBottom: '10px' }"
|
||||||
message='{{ i18n "secAlertTitle" }}'
|
message='{{ i18n "secAlertTitle" }}' color="red" description='{{ i18n "secAlertSsl" }}' show-icon closable>
|
||||||
color="red"
|
|
||||||
description='{{ i18n "secAlertSsl" }}'
|
|
||||||
show-icon closable>
|
|
||||||
</a-alert>
|
</a-alert>
|
||||||
</transition>
|
</transition>
|
||||||
<transition name="list" appear>
|
<transition name="list" appear>
|
||||||
<a-row v-if="!loadingStates.fetched">
|
<a-row v-if="!loadingStates.fetched">
|
||||||
<a-card :style="{ textAlign: 'center', padding: '30px 0', marginTop: '10px', background: 'transparent', border: 'none' }">
|
<a-card
|
||||||
|
:style="{ textAlign: 'center', padding: '30px 0', marginTop: '10px', background: 'transparent', border: 'none' }">
|
||||||
<a-spin tip='{{ i18n "loading" }}'></a-spin>
|
<a-spin tip='{{ i18n "loading" }}'></a-spin>
|
||||||
</a-card>
|
</a-card>
|
||||||
</a-row>
|
</a-row>
|
||||||
|
|
@ -26,40 +24,47 @@
|
||||||
<a-card size="small" :style="{ padding: '16px' }" hoverable>
|
<a-card size="small" :style="{ padding: '16px' }" hoverable>
|
||||||
<a-row>
|
<a-row>
|
||||||
<a-col :sm="12" :md="5">
|
<a-col :sm="12" :md="5">
|
||||||
<a-custom-statistic title='{{ i18n "pages.inbounds.totalDownUp" }}' :value="`${SizeFormatter.sizeFormat(total.up)} / ${SizeFormatter.sizeFormat(total.down)}`">
|
<a-custom-statistic title='{{ i18n "pages.inbounds.totalDownUp" }}'
|
||||||
|
:value="`${SizeFormatter.sizeFormat(total.up)} / ${SizeFormatter.sizeFormat(total.down)}`">
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<a-icon type="swap"></a-icon>
|
<a-icon type="swap"></a-icon>
|
||||||
</template>
|
</template>
|
||||||
</a-custom-statistic>
|
</a-custom-statistic>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :sm="12" :md="5">
|
<a-col :sm="12" :md="5">
|
||||||
<a-custom-statistic title='{{ i18n "pages.inbounds.totalUsage" }}' :value="SizeFormatter.sizeFormat(total.up + total.down)" :style="{ marginTop: isMobile ? '10px' : 0 }">
|
<a-custom-statistic title='{{ i18n "pages.inbounds.totalUsage" }}'
|
||||||
|
:value="SizeFormatter.sizeFormat(total.up + total.down)"
|
||||||
|
:style="{ marginTop: isMobile ? '10px' : 0 }">
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<a-icon type="pie-chart"></a-icon>
|
<a-icon type="pie-chart"></a-icon>
|
||||||
</template>
|
</template>
|
||||||
</a-custom-statistic>
|
</a-custom-statistic>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :sm="12" :md="5">
|
<a-col :sm="12" :md="5">
|
||||||
<a-custom-statistic title='{{ i18n "pages.inbounds.allTimeTrafficUsage" }}' :value="SizeFormatter.sizeFormat(total.allTime)" :style="{ marginTop: isMobile ? '10px' : 0 }">
|
<a-custom-statistic title='{{ i18n "pages.inbounds.allTimeTrafficUsage" }}'
|
||||||
|
:value="SizeFormatter.sizeFormat(total.allTime)" :style="{ marginTop: isMobile ? '10px' : 0 }">
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<a-icon type="history"></a-icon>
|
<a-icon type="history"></a-icon>
|
||||||
</template>
|
</template>
|
||||||
</a-custom-statistic>
|
</a-custom-statistic>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :sm="12" :md="5">
|
<a-col :sm="12" :md="5">
|
||||||
<a-custom-statistic title='{{ i18n "pages.inbounds.inboundCount" }}' :value="dbInbounds.length" :style="{ marginTop: isMobile ? '10px' : 0 }">
|
<a-custom-statistic title='{{ i18n "pages.inbounds.inboundCount" }}' :value="dbInbounds.length"
|
||||||
|
:style="{ marginTop: isMobile ? '10px' : 0 }">
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<a-icon type="bars"></a-icon>
|
<a-icon type="bars"></a-icon>
|
||||||
</template>
|
</template>
|
||||||
</a-custom-statistic>
|
</a-custom-statistic>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :sm="12" :md="4">
|
<a-col :sm="12" :md="4">
|
||||||
<a-custom-statistic title='{{ i18n "clients" }}' value=" " :style="{ marginTop: isMobile ? '10px' : 0 }">
|
<a-custom-statistic title='{{ i18n "clients" }}' value=" "
|
||||||
|
:style="{ marginTop: isMobile ? '10px' : 0 }">
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<a-space direction="horizontal">
|
<a-space direction="horizontal">
|
||||||
<a-icon type="team"></a-icon>
|
<a-icon type="team"></a-icon>
|
||||||
<div>
|
<div>
|
||||||
<a-back-top :target="() => document.getElementById('content-layout')" visibility-height="200"></a-back-top>
|
<a-back-top :target="() => document.getElementById('content-layout')"
|
||||||
|
visibility-height="200"></a-back-top>
|
||||||
<a-tag color="green">[[ total.clients ]]</a-tag>
|
<a-tag color="green">[[ total.clients ]]</a-tag>
|
||||||
<a-popover title='{{ i18n "disabled" }}' :overlay-class-name="themeSwitcher.currentTheme">
|
<a-popover title='{{ i18n "disabled" }}' :overlay-class-name="themeSwitcher.currentTheme">
|
||||||
<template slot="content">
|
<template slot="content">
|
||||||
|
|
@ -73,7 +78,8 @@
|
||||||
</template>
|
</template>
|
||||||
<a-tag color="red" v-if="total.depleted.length">[[ total.depleted.length ]]</a-tag>
|
<a-tag color="red" v-if="total.depleted.length">[[ total.depleted.length ]]</a-tag>
|
||||||
</a-popover>
|
</a-popover>
|
||||||
<a-popover title='{{ i18n "depletingSoon" }}' :overlay-class-name="themeSwitcher.currentTheme">
|
<a-popover title='{{ i18n "depletingSoon" }}'
|
||||||
|
:overlay-class-name="themeSwitcher.currentTheme">
|
||||||
<template slot="content">
|
<template slot="content">
|
||||||
<div v-for="clientEmail in total.expiring"><span>[[ clientEmail ]]</span></div>
|
<div v-for="clientEmail in total.expiring"><span>[[ clientEmail ]]</span></div>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -146,11 +152,8 @@
|
||||||
<template #content>
|
<template #content>
|
||||||
<a-space direction="vertical">
|
<a-space direction="vertical">
|
||||||
<span>{{ i18n "pages.inbounds.autoRefreshInterval" }}</span>
|
<span>{{ i18n "pages.inbounds.autoRefreshInterval" }}</span>
|
||||||
<a-select v-model="refreshInterval"
|
<a-select v-model="refreshInterval" :disabled="!isRefreshEnabled" :style="{ width: '100%' }"
|
||||||
:disabled="!isRefreshEnabled"
|
@change="changeRefreshInterval" :dropdown-class-name="themeSwitcher.currentTheme">
|
||||||
:style="{ width: '100%' }"
|
|
||||||
@change="changeRefreshInterval"
|
|
||||||
:dropdown-class-name="themeSwitcher.currentTheme">
|
|
||||||
<a-select-option v-for="key in [5,10,30,60]" :value="key*1000">[[ key ]]s</a-select-option>
|
<a-select-option v-for="key in [5,10,30,60]" :value="key*1000">[[ key ]]s</a-select-option>
|
||||||
</a-select>
|
</a-select>
|
||||||
</a-space>
|
</a-space>
|
||||||
|
|
@ -167,8 +170,10 @@
|
||||||
<a-icon slot="checkedChildren" type="search"></a-icon>
|
<a-icon slot="checkedChildren" type="search"></a-icon>
|
||||||
<a-icon slot="unCheckedChildren" type="filter"></a-icon>
|
<a-icon slot="unCheckedChildren" type="filter"></a-icon>
|
||||||
</a-switch>
|
</a-switch>
|
||||||
<a-input v-if="!enableFilter" v-model.lazy="searchKey" placeholder='{{ i18n "search" }}' autofocus :style="{ maxWidth: '300px' }" :size="isMobile ? 'small' : ''"></a-input>
|
<a-input v-if="!enableFilter" v-model.lazy="searchKey" placeholder='{{ i18n "search" }}' autofocus
|
||||||
<a-radio-group v-if="enableFilter" v-model="filterBy" @change="filterInbounds" button-style="solid" :size="isMobile ? 'small' : ''">
|
:style="{ maxWidth: '300px' }" :size="isMobile ? 'small' : ''"></a-input>
|
||||||
|
<a-radio-group v-if="enableFilter" v-model="filterBy" @change="filterInbounds" button-style="solid"
|
||||||
|
:size="isMobile ? 'small' : ''">
|
||||||
<a-radio-button value="">{{ i18n "none" }}</a-radio-button>
|
<a-radio-button value="">{{ i18n "none" }}</a-radio-button>
|
||||||
<a-radio-button value="deactive">{{ i18n "disabled" }}</a-radio-button>
|
<a-radio-button value="deactive">{{ i18n "disabled" }}</a-radio-button>
|
||||||
<a-radio-button value="depleted">{{ i18n "depleted" }}</a-radio-button>
|
<a-radio-button value="depleted">{{ i18n "depleted" }}</a-radio-button>
|
||||||
|
|
@ -177,25 +182,24 @@
|
||||||
</a-radio-group>
|
</a-radio-group>
|
||||||
</div>
|
</div>
|
||||||
<a-table :columns="isMobile ? mobileColumns : columns" :row-key="dbInbound => dbInbound.id"
|
<a-table :columns="isMobile ? mobileColumns : columns" :row-key="dbInbound => dbInbound.id"
|
||||||
:data-source="searchedInbounds"
|
:data-source="searchedInbounds" :scroll="isMobile ? {} : { x: 1000 }"
|
||||||
:scroll="isMobile ? {} : { x: 1000 }"
|
:pagination=pagination(searchedInbounds) :expand-icon-as-cell="false" :expand-row-by-click="false"
|
||||||
:pagination=pagination(searchedInbounds)
|
:expand-icon-column-index="0" :indent-size="0"
|
||||||
:expand-icon-as-cell="false"
|
|
||||||
:expand-row-by-click="false"
|
|
||||||
:expand-icon-column-index="0"
|
|
||||||
:indent-size="0"
|
|
||||||
:row-class-name="dbInbound => (dbInbound.isMultiUser() ? '' : 'hideExpandIcon')"
|
:row-class-name="dbInbound => (dbInbound.isMultiUser() ? '' : 'hideExpandIcon')"
|
||||||
:style="{ marginTop: '10px' }"
|
:style="{ marginTop: '10px' }"
|
||||||
:locale='{ filterConfirm: `{{ i18n "confirm" }}`, filterReset: `{{ i18n "reset" }}`, emptyText: `{{ i18n "noData" }}` }'>
|
:locale='{ filterConfirm: `{{ i18n "confirm" }}`, filterReset: `{{ i18n "reset" }}`, emptyText: `{{ i18n "noData" }}` }'>
|
||||||
<template slot="action" slot-scope="text, dbInbound">
|
<template slot="action" slot-scope="text, dbInbound">
|
||||||
<a-dropdown :trigger="['click']">
|
<a-dropdown :trigger="['click']">
|
||||||
<a-icon @click="e => e.preventDefault()" type="more" :style="{ fontSize: '20px', textDecoration: 'solid' }"></a-icon>
|
<a-icon @click="e => e.preventDefault()" type="more"
|
||||||
<a-menu slot="overlay" @click="a => clickAction(a, dbInbound)" :theme="themeSwitcher.currentTheme">
|
:style="{ fontSize: '20px', textDecoration: 'solid' }"></a-icon>
|
||||||
|
<a-menu slot="overlay" @click="a => clickAction(a, dbInbound)"
|
||||||
|
:theme="themeSwitcher.currentTheme">
|
||||||
<a-menu-item key="edit">
|
<a-menu-item key="edit">
|
||||||
<a-icon type="edit"></a-icon>
|
<a-icon type="edit"></a-icon>
|
||||||
{{ i18n "edit" }}
|
{{ i18n "edit" }}
|
||||||
</a-menu-item>
|
</a-menu-item>
|
||||||
<a-menu-item key="qrcode" v-if="(dbInbound.isSS && !dbInbound.toInbound().isSSMultiUser) || dbInbound.isWireguard">
|
<a-menu-item key="qrcode"
|
||||||
|
v-if="(dbInbound.isSS && !dbInbound.toInbound().isSSMultiUser) || dbInbound.isWireguard">
|
||||||
<a-icon type="qrcode"></a-icon>
|
<a-icon type="qrcode"></a-icon>
|
||||||
{{ i18n "qrCode" }}
|
{{ i18n "qrCode" }}
|
||||||
</a-menu-item>
|
</a-menu-item>
|
||||||
|
|
@ -247,7 +251,8 @@
|
||||||
</span>
|
</span>
|
||||||
</a-menu-item>
|
</a-menu-item>
|
||||||
<a-menu-item v-if="isMobile">
|
<a-menu-item v-if="isMobile">
|
||||||
<a-switch size="small" v-model="dbInbound.enable" @change="switchEnable(dbInbound.id,dbInbound.enable)"></a-switch>
|
<a-switch size="small" v-model="dbInbound.enable"
|
||||||
|
@change="switchEnable(dbInbound.id,dbInbound.enable)"></a-switch>
|
||||||
{{ i18n "pages.inbounds.enable" }}
|
{{ i18n "pages.inbounds.enable" }}
|
||||||
</a-menu-item>
|
</a-menu-item>
|
||||||
</a-menu>
|
</a-menu>
|
||||||
|
|
@ -257,8 +262,10 @@
|
||||||
<a-tag :style="{ margin: '0' }" color="purple">[[ dbInbound.protocol ]]</a-tag>
|
<a-tag :style="{ margin: '0' }" color="purple">[[ dbInbound.protocol ]]</a-tag>
|
||||||
<template v-if="dbInbound.isVMess || dbInbound.isVLess || dbInbound.isTrojan || dbInbound.isSS">
|
<template v-if="dbInbound.isVMess || dbInbound.isVLess || dbInbound.isTrojan || dbInbound.isSS">
|
||||||
<a-tag :style="{ margin: '0' }" color="green">[[ dbInbound.toInbound().stream.network ]]</a-tag>
|
<a-tag :style="{ margin: '0' }" color="green">[[ dbInbound.toInbound().stream.network ]]</a-tag>
|
||||||
<a-tag :style="{ margin: '0' }" v-if="dbInbound.toInbound().stream.isTls" color="blue">TLS</a-tag>
|
<a-tag :style="{ margin: '0' }" v-if="dbInbound.toInbound().stream.isTls"
|
||||||
<a-tag :style="{ margin: '0' }" v-if="dbInbound.toInbound().stream.isReality" color="blue">Reality</a-tag>
|
color="blue">TLS</a-tag>
|
||||||
|
<a-tag :style="{ margin: '0' }" v-if="dbInbound.toInbound().stream.isReality"
|
||||||
|
color="blue">Reality</a-tag>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
<template slot="clients" slot-scope="text, dbInbound">
|
<template slot="clients" slot-scope="text, dbInbound">
|
||||||
|
|
@ -266,59 +273,75 @@
|
||||||
<a-tag :style="{ margin: '0' }" color="green">[[ clientCount[dbInbound.id].clients ]]</a-tag>
|
<a-tag :style="{ margin: '0' }" color="green">[[ clientCount[dbInbound.id].clients ]]</a-tag>
|
||||||
<a-popover title='{{ i18n "disabled" }}' :overlay-class-name="themeSwitcher.currentTheme">
|
<a-popover title='{{ i18n "disabled" }}' :overlay-class-name="themeSwitcher.currentTheme">
|
||||||
<template slot="content">
|
<template slot="content">
|
||||||
<div v-for="clientEmail in clientCount[dbInbound.id].deactive" :key="clientEmail" class="client-popup-item">
|
<div v-for="clientEmail in clientCount[dbInbound.id].deactive" :key="clientEmail"
|
||||||
|
class="client-popup-item">
|
||||||
<span>[[ clientEmail ]]</span>
|
<span>[[ clientEmail ]]</span>
|
||||||
<a-tooltip :overlay-class-name="themeSwitcher.currentTheme">
|
<a-tooltip :overlay-class-name="themeSwitcher.currentTheme">
|
||||||
<template #title>
|
<template #title>
|
||||||
[[ clientCount[dbInbound.id].comments.get(clientEmail) ]]
|
[[ clientCount[dbInbound.id].comments.get(clientEmail) ]]
|
||||||
</template>
|
</template>
|
||||||
<a-icon type="message" v-if="clientCount[dbInbound.id].comments.get(clientEmail)"></a-icon>
|
<a-icon type="message"
|
||||||
|
v-if="clientCount[dbInbound.id].comments.get(clientEmail)"></a-icon>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<a-tag :style="{ margin: '0', padding: '0 2px' }" v-if="clientCount[dbInbound.id].deactive.length">[[ clientCount[dbInbound.id].deactive.length ]]</a-tag>
|
<a-tag :style="{ margin: '0', padding: '0 2px' }"
|
||||||
|
v-if="clientCount[dbInbound.id].deactive.length">[[
|
||||||
|
clientCount[dbInbound.id].deactive.length ]]</a-tag>
|
||||||
</a-popover>
|
</a-popover>
|
||||||
<a-popover title='{{ i18n "depleted" }}' :overlay-class-name="themeSwitcher.currentTheme">
|
<a-popover title='{{ i18n "depleted" }}' :overlay-class-name="themeSwitcher.currentTheme">
|
||||||
<template slot="content">
|
<template slot="content">
|
||||||
<div v-for="clientEmail in clientCount[dbInbound.id].depleted" :key="clientEmail" class="client-popup-item">
|
<div v-for="clientEmail in clientCount[dbInbound.id].depleted" :key="clientEmail"
|
||||||
|
class="client-popup-item">
|
||||||
<span>[[ clientEmail ]]</span>
|
<span>[[ clientEmail ]]</span>
|
||||||
<a-tooltip :overlay-class-name="themeSwitcher.currentTheme">
|
<a-tooltip :overlay-class-name="themeSwitcher.currentTheme">
|
||||||
<template #title>
|
<template #title>
|
||||||
[[ clientCount[dbInbound.id].comments.get(clientEmail) ]]
|
[[ clientCount[dbInbound.id].comments.get(clientEmail) ]]
|
||||||
</template>
|
</template>
|
||||||
<a-icon type="message" v-if="clientCount[dbInbound.id].comments.get(clientEmail)"></a-icon>
|
<a-icon type="message"
|
||||||
|
v-if="clientCount[dbInbound.id].comments.get(clientEmail)"></a-icon>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<a-tag :style="{ margin: '0', padding: '0 2px' }" color="red" v-if="clientCount[dbInbound.id].depleted.length">[[ clientCount[dbInbound.id].depleted.length ]]</a-tag>
|
<a-tag :style="{ margin: '0', padding: '0 2px' }" color="red"
|
||||||
|
v-if="clientCount[dbInbound.id].depleted.length">[[
|
||||||
|
clientCount[dbInbound.id].depleted.length ]]</a-tag>
|
||||||
</a-popover>
|
</a-popover>
|
||||||
<a-popover title='{{ i18n "depletingSoon" }}' :overlay-class-name="themeSwitcher.currentTheme">
|
<a-popover title='{{ i18n "depletingSoon" }}' :overlay-class-name="themeSwitcher.currentTheme">
|
||||||
<template slot="content">
|
<template slot="content">
|
||||||
<div v-for="clientEmail in clientCount[dbInbound.id].expiring" :key="clientEmail" class="client-popup-item">
|
<div v-for="clientEmail in clientCount[dbInbound.id].expiring" :key="clientEmail"
|
||||||
|
class="client-popup-item">
|
||||||
<span>[[ clientEmail ]]</span>
|
<span>[[ clientEmail ]]</span>
|
||||||
<a-tooltip :overlay-class-name="themeSwitcher.currentTheme">
|
<a-tooltip :overlay-class-name="themeSwitcher.currentTheme">
|
||||||
<template #title>
|
<template #title>
|
||||||
[[ clientCount[dbInbound.id].comments.get(clientEmail) ]]
|
[[ clientCount[dbInbound.id].comments.get(clientEmail) ]]
|
||||||
</template>
|
</template>
|
||||||
<a-icon type="message" v-if="clientCount[dbInbound.id].comments.get(clientEmail)"></a-icon>
|
<a-icon type="message"
|
||||||
|
v-if="clientCount[dbInbound.id].comments.get(clientEmail)"></a-icon>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<a-tag :style="{ margin: '0', padding: '0 2px' }" color="orange" v-if="clientCount[dbInbound.id].expiring.length">[[ clientCount[dbInbound.id].expiring.length ]]</a-tag>
|
<a-tag :style="{ margin: '0', padding: '0 2px' }" color="orange"
|
||||||
|
v-if="clientCount[dbInbound.id].expiring.length">[[
|
||||||
|
clientCount[dbInbound.id].expiring.length ]]</a-tag>
|
||||||
</a-popover>
|
</a-popover>
|
||||||
<a-popover title='{{ i18n "online" }}' :overlay-class-name="themeSwitcher.currentTheme">
|
<a-popover title='{{ i18n "online" }}' :overlay-class-name="themeSwitcher.currentTheme">
|
||||||
<template slot="content">
|
<template slot="content">
|
||||||
<div v-for="clientEmail in clientCount[dbInbound.id].online" :key="clientEmail" class="client-popup-item">
|
<div v-for="clientEmail in clientCount[dbInbound.id].online" :key="clientEmail"
|
||||||
|
class="client-popup-item">
|
||||||
<span>[[ clientEmail ]]</span>
|
<span>[[ clientEmail ]]</span>
|
||||||
<a-tooltip :overlay-class-name="themeSwitcher.currentTheme">
|
<a-tooltip :overlay-class-name="themeSwitcher.currentTheme">
|
||||||
<template #title>
|
<template #title>
|
||||||
[[ clientCount[dbInbound.id].comments.get(clientEmail) ]]
|
[[ clientCount[dbInbound.id].comments.get(clientEmail) ]]
|
||||||
</template>
|
</template>
|
||||||
<a-icon type="message" v-if="clientCount[dbInbound.id].comments.get(clientEmail)"></a-icon>
|
<a-icon type="message"
|
||||||
|
v-if="clientCount[dbInbound.id].comments.get(clientEmail)"></a-icon>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<a-tag :style="{ margin: '0', padding: '0 2px' }" color="blue" v-if="clientCount[dbInbound.id].online.length">[[ clientCount[dbInbound.id].online.length ]]</a-tag>
|
<a-tag :style="{ margin: '0', padding: '0 2px' }" color="blue"
|
||||||
|
v-if="clientCount[dbInbound.id].online.length">[[ clientCount[dbInbound.id].online.length
|
||||||
|
]]</a-tag>
|
||||||
</a-popover>
|
</a-popover>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -336,14 +359,17 @@
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</template>
|
</template>
|
||||||
<a-tag :color="ColorUtils.usageColor(dbInbound.up + dbInbound.down, app.trafficDiff, dbInbound.total)">
|
<a-tag
|
||||||
|
:color="ColorUtils.usageColor(dbInbound.up + dbInbound.down, app.trafficDiff, dbInbound.total)">
|
||||||
[[ SizeFormatter.sizeFormat(dbInbound.up + dbInbound.down) ]] /
|
[[ SizeFormatter.sizeFormat(dbInbound.up + dbInbound.down) ]] /
|
||||||
<template v-if="dbInbound.total > 0">
|
<template v-if="dbInbound.total > 0">
|
||||||
[[ SizeFormatter.sizeFormat(dbInbound.total) ]]
|
[[ SizeFormatter.sizeFormat(dbInbound.total) ]]
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<svg height="10px" width="14px" viewBox="0 0 640 512" fill="currentColor">
|
<svg height="10px" width="14px" viewBox="0 0 640 512" fill="currentColor">
|
||||||
<path d="M484.4 96C407 96 349.2 164.1 320 208.5C290.8 164.1 233 96 155.6 96C69.75 96 0 167.8 0 256s69.75 160 155.6 160C233.1 416 290.8 347.9 320 303.5C349.2 347.9 407 416 484.4 416C570.3 416 640 344.2 640 256S570.3 96 484.4 96zM155.6 368C96.25 368 48 317.8 48 256s48.25-112 107.6-112c67.75 0 120.5 82.25 137.1 112C276 285.8 223.4 368 155.6 368zM484.4 368c-67.75 0-120.5-82.25-137.1-112C364 226.2 416.6 144 484.4 144C543.8 144 592 194.2 592 256S543.8 368 484.4 368z" fill="currentColor"></path>
|
<path
|
||||||
|
d="M484.4 96C407 96 349.2 164.1 320 208.5C290.8 164.1 233 96 155.6 96C69.75 96 0 167.8 0 256s69.75 160 155.6 160C233.1 416 290.8 347.9 320 303.5C349.2 347.9 407 416 484.4 416C570.3 416 640 344.2 640 256S570.3 96 484.4 96zM155.6 368C96.25 368 48 317.8 48 256s48.25-112 107.6-112c67.75 0 120.5 82.25 137.1 112C276 285.8 223.4 368 155.6 368zM484.4 368c-67.75 0-120.5-82.25-137.1-112C364 226.2 416.6 144 484.4 144C543.8 144 592 194.2 592 256S543.8 368 484.4 368z"
|
||||||
|
fill="currentColor"></path>
|
||||||
</svg>
|
</svg>
|
||||||
</template>
|
</template>
|
||||||
</a-tag>
|
</a-tag>
|
||||||
|
|
@ -353,7 +379,8 @@
|
||||||
<a-tag>[[ SizeFormatter.sizeFormat(dbInbound.allTime || 0) ]]</a-tag>
|
<a-tag>[[ SizeFormatter.sizeFormat(dbInbound.allTime || 0) ]]</a-tag>
|
||||||
</template>
|
</template>
|
||||||
<template slot="enable" slot-scope="text, dbInbound">
|
<template slot="enable" slot-scope="text, dbInbound">
|
||||||
<a-switch v-model="dbInbound.enable" @change="switchEnable(dbInbound.id,dbInbound.enable)"></a-switch>
|
<a-switch v-model="dbInbound.enable"
|
||||||
|
@change="switchEnable(dbInbound.id,dbInbound.enable)"></a-switch>
|
||||||
</template>
|
</template>
|
||||||
<template slot="expiryTime" slot-scope="text, dbInbound">
|
<template slot="expiryTime" slot-scope="text, dbInbound">
|
||||||
<a-popover v-if="dbInbound.expiryTime > 0" :overlay-class-name="themeSwitcher.currentTheme">
|
<a-popover v-if="dbInbound.expiryTime > 0" :overlay-class-name="themeSwitcher.currentTheme">
|
||||||
|
|
@ -363,28 +390,36 @@
|
||||||
<template v-else slot="content">
|
<template v-else slot="content">
|
||||||
[[ DateUtil.convertToJalalian(moment(dbInbound.expiryTime)) ]]
|
[[ DateUtil.convertToJalalian(moment(dbInbound.expiryTime)) ]]
|
||||||
</template>
|
</template>
|
||||||
<a-tag :style="{ minWidth: '50px' }" :color="ColorUtils.usageColor(new Date().getTime(), app.expireDiff, dbInbound._expiryTime)">
|
<a-tag :style="{ minWidth: '50px' }"
|
||||||
|
:color="ColorUtils.usageColor(new Date().getTime(), app.expireDiff, dbInbound._expiryTime)">
|
||||||
[[ remainedDays(dbInbound._expiryTime) ]]
|
[[ remainedDays(dbInbound._expiryTime) ]]
|
||||||
</a-tag>
|
</a-tag>
|
||||||
</a-popover>
|
</a-popover>
|
||||||
<a-tag v-else color="purple" class="infinite-tag">
|
<a-tag v-else color="purple" class="infinite-tag">
|
||||||
<svg height="10px" width="14px" viewBox="0 0 640 512" fill="currentColor">
|
<svg height="10px" width="14px" viewBox="0 0 640 512" fill="currentColor">
|
||||||
<path d="M484.4 96C407 96 349.2 164.1 320 208.5C290.8 164.1 233 96 155.6 96C69.75 96 0 167.8 0 256s69.75 160 155.6 160C233.1 416 290.8 347.9 320 303.5C349.2 347.9 407 416 484.4 416C570.3 416 640 344.2 640 256S570.3 96 484.4 96zM155.6 368C96.25 368 48 317.8 48 256s48.25-112 107.6-112c67.75 0 120.5 82.25 137.1 112C276 285.8 223.4 368 155.6 368zM484.4 368c-67.75 0-120.5-82.25-137.1-112C364 226.2 416.6 144 484.4 144C543.8 144 592 194.2 592 256S543.8 368 484.4 368z" fill="currentColor"></path>
|
<path
|
||||||
|
d="M484.4 96C407 96 349.2 164.1 320 208.5C290.8 164.1 233 96 155.6 96C69.75 96 0 167.8 0 256s69.75 160 155.6 160C233.1 416 290.8 347.9 320 303.5C349.2 347.9 407 416 484.4 416C570.3 416 640 344.2 640 256S570.3 96 484.4 96zM155.6 368C96.25 368 48 317.8 48 256s48.25-112 107.6-112c67.75 0 120.5 82.25 137.1 112C276 285.8 223.4 368 155.6 368zM484.4 368c-67.75 0-120.5-82.25-137.1-112C364 226.2 416.6 144 484.4 144C543.8 144 592 194.2 592 256S543.8 368 484.4 368z"
|
||||||
|
fill="currentColor"></path>
|
||||||
</svg>
|
</svg>
|
||||||
</a-tag>
|
</a-tag>
|
||||||
</template>
|
</template>
|
||||||
<template slot="info" slot-scope="text, dbInbound">
|
<template slot="info" slot-scope="text, dbInbound">
|
||||||
<a-popover placement="bottomRight" :overlay-class-name="themeSwitcher.currentTheme" trigger="click">
|
<a-popover placement="bottomRight" :overlay-class-name="themeSwitcher.currentTheme"
|
||||||
|
trigger="click">
|
||||||
<template slot="content">
|
<template slot="content">
|
||||||
<table cellpadding="2">
|
<table cellpadding="2">
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ i18n "pages.inbounds.protocol" }}</td>
|
<td>{{ i18n "pages.inbounds.protocol" }}</td>
|
||||||
<td>
|
<td>
|
||||||
<a-tag :style="{ margin: '0' }" color="purple">[[ dbInbound.protocol ]]</a-tag>
|
<a-tag :style="{ margin: '0' }" color="purple">[[ dbInbound.protocol ]]</a-tag>
|
||||||
<template v-if="dbInbound.isVMess || dbInbound.isVLess || dbInbound.isTrojan || dbInbound.isSS">
|
<template
|
||||||
<a-tag :style="{ margin: '0' }" color="blue">[[ dbInbound.toInbound().stream.network ]]</a-tag>
|
v-if="dbInbound.isVMess || dbInbound.isVLess || dbInbound.isTrojan || dbInbound.isSS">
|
||||||
<a-tag :style="{ margin: '0' }" v-if="dbInbound.toInbound().stream.isTls" color="green">tls</a-tag>
|
<a-tag :style="{ margin: '0' }" color="blue">[[ dbInbound.toInbound().stream.network
|
||||||
<a-tag :style="{ margin: '0' }" v-if="dbInbound.toInbound().stream.isReality" color="green">reality</a-tag>
|
]]</a-tag>
|
||||||
|
<a-tag :style="{ margin: '0' }" v-if="dbInbound.toInbound().stream.isTls"
|
||||||
|
color="green">tls</a-tag>
|
||||||
|
<a-tag :style="{ margin: '0' }" v-if="dbInbound.toInbound().stream.isReality"
|
||||||
|
color="green">reality</a-tag>
|
||||||
</template>
|
</template>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
@ -395,62 +430,82 @@
|
||||||
<tr v-if="clientCount[dbInbound.id]">
|
<tr v-if="clientCount[dbInbound.id]">
|
||||||
<td>{{ i18n "clients" }}</td>
|
<td>{{ i18n "clients" }}</td>
|
||||||
<td>
|
<td>
|
||||||
<a-tag :style="{ margin: '0' }" color="blue">[[ clientCount[dbInbound.id].clients ]]</a-tag>
|
<a-tag :style="{ margin: '0' }" color="blue">[[ clientCount[dbInbound.id].clients
|
||||||
<a-popover title='{{ i18n "disabled" }}' :overlay-class-name="themeSwitcher.currentTheme">
|
]]</a-tag>
|
||||||
|
<a-popover title='{{ i18n "disabled" }}'
|
||||||
|
:overlay-class-name="themeSwitcher.currentTheme">
|
||||||
<template slot="content">
|
<template slot="content">
|
||||||
<div v-for="clientEmail in clientCount[dbInbound.id].deactive" :key="clientEmail" class="client-popup-item">
|
<div v-for="clientEmail in clientCount[dbInbound.id].deactive" :key="clientEmail"
|
||||||
|
class="client-popup-item">
|
||||||
<span>[[ clientEmail ]]</span>
|
<span>[[ clientEmail ]]</span>
|
||||||
<a-tooltip :overlay-class-name="themeSwitcher.currentTheme">
|
<a-tooltip :overlay-class-name="themeSwitcher.currentTheme">
|
||||||
<template #title>
|
<template #title>
|
||||||
[[ clientCount[dbInbound.id].comments.get(clientEmail) ]]
|
[[ clientCount[dbInbound.id].comments.get(clientEmail) ]]
|
||||||
</template>
|
</template>
|
||||||
<a-icon type="message" v-if="clientCount[dbInbound.id].comments.get(clientEmail)"></a-icon>
|
<a-icon type="message"
|
||||||
|
v-if="clientCount[dbInbound.id].comments.get(clientEmail)"></a-icon>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<a-tag :style="{ margin: '0', padding: '0 2px' }" v-if="clientCount[dbInbound.id].deactive.length">[[ clientCount[dbInbound.id].deactive.length ]]</a-tag>
|
<a-tag :style="{ margin: '0', padding: '0 2px' }"
|
||||||
|
v-if="clientCount[dbInbound.id].deactive.length">[[
|
||||||
|
clientCount[dbInbound.id].deactive.length ]]</a-tag>
|
||||||
</a-popover>
|
</a-popover>
|
||||||
<a-popover title='{{ i18n "depleted" }}' :overlay-class-name="themeSwitcher.currentTheme">
|
<a-popover title='{{ i18n "depleted" }}'
|
||||||
|
:overlay-class-name="themeSwitcher.currentTheme">
|
||||||
<template slot="content">
|
<template slot="content">
|
||||||
<div v-for="clientEmail in clientCount[dbInbound.id].depleted" :key="clientEmail" class="client-popup-item">
|
<div v-for="clientEmail in clientCount[dbInbound.id].depleted" :key="clientEmail"
|
||||||
|
class="client-popup-item">
|
||||||
<span>[[ clientEmail ]]</span>
|
<span>[[ clientEmail ]]</span>
|
||||||
<a-tooltip :overlay-class-name="themeSwitcher.currentTheme">
|
<a-tooltip :overlay-class-name="themeSwitcher.currentTheme">
|
||||||
<template #title>
|
<template #title>
|
||||||
[[ clientCount[dbInbound.id].comments.get(clientEmail) ]]
|
[[ clientCount[dbInbound.id].comments.get(clientEmail) ]]
|
||||||
</template>
|
</template>
|
||||||
<a-icon type="message" v-if="clientCount[dbInbound.id].comments.get(clientEmail)"></a-icon>
|
<a-icon type="message"
|
||||||
|
v-if="clientCount[dbInbound.id].comments.get(clientEmail)"></a-icon>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<a-tag :style="{ margin: '0', padding: '0 2px' }" color="red" v-if="clientCount[dbInbound.id].depleted.length">[[ clientCount[dbInbound.id].depleted.length ]]</a-tag>
|
<a-tag :style="{ margin: '0', padding: '0 2px' }" color="red"
|
||||||
|
v-if="clientCount[dbInbound.id].depleted.length">[[
|
||||||
|
clientCount[dbInbound.id].depleted.length ]]</a-tag>
|
||||||
</a-popover>
|
</a-popover>
|
||||||
<a-popover title='{{ i18n "depletingSoon" }}' :overlay-class-name="themeSwitcher.currentTheme">
|
<a-popover title='{{ i18n "depletingSoon" }}'
|
||||||
|
:overlay-class-name="themeSwitcher.currentTheme">
|
||||||
<template slot="content">
|
<template slot="content">
|
||||||
<div v-for="clientEmail in clientCount[dbInbound.id].expiring" :key="clientEmail" class="client-popup-item">
|
<div v-for="clientEmail in clientCount[dbInbound.id].expiring" :key="clientEmail"
|
||||||
|
class="client-popup-item">
|
||||||
<span>[[ clientEmail ]]</span>
|
<span>[[ clientEmail ]]</span>
|
||||||
<a-tooltip :overlay-class-name="themeSwitcher.currentTheme">
|
<a-tooltip :overlay-class-name="themeSwitcher.currentTheme">
|
||||||
<template #title>
|
<template #title>
|
||||||
[[ clientCount[dbInbound.id].comments.get(clientEmail) ]]
|
[[ clientCount[dbInbound.id].comments.get(clientEmail) ]]
|
||||||
</template>
|
</template>
|
||||||
<a-icon type="message" v-if="clientCount[dbInbound.id].comments.get(clientEmail)"></a-icon>
|
<a-icon type="message"
|
||||||
|
v-if="clientCount[dbInbound.id].comments.get(clientEmail)"></a-icon>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<a-tag :style="{ margin: '0', padding: '0 2px' }" color="orange" v-if="clientCount[dbInbound.id].expiring.length">[[ clientCount[dbInbound.id].expiring.length ]]</a-tag>
|
<a-tag :style="{ margin: '0', padding: '0 2px' }" color="orange"
|
||||||
|
v-if="clientCount[dbInbound.id].expiring.length">[[
|
||||||
|
clientCount[dbInbound.id].expiring.length ]]</a-tag>
|
||||||
</a-popover>
|
</a-popover>
|
||||||
<a-popover title='{{ i18n "online" }}' :overlay-class-name="themeSwitcher.currentTheme">
|
<a-popover title='{{ i18n "online" }}' :overlay-class-name="themeSwitcher.currentTheme">
|
||||||
<template slot="content">
|
<template slot="content">
|
||||||
<div v-for="clientEmail in clientCount[dbInbound.id].online" :key="clientEmail" class="client-popup-item">
|
<div v-for="clientEmail in clientCount[dbInbound.id].online" :key="clientEmail"
|
||||||
|
class="client-popup-item">
|
||||||
<span>[[ clientEmail ]]</span>
|
<span>[[ clientEmail ]]</span>
|
||||||
<a-tooltip :overlay-class-name="themeSwitcher.currentTheme">
|
<a-tooltip :overlay-class-name="themeSwitcher.currentTheme">
|
||||||
<template #title>
|
<template #title>
|
||||||
[[ clientCount[dbInbound.id].comments.get(clientEmail) ]]
|
[[ clientCount[dbInbound.id].comments.get(clientEmail) ]]
|
||||||
</template>
|
</template>
|
||||||
<a-icon type="message" v-if="clientCount[dbInbound.id].comments.get(clientEmail)"></a-icon>
|
<a-icon type="message"
|
||||||
|
v-if="clientCount[dbInbound.id].comments.get(clientEmail)"></a-icon>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<a-tag :style="{ margin: '0', padding: '0 2px' }" color="green" v-if="clientCount[dbInbound.id].online.length">[[ clientCount[dbInbound.id].online.length ]]</a-tag>
|
<a-tag :style="{ margin: '0', padding: '0 2px' }" color="green"
|
||||||
|
v-if="clientCount[dbInbound.id].online.length">[[
|
||||||
|
clientCount[dbInbound.id].online.length ]]</a-tag>
|
||||||
</a-popover>
|
</a-popover>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
@ -464,20 +519,25 @@
|
||||||
<td>↑[[ SizeFormatter.sizeFormat(dbInbound.up) ]]</td>
|
<td>↑[[ SizeFormatter.sizeFormat(dbInbound.up) ]]</td>
|
||||||
<td>↓[[ SizeFormatter.sizeFormat(dbInbound.down) ]]</td>
|
<td>↓[[ SizeFormatter.sizeFormat(dbInbound.down) ]]</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-if="dbInbound.total > 0 && dbInbound.up + dbInbound.down < dbInbound.total">
|
<tr
|
||||||
|
v-if="dbInbound.total > 0 && dbInbound.up + dbInbound.down < dbInbound.total">
|
||||||
<td>{{ i18n "remained" }}</td>
|
<td>{{ i18n "remained" }}</td>
|
||||||
<td>[[ SizeFormatter.sizeFormat(dbInbound.total - dbInbound.up - dbInbound.down) ]]</td>
|
<td>[[ SizeFormatter.sizeFormat(dbInbound.total - dbInbound.up - dbInbound.down)
|
||||||
|
]]</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</template>
|
</template>
|
||||||
<a-tag :color="ColorUtils.usageColor(dbInbound.up + dbInbound.down, app.trafficDiff, dbInbound.total)">
|
<a-tag
|
||||||
|
:color="ColorUtils.usageColor(dbInbound.up + dbInbound.down, app.trafficDiff, dbInbound.total)">
|
||||||
[[ SizeFormatter.sizeFormat(dbInbound.up + dbInbound.down) ]] /
|
[[ SizeFormatter.sizeFormat(dbInbound.up + dbInbound.down) ]] /
|
||||||
<template v-if="dbInbound.total > 0">
|
<template v-if="dbInbound.total > 0">
|
||||||
[[ SizeFormatter.sizeFormat(dbInbound.total) ]]
|
[[ SizeFormatter.sizeFormat(dbInbound.total) ]]
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<svg height="10px" width="14px" viewBox="0 0 640 512" fill="currentColor">
|
<svg height="10px" width="14px" viewBox="0 0 640 512" fill="currentColor">
|
||||||
<path d="M484.4 96C407 96 349.2 164.1 320 208.5C290.8 164.1 233 96 155.6 96C69.75 96 0 167.8 0 256s69.75 160 155.6 160C233.1 416 290.8 347.9 320 303.5C349.2 347.9 407 416 484.4 416C570.3 416 640 344.2 640 256S570.3 96 484.4 96zM155.6 368C96.25 368 48 317.8 48 256s48.25-112 107.6-112c67.75 0 120.5 82.25 137.1 112C276 285.8 223.4 368 155.6 368zM484.4 368c-67.75 0-120.5-82.25-137.1-112C364 226.2 416.6 144 484.4 144C543.8 144 592 194.2 592 256S543.8 368 484.4 368z" fill="currentColor"></path>
|
<path
|
||||||
|
d="M484.4 96C407 96 349.2 164.1 320 208.5C290.8 164.1 233 96 155.6 96C69.75 96 0 167.8 0 256s69.75 160 155.6 160C233.1 416 290.8 347.9 320 303.5C349.2 347.9 407 416 484.4 416C570.3 416 640 344.2 640 256S570.3 96 484.4 96zM155.6 368C96.25 368 48 317.8 48 256s48.25-112 107.6-112c67.75 0 120.5 82.25 137.1 112C276 285.8 223.4 368 155.6 368zM484.4 368c-67.75 0-120.5-82.25-137.1-112C364 226.2 416.6 144 484.4 144C543.8 144 592 194.2 592 256S543.8 368 484.4 368z"
|
||||||
|
fill="currentColor"></path>
|
||||||
</svg>
|
</svg>
|
||||||
</template>
|
</template>
|
||||||
</a-tag>
|
</a-tag>
|
||||||
|
|
@ -487,8 +547,8 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ i18n "pages.inbounds.expireDate" }}</td>
|
<td>{{ i18n "pages.inbounds.expireDate" }}</td>
|
||||||
<td>
|
<td>
|
||||||
<a-tag :style="{ minWidth: '50px', textAlign: 'center' }" v-if="dbInbound.expiryTime > 0"
|
<a-tag :style="{ minWidth: '50px', textAlign: 'center' }"
|
||||||
:color="dbInbound.isExpiry? 'red': 'blue'">
|
v-if="dbInbound.expiryTime > 0" :color="dbInbound.isExpiry? 'red': 'blue'">
|
||||||
<template v-if="app.datepicker === 'gregorian'">
|
<template v-if="app.datepicker === 'gregorian'">
|
||||||
[[ DateUtil.formatMillis(dbInbound.expiryTime) ]]
|
[[ DateUtil.formatMillis(dbInbound.expiryTime) ]]
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -498,15 +558,25 @@
|
||||||
</a-tag>
|
</a-tag>
|
||||||
<a-tag v-else :style="{ textAlign: 'center' }" color="purple" class="infinite-tag">
|
<a-tag v-else :style="{ textAlign: 'center' }" color="purple" class="infinite-tag">
|
||||||
<svg height="10px" width="14px" viewBox="0 0 640 512" fill="currentColor">
|
<svg height="10px" width="14px" viewBox="0 0 640 512" fill="currentColor">
|
||||||
<path d="M484.4 96C407 96 349.2 164.1 320 208.5C290.8 164.1 233 96 155.6 96C69.75 96 0 167.8 0 256s69.75 160 155.6 160C233.1 416 290.8 347.9 320 303.5C349.2 347.9 407 416 484.4 416C570.3 416 640 344.2 640 256S570.3 96 484.4 96zM155.6 368C96.25 368 48 317.8 48 256s48.25-112 107.6-112c67.75 0 120.5 82.25 137.1 112C276 285.8 223.4 368 155.6 368zM484.4 368c-67.75 0-120.5-82.25-137.1-112C364 226.2 416.6 144 484.4 144C543.8 144 592 194.2 592 256S543.8 368 484.4 368z" fill="currentColor"></path>
|
<path
|
||||||
|
d="M484.4 96C407 96 349.2 164.1 320 208.5C290.8 164.1 233 96 155.6 96C69.75 96 0 167.8 0 256s69.75 160 155.6 160C233.1 416 290.8 347.9 320 303.5C349.2 347.9 407 416 484.4 416C570.3 416 640 344.2 640 256S570.3 96 484.4 96zM155.6 368C96.25 368 48 317.8 48 256s48.25-112 107.6-112c67.75 0 120.5 82.25 137.1 112C276 285.8 223.4 368 155.6 368zM484.4 368c-67.75 0-120.5-82.25-137.1-112C364 226.2 416.6 144 484.4 144C543.8 144 592 194.2 592 256S543.8 368 484.4 368z"
|
||||||
|
fill="currentColor"></path>
|
||||||
</svg>
|
</svg>
|
||||||
</a-tag>
|
</a-tag>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{{ i18n "pages.inbounds.periodicTrafficResetTitle" }}</td>
|
||||||
|
<td>
|
||||||
|
<a-tag color="blue">[[ i18n("pages.inbounds.periodicTrafficReset." +
|
||||||
|
dbInbound.trafficReset) ]]</a-tag>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</template>
|
</template>
|
||||||
<a-badge>
|
<a-badge>
|
||||||
<a-icon v-if="!dbInbound.enable" slot="count" type="pause-circle" :style="{ color: themeSwitcher.isDarkTheme ? '#2c3950' : '#bcbcbc' }"></a-icon>
|
<a-icon v-if="!dbInbound.enable" slot="count" type="pause-circle"
|
||||||
|
:style="{ color: themeSwitcher.isDarkTheme ? '#2c3950' : '#bcbcbc' }"></a-icon>
|
||||||
<a-button shape="round" size="small" :style="{ fontSize: '14px', padding: '0 10px' }">
|
<a-button shape="round" size="small" :style="{ fontSize: '14px', padding: '0 10px' }">
|
||||||
<a-icon type="info"></a-icon>
|
<a-icon type="info"></a-icon>
|
||||||
</a-button>
|
</a-button>
|
||||||
|
|
@ -514,11 +584,8 @@
|
||||||
</a-popover>
|
</a-popover>
|
||||||
</template>
|
</template>
|
||||||
<template slot="expandedRowRender" slot-scope="record">
|
<template slot="expandedRowRender" slot-scope="record">
|
||||||
<a-table
|
<a-table :row-key="client => client.id" :columns="isMobile ? innerMobileColumns : innerColumns"
|
||||||
:row-key="client => client.id"
|
:data-source="getInboundClients(record)" :pagination=pagination(getInboundClients(record))
|
||||||
:columns="isMobile ? innerMobileColumns : innerColumns"
|
|
||||||
:data-source="getInboundClients(record)"
|
|
||||||
:pagination=pagination(getInboundClients(record))
|
|
||||||
:style="{ margin: `-10px ${isMobile ? '2px' : '22px'} -11px` }">
|
:style="{ margin: `-10px ${isMobile ? '2px' : '22px'} -11px` }">
|
||||||
{{template "component/aClientTable"}}
|
{{template "component/aClientTable"}}
|
||||||
</a-table>
|
</a-table>
|
||||||
|
|
@ -781,12 +848,15 @@
|
||||||
deactive.push(client.email);
|
deactive.push(client.email);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
clientStats.forEach(client => {
|
clientStats.forEach(stats => {
|
||||||
if (!client.enable) {
|
const exhausted = stats.total > 0 && (stats.up + stats.down) >= stats.total;
|
||||||
depleted.push(client.email);
|
const expired = stats.expiryTime > 0 && stats.expiryTime <= now;
|
||||||
|
if (expired || exhausted) {
|
||||||
|
depleted.push(stats.email);
|
||||||
} else {
|
} else {
|
||||||
if ((client.expiryTime > 0 && (client.expiryTime - now < this.expireDiff)) ||
|
const expiringSoon = (stats.expiryTime > 0 && (stats.expiryTime - now < this.expireDiff)) ||
|
||||||
(client.total > 0 && (client.total - (client.up + client.down) < this.trafficDiff))) expiring.push(client.email);
|
(stats.total > 0 && (stats.total - (stats.up + stats.down) < this.trafficDiff));
|
||||||
|
if (expiringSoon) expiring.push(stats.email);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -951,6 +1021,8 @@
|
||||||
remark: dbInbound.remark + " - Cloned",
|
remark: dbInbound.remark + " - Cloned",
|
||||||
enable: dbInbound.enable,
|
enable: dbInbound.enable,
|
||||||
expiryTime: dbInbound.expiryTime,
|
expiryTime: dbInbound.expiryTime,
|
||||||
|
trafficReset: dbInbound.trafficReset,
|
||||||
|
lastTrafficResetTime: dbInbound.lastTrafficResetTime,
|
||||||
|
|
||||||
listen: '',
|
listen: '',
|
||||||
port: RandomUtil.randomInteger(10000, 60000),
|
port: RandomUtil.randomInteger(10000, 60000),
|
||||||
|
|
@ -995,6 +1067,8 @@
|
||||||
remark: dbInbound.remark,
|
remark: dbInbound.remark,
|
||||||
enable: dbInbound.enable,
|
enable: dbInbound.enable,
|
||||||
expiryTime: dbInbound.expiryTime,
|
expiryTime: dbInbound.expiryTime,
|
||||||
|
trafficReset: dbInbound.trafficReset,
|
||||||
|
lastTrafficResetTime: dbInbound.lastTrafficResetTime,
|
||||||
|
|
||||||
listen: inbound.listen,
|
listen: inbound.listen,
|
||||||
port: inbound.port,
|
port: inbound.port,
|
||||||
|
|
@ -1018,6 +1092,8 @@
|
||||||
remark: dbInbound.remark,
|
remark: dbInbound.remark,
|
||||||
enable: dbInbound.enable,
|
enable: dbInbound.enable,
|
||||||
expiryTime: dbInbound.expiryTime,
|
expiryTime: dbInbound.expiryTime,
|
||||||
|
trafficReset: dbInbound.trafficReset,
|
||||||
|
lastTrafficResetTime: dbInbound.lastTrafficResetTime,
|
||||||
|
|
||||||
listen: inbound.listen,
|
listen: inbound.listen,
|
||||||
port: inbound.port,
|
port: inbound.port,
|
||||||
|
|
@ -1357,6 +1433,16 @@
|
||||||
clientStats = dbInbound.clientStats ? dbInbound.clientStats.find(stats => stats.email === email) : null;
|
clientStats = dbInbound.clientStats ? dbInbound.clientStats.find(stats => stats.email === email) : null;
|
||||||
return clientStats ? clientStats['enable'] : true;
|
return clientStats ? clientStats['enable'] : true;
|
||||||
},
|
},
|
||||||
|
// Returns true when client's traffic is exhausted or expiry time is passed
|
||||||
|
isClientDepleted(dbInbound, email) {
|
||||||
|
if (!email || !dbInbound || !dbInbound.clientStats) return false;
|
||||||
|
const stats = dbInbound.clientStats.find(s => s.email === email);
|
||||||
|
if (!stats) return false;
|
||||||
|
const now = new Date().getTime();
|
||||||
|
const exhausted = stats.total > 0 && (stats.up + stats.down) >= stats.total;
|
||||||
|
const expired = stats.expiryTime > 0 && now >= stats.expiryTime;
|
||||||
|
return exhausted || expired;
|
||||||
|
},
|
||||||
isClientOnline(email) {
|
isClientOnline(email) {
|
||||||
return this.onlineClients.includes(email);
|
return this.onlineClients.includes(email);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
{{ template "page/head_end" .}}
|
{{ template "page/head_end" .}}
|
||||||
|
|
||||||
{{ template "page/body_start" .}}
|
{{ template "page/body_start" .}}
|
||||||
<a-layout id="app" v-cloak :class="themeSwitcher.currentTheme">
|
<a-layout id="app" v-cloak :class="themeSwitcher.currentTheme + ' index-page'">
|
||||||
<a-sidebar></a-sidebar>
|
<a-sidebar></a-sidebar>
|
||||||
<a-layout id="content-layout">
|
<a-layout id="content-layout">
|
||||||
<a-layout-content>
|
<a-layout-content>
|
||||||
|
|
@ -41,6 +41,11 @@
|
||||||
<div><b>{{ i18n "pages.index.frequency" }}:</b> [[ CPUFormatter.cpuSpeedFormat(status.cpuSpeedMhz) ]]</div>
|
<div><b>{{ i18n "pages.index.frequency" }}:</b> [[ CPUFormatter.cpuSpeedFormat(status.cpuSpeedMhz) ]]</div>
|
||||||
</template>
|
</template>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
|
<a-tooltip :overlay-class-name="themeSwitcher.currentTheme">
|
||||||
|
<a-button size="small" type="default" class="ml-8" @click="openCpuHistory()">
|
||||||
|
<a-icon type="history" />
|
||||||
|
</a-button>
|
||||||
|
</a-tooltip>
|
||||||
</div>
|
</div>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="12" class="text-center">
|
<a-col :span="12" class="text-center">
|
||||||
|
|
@ -88,7 +93,7 @@
|
||||||
</template>
|
</template>
|
||||||
<template #extra>
|
<template #extra>
|
||||||
<template v-if="status.xray.state != 'error'">
|
<template v-if="status.xray.state != 'error'">
|
||||||
<a-badge status="processing" class="running-animation" :text="status.xray.stateMsg" :color="status.xray.color"/>
|
<a-badge status="processing" :class="({ green: 'xray-running-animation', orange: 'xray-stop-animation' }[status.xray.color]) || 'xray-processing-animation'" :text="status.xray.stateMsg" :color="status.xray.color"/>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<a-popover :overlay-class-name="themeSwitcher.currentTheme">
|
<a-popover :overlay-class-name="themeSwitcher.currentTheme">
|
||||||
|
|
@ -105,7 +110,7 @@
|
||||||
<template slot="content">
|
<template slot="content">
|
||||||
<span class="max-w-400" v-for="line in status.xray.errorMsg.split('\n')">[[ line ]]</span>
|
<span class="max-w-400" v-for="line in status.xray.errorMsg.split('\n')">[[ line ]]</span>
|
||||||
</template>
|
</template>
|
||||||
<a-badge :text="status.xray.stateMsg" :color="status.xray.color"/>
|
<a-badge :text="status.xray.stateMsg" :color="status.xray.color" :class="status.xray.color === 'red' ? 'xray-error-animation' : ''"/>
|
||||||
</a-popover>
|
</a-popover>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -423,6 +428,36 @@
|
||||||
</a-list-item>
|
</a-list-item>
|
||||||
</a-list>
|
</a-list>
|
||||||
</a-modal>
|
</a-modal>
|
||||||
|
<!-- CPU History Modal -->
|
||||||
|
<a-modal id="cpu-history-modal"
|
||||||
|
v-model="cpuHistoryModal.visible"
|
||||||
|
:closable="true" @cancel="() => cpuHistoryModal.visible = false"
|
||||||
|
:class="themeSwitcher.currentTheme"
|
||||||
|
width="900px" footer="">
|
||||||
|
<template slot="title">
|
||||||
|
CPU History
|
||||||
|
<a-select size="small" v-model="cpuHistoryModal.minutes" class="ml-10" style="width: 120px" @change="loadCpuHistory">
|
||||||
|
<a-select-option :value="15">15 min</a-select-option>
|
||||||
|
<a-select-option :value="60">1 hour</a-select-option>
|
||||||
|
<a-select-option :value="180">3 hours</a-select-option>
|
||||||
|
<a-select-option :value="360">6 hours</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</template>
|
||||||
|
<div style="padding: 8px 0;">
|
||||||
|
<sparkline :data="cpuHistoryLong"
|
||||||
|
:labels="cpuHistoryLabels"
|
||||||
|
:vb-width="840"
|
||||||
|
:height="220"
|
||||||
|
:stroke="status.cpu.color"
|
||||||
|
:stroke-width="2.2"
|
||||||
|
:show-grid="true"
|
||||||
|
:show-axes="true"
|
||||||
|
:tick-count-x="5"
|
||||||
|
:fill-opacity="0.18"
|
||||||
|
:marker-radius="3.2"
|
||||||
|
:show-tooltip="true" />
|
||||||
|
</div>
|
||||||
|
</a-modal>
|
||||||
</a-layout>
|
</a-layout>
|
||||||
{{template "page/body_scripts" .}}
|
{{template "page/body_scripts" .}}
|
||||||
{{template "component/aSidebar" .}}
|
{{template "component/aSidebar" .}}
|
||||||
|
|
@ -430,6 +465,190 @@
|
||||||
{{template "component/aCustomStatistic" .}}
|
{{template "component/aCustomStatistic" .}}
|
||||||
{{template "modals/textModal"}}
|
{{template "modals/textModal"}}
|
||||||
<script>
|
<script>
|
||||||
|
// Tiny Sparkline component using an inline SVG polyline
|
||||||
|
Vue.component('sparkline', {
|
||||||
|
props: {
|
||||||
|
data: { type: Array, required: true },
|
||||||
|
// viewBox width for drawing space; SVG width will be 100% of container
|
||||||
|
vbWidth: { type: Number, default: 320 },
|
||||||
|
height: { type: Number, default: 80 },
|
||||||
|
stroke: { type: String, default: '#008771' },
|
||||||
|
strokeWidth: { type: Number, default: 2 },
|
||||||
|
maxPoints: { type: Number, default: 120 },
|
||||||
|
showGrid: { type: Boolean, default: true },
|
||||||
|
gridColor: { type: String, default: 'rgba(255,255,255,0.08)' },
|
||||||
|
fillOpacity: { type: Number, default: 0.15 },
|
||||||
|
showMarker: { type: Boolean, default: true },
|
||||||
|
markerRadius: { type: Number, default: 2.8 },
|
||||||
|
// New opts for axes/labels/tooltip
|
||||||
|
labels: { type: Array, default: () => [] }, // same length as data for x labels (e.g., timestamps)
|
||||||
|
showAxes: { type: Boolean, default: false },
|
||||||
|
yTickStep: { type: Number, default: 25 }, // percent ticks
|
||||||
|
tickCountX: { type: Number, default: 4 },
|
||||||
|
paddingLeft: { type: Number, default: 32 },
|
||||||
|
paddingRight: { type: Number, default: 6 },
|
||||||
|
paddingTop: { type: Number, default: 6 },
|
||||||
|
paddingBottom: { type: Number, default: 20 },
|
||||||
|
showTooltip: { type: Boolean, default: false },
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
hoverIdx: -1,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
viewBoxAttr() {
|
||||||
|
return '0 0 ' + this.vbWidth + ' ' + this.height
|
||||||
|
},
|
||||||
|
drawWidth() {
|
||||||
|
return Math.max(1, this.vbWidth - this.paddingLeft - this.paddingRight)
|
||||||
|
},
|
||||||
|
drawHeight() {
|
||||||
|
return Math.max(1, this.height - this.paddingTop - this.paddingBottom)
|
||||||
|
},
|
||||||
|
nPoints() {
|
||||||
|
return Math.min(this.data.length, this.maxPoints)
|
||||||
|
},
|
||||||
|
dataSlice() {
|
||||||
|
const n = this.nPoints
|
||||||
|
if (n === 0) return []
|
||||||
|
return this.data.slice(this.data.length - n)
|
||||||
|
},
|
||||||
|
labelsSlice() {
|
||||||
|
const n = this.nPoints
|
||||||
|
if (!this.labels || this.labels.length === 0 || n === 0) return []
|
||||||
|
const start = Math.max(0, this.labels.length - n)
|
||||||
|
return this.labels.slice(start)
|
||||||
|
},
|
||||||
|
pointsArr() {
|
||||||
|
const n = this.nPoints
|
||||||
|
if (n === 0) return []
|
||||||
|
const slice = this.dataSlice
|
||||||
|
const max = 100
|
||||||
|
const w = this.drawWidth
|
||||||
|
const h = this.drawHeight
|
||||||
|
const dx = n > 1 ? w / (n - 1) : 0
|
||||||
|
return slice.map((v, i) => {
|
||||||
|
const x = Math.round(this.paddingLeft + i * dx)
|
||||||
|
const y = Math.round(this.paddingTop + (h - (Math.max(0, Math.min(100, v)) / max) * h))
|
||||||
|
return [x, y]
|
||||||
|
})
|
||||||
|
},
|
||||||
|
points() {
|
||||||
|
return this.pointsArr.map(p => `${p[0]},${p[1]}`).join(' ')
|
||||||
|
},
|
||||||
|
areaPath() {
|
||||||
|
if (this.pointsArr.length === 0) return ''
|
||||||
|
const first = this.pointsArr[0]
|
||||||
|
const last = this.pointsArr[this.pointsArr.length - 1]
|
||||||
|
const line = this.points
|
||||||
|
// Close to bottom to create an area fill
|
||||||
|
return `M ${first[0]},${this.paddingTop + this.drawHeight} L ${line.replace(/ /g,' L ')} L ${last[0]},${this.paddingTop + this.drawHeight} Z`
|
||||||
|
},
|
||||||
|
gridLines() {
|
||||||
|
if (!this.showGrid) return []
|
||||||
|
const h = this.drawHeight
|
||||||
|
const w = this.drawWidth
|
||||||
|
// draw at 25%, 50%, 75%
|
||||||
|
return [0.25, 0.5, 0.75]
|
||||||
|
.map(r => Math.round(this.paddingTop + h * r))
|
||||||
|
.map(y => ({ x1: this.paddingLeft, y1: y, x2: this.paddingLeft + w, y2: y }))
|
||||||
|
},
|
||||||
|
lastPoint() {
|
||||||
|
if (this.pointsArr.length === 0) return null
|
||||||
|
return this.pointsArr[this.pointsArr.length - 1]
|
||||||
|
},
|
||||||
|
yTicks() {
|
||||||
|
if (!this.showAxes) return []
|
||||||
|
const step = Math.max(1, this.yTickStep)
|
||||||
|
const ticks = []
|
||||||
|
for (let p = 0; p <= 100; p += step) {
|
||||||
|
const y = Math.round(this.paddingTop + (this.drawHeight - (p / 100) * this.drawHeight))
|
||||||
|
ticks.push({ y, label: `${p}%` })
|
||||||
|
}
|
||||||
|
return ticks
|
||||||
|
},
|
||||||
|
xTicks() {
|
||||||
|
if (!this.showAxes) return []
|
||||||
|
const labels = this.labelsSlice
|
||||||
|
const n = this.nPoints
|
||||||
|
const m = Math.max(2, this.tickCountX)
|
||||||
|
const ticks = []
|
||||||
|
if (n === 0) return ticks
|
||||||
|
const w = this.drawWidth
|
||||||
|
const dx = n > 1 ? w / (n - 1) : 0
|
||||||
|
const positions = []
|
||||||
|
for (let i = 0; i < m; i++) {
|
||||||
|
const idx = Math.round((i * (n - 1)) / (m - 1))
|
||||||
|
positions.push(idx)
|
||||||
|
}
|
||||||
|
positions.forEach(idx => {
|
||||||
|
const label = labels[idx] != null ? String(labels[idx]) : String(idx)
|
||||||
|
const x = Math.round(this.paddingLeft + idx * dx)
|
||||||
|
ticks.push({ x, label })
|
||||||
|
})
|
||||||
|
return ticks
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
onMouseMove(evt) {
|
||||||
|
if (!this.showTooltip || this.pointsArr.length === 0) return
|
||||||
|
const rect = evt.currentTarget.getBoundingClientRect()
|
||||||
|
const px = evt.clientX - rect.left
|
||||||
|
// translate to viewBox space
|
||||||
|
const x = (px / rect.width) * this.vbWidth
|
||||||
|
const n = this.nPoints
|
||||||
|
const dx = n > 1 ? this.drawWidth / (n - 1) : 0
|
||||||
|
const idx = Math.max(0, Math.min(n - 1, Math.round((x - this.paddingLeft) / (dx || 1))))
|
||||||
|
this.hoverIdx = idx
|
||||||
|
},
|
||||||
|
onMouseLeave() {
|
||||||
|
this.hoverIdx = -1
|
||||||
|
},
|
||||||
|
fmtHoverText() {
|
||||||
|
const labels = this.labelsSlice
|
||||||
|
const idx = this.hoverIdx
|
||||||
|
if (idx < 0 || idx >= this.dataSlice.length) return ''
|
||||||
|
const val = Math.max(0, Math.min(100, Number(this.dataSlice[idx] || 0)))
|
||||||
|
const lab = labels[idx] != null ? labels[idx] : ''
|
||||||
|
return `${val}%${lab ? ' • ' + lab : ''}`
|
||||||
|
},
|
||||||
|
},
|
||||||
|
template: `
|
||||||
|
<svg width="100%" :height="height" :viewBox="viewBoxAttr" preserveAspectRatio="none" style="display:block"
|
||||||
|
@mousemove="onMouseMove" @mouseleave="onMouseLeave">
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="spkGrad" x1="0" y1="0" x2="0" y2="1">
|
||||||
|
<stop offset="0%" :stop-color="stroke" :stop-opacity="fillOpacity"/>
|
||||||
|
<stop offset="100%" :stop-color="stroke" stop-opacity="0"/>
|
||||||
|
</linearGradient>
|
||||||
|
</defs>
|
||||||
|
<g v-if="showGrid">
|
||||||
|
<line v-for="(g,i) in gridLines" :key="i" :x1="g.x1" :y1="g.y1" :x2="g.x2" :y2="g.y2" :stroke="gridColor" stroke-width="1"/>
|
||||||
|
</g>
|
||||||
|
<g v-if="showAxes">
|
||||||
|
<!-- Y ticks/labels -->
|
||||||
|
<g v-for="(t,i) in yTicks" :key="'y'+i">
|
||||||
|
<text :x="Math.max(0, paddingLeft - 4)" :y="t.y + 4" text-anchor="end" font-size="10" fill="rgba(200,200,200,0.8)" v-text="t.label"></text>
|
||||||
|
</g>
|
||||||
|
<!-- X ticks/labels -->
|
||||||
|
<g v-for="(t,i) in xTicks" :key="'x'+i">
|
||||||
|
<text :x="t.x" :y="paddingTop + drawHeight + 14" text-anchor="middle" font-size="10" fill="rgba(200,200,200,0.8)" v-text="t.label"></text>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<path v-if="areaPath" :d="areaPath" fill="url(#spkGrad)" stroke="none" />
|
||||||
|
<polyline :points="points" fill="none" :stroke="stroke" :stroke-width="strokeWidth" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
<circle v-if="showMarker && lastPoint" :cx="lastPoint[0]" :cy="lastPoint[1]" :r="markerRadius" :fill="stroke" />
|
||||||
|
<!-- Hover marker/tooltip -->
|
||||||
|
<g v-if="showTooltip && hoverIdx >= 0">
|
||||||
|
<line :x1="pointsArr[hoverIdx][0]" :x2="pointsArr[hoverIdx][0]" :y1="paddingTop" :y2="paddingTop + drawHeight" stroke="rgba(255,255,255,0.25)" stroke-width="1" />
|
||||||
|
<circle :cx="pointsArr[hoverIdx][0]" :cy="pointsArr[hoverIdx][1]" r="3.5" :fill="stroke" />
|
||||||
|
<text :x="pointsArr[hoverIdx][0]" :y="paddingTop + 12" text-anchor="middle" font-size="11" fill="#fff" style="paint-order: stroke; stroke: rgba(0,0,0,0.35); stroke-width: 3;" v-text="fmtHoverText()"></text>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
`,
|
||||||
|
})
|
||||||
|
|
||||||
class CurTotal {
|
class CurTotal {
|
||||||
|
|
||||||
constructor(current, total) {
|
constructor(current, total) {
|
||||||
|
|
@ -675,6 +894,10 @@
|
||||||
spinning: false
|
spinning: false
|
||||||
},
|
},
|
||||||
status: new Status(),
|
status: new Status(),
|
||||||
|
cpuHistory: [], // keep last N cpu utilization points (0..100)
|
||||||
|
cpuHistoryLong: [], // long-range history for modal (values)
|
||||||
|
cpuHistoryLabels: [], // formatted timestamps matching long history
|
||||||
|
cpuHistoryModal: { visible: false, minutes: 60 },
|
||||||
versionModal,
|
versionModal,
|
||||||
logModal,
|
logModal,
|
||||||
xraylogModal,
|
xraylogModal,
|
||||||
|
|
@ -705,6 +928,45 @@
|
||||||
},
|
},
|
||||||
setStatus(data) {
|
setStatus(data) {
|
||||||
this.status = new Status(data);
|
this.status = new Status(data);
|
||||||
|
// Push CPU percent into history (clamped 0..100)
|
||||||
|
const v = Math.max(0, Math.min(100, Number(data?.cpu ?? 0)))
|
||||||
|
this.cpuHistory.push(v)
|
||||||
|
const maxPoints = this.isMobile ? 60 : 120
|
||||||
|
if (this.cpuHistory.length > maxPoints) {
|
||||||
|
this.cpuHistory.splice(0, this.cpuHistory.length - maxPoints)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
openCpuHistory() {
|
||||||
|
this.cpuHistoryModal.visible = true
|
||||||
|
this.loadCpuHistory()
|
||||||
|
},
|
||||||
|
async loadCpuHistory() {
|
||||||
|
const mins = this.cpuHistoryModal.minutes || 60
|
||||||
|
try {
|
||||||
|
const msg = await HttpUtil.get(`/panel/api/server/cpuHistory?q=${mins}`)
|
||||||
|
if (msg.success && Array.isArray(msg.obj)) {
|
||||||
|
// msg.obj is array of {t, cpu}
|
||||||
|
const arr = msg.obj.map(p => Math.max(0, Math.min(100, Number(p.cpu || 0))))
|
||||||
|
const labels = msg.obj.map(p => {
|
||||||
|
const t = p.t
|
||||||
|
let d
|
||||||
|
if (typeof t === 'number') {
|
||||||
|
// Heuristic: if seconds, convert to ms
|
||||||
|
d = new Date(t < 1e12 ? t * 1000 : t)
|
||||||
|
} else {
|
||||||
|
d = new Date(t)
|
||||||
|
}
|
||||||
|
if (isNaN(d.getTime())) return ''
|
||||||
|
const hh = String(d.getHours()).padStart(2, '0')
|
||||||
|
const mm = String(d.getMinutes()).padStart(2, '0')
|
||||||
|
return `${hh}:${mm}`
|
||||||
|
})
|
||||||
|
this.cpuHistoryLong = arr
|
||||||
|
this.cpuHistoryLabels = labels
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to load CPU history', e)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async openSelectV2rayVersion() {
|
async openSelectV2rayVersion() {
|
||||||
this.loading(true);
|
this.loading(true);
|
||||||
|
|
|
||||||
|
|
@ -102,14 +102,15 @@
|
||||||
<a-tag :color="inbound.stream.security == 'none' ? 'red' : 'green'">[[ inbound.stream.security ]]</a-tag>
|
<a-tag :color="inbound.stream.security == 'none' ? 'red' : 'green'">[[ inbound.stream.security ]]</a-tag>
|
||||||
<br />
|
<br />
|
||||||
<td>Authentication</td>
|
<td>Authentication</td>
|
||||||
<a-tag :color="inbound.settings.selectedAuth ? 'green' : 'red'">[[ inbound.settings.selectedAuth ? inbound.settings.selectedAuth : '' ]]</a-tag>
|
<a-tag v-if="inbound.settings.selectedAuth" color="green">[[ inbound.settings.selectedAuth ? inbound.settings.selectedAuth : '' ]]</a-tag>
|
||||||
|
<a-tag v-else color="red">{{ i18n "none" }}</a-tag>
|
||||||
<br />
|
<br />
|
||||||
{{ i18n "encryption" }}
|
{{ i18n "encryption" }}
|
||||||
<a-tag :color="inbound.settings.encryption ? 'green' : 'red'">[[ inbound.settings.encryption ? inbound.settings.encryption : '' ]]</a-tag>
|
<a-tag :color="inbound.settings.encryption ? 'green' : 'red'">[[ inbound.settings.encryption ? inbound.settings.encryption : '' ]]</a-tag>
|
||||||
<br />
|
<br />
|
||||||
<template v-if="inbound.stream.security != 'none'">
|
<template v-if="inbound.stream.security != 'none'">
|
||||||
{{ i18n "domainName" }}
|
{{ i18n "domainName" }}
|
||||||
<a-tag v-if="inbound.serverName" :color="inbound.serverName ? 'green' : 'orange'">[[ inbound.serverName ? inbound.serverName : '' ]]</a-tag>
|
<a-tag v-if="inbound.serverName" color="green">[[ inbound.serverName ? inbound.serverName : '' ]]</a-tag>
|
||||||
<a-tag v-else color="orange">{{ i18n "none" }}</a-tag>
|
<a-tag v-else color="orange">{{ i18n "none" }}</a-tag>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -179,9 +180,9 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ i18n "status" }}</td>
|
<td>{{ i18n "status" }}</td>
|
||||||
<td>
|
<td>
|
||||||
<a-tag v-if="isEnable" color="green">{{ i18n "enabled" }}</a-tag>
|
<a-tag v-if="isEnable && isActive && !isDepleted" color="green">{{ i18n "enabled" }}</a-tag>
|
||||||
<a-tag v-else>{{ i18n "disabled" }}</a-tag>
|
<a-tag v-if="!isEnable && !isDepleted">{{ i18n "disabled" }}</a-tag>
|
||||||
<a-tag v-if="!isActive" color="red">{{ i18n "depleted" }}</a-tag>
|
<a-tag v-if="isDepleted" color="red">{{ i18n "depleted" }}</a-tag>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-if="infoModal.clientStats">
|
<tr v-if="infoModal.clientStats">
|
||||||
|
|
@ -586,6 +587,14 @@
|
||||||
}
|
}
|
||||||
return infoModal.dbInbound.isEnable;
|
return infoModal.dbInbound.isEnable;
|
||||||
},
|
},
|
||||||
|
get isDepleted() {
|
||||||
|
const stats = this.infoModal.clientStats;
|
||||||
|
if (!stats) return false;
|
||||||
|
const now = new Date().getTime();
|
||||||
|
const expired = stats.expiryTime > 0 && now >= stats.expiryTime;
|
||||||
|
const exhausted = stats.total > 0 && (stats.up + stats.down) >= stats.total;
|
||||||
|
return expired || exhausted;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
copy(content) {
|
copy(content) {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
{{ template "page/head_end" .}}
|
{{ template "page/head_end" .}}
|
||||||
|
|
||||||
{{ template "page/body_start" .}}
|
{{ template "page/body_start" .}}
|
||||||
<a-layout id="app" v-cloak :class="themeSwitcher.currentTheme">
|
<a-layout id="app" v-cloak :class="themeSwitcher.currentTheme + ' subscription-page'">
|
||||||
<a-layout-content class="p-2">
|
<a-layout-content class="p-2">
|
||||||
<a-row type="flex" justify="center" class="mt-2">
|
<a-row type="flex" justify="center" class="mt-2">
|
||||||
<a-col :xs="24" :sm="22" :md="18" :lg="14" :xl="12">
|
<a-col :xs="24" :sm="22" :md="18" :lg="14" :xl="12">
|
||||||
|
|
@ -200,7 +200,7 @@
|
||||||
style="text-align:center;">
|
style="text-align:center;">
|
||||||
<!-- Android dropdown -->
|
<!-- Android dropdown -->
|
||||||
<a-dropdown :trigger="['click']">
|
<a-dropdown :trigger="['click']">
|
||||||
<a-button :block="isMobile"
|
<a-button icon="android" :block="isMobile"
|
||||||
:style="{ marginTop: isMobile ? '6px' : 0 }"
|
:style="{ marginTop: isMobile ? '6px' : 0 }"
|
||||||
size="large" type="primary">
|
size="large" type="primary">
|
||||||
Android <a-icon type="down" />
|
Android <a-icon type="down" />
|
||||||
|
|
@ -225,7 +225,7 @@
|
||||||
style="text-align:center;">
|
style="text-align:center;">
|
||||||
<!-- iOS dropdown -->
|
<!-- iOS dropdown -->
|
||||||
<a-dropdown :trigger="['click']">
|
<a-dropdown :trigger="['click']">
|
||||||
<a-button :block="isMobile"
|
<a-button icon="apple" :block="isMobile"
|
||||||
:style="{ marginTop: isMobile ? '6px' : 0 }"
|
:style="{ marginTop: isMobile ? '6px' : 0 }"
|
||||||
size="large" type="primary">
|
size="large" type="primary">
|
||||||
iOS <a-icon type="down" />
|
iOS <a-icon type="down" />
|
||||||
|
|
|
||||||
|
|
@ -535,7 +535,9 @@
|
||||||
switch (o.protocol) {
|
switch (o.protocol) {
|
||||||
case Protocols.VMess:
|
case Protocols.VMess:
|
||||||
case Protocols.VLESS:
|
case Protocols.VLESS:
|
||||||
serverObj = o.settings.vnext;
|
if (o.settings && o.settings.address && o.settings.port) {
|
||||||
|
return [o.settings.address + ':' + o.settings.port];
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Protocols.HTTP:
|
case Protocols.HTTP:
|
||||||
case Protocols.Mixed:
|
case Protocols.Mixed:
|
||||||
|
|
|
||||||
44
web/job/periodic_traffic_reset_job.go
Normal file
44
web/job/periodic_traffic_reset_job.go
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
package job
|
||||||
|
|
||||||
|
import (
|
||||||
|
"x-ui/logger"
|
||||||
|
"x-ui/web/service"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Period string
|
||||||
|
|
||||||
|
type PeriodicTrafficResetJob struct {
|
||||||
|
inboundService service.InboundService
|
||||||
|
period Period
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewPeriodicTrafficResetJob(period Period) *PeriodicTrafficResetJob {
|
||||||
|
return &PeriodicTrafficResetJob{
|
||||||
|
period: period,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (j *PeriodicTrafficResetJob) Run() {
|
||||||
|
inbounds, err := j.inboundService.GetInboundsByTrafficReset(string(j.period))
|
||||||
|
logger.Infof("Running periodic traffic reset job for period: %s", j.period)
|
||||||
|
if err != nil {
|
||||||
|
logger.Warning("Failed to get inbounds for traffic reset:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resetCount := 0
|
||||||
|
|
||||||
|
for _, inbound := range inbounds {
|
||||||
|
if err := j.inboundService.ResetAllClientTraffics(inbound.Id); err != nil {
|
||||||
|
logger.Warning("Failed to reset traffic for inbound", inbound.Id, ":", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
resetCount++
|
||||||
|
logger.Infof("Reset traffic for inbound %d (%s)", inbound.Id, inbound.Remark)
|
||||||
|
}
|
||||||
|
|
||||||
|
if resetCount > 0 {
|
||||||
|
logger.Infof("Periodic traffic reset completed: %d inbounds reset", resetCount)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -41,6 +41,16 @@ func (s *InboundService) GetAllInbounds() ([]*model.Inbound, error) {
|
||||||
return inbounds, nil
|
return inbounds, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *InboundService) GetInboundsByTrafficReset(period string) ([]*model.Inbound, error) {
|
||||||
|
db := database.GetDB()
|
||||||
|
var inbounds []*model.Inbound
|
||||||
|
err := db.Model(model.Inbound{}).Where("traffic_reset = ?", period).Find(&inbounds).Error
|
||||||
|
if err != nil && err != gorm.ErrRecordNotFound {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return inbounds, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *InboundService) checkPortExist(listen string, port int, ignoreId int) (bool, error) {
|
func (s *InboundService) checkPortExist(listen string, port int, ignoreId int) (bool, error) {
|
||||||
db := database.GetDB()
|
db := database.GetDB()
|
||||||
if listen == "" || listen == "0.0.0.0" || listen == "::" || listen == "::0" {
|
if listen == "" || listen == "0.0.0.0" || listen == "::" || listen == "::0" {
|
||||||
|
|
@ -409,6 +419,7 @@ func (s *InboundService) UpdateInbound(inbound *model.Inbound) (*model.Inbound,
|
||||||
oldInbound.Remark = inbound.Remark
|
oldInbound.Remark = inbound.Remark
|
||||||
oldInbound.Enable = inbound.Enable
|
oldInbound.Enable = inbound.Enable
|
||||||
oldInbound.ExpiryTime = inbound.ExpiryTime
|
oldInbound.ExpiryTime = inbound.ExpiryTime
|
||||||
|
oldInbound.TrafficReset = inbound.TrafficReset
|
||||||
oldInbound.Listen = inbound.Listen
|
oldInbound.Listen = inbound.Listen
|
||||||
oldInbound.Port = inbound.Port
|
oldInbound.Port = inbound.Port
|
||||||
oldInbound.Protocol = inbound.Protocol
|
oldInbound.Protocol = inbound.Protocol
|
||||||
|
|
@ -698,6 +709,7 @@ func (s *InboundService) DelInboundClient(inboundId int, clientId string) (bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *InboundService) UpdateInboundClient(data *model.Inbound, clientId string) (bool, error) {
|
func (s *InboundService) UpdateInboundClient(data *model.Inbound, clientId string) (bool, error) {
|
||||||
|
// TODO: check if TrafficReset field is updating
|
||||||
clients, err := s.GetClients(data)
|
clients, err := s.GetClients(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
|
|
@ -1260,7 +1272,7 @@ func (s *InboundService) AddClientStat(tx *gorm.DB, inboundId int, client *model
|
||||||
clientTraffic.Email = client.Email
|
clientTraffic.Email = client.Email
|
||||||
clientTraffic.Total = client.TotalGB
|
clientTraffic.Total = client.TotalGB
|
||||||
clientTraffic.ExpiryTime = client.ExpiryTime
|
clientTraffic.ExpiryTime = client.ExpiryTime
|
||||||
clientTraffic.Enable = true
|
clientTraffic.Enable = client.Enable
|
||||||
clientTraffic.Up = 0
|
clientTraffic.Up = 0
|
||||||
clientTraffic.Down = 0
|
clientTraffic.Down = 0
|
||||||
clientTraffic.Reset = client.Reset
|
clientTraffic.Reset = client.Reset
|
||||||
|
|
@ -1273,7 +1285,7 @@ func (s *InboundService) UpdateClientStat(tx *gorm.DB, email string, client *mod
|
||||||
result := tx.Model(xray.ClientTraffic{}).
|
result := tx.Model(xray.ClientTraffic{}).
|
||||||
Where("email = ?", email).
|
Where("email = ?", email).
|
||||||
Updates(map[string]any{
|
Updates(map[string]any{
|
||||||
"enable": true,
|
"enable": client.Enable,
|
||||||
"email": client.Email,
|
"email": client.Email,
|
||||||
"total": client.TotalGB,
|
"total": client.TotalGB,
|
||||||
"expiry_time": client.ExpiryTime,
|
"expiry_time": client.ExpiryTime,
|
||||||
|
|
@ -1684,6 +1696,7 @@ func (s *InboundService) ResetClientTrafficLimitByEmail(clientEmail string, tota
|
||||||
func (s *InboundService) ResetClientTrafficByEmail(clientEmail string) error {
|
func (s *InboundService) ResetClientTrafficByEmail(clientEmail string) error {
|
||||||
db := database.GetDB()
|
db := database.GetDB()
|
||||||
|
|
||||||
|
// Reset traffic stats in ClientTraffic table
|
||||||
result := db.Model(xray.ClientTraffic{}).
|
result := db.Model(xray.ClientTraffic{}).
|
||||||
Where("email = ?", clientEmail).
|
Where("email = ?", clientEmail).
|
||||||
Updates(map[string]any{"enable": true, "up": 0, "down": 0})
|
Updates(map[string]any{"enable": true, "up": 0, "down": 0})
|
||||||
|
|
@ -1692,6 +1705,7 @@ func (s *InboundService) ResetClientTrafficByEmail(clientEmail string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1759,7 +1773,9 @@ func (s *InboundService) ResetClientTraffic(id int, clientEmail string) (bool, e
|
||||||
|
|
||||||
func (s *InboundService) ResetAllClientTraffics(id int) error {
|
func (s *InboundService) ResetAllClientTraffics(id int) error {
|
||||||
db := database.GetDB()
|
db := database.GetDB()
|
||||||
|
now := time.Now().Unix() * 1000
|
||||||
|
|
||||||
|
return db.Transaction(func(tx *gorm.DB) error {
|
||||||
whereText := "inbound_id "
|
whereText := "inbound_id "
|
||||||
if id == -1 {
|
if id == -1 {
|
||||||
whereText += " > ?"
|
whereText += " > ?"
|
||||||
|
|
@ -1767,12 +1783,29 @@ func (s *InboundService) ResetAllClientTraffics(id int) error {
|
||||||
whereText += " = ?"
|
whereText += " = ?"
|
||||||
}
|
}
|
||||||
|
|
||||||
result := db.Model(xray.ClientTraffic{}).
|
// Reset client traffics
|
||||||
|
result := tx.Model(xray.ClientTraffic{}).
|
||||||
Where(whereText, id).
|
Where(whereText, id).
|
||||||
Updates(map[string]any{"enable": true, "up": 0, "down": 0})
|
Updates(map[string]any{"enable": true, "up": 0, "down": 0})
|
||||||
|
|
||||||
err := result.Error
|
if result.Error != nil {
|
||||||
return err
|
return result.Error
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update lastTrafficResetTime for the inbound(s)
|
||||||
|
inboundWhereText := "id "
|
||||||
|
if id == -1 {
|
||||||
|
inboundWhereText += " > ?"
|
||||||
|
} else {
|
||||||
|
inboundWhereText += " = ?"
|
||||||
|
}
|
||||||
|
|
||||||
|
result = tx.Model(model.Inbound{}).
|
||||||
|
Where(inboundWhereText, id).
|
||||||
|
Update("last_traffic_reset_time", now)
|
||||||
|
|
||||||
|
return result.Error
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *InboundService) ResetAllTraffics() error {
|
func (s *InboundService) ResetAllTraffics() error {
|
||||||
|
|
@ -1804,8 +1837,14 @@ func (s *InboundService) DelDepletedClients(id int) (err error) {
|
||||||
whereText += "= ?"
|
whereText += "= ?"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only consider truly depleted clients: expired OR traffic exhausted
|
||||||
|
now := time.Now().Unix() * 1000
|
||||||
depletedClients := []xray.ClientTraffic{}
|
depletedClients := []xray.ClientTraffic{}
|
||||||
err = db.Model(xray.ClientTraffic{}).Where(whereText+" and enable = ?", id, false).Select("inbound_id, GROUP_CONCAT(email) as email").Group("inbound_id").Find(&depletedClients).Error
|
err = db.Model(xray.ClientTraffic{}).
|
||||||
|
Where(whereText+" and ((total > 0 and up + down >= total) or (expiry_time > 0 and expiry_time <= ?))", id, now).
|
||||||
|
Select("inbound_id, GROUP_CONCAT(email) as email").
|
||||||
|
Group("inbound_id").
|
||||||
|
Find(&depletedClients).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -1856,7 +1895,8 @@ func (s *InboundService) DelDepletedClients(id int) (err error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = tx.Where(whereText+" and enable = ?", id, false).Delete(xray.ClientTraffic{}).Error
|
// Delete stats only for truly depleted clients
|
||||||
|
err = tx.Where(whereText+" and ((total > 0 and up + down >= total) or (expiry_time > 0 and expiry_time <= ?))", id, now).Delete(xray.ClientTraffic{}).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -1904,18 +1944,17 @@ func (s *InboundService) GetClientTrafficTgBot(tgId int64) ([]*xray.ClientTraffi
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *InboundService) GetClientTrafficByEmail(email string) (traffic *xray.ClientTraffic, err error) {
|
func (s *InboundService) GetClientTrafficByEmail(email string) (traffic *xray.ClientTraffic, err error) {
|
||||||
db := database.GetDB()
|
// Prefer retrieving along with client to reflect actual enabled state from inbound settings
|
||||||
var traffics []*xray.ClientTraffic
|
t, client, err := s.GetClientByEmail(email)
|
||||||
|
|
||||||
err = db.Model(xray.ClientTraffic{}).Where("email = ?", email).Find(&traffics).Error
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Warningf("Error retrieving ClientTraffic with email %s: %v", email, err)
|
logger.Warningf("Error retrieving ClientTraffic with email %s: %v", email, err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(traffics) > 0 {
|
if t != nil && client != nil {
|
||||||
return traffics[0], nil
|
// Ensure enable mirrors the client's current enable flag in settings
|
||||||
|
t.Enable = client.Enable
|
||||||
|
return t, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1950,6 +1989,12 @@ func (s *InboundService) GetClientTrafficByID(id string) ([]xray.ClientTraffic,
|
||||||
logger.Debug(err)
|
logger.Debug(err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
// Reconcile enable flag with client settings per email to avoid stale DB value
|
||||||
|
for i := range traffics {
|
||||||
|
if ct, client, e := s.GetClientByEmail(traffics[i].Email); e == nil && ct != nil && client != nil {
|
||||||
|
traffics[i].Enable = client.Enable
|
||||||
|
}
|
||||||
|
}
|
||||||
return traffics, err
|
return traffics, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ import (
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"x-ui/config"
|
"x-ui/config"
|
||||||
|
|
@ -98,6 +99,20 @@ type ServerService struct {
|
||||||
cachedIPv4 string
|
cachedIPv4 string
|
||||||
cachedIPv6 string
|
cachedIPv6 string
|
||||||
noIPv6 bool
|
noIPv6 bool
|
||||||
|
// CPU utilization smoothing state
|
||||||
|
mu sync.Mutex
|
||||||
|
lastCPUTimes cpu.TimesStat
|
||||||
|
hasLastCPUSample bool
|
||||||
|
emaCPU float64
|
||||||
|
// CPU history buffer (in-memory, protected by mu)
|
||||||
|
cpuHistory []CPUSample
|
||||||
|
cpuCapacity int
|
||||||
|
}
|
||||||
|
|
||||||
|
// CPUSample represents a single CPU utilization sample with timestamp
|
||||||
|
type CPUSample struct {
|
||||||
|
T int64 `json:"t"` // unix seconds
|
||||||
|
Cpu float64 `json:"cpu"` // percent 0..100
|
||||||
}
|
}
|
||||||
|
|
||||||
type LogEntry struct {
|
type LogEntry struct {
|
||||||
|
|
@ -149,11 +164,11 @@ func (s *ServerService) GetStatus(lastStatus *Status) *Status {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CPU stats
|
// CPU stats
|
||||||
percents, err := cpu.Percent(0, false)
|
util, err := s.sampleCPUUtilization()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Warning("get cpu percent failed:", err)
|
logger.Warning("get cpu percent failed:", err)
|
||||||
} else {
|
} else {
|
||||||
status.Cpu = percents[0]
|
status.Cpu = util
|
||||||
}
|
}
|
||||||
|
|
||||||
status.CpuCores, err = cpu.Counts(false)
|
status.CpuCores, err = cpu.Counts(false)
|
||||||
|
|
@ -317,6 +332,137 @@ func (s *ServerService) GetStatus(lastStatus *Status) *Status {
|
||||||
return status
|
return status
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AppendCpuSample appends a CPU sample into the in-memory history with capacity trimming.
|
||||||
|
func (s *ServerService) AppendCpuSample(t time.Time, v float64) {
|
||||||
|
s.mu.Lock()
|
||||||
|
defer s.mu.Unlock()
|
||||||
|
if s.cpuCapacity == 0 {
|
||||||
|
s.cpuCapacity = 10800 // ~6 hours at 2s per sample
|
||||||
|
}
|
||||||
|
p := CPUSample{T: t.Unix(), Cpu: v}
|
||||||
|
s.cpuHistory = append(s.cpuHistory, p)
|
||||||
|
if len(s.cpuHistory) > s.cpuCapacity {
|
||||||
|
drop := len(s.cpuHistory) - s.cpuCapacity
|
||||||
|
s.cpuHistory = s.cpuHistory[drop:]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCpuHistory returns samples from the last 'mins' minutes (bounded 1..360).
|
||||||
|
func (s *ServerService) GetCpuHistory(mins int) []CPUSample {
|
||||||
|
if mins < 1 {
|
||||||
|
mins = 1
|
||||||
|
}
|
||||||
|
if mins > 360 {
|
||||||
|
mins = 360
|
||||||
|
}
|
||||||
|
cutoff := time.Now().Add(-time.Duration(mins) * time.Minute).Unix()
|
||||||
|
s.mu.Lock()
|
||||||
|
defer s.mu.Unlock()
|
||||||
|
if len(s.cpuHistory) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
// find first index >= cutoff (linear scan from end is fine for these sizes)
|
||||||
|
i := len(s.cpuHistory) - 1
|
||||||
|
for ; i >= 0; i-- {
|
||||||
|
if s.cpuHistory[i].T < cutoff {
|
||||||
|
i++
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if i < 0 {
|
||||||
|
i = 0
|
||||||
|
}
|
||||||
|
// copy to avoid exposing internal slice
|
||||||
|
out := make([]CPUSample, len(s.cpuHistory)-i)
|
||||||
|
copy(out, s.cpuHistory[i:])
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// sampleCPUUtilization returns a smoothed total CPU utilization percentage across all logical processors.
|
||||||
|
// It computes utilization from CPU time deltas (non-blocking) and applies an exponential moving average
|
||||||
|
// to reduce spikes similar to Task Manager's smoothing.
|
||||||
|
func (s *ServerService) sampleCPUUtilization() (float64, error) {
|
||||||
|
// Prefer native Windows API to avoid external deps for CPU percent
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
if pct, err := sys.CPUPercentRaw(); err == nil {
|
||||||
|
s.mu.Lock()
|
||||||
|
// Smooth with EMA
|
||||||
|
const alpha = 0.3
|
||||||
|
if s.emaCPU == 0 {
|
||||||
|
s.emaCPU = pct
|
||||||
|
} else {
|
||||||
|
s.emaCPU = alpha*pct + (1-alpha)*s.emaCPU
|
||||||
|
}
|
||||||
|
val := s.emaCPU
|
||||||
|
s.mu.Unlock()
|
||||||
|
return val, nil
|
||||||
|
}
|
||||||
|
// If native call fails, fall back to gopsutil times
|
||||||
|
}
|
||||||
|
// Read aggregate CPU times (all CPUs combined)
|
||||||
|
times, err := cpu.Times(false)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
if len(times) == 0 {
|
||||||
|
return 0, fmt.Errorf("no cpu times available")
|
||||||
|
}
|
||||||
|
|
||||||
|
cur := times[0]
|
||||||
|
|
||||||
|
s.mu.Lock()
|
||||||
|
defer s.mu.Unlock()
|
||||||
|
|
||||||
|
// If this is the first sample, initialize and return current EMA (0 by default)
|
||||||
|
if !s.hasLastCPUSample {
|
||||||
|
s.lastCPUTimes = cur
|
||||||
|
s.hasLastCPUSample = true
|
||||||
|
return s.emaCPU, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compute busy and total deltas
|
||||||
|
idleDelta := cur.Idle - s.lastCPUTimes.Idle
|
||||||
|
// Sum of busy deltas (exclude Idle)
|
||||||
|
busyDelta := (cur.User - s.lastCPUTimes.User) +
|
||||||
|
(cur.System - s.lastCPUTimes.System) +
|
||||||
|
(cur.Nice - s.lastCPUTimes.Nice) +
|
||||||
|
(cur.Iowait - s.lastCPUTimes.Iowait) +
|
||||||
|
(cur.Irq - s.lastCPUTimes.Irq) +
|
||||||
|
(cur.Softirq - s.lastCPUTimes.Softirq) +
|
||||||
|
(cur.Steal - s.lastCPUTimes.Steal) +
|
||||||
|
(cur.Guest - s.lastCPUTimes.Guest) +
|
||||||
|
(cur.GuestNice - s.lastCPUTimes.GuestNice)
|
||||||
|
|
||||||
|
totalDelta := busyDelta + idleDelta
|
||||||
|
|
||||||
|
// Update last sample for next time
|
||||||
|
s.lastCPUTimes = cur
|
||||||
|
|
||||||
|
// Guard against division by zero or negative deltas (e.g., counter resets)
|
||||||
|
if totalDelta <= 0 {
|
||||||
|
return s.emaCPU, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
raw := 100.0 * (busyDelta / totalDelta)
|
||||||
|
if raw < 0 {
|
||||||
|
raw = 0
|
||||||
|
}
|
||||||
|
if raw > 100 {
|
||||||
|
raw = 100
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exponential moving average to smooth spikes
|
||||||
|
const alpha = 0.3 // smoothing factor (0<alpha<=1). Higher = more responsive, lower = smoother
|
||||||
|
if s.emaCPU == 0 {
|
||||||
|
// Initialize EMA with the first real reading to avoid long warm-up from zero
|
||||||
|
s.emaCPU = raw
|
||||||
|
} else {
|
||||||
|
s.emaCPU = alpha*raw + (1-alpha)*s.emaCPU
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.emaCPU, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *ServerService) GetXrayVersions() ([]string, error) {
|
func (s *ServerService) GetXrayVersions() ([]string, error) {
|
||||||
const (
|
const (
|
||||||
XrayURL = "https://api.github.com/repos/XTLS/Xray-core/releases"
|
XrayURL = "https://api.github.com/repos/XTLS/Xray-core/releases"
|
||||||
|
|
|
||||||
|
|
@ -548,6 +548,57 @@ func (t *Tgbot) answerCallback(callbackQuery *telego.CallbackQuery, isAdmin bool
|
||||||
if len(dataArray) >= 2 && len(dataArray[1]) > 0 {
|
if len(dataArray) >= 2 && len(dataArray[1]) > 0 {
|
||||||
email := dataArray[1]
|
email := dataArray[1]
|
||||||
switch dataArray[0] {
|
switch dataArray[0] {
|
||||||
|
case "get_clients_for_sub":
|
||||||
|
inboundId := dataArray[1]
|
||||||
|
inboundIdInt, err := strconv.Atoi(inboundId)
|
||||||
|
if err != nil {
|
||||||
|
t.sendCallbackAnswerTgBot(callbackQuery.ID, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
clientsKB, err := t.getInboundClientsFor(inboundIdInt, "client_sub_links")
|
||||||
|
if err != nil {
|
||||||
|
t.sendCallbackAnswerTgBot(callbackQuery.ID, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
inbound, _ := t.inboundService.GetInbound(inboundIdInt)
|
||||||
|
t.SendMsgToTgbot(chatId, t.I18nBot("tgbot.answers.chooseClient", "Inbound=="+inbound.Remark), clientsKB)
|
||||||
|
case "get_clients_for_individual":
|
||||||
|
inboundId := dataArray[1]
|
||||||
|
inboundIdInt, err := strconv.Atoi(inboundId)
|
||||||
|
if err != nil {
|
||||||
|
t.sendCallbackAnswerTgBot(callbackQuery.ID, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
clientsKB, err := t.getInboundClientsFor(inboundIdInt, "client_individual_links")
|
||||||
|
if err != nil {
|
||||||
|
t.sendCallbackAnswerTgBot(callbackQuery.ID, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
inbound, _ := t.inboundService.GetInbound(inboundIdInt)
|
||||||
|
t.SendMsgToTgbot(chatId, t.I18nBot("tgbot.answers.chooseClient", "Inbound=="+inbound.Remark), clientsKB)
|
||||||
|
case "get_clients_for_qr":
|
||||||
|
inboundId := dataArray[1]
|
||||||
|
inboundIdInt, err := strconv.Atoi(inboundId)
|
||||||
|
if err != nil {
|
||||||
|
t.sendCallbackAnswerTgBot(callbackQuery.ID, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
clientsKB, err := t.getInboundClientsFor(inboundIdInt, "client_qr_links")
|
||||||
|
if err != nil {
|
||||||
|
t.sendCallbackAnswerTgBot(callbackQuery.ID, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
inbound, _ := t.inboundService.GetInbound(inboundIdInt)
|
||||||
|
t.SendMsgToTgbot(chatId, t.I18nBot("tgbot.answers.chooseClient", "Inbound=="+inbound.Remark), clientsKB)
|
||||||
|
case "client_sub_links":
|
||||||
|
t.sendClientSubLinks(chatId, email)
|
||||||
|
return
|
||||||
|
case "client_individual_links":
|
||||||
|
t.sendClientIndividualLinks(chatId, email)
|
||||||
|
return
|
||||||
|
case "client_qr_links":
|
||||||
|
t.sendClientQRLinks(chatId, email)
|
||||||
|
return
|
||||||
case "client_get_usage":
|
case "client_get_usage":
|
||||||
t.sendCallbackAnswerTgBot(callbackQuery.ID, t.I18nBot("tgbot.messages.email", "Email=="+email))
|
t.sendCallbackAnswerTgBot(callbackQuery.ID, t.I18nBot("tgbot.messages.email", "Email=="+email))
|
||||||
t.searchClient(chatId, email)
|
t.searchClient(chatId, email)
|
||||||
|
|
@ -1327,6 +1378,27 @@ func (t *Tgbot) answerCallback(callbackQuery *telego.CallbackQuery, isAdmin bool
|
||||||
}
|
}
|
||||||
t.sendCallbackAnswerTgBot(callbackQuery.ID, t.I18nBot("tgbot.buttons.allClients"))
|
t.sendCallbackAnswerTgBot(callbackQuery.ID, t.I18nBot("tgbot.buttons.allClients"))
|
||||||
t.SendMsgToTgbot(chatId, t.I18nBot("tgbot.answers.chooseInbound"), inbounds)
|
t.SendMsgToTgbot(chatId, t.I18nBot("tgbot.answers.chooseInbound"), inbounds)
|
||||||
|
case "admin_client_sub_links":
|
||||||
|
inbounds, err := t.getInboundsFor("get_clients_for_sub")
|
||||||
|
if err != nil {
|
||||||
|
t.sendCallbackAnswerTgBot(callbackQuery.ID, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
t.SendMsgToTgbot(chatId, t.I18nBot("tgbot.answers.chooseInbound"), inbounds)
|
||||||
|
case "admin_client_individual_links":
|
||||||
|
inbounds, err := t.getInboundsFor("get_clients_for_individual")
|
||||||
|
if err != nil {
|
||||||
|
t.sendCallbackAnswerTgBot(callbackQuery.ID, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
t.SendMsgToTgbot(chatId, t.I18nBot("tgbot.answers.chooseInbound"), inbounds)
|
||||||
|
case "admin_client_qr_links":
|
||||||
|
inbounds, err := t.getInboundsFor("get_clients_for_qr")
|
||||||
|
if err != nil {
|
||||||
|
t.sendCallbackAnswerTgBot(callbackQuery.ID, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
t.SendMsgToTgbot(chatId, t.I18nBot("tgbot.answers.chooseInbound"), inbounds)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1927,6 +1999,11 @@ func (t *Tgbot) SendAnswer(chatId int64, msg string, isAdmin bool) {
|
||||||
tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.allClients")).WithCallbackData(t.encodeQuery("get_inbounds")),
|
tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.allClients")).WithCallbackData(t.encodeQuery("get_inbounds")),
|
||||||
tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.addClient")).WithCallbackData(t.encodeQuery("add_client")),
|
tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.addClient")).WithCallbackData(t.encodeQuery("add_client")),
|
||||||
),
|
),
|
||||||
|
tu.InlineKeyboardRow(
|
||||||
|
tu.InlineKeyboardButton(t.I18nBot("pages.settings.subSettings")).WithCallbackData(t.encodeQuery("admin_client_sub_links")),
|
||||||
|
tu.InlineKeyboardButton(t.I18nBot("subscription.individualLinks")).WithCallbackData(t.encodeQuery("admin_client_individual_links")),
|
||||||
|
tu.InlineKeyboardButton(t.I18nBot("qrCode")).WithCallbackData(t.encodeQuery("admin_client_qr_links")),
|
||||||
|
),
|
||||||
// TODOOOOOOOOOOOOOO: Add restart button here.
|
// TODOOOOOOOOOOOOOO: Add restart button here.
|
||||||
)
|
)
|
||||||
numericKeyboardClient := tu.InlineKeyboard(
|
numericKeyboardClient := tu.InlineKeyboard(
|
||||||
|
|
@ -2075,6 +2152,9 @@ func (t *Tgbot) sendClientSubLinks(chatId int64, email string) {
|
||||||
tu.InlineKeyboardRow(
|
tu.InlineKeyboardRow(
|
||||||
tu.InlineKeyboardButton(t.I18nBot("subscription.individualLinks")).WithCallbackData(t.encodeQuery("client_individual_links "+email)),
|
tu.InlineKeyboardButton(t.I18nBot("subscription.individualLinks")).WithCallbackData(t.encodeQuery("client_individual_links "+email)),
|
||||||
),
|
),
|
||||||
|
tu.InlineKeyboardRow(
|
||||||
|
tu.InlineKeyboardButton(t.I18nBot("qrCode")).WithCallbackData(t.encodeQuery("client_qr_links "+email)),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
t.SendMsgToTgbot(chatId, msg, inlineKeyboard)
|
t.SendMsgToTgbot(chatId, msg, inlineKeyboard)
|
||||||
}
|
}
|
||||||
|
|
@ -2459,6 +2539,74 @@ func (t *Tgbot) getInbounds() (*telego.InlineKeyboardMarkup, error) {
|
||||||
return keyboard, nil
|
return keyboard, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getInboundsFor builds an inline keyboard of inbounds where each button leads to a custom next action
|
||||||
|
// nextAction should be one of: get_clients_for_sub|get_clients_for_individual|get_clients_for_qr
|
||||||
|
func (t *Tgbot) getInboundsFor(nextAction string) (*telego.InlineKeyboardMarkup, error) {
|
||||||
|
inbounds, err := t.inboundService.GetAllInbounds()
|
||||||
|
if err != nil {
|
||||||
|
logger.Warning("GetAllInbounds run failed:", err)
|
||||||
|
return nil, errors.New(t.I18nBot("tgbot.answers.getInboundsFailed"))
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(inbounds) == 0 {
|
||||||
|
logger.Warning("No inbounds found")
|
||||||
|
return nil, errors.New(t.I18nBot("tgbot.answers.getInboundsFailed"))
|
||||||
|
}
|
||||||
|
|
||||||
|
var buttons []telego.InlineKeyboardButton
|
||||||
|
for _, inbound := range inbounds {
|
||||||
|
status := "❌"
|
||||||
|
if inbound.Enable {
|
||||||
|
status = "✅"
|
||||||
|
}
|
||||||
|
callbackData := t.encodeQuery(fmt.Sprintf("%s %d", nextAction, inbound.Id))
|
||||||
|
buttons = append(buttons, tu.InlineKeyboardButton(fmt.Sprintf("%v - %v", inbound.Remark, status)).WithCallbackData(callbackData))
|
||||||
|
}
|
||||||
|
|
||||||
|
cols := 1
|
||||||
|
if len(buttons) >= 6 {
|
||||||
|
cols = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
keyboard := tu.InlineKeyboardGrid(tu.InlineKeyboardCols(cols, buttons...))
|
||||||
|
return keyboard, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// getInboundClientsFor lists clients of an inbound with a specific action prefix to be appended with email
|
||||||
|
func (t *Tgbot) getInboundClientsFor(inboundID int, action string) (*telego.InlineKeyboardMarkup, error) {
|
||||||
|
inbound, err := t.inboundService.GetInbound(inboundID)
|
||||||
|
if err != nil {
|
||||||
|
logger.Warning("getInboundClientsFor run failed:", err)
|
||||||
|
return nil, errors.New(t.I18nBot("tgbot.answers.getInboundsFailed"))
|
||||||
|
}
|
||||||
|
clients, err := t.inboundService.GetClients(inbound)
|
||||||
|
var buttons []telego.InlineKeyboardButton
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logger.Warning("GetInboundClients run failed:", err)
|
||||||
|
return nil, errors.New(t.I18nBot("tgbot.answers.getInboundsFailed"))
|
||||||
|
} else {
|
||||||
|
if len(clients) > 0 {
|
||||||
|
for _, client := range clients {
|
||||||
|
buttons = append(buttons, tu.InlineKeyboardButton(client.Email).WithCallbackData(t.encodeQuery(action+" "+client.Email)))
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return nil, errors.New(t.I18nBot("tgbot.answers.getClientsFailed"))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
cols := 0
|
||||||
|
if len(buttons) < 6 {
|
||||||
|
cols = 3
|
||||||
|
} else {
|
||||||
|
cols = 2
|
||||||
|
}
|
||||||
|
keyboard := tu.InlineKeyboardGrid(tu.InlineKeyboardCols(cols, buttons...))
|
||||||
|
|
||||||
|
return keyboard, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (t *Tgbot) getInboundsAddClient() (*telego.InlineKeyboardMarkup, error) {
|
func (t *Tgbot) getInboundsAddClient() (*telego.InlineKeyboardMarkup, error) {
|
||||||
inbounds, err := t.inboundService.GetAllInbounds()
|
inbounds, err := t.inboundService.GetAllInbounds()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -244,6 +244,9 @@
|
||||||
"exportInbound" = "تصدير الإدخال"
|
"exportInbound" = "تصدير الإدخال"
|
||||||
"import" = "استيراد"
|
"import" = "استيراد"
|
||||||
"importInbound" = "استيراد إدخال"
|
"importInbound" = "استيراد إدخال"
|
||||||
|
"periodicTrafficResetTitle" = "إعادة تعيين حركة المرور"
|
||||||
|
"periodicTrafficResetDesc" = "إعادة تعيين عداد حركة المرور تلقائيًا في فترات محددة"
|
||||||
|
"lastReset" = "آخر إعادة تعيين"
|
||||||
|
|
||||||
[pages.client]
|
[pages.client]
|
||||||
"add" = "أضف عميل"
|
"add" = "أضف عميل"
|
||||||
|
|
@ -263,6 +266,12 @@
|
||||||
"renew" = "تجديد تلقائي"
|
"renew" = "تجديد تلقائي"
|
||||||
"renewDesc" = "تجديد تلقائي بعد انتهاء الصلاحية. (0 = تعطيل)(الوحدة: يوم)"
|
"renewDesc" = "تجديد تلقائي بعد انتهاء الصلاحية. (0 = تعطيل)(الوحدة: يوم)"
|
||||||
|
|
||||||
|
[pages.inbounds.periodicTrafficReset]
|
||||||
|
"never" = "أبداً"
|
||||||
|
"daily" = "يومياً"
|
||||||
|
"weekly" = "أسبوعياً"
|
||||||
|
"monthly" = "شهرياً"
|
||||||
|
|
||||||
[pages.inbounds.toasts]
|
[pages.inbounds.toasts]
|
||||||
"obtain" = "تم الحصول عليه"
|
"obtain" = "تم الحصول عليه"
|
||||||
"updateSuccess" = "تم التحديث بنجاح"
|
"updateSuccess" = "تم التحديث بنجاح"
|
||||||
|
|
|
||||||
|
|
@ -244,6 +244,9 @@
|
||||||
"exportInbound" = "Export Inbound"
|
"exportInbound" = "Export Inbound"
|
||||||
"import" = "Import"
|
"import" = "Import"
|
||||||
"importInbound" = "Import an Inbound"
|
"importInbound" = "Import an Inbound"
|
||||||
|
"periodicTrafficResetTitle" = "Traffic Reset"
|
||||||
|
"periodicTrafficResetDesc" = "Automatically reset traffic counter at specified intervals"
|
||||||
|
"lastReset" = "Last Reset"
|
||||||
|
|
||||||
[pages.client]
|
[pages.client]
|
||||||
"add" = "Add Client"
|
"add" = "Add Client"
|
||||||
|
|
@ -263,6 +266,12 @@
|
||||||
"renew" = "Auto Renew"
|
"renew" = "Auto Renew"
|
||||||
"renewDesc" = "Auto-renewal after expiration. (0 = disable)(unit: day)"
|
"renewDesc" = "Auto-renewal after expiration. (0 = disable)(unit: day)"
|
||||||
|
|
||||||
|
[pages.inbounds.periodicTrafficReset]
|
||||||
|
"never" = "Never"
|
||||||
|
"daily" = "Daily"
|
||||||
|
"weekly" = "Weekly"
|
||||||
|
"monthly" = "Monthly"
|
||||||
|
|
||||||
[pages.inbounds.toasts]
|
[pages.inbounds.toasts]
|
||||||
"obtain" = "Obtain"
|
"obtain" = "Obtain"
|
||||||
"updateSuccess" = "The update was successful."
|
"updateSuccess" = "The update was successful."
|
||||||
|
|
|
||||||
|
|
@ -244,6 +244,9 @@
|
||||||
"exportInbound" = "Exportación entrante"
|
"exportInbound" = "Exportación entrante"
|
||||||
"import" = "Importar"
|
"import" = "Importar"
|
||||||
"importInbound" = "Importar un entrante"
|
"importInbound" = "Importar un entrante"
|
||||||
|
"periodicTrafficResetTitle" = "Reset de Tráfico"
|
||||||
|
"periodicTrafficResetDesc" = "Reiniciar automáticamente el contador de tráfico en intervalos especificados"
|
||||||
|
"lastReset" = "Último reinicio"
|
||||||
|
|
||||||
[pages.client]
|
[pages.client]
|
||||||
"add" = "Agregar Cliente"
|
"add" = "Agregar Cliente"
|
||||||
|
|
@ -263,6 +266,12 @@
|
||||||
"renew" = "Renovación automática"
|
"renew" = "Renovación automática"
|
||||||
"renewDesc" = "Renovación automática después de la expiración. (0 = desactivar) (unidad: día)"
|
"renewDesc" = "Renovación automática después de la expiración. (0 = desactivar) (unidad: día)"
|
||||||
|
|
||||||
|
[pages.inbounds.periodicTrafficReset]
|
||||||
|
"never" = "Nunca"
|
||||||
|
"daily" = "Diariamente"
|
||||||
|
"weekly" = "Semanalmente"
|
||||||
|
"monthly" = "Mensualmente"
|
||||||
|
|
||||||
[pages.inbounds.toasts]
|
[pages.inbounds.toasts]
|
||||||
"obtain" = "Recibir"
|
"obtain" = "Recibir"
|
||||||
"updateSuccess" = "La actualización fue exitosa"
|
"updateSuccess" = "La actualización fue exitosa"
|
||||||
|
|
|
||||||
|
|
@ -244,6 +244,9 @@
|
||||||
"exportInbound" = "استخراج ورودی"
|
"exportInbound" = "استخراج ورودی"
|
||||||
"import" = "افزودن"
|
"import" = "افزودن"
|
||||||
"importInbound" = "افزودن یک ورودی"
|
"importInbound" = "افزودن یک ورودی"
|
||||||
|
"periodicTrafficResetTitle" = "بازنشانی ترافیک"
|
||||||
|
"periodicTrafficResetDesc" = "بازنشانی خودکار شمارنده ترافیک در فواصل زمانی مشخص"
|
||||||
|
"lastReset" = "آخرین بازنشانی"
|
||||||
|
|
||||||
[pages.client]
|
[pages.client]
|
||||||
"add" = "کاربر جدید"
|
"add" = "کاربر جدید"
|
||||||
|
|
@ -261,7 +264,13 @@
|
||||||
"expireDays" = "مدت زمان"
|
"expireDays" = "مدت زمان"
|
||||||
"days" = "(روز)"
|
"days" = "(روز)"
|
||||||
"renew" = "تمدید خودکار"
|
"renew" = "تمدید خودکار"
|
||||||
"renewDesc" = "(تمدید خودکار پساز انقضا. (0 = غیرفعال)(واحد: روز"
|
"renewDesc" = "تمدید خودکار پساز انقضا. (0 = غیرفعال)(واحد: روز)"
|
||||||
|
|
||||||
|
[pages.inbounds.periodicTrafficReset]
|
||||||
|
"never" = "هرگز"
|
||||||
|
"daily" = "روزانه"
|
||||||
|
"weekly" = "هفتگی"
|
||||||
|
"monthly" = "ماهانه"
|
||||||
|
|
||||||
[pages.inbounds.toasts]
|
[pages.inbounds.toasts]
|
||||||
"obtain" = "فراهمسازی"
|
"obtain" = "فراهمسازی"
|
||||||
|
|
|
||||||
|
|
@ -244,6 +244,9 @@
|
||||||
"exportInbound" = "Ekspor Masuk"
|
"exportInbound" = "Ekspor Masuk"
|
||||||
"import" = "Impor"
|
"import" = "Impor"
|
||||||
"importInbound" = "Impor Masuk"
|
"importInbound" = "Impor Masuk"
|
||||||
|
"periodicTrafficResetTitle" = "Reset Trafik Berkala"
|
||||||
|
"periodicTrafficResetDesc" = "Reset otomatis penghitung trafik pada interval tertentu"
|
||||||
|
"lastReset" = "Reset Terakhir"
|
||||||
|
|
||||||
[pages.client]
|
[pages.client]
|
||||||
"add" = "Tambah Klien"
|
"add" = "Tambah Klien"
|
||||||
|
|
@ -263,6 +266,12 @@
|
||||||
"renew" = "Perpanjang Otomatis"
|
"renew" = "Perpanjang Otomatis"
|
||||||
"renewDesc" = "Perpanjangan otomatis setelah kedaluwarsa. (0 = nonaktif)(unit: hari)"
|
"renewDesc" = "Perpanjangan otomatis setelah kedaluwarsa. (0 = nonaktif)(unit: hari)"
|
||||||
|
|
||||||
|
[pages.inbounds.periodicTrafficReset]
|
||||||
|
"never" = "Tidak Pernah"
|
||||||
|
"daily" = "Harian"
|
||||||
|
"weekly" = "Mingguan"
|
||||||
|
"monthly" = "Bulanan"
|
||||||
|
|
||||||
[pages.inbounds.toasts]
|
[pages.inbounds.toasts]
|
||||||
"obtain" = "Dapatkan"
|
"obtain" = "Dapatkan"
|
||||||
"updateSuccess" = "Pembaruan berhasil"
|
"updateSuccess" = "Pembaruan berhasil"
|
||||||
|
|
|
||||||
|
|
@ -244,6 +244,9 @@
|
||||||
"exportInbound" = "インバウンドルールをエクスポート"
|
"exportInbound" = "インバウンドルールをエクスポート"
|
||||||
"import" = "インポート"
|
"import" = "インポート"
|
||||||
"importInbound" = "インバウンドルールをインポート"
|
"importInbound" = "インバウンドルールをインポート"
|
||||||
|
"periodicTrafficResetTitle" = "トラフィックリセット"
|
||||||
|
"periodicTrafficResetDesc" = "指定された間隔でトラフィックカウンタを自動的にリセット"
|
||||||
|
"lastReset" = "最後のリセット"
|
||||||
|
|
||||||
[pages.client]
|
[pages.client]
|
||||||
"add" = "クライアント追加"
|
"add" = "クライアント追加"
|
||||||
|
|
@ -263,6 +266,12 @@
|
||||||
"renew" = "自動更新"
|
"renew" = "自動更新"
|
||||||
"renewDesc" = "期限が切れた後に自動更新。(0 = 無効)(単位:日)"
|
"renewDesc" = "期限が切れた後に自動更新。(0 = 無効)(単位:日)"
|
||||||
|
|
||||||
|
[pages.inbounds.periodicTrafficReset]
|
||||||
|
"never" = "なし"
|
||||||
|
"daily" = "毎日"
|
||||||
|
"weekly" = "毎週"
|
||||||
|
"monthly" = "毎月"
|
||||||
|
|
||||||
[pages.inbounds.toasts]
|
[pages.inbounds.toasts]
|
||||||
"obtain" = "取得"
|
"obtain" = "取得"
|
||||||
"updateSuccess" = "更新が成功しました"
|
"updateSuccess" = "更新が成功しました"
|
||||||
|
|
|
||||||
|
|
@ -244,6 +244,9 @@
|
||||||
"exportInbound" = "Exportar Inbound"
|
"exportInbound" = "Exportar Inbound"
|
||||||
"import" = "Importar"
|
"import" = "Importar"
|
||||||
"importInbound" = "Importar um Inbound"
|
"importInbound" = "Importar um Inbound"
|
||||||
|
"periodicTrafficResetTitle" = "Reset de Tráfego"
|
||||||
|
"periodicTrafficResetDesc" = "Reinicia automaticamente o contador de tráfego em intervalos especificados"
|
||||||
|
"lastReset" = "Último Reset"
|
||||||
|
|
||||||
[pages.client]
|
[pages.client]
|
||||||
"add" = "Adicionar Cliente"
|
"add" = "Adicionar Cliente"
|
||||||
|
|
@ -263,6 +266,12 @@
|
||||||
"renew" = "Renovação Automática"
|
"renew" = "Renovação Automática"
|
||||||
"renewDesc" = "Renovação automática após expiração. (0 = desativado)(unidade: dia)"
|
"renewDesc" = "Renovação automática após expiração. (0 = desativado)(unidade: dia)"
|
||||||
|
|
||||||
|
[pages.inbounds.periodicTrafficReset]
|
||||||
|
"never" = "Nunca"
|
||||||
|
"daily" = "Diariamente"
|
||||||
|
"weekly" = "Semanalmente"
|
||||||
|
"monthly" = "Mensalmente"
|
||||||
|
|
||||||
[pages.inbounds.toasts]
|
[pages.inbounds.toasts]
|
||||||
"obtain" = "Obter"
|
"obtain" = "Obter"
|
||||||
"updateSuccess" = "A atualização foi bem-sucedida"
|
"updateSuccess" = "A atualização foi bem-sucedida"
|
||||||
|
|
|
||||||
|
|
@ -244,6 +244,9 @@
|
||||||
"exportInbound" = "Экспорт инбаундов"
|
"exportInbound" = "Экспорт инбаундов"
|
||||||
"import" = "Импортировать"
|
"import" = "Импортировать"
|
||||||
"importInbound" = "Импорт инбаундов"
|
"importInbound" = "Импорт инбаундов"
|
||||||
|
"periodicTrafficResetTitle" = "Сброс трафика"
|
||||||
|
"periodicTrafficResetDesc" = "Автоматический сброс счетчика трафика через указанные интервалы"
|
||||||
|
"lastReset" = "Последний сброс"
|
||||||
|
|
||||||
[pages.client]
|
[pages.client]
|
||||||
"add" = "Создать клиента"
|
"add" = "Создать клиента"
|
||||||
|
|
@ -263,6 +266,12 @@
|
||||||
"renew" = "Автопродление"
|
"renew" = "Автопродление"
|
||||||
"renewDesc" = "Автопродление после истечения срока действия. (0 = отключить)(единица: день)"
|
"renewDesc" = "Автопродление после истечения срока действия. (0 = отключить)(единица: день)"
|
||||||
|
|
||||||
|
[pages.inbounds.periodicTrafficReset]
|
||||||
|
"never" = "Никогда"
|
||||||
|
"daily" = "Ежедневно"
|
||||||
|
"weekly" = "Еженедельно"
|
||||||
|
"monthly" = "Ежемесячно"
|
||||||
|
|
||||||
[pages.inbounds.toasts]
|
[pages.inbounds.toasts]
|
||||||
"obtain" = "Получить"
|
"obtain" = "Получить"
|
||||||
"updateSuccess" = "Обновление прошло успешно"
|
"updateSuccess" = "Обновление прошло успешно"
|
||||||
|
|
|
||||||
|
|
@ -244,6 +244,9 @@
|
||||||
"exportInbound" = "Geleni Dışa Aktar"
|
"exportInbound" = "Geleni Dışa Aktar"
|
||||||
"import" = "İçe Aktar"
|
"import" = "İçe Aktar"
|
||||||
"importInbound" = "Bir Gelen İçe Aktar"
|
"importInbound" = "Bir Gelen İçe Aktar"
|
||||||
|
"periodicTrafficResetTitle" = "Trafik Sıfırlama"
|
||||||
|
"periodicTrafficResetDesc" = "Belirtilen aralıklarla trafik sayacını otomatik olarak sıfırla"
|
||||||
|
"lastReset" = "Son Sıfırlama"
|
||||||
|
|
||||||
[pages.client]
|
[pages.client]
|
||||||
"add" = "Müşteri Ekle"
|
"add" = "Müşteri Ekle"
|
||||||
|
|
@ -263,6 +266,12 @@
|
||||||
"renew" = "Otomatik Yenile"
|
"renew" = "Otomatik Yenile"
|
||||||
"renewDesc" = "Süresi dolduktan sonra otomatik yenileme. (0 = devre dışı)(birim: gün)"
|
"renewDesc" = "Süresi dolduktan sonra otomatik yenileme. (0 = devre dışı)(birim: gün)"
|
||||||
|
|
||||||
|
[pages.inbounds.periodicTrafficReset]
|
||||||
|
"never" = "Asla"
|
||||||
|
"daily" = "Günlük"
|
||||||
|
"weekly" = "Haftalık"
|
||||||
|
"monthly" = "Aylık"
|
||||||
|
|
||||||
[pages.inbounds.toasts]
|
[pages.inbounds.toasts]
|
||||||
"obtain" = "Elde Et"
|
"obtain" = "Elde Et"
|
||||||
"updateSuccess" = "Güncelleme başarılı oldu"
|
"updateSuccess" = "Güncelleme başarılı oldu"
|
||||||
|
|
|
||||||
|
|
@ -244,6 +244,9 @@
|
||||||
"exportInbound" = "Експортувати вхідні"
|
"exportInbound" = "Експортувати вхідні"
|
||||||
"import" = "Імпорт"
|
"import" = "Імпорт"
|
||||||
"importInbound" = "Імпортувати вхідний"
|
"importInbound" = "Імпортувати вхідний"
|
||||||
|
"periodicTrafficResetTitle" = "Скидання трафіку"
|
||||||
|
"periodicTrafficResetDesc" = "Автоматично скидати лічильник трафіку через певні проміжки часу"
|
||||||
|
"lastReset" = "Останнє скидання"
|
||||||
|
|
||||||
[pages.client]
|
[pages.client]
|
||||||
"add" = "Додати клієнта"
|
"add" = "Додати клієнта"
|
||||||
|
|
@ -263,6 +266,12 @@
|
||||||
"renew" = "Автоматичне оновлення"
|
"renew" = "Автоматичне оновлення"
|
||||||
"renewDesc" = "Автоматичне поновлення після закінчення терміну дії. (0 = вимкнено)(одиниця: день)"
|
"renewDesc" = "Автоматичне поновлення після закінчення терміну дії. (0 = вимкнено)(одиниця: день)"
|
||||||
|
|
||||||
|
[pages.inbounds.periodicTrafficReset]
|
||||||
|
"never" = "Ніколи"
|
||||||
|
"daily" = "Щодня"
|
||||||
|
"weekly" = "Щотижня"
|
||||||
|
"monthly" = "Щомісяця"
|
||||||
|
|
||||||
[pages.inbounds.toasts]
|
[pages.inbounds.toasts]
|
||||||
"obtain" = "Отримати"
|
"obtain" = "Отримати"
|
||||||
"updateSuccess" = "Оновлення пройшло успішно"
|
"updateSuccess" = "Оновлення пройшло успішно"
|
||||||
|
|
|
||||||
|
|
@ -244,6 +244,9 @@
|
||||||
"exportInbound" = "Xuất nhập khẩu"
|
"exportInbound" = "Xuất nhập khẩu"
|
||||||
"import" = "Nhập"
|
"import" = "Nhập"
|
||||||
"importInbound" = "Nhập inbound"
|
"importInbound" = "Nhập inbound"
|
||||||
|
"periodicTrafficResetTitle" = "Đặt lại lưu lượng"
|
||||||
|
"periodicTrafficResetDesc" = "Tự động đặt lại bộ đếm lưu lượng theo khoảng thời gian xác định"
|
||||||
|
"lastReset" = "Đặt lại lần cuối"
|
||||||
|
|
||||||
[pages.client]
|
[pages.client]
|
||||||
"add" = "Thêm người dùng"
|
"add" = "Thêm người dùng"
|
||||||
|
|
@ -263,6 +266,12 @@
|
||||||
"renew" = "Tự động gia hạn"
|
"renew" = "Tự động gia hạn"
|
||||||
"renewDesc" = "Tự động gia hạn sau khi hết hạn. (0 = tắt)(đơn vị: ngày)"
|
"renewDesc" = "Tự động gia hạn sau khi hết hạn. (0 = tắt)(đơn vị: ngày)"
|
||||||
|
|
||||||
|
[pages.inbounds.periodicTrafficReset]
|
||||||
|
"never" = "Không bao giờ"
|
||||||
|
"daily" = "Hàng ngày"
|
||||||
|
"weekly" = "Hàng tuần"
|
||||||
|
"monthly" = "Hàng tháng"
|
||||||
|
|
||||||
[pages.inbounds.toasts]
|
[pages.inbounds.toasts]
|
||||||
"obtain" = "Nhận"
|
"obtain" = "Nhận"
|
||||||
"updateSuccess" = "Cập nhật thành công"
|
"updateSuccess" = "Cập nhật thành công"
|
||||||
|
|
|
||||||
|
|
@ -244,6 +244,9 @@
|
||||||
"exportInbound" = "导出入站规则"
|
"exportInbound" = "导出入站规则"
|
||||||
"import"="导入"
|
"import"="导入"
|
||||||
"importInbound" = "导入入站规则"
|
"importInbound" = "导入入站规则"
|
||||||
|
"periodicTrafficResetTitle" = "流量重置"
|
||||||
|
"periodicTrafficResetDesc" = "按指定间隔自动重置流量计数器"
|
||||||
|
"lastReset" = "上次重置"
|
||||||
|
|
||||||
[pages.client]
|
[pages.client]
|
||||||
"add" = "添加客户端"
|
"add" = "添加客户端"
|
||||||
|
|
@ -263,6 +266,12 @@
|
||||||
"renew" = "自动续订"
|
"renew" = "自动续订"
|
||||||
"renewDesc" = "到期后自动续订。(0 = 禁用)(单位: 天)"
|
"renewDesc" = "到期后自动续订。(0 = 禁用)(单位: 天)"
|
||||||
|
|
||||||
|
[pages.inbounds.periodicTrafficReset]
|
||||||
|
"never" = "从不"
|
||||||
|
"daily" = "每日"
|
||||||
|
"weekly" = "每周"
|
||||||
|
"monthly" = "每月"
|
||||||
|
|
||||||
[pages.inbounds.toasts]
|
[pages.inbounds.toasts]
|
||||||
"obtain" = "获取"
|
"obtain" = "获取"
|
||||||
"updateSuccess" = "更新成功"
|
"updateSuccess" = "更新成功"
|
||||||
|
|
|
||||||
|
|
@ -244,6 +244,9 @@
|
||||||
"exportInbound" = "匯出入站規則"
|
"exportInbound" = "匯出入站規則"
|
||||||
"import"="匯入"
|
"import"="匯入"
|
||||||
"importInbound" = "匯入入站規則"
|
"importInbound" = "匯入入站規則"
|
||||||
|
"periodicTrafficResetTitle" = "流量重置"
|
||||||
|
"periodicTrafficResetDesc" = "按指定間隔自動重置流量計數器"
|
||||||
|
"lastReset" = "上次重置"
|
||||||
|
|
||||||
[pages.client]
|
[pages.client]
|
||||||
"add" = "新增客戶端"
|
"add" = "新增客戶端"
|
||||||
|
|
@ -263,6 +266,12 @@
|
||||||
"renew" = "自動續訂"
|
"renew" = "自動續訂"
|
||||||
"renewDesc" = "到期後自動續訂。(0 = 禁用)(單位: 天)"
|
"renewDesc" = "到期後自動續訂。(0 = 禁用)(單位: 天)"
|
||||||
|
|
||||||
|
[pages.inbounds.periodicTrafficReset]
|
||||||
|
"never" = "從不"
|
||||||
|
"daily" = "每日"
|
||||||
|
"weekly" = "每週"
|
||||||
|
"monthly" = "每月"
|
||||||
|
|
||||||
[pages.inbounds.toasts]
|
[pages.inbounds.toasts]
|
||||||
"obtain" = "獲取"
|
"obtain" = "獲取"
|
||||||
"updateSuccess" = "更新成功"
|
"updateSuccess" = "更新成功"
|
||||||
|
|
|
||||||
|
|
@ -289,6 +289,14 @@ func (s *Server) startTask() {
|
||||||
// check client ips from log file every day
|
// check client ips from log file every day
|
||||||
s.cron.AddJob("@daily", job.NewClearLogsJob())
|
s.cron.AddJob("@daily", job.NewClearLogsJob())
|
||||||
|
|
||||||
|
// Inbound traffic reset jobs
|
||||||
|
// Run once a day, midnight
|
||||||
|
s.cron.AddJob("@daily", job.NewPeriodicTrafficResetJob("daily"))
|
||||||
|
// Run once a week, midnight between Sat/Sun
|
||||||
|
s.cron.AddJob("@weekly", job.NewPeriodicTrafficResetJob("weekly"))
|
||||||
|
// Run once a month, midnight, first of month
|
||||||
|
s.cron.AddJob("@monthly", job.NewPeriodicTrafficResetJob("monthly"))
|
||||||
|
|
||||||
// Make a traffic condition every day, 8:30
|
// Make a traffic condition every day, 8:30
|
||||||
var entry cron.EntryID
|
var entry cron.EntryID
|
||||||
isTgbotenabled, err := s.settingService.GetTgbotEnabled()
|
isTgbotenabled, err := s.settingService.GetTgbotEnabled()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue