Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| af5bd9f75d | |||
| 0fd36e4e6d | |||
| 0f29e2ad31 | |||
| 4ce3647670 | |||
| 90976cded1 | |||
| f5714eccee |
@@ -110,7 +110,9 @@ jobs:
|
||||
|
||||
- name: Upload to Release
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
if: github.event_name == 'release' && github.event.action == 'published'
|
||||
if: |
|
||||
(github.event_name == 'release' && github.event.action == 'published') ||
|
||||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
tag: ${{ github.ref }}
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
1.3.8
|
||||
1.3.9
|
||||
+7
-1
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/alireza0/s-ui/config"
|
||||
"github.com/alireza0/s-ui/database/model"
|
||||
@@ -49,7 +50,12 @@ func OpenDB(dbPath string) error {
|
||||
c := &gorm.Config{
|
||||
Logger: gormLogger,
|
||||
}
|
||||
db, err = gorm.Open(sqlite.Open(dbPath), c)
|
||||
sep := "?"
|
||||
if strings.Contains(dbPath, "?") {
|
||||
sep = "&"
|
||||
}
|
||||
dsn := dbPath + sep + "_busy_timeout=10000"
|
||||
db, err = gorm.Open(sqlite.Open(dsn), c)
|
||||
|
||||
if config.IsDebug() {
|
||||
db = db.Debug()
|
||||
|
||||
+1
-1
Submodule frontend updated: 32054ae938...ade7c316e7
@@ -10,7 +10,7 @@ require (
|
||||
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7
|
||||
github.com/robfig/cron/v3 v3.0.1
|
||||
github.com/sagernet/sing v0.7.18
|
||||
github.com/sagernet/sing-box v1.12.20
|
||||
github.com/sagernet/sing-box v1.12.21
|
||||
github.com/sagernet/sing-dns v0.4.6
|
||||
github.com/shirou/gopsutil/v4 v4.26.1
|
||||
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20241231184526-a9ab2273dd10
|
||||
@@ -110,7 +110,7 @@ require (
|
||||
github.com/sagernet/nftables v0.3.0-beta.4 // indirect
|
||||
github.com/sagernet/quic-go v0.52.0-sing-box-mod.3 // indirect
|
||||
github.com/sagernet/sing-mux v0.3.4 // indirect
|
||||
github.com/sagernet/sing-quic v0.5.2 // indirect
|
||||
github.com/sagernet/sing-quic v0.5.3 // indirect
|
||||
github.com/sagernet/sing-shadowsocks v0.2.8 // indirect
|
||||
github.com/sagernet/sing-shadowsocks2 v0.2.1 // indirect
|
||||
github.com/sagernet/sing-shadowtls v0.2.1-0.20250503051639-fcd445d33c11 // indirect
|
||||
|
||||
@@ -217,14 +217,14 @@ github.com/sagernet/quic-go v0.52.0-sing-box-mod.3 h1:ySqffGm82rPqI1TUPqmtHIYd12
|
||||
github.com/sagernet/quic-go v0.52.0-sing-box-mod.3/go.mod h1:OV+V5kEBb8kJS7k29MzDu6oj9GyMc7HA07sE1tedxz4=
|
||||
github.com/sagernet/sing v0.7.18 h1:iZHkaru1/MoHugx3G+9S3WG4owMewKO/KvieE2Pzk4E=
|
||||
github.com/sagernet/sing v0.7.18/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak=
|
||||
github.com/sagernet/sing-box v1.12.20 h1:5KarG2Q8/8k8VKXN6sywTc0Gs06HKZ4++zu2y4bw9KA=
|
||||
github.com/sagernet/sing-box v1.12.20/go.mod h1:ePKI4HpMVy+wtAumZx6pJxwq2ddiwmU+0ZoVteNdTsY=
|
||||
github.com/sagernet/sing-box v1.12.21 h1:SyTTag/f/JQmP7/1tTVlbhfKgAzB84sFhocmnwmANB8=
|
||||
github.com/sagernet/sing-box v1.12.21/go.mod h1:jjM3DQWWJSMW3U0uv3AxYRjyLnHu/SXN3A6Svex83/w=
|
||||
github.com/sagernet/sing-dns v0.4.6 h1:mjZC0o6d5sQ1sraoOBbK3G3apCbuL8wWYwu2RNu5rbM=
|
||||
github.com/sagernet/sing-dns v0.4.6/go.mod h1:dweQs54ng2YGzoJfz+F9dGuDNdP5pJ3PLeggnK5VWc8=
|
||||
github.com/sagernet/sing-mux v0.3.4 h1:ZQplKl8MNXutjzbMVtWvWG31fohhgOfCuUZR4dVQ8+s=
|
||||
github.com/sagernet/sing-mux v0.3.4/go.mod h1:QvlKMyNBNrQoyX4x+gq028uPbLM2XeRpWtDsWBJbFSk=
|
||||
github.com/sagernet/sing-quic v0.5.2 h1:I3vlfRImhr0uLwRS3b3ib70RMG9FcXtOKKUDz3eKRWc=
|
||||
github.com/sagernet/sing-quic v0.5.2/go.mod h1:evP1e++ZG8TJHVV5HudXV4vWeYzGfCdF4HwSJZcdqkI=
|
||||
github.com/sagernet/sing-quic v0.5.3 h1:K937DKJN98xqyztijRkLJqbBfyV4rEZcYxFyP3EBikU=
|
||||
github.com/sagernet/sing-quic v0.5.3/go.mod h1:evP1e++ZG8TJHVV5HudXV4vWeYzGfCdF4HwSJZcdqkI=
|
||||
github.com/sagernet/sing-shadowsocks v0.2.8 h1:PURj5PRoAkqeHh2ZW205RWzN9E9RtKCVCzByXruQWfE=
|
||||
github.com/sagernet/sing-shadowsocks v0.2.8/go.mod h1:lo7TWEMDcN5/h5B8S0ew+r78ZODn6SwVaFhvB6H+PTI=
|
||||
github.com/sagernet/sing-shadowsocks2 v0.2.1 h1:dWV9OXCeFPuYGHb6IRqlSptVnSzOelnqqs2gQ2/Qioo=
|
||||
|
||||
+3
-1
@@ -169,7 +169,9 @@ func (s *ConfigService) Save(obj string, act string, data json.RawMessage, initU
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = s.restartCoreWithConfig(data)
|
||||
configData := make(json.RawMessage, len(data))
|
||||
copy(configData, data)
|
||||
go func() { _ = s.restartCoreWithConfig(configData) }()
|
||||
case "settings":
|
||||
err = s.SettingService.Save(tx, data)
|
||||
default:
|
||||
|
||||
+33
-11
@@ -9,6 +9,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/alireza0/s-ui/config"
|
||||
"github.com/alireza0/s-ui/database"
|
||||
"github.com/alireza0/s-ui/database/model"
|
||||
"github.com/alireza0/s-ui/logger"
|
||||
|
||||
"github.com/sagernet/sing-box/common/tls"
|
||||
@@ -40,10 +42,11 @@ func (s *ServerService) GetStatus(request string) *map[string]interface{} {
|
||||
case "net":
|
||||
status["net"] = s.GetNetInfo()
|
||||
case "sys":
|
||||
status["uptime"] = s.GetUptime()
|
||||
status["sys"] = s.GetSystemInfo()
|
||||
case "sbd":
|
||||
status["sbd"] = s.GetSingboxInfo()
|
||||
case "db":
|
||||
status["db"] = s.GetDatabaseInfo()
|
||||
}
|
||||
}
|
||||
return &status
|
||||
@@ -59,16 +62,6 @@ func (s *ServerService) GetCpuPercent() float64 {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *ServerService) GetUptime() uint64 {
|
||||
upTime, err := host.Uptime()
|
||||
if err != nil {
|
||||
logger.Warning("get uptime failed:", err)
|
||||
return 0
|
||||
} else {
|
||||
return upTime
|
||||
}
|
||||
}
|
||||
|
||||
func (s *ServerService) GetMemInfo() map[string]interface{} {
|
||||
info := make(map[string]interface{}, 0)
|
||||
memInfo, err := mem.VirtualMemory()
|
||||
@@ -192,6 +185,7 @@ func (s *ServerService) GetSystemInfo() map[string]interface{} {
|
||||
}
|
||||
info["ipv4"] = ipv4
|
||||
info["ipv6"] = ipv6
|
||||
info["bootTime"], _ = host.BootTime()
|
||||
|
||||
return info
|
||||
}
|
||||
@@ -259,3 +253,31 @@ func (s *ServerService) generateWireGuardKey(pk string) []string {
|
||||
}
|
||||
return []string{"PrivateKey: " + wgKeys.String(), "PublicKey: " + wgKeys.PublicKey().String()}
|
||||
}
|
||||
|
||||
func (s *ServerService) GetDatabaseInfo() map[string]int64 {
|
||||
info := make(map[string]int64, 0)
|
||||
db := database.GetDB()
|
||||
if db == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var clientsCount, inboundsCount, outboundsCount, servicesCount, endpointsCount, clientUp, clientDown int64
|
||||
|
||||
db.Model(&model.Client{}).Count(&clientsCount)
|
||||
db.Model(&model.Inbound{}).Count(&inboundsCount)
|
||||
db.Model(&model.Outbound{}).Count(&outboundsCount)
|
||||
db.Model(&model.Service{}).Count(&servicesCount)
|
||||
db.Model(&model.Endpoint{}).Count(&endpointsCount)
|
||||
db.Model(&model.Client{}).Select("COALESCE(SUM(up),0)").Scan(&clientUp)
|
||||
db.Model(&model.Client{}).Select("COALESCE(SUM(down),0)").Scan(&clientDown)
|
||||
|
||||
info["clients"] = clientsCount
|
||||
info["inbounds"] = inboundsCount
|
||||
info["outbounds"] = outboundsCount
|
||||
info["services"] = servicesCount
|
||||
info["endpoints"] = endpointsCount
|
||||
info["clientUp"] = clientUp
|
||||
info["clientDown"] = clientDown
|
||||
|
||||
return info
|
||||
}
|
||||
|
||||
+7
-1
@@ -125,7 +125,13 @@ func (s *ClashService) ConvertToClashMeta(outbounds *[]map[string]interface{}) (
|
||||
proxy := make(map[string]interface{})
|
||||
proxy["name"] = obMap["tag"]
|
||||
proxy["type"] = t
|
||||
proxy["server"] = obMap["server"]
|
||||
|
||||
server, _ := obMap["server"].(string)
|
||||
if len(server) > 0 && strings.Contains(server, ":") && !strings.Contains(server, ".") && !(strings.HasPrefix(server, "[") && strings.HasSuffix(server, "]")) {
|
||||
server = "'[" + server + "]'"
|
||||
}
|
||||
proxy["server"] = server
|
||||
|
||||
proxy["port"] = obMap["server_port"]
|
||||
|
||||
switch t {
|
||||
|
||||
Reference in New Issue
Block a user