Compare commits

..

6 Commits

Author SHA1 Message Date
Alireza Ahmadi af5bd9f75d v1.3.9 2026-02-10 00:02:29 +01:00
Alireza Ahmadi 0fd36e4e6d Sing-Box v1.12.21 2026-02-10 00:02:07 +01:00
Alireza Ahmadi 0f29e2ad31 [clash] fix ipv6 by simple detection #871 2026-02-09 01:02:29 +01:00
Alireza Ahmadi 4ce3647670 db status data for first page 2026-02-09 00:51:31 +01:00
Alireza Ahmadi 90976cded1 fix dblock on failure #964 2026-02-08 21:19:28 +01:00
Alireza Ahmadi f5714eccee release on tag 2026-02-08 17:17:37 +01:00
9 changed files with 61 additions and 23 deletions
+3 -1
View File
@@ -110,7 +110,9 @@ jobs:
- name: Upload to Release - name: Upload to Release
uses: svenstaro/upload-release-action@v2 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: with:
repo_token: ${{ secrets.GITHUB_TOKEN }} repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }} tag: ${{ github.ref }}
+1 -1
View File
@@ -1 +1 @@
1.3.8 1.3.9
+7 -1
View File
@@ -4,6 +4,7 @@ import (
"encoding/json" "encoding/json"
"os" "os"
"path" "path"
"strings"
"github.com/alireza0/s-ui/config" "github.com/alireza0/s-ui/config"
"github.com/alireza0/s-ui/database/model" "github.com/alireza0/s-ui/database/model"
@@ -49,7 +50,12 @@ func OpenDB(dbPath string) error {
c := &gorm.Config{ c := &gorm.Config{
Logger: gormLogger, 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() { if config.IsDebug() {
db = db.Debug() db = db.Debug()
+2 -2
View File
@@ -10,7 +10,7 @@ require (
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 github.com/op/go-logging v0.0.0-20160315200505-970db520ece7
github.com/robfig/cron/v3 v3.0.1 github.com/robfig/cron/v3 v3.0.1
github.com/sagernet/sing v0.7.18 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/sagernet/sing-dns v0.4.6
github.com/shirou/gopsutil/v4 v4.26.1 github.com/shirou/gopsutil/v4 v4.26.1
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20241231184526-a9ab2273dd10 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/nftables v0.3.0-beta.4 // indirect
github.com/sagernet/quic-go v0.52.0-sing-box-mod.3 // 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-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-shadowsocks v0.2.8 // indirect
github.com/sagernet/sing-shadowsocks2 v0.2.1 // indirect github.com/sagernet/sing-shadowsocks2 v0.2.1 // indirect
github.com/sagernet/sing-shadowtls v0.2.1-0.20250503051639-fcd445d33c11 // indirect github.com/sagernet/sing-shadowtls v0.2.1-0.20250503051639-fcd445d33c11 // indirect
+4 -4
View File
@@ -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/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 h1:iZHkaru1/MoHugx3G+9S3WG4owMewKO/KvieE2Pzk4E=
github.com/sagernet/sing v0.7.18/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak= 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.21 h1:SyTTag/f/JQmP7/1tTVlbhfKgAzB84sFhocmnwmANB8=
github.com/sagernet/sing-box v1.12.20/go.mod h1:ePKI4HpMVy+wtAumZx6pJxwq2ddiwmU+0ZoVteNdTsY= 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 h1:mjZC0o6d5sQ1sraoOBbK3G3apCbuL8wWYwu2RNu5rbM=
github.com/sagernet/sing-dns v0.4.6/go.mod h1:dweQs54ng2YGzoJfz+F9dGuDNdP5pJ3PLeggnK5VWc8= 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 h1:ZQplKl8MNXutjzbMVtWvWG31fohhgOfCuUZR4dVQ8+s=
github.com/sagernet/sing-mux v0.3.4/go.mod h1:QvlKMyNBNrQoyX4x+gq028uPbLM2XeRpWtDsWBJbFSk= 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.3 h1:K937DKJN98xqyztijRkLJqbBfyV4rEZcYxFyP3EBikU=
github.com/sagernet/sing-quic v0.5.2/go.mod h1:evP1e++ZG8TJHVV5HudXV4vWeYzGfCdF4HwSJZcdqkI= 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 h1:PURj5PRoAkqeHh2ZW205RWzN9E9RtKCVCzByXruQWfE=
github.com/sagernet/sing-shadowsocks v0.2.8/go.mod h1:lo7TWEMDcN5/h5B8S0ew+r78ZODn6SwVaFhvB6H+PTI= 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= github.com/sagernet/sing-shadowsocks2 v0.2.1 h1:dWV9OXCeFPuYGHb6IRqlSptVnSzOelnqqs2gQ2/Qioo=
+3 -1
View File
@@ -169,7 +169,9 @@ func (s *ConfigService) Save(obj string, act string, data json.RawMessage, initU
if err != nil { if err != nil {
return nil, err return nil, err
} }
err = s.restartCoreWithConfig(data) configData := make(json.RawMessage, len(data))
copy(configData, data)
go func() { _ = s.restartCoreWithConfig(configData) }()
case "settings": case "settings":
err = s.SettingService.Save(tx, data) err = s.SettingService.Save(tx, data)
default: default:
+33 -11
View File
@@ -9,6 +9,8 @@ import (
"time" "time"
"github.com/alireza0/s-ui/config" "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/alireza0/s-ui/logger"
"github.com/sagernet/sing-box/common/tls" "github.com/sagernet/sing-box/common/tls"
@@ -40,10 +42,11 @@ func (s *ServerService) GetStatus(request string) *map[string]interface{} {
case "net": case "net":
status["net"] = s.GetNetInfo() status["net"] = s.GetNetInfo()
case "sys": case "sys":
status["uptime"] = s.GetUptime()
status["sys"] = s.GetSystemInfo() status["sys"] = s.GetSystemInfo()
case "sbd": case "sbd":
status["sbd"] = s.GetSingboxInfo() status["sbd"] = s.GetSingboxInfo()
case "db":
status["db"] = s.GetDatabaseInfo()
} }
} }
return &status 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{} { func (s *ServerService) GetMemInfo() map[string]interface{} {
info := make(map[string]interface{}, 0) info := make(map[string]interface{}, 0)
memInfo, err := mem.VirtualMemory() memInfo, err := mem.VirtualMemory()
@@ -192,6 +185,7 @@ func (s *ServerService) GetSystemInfo() map[string]interface{} {
} }
info["ipv4"] = ipv4 info["ipv4"] = ipv4
info["ipv6"] = ipv6 info["ipv6"] = ipv6
info["bootTime"], _ = host.BootTime()
return info return info
} }
@@ -259,3 +253,31 @@ func (s *ServerService) generateWireGuardKey(pk string) []string {
} }
return []string{"PrivateKey: " + wgKeys.String(), "PublicKey: " + wgKeys.PublicKey().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
View File
@@ -125,7 +125,13 @@ func (s *ClashService) ConvertToClashMeta(outbounds *[]map[string]interface{}) (
proxy := make(map[string]interface{}) proxy := make(map[string]interface{})
proxy["name"] = obMap["tag"] proxy["name"] = obMap["tag"]
proxy["type"] = t 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"] proxy["port"] = obMap["server_port"]
switch t { switch t {