Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9d1ad833f9 | |||
| e6f7354ce7 | |||
| a2c3033f5a | |||
| 03cda07c9d | |||
| fb999b4ee8 | |||
| e3ebfcf721 | |||
| 33071deb53 | |||
| 9b3b8d4540 | |||
| 98bf124078 | |||
| abc73a6525 | |||
| 2276175354 | |||
| 7f24735677 | |||
| 4d1544864d | |||
| 4aadee7ca0 | |||
| 6aba1354d5 | |||
| 63b229143d | |||
| f861950c50 | |||
| 97d1694bfa |
@@ -14,7 +14,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
- name: Set up Node.js
|
- name: Set up Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v5
|
||||||
with:
|
with:
|
||||||
node-version: 20
|
node-version: 20
|
||||||
- name: Install dependencies and build frontend
|
- name: Install dependencies and build frontend
|
||||||
|
|||||||
@@ -37,13 +37,13 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v6
|
||||||
with:
|
with:
|
||||||
cache: false
|
cache: false
|
||||||
go-version-file: go.mod
|
go-version-file: go.mod
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v5
|
||||||
with:
|
with:
|
||||||
node-version: '22'
|
node-version: '22'
|
||||||
registry-url: 'https://registry.npmjs.org'
|
registry-url: 'https://registry.npmjs.org'
|
||||||
|
|||||||
@@ -26,13 +26,13 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v6
|
||||||
with:
|
with:
|
||||||
cache: false
|
cache: false
|
||||||
go-version-file: go.mod
|
go-version-file: go.mod
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v5
|
||||||
with:
|
with:
|
||||||
node-version: '22'
|
node-version: '22'
|
||||||
registry-url: 'https://registry.npmjs.org'
|
registry-url: 'https://registry.npmjs.org'
|
||||||
@@ -110,13 +110,13 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v6
|
||||||
with:
|
with:
|
||||||
cache: false
|
cache: false
|
||||||
go-version-file: go.mod
|
go-version-file: go.mod
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v5
|
||||||
with:
|
with:
|
||||||
node-version: '22'
|
node-version: '22'
|
||||||
registry-url: 'https://registry.npmjs.org'
|
registry-url: 'https://registry.npmjs.org'
|
||||||
|
|||||||
+1
-2
@@ -7,7 +7,6 @@ import (
|
|||||||
"s-ui/service"
|
"s-ui/service"
|
||||||
"s-ui/util"
|
"s-ui/util"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -86,7 +85,7 @@ func (a *ApiService) getData(c *gin.Context) (interface{}, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
subURI, err := a.SettingService.GetFinalSubURI(strings.Split(c.Request.Host, ":")[0])
|
subURI, err := a.SettingService.GetFinalSubURI(getHostname(c))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -29,8 +29,11 @@ func getRemoteIp(c *gin.Context) string {
|
|||||||
|
|
||||||
func getHostname(c *gin.Context) string {
|
func getHostname(c *gin.Context) string {
|
||||||
host := c.Request.Host
|
host := c.Request.Host
|
||||||
if colonIndex := strings.LastIndex(host, ":"); colonIndex != -1 {
|
if strings.Contains(host, ":") {
|
||||||
host, _, _ = net.SplitHostPort(c.Request.Host)
|
host, _, _ = net.SplitHostPort(c.Request.Host)
|
||||||
|
if strings.Contains(host, ":") {
|
||||||
|
host = "[" + host + "]"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return host
|
return host
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
1.3.4
|
1.3.6
|
||||||
+1
-1
Submodule frontend updated: a892446541...1ba1f776bf
@@ -1,6 +1,6 @@
|
|||||||
module s-ui
|
module s-ui
|
||||||
|
|
||||||
go 1.25.0
|
go 1.25.1
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/gin-contrib/gzip v1.2.3
|
github.com/gin-contrib/gzip v1.2.3
|
||||||
@@ -9,14 +9,14 @@ require (
|
|||||||
github.com/gofrs/uuid/v5 v5.3.2
|
github.com/gofrs/uuid/v5 v5.3.2
|
||||||
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.6-0.20250825114712-2aeec120ce28
|
github.com/sagernet/sing v0.7.10
|
||||||
github.com/sagernet/sing-box v1.12.4
|
github.com/sagernet/sing-box v1.12.8
|
||||||
github.com/sagernet/sing-dns v0.4.6
|
github.com/sagernet/sing-dns v0.4.6
|
||||||
github.com/shirou/gopsutil/v4 v4.25.7
|
github.com/shirou/gopsutil/v4 v4.25.8
|
||||||
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20241231184526-a9ab2273dd10
|
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20241231184526-a9ab2273dd10
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
gorm.io/driver/sqlite v1.6.0
|
gorm.io/driver/sqlite v1.6.0
|
||||||
gorm.io/gorm v1.30.2
|
gorm.io/gorm v1.31.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
@@ -107,11 +107,11 @@ 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-beta.1 // indirect
|
github.com/sagernet/quic-go v0.52.0-beta.1 // indirect
|
||||||
github.com/sagernet/sing-mux v0.3.3 // indirect
|
github.com/sagernet/sing-mux v0.3.3 // indirect
|
||||||
github.com/sagernet/sing-quic v0.5.0 // indirect
|
github.com/sagernet/sing-quic v0.5.2-0.20250909083218-00a55617c0fb // 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
|
||||||
github.com/sagernet/sing-tun v0.7.0-beta.1 // indirect
|
github.com/sagernet/sing-tun v0.7.2 // indirect
|
||||||
github.com/sagernet/sing-vmess v0.2.7 // indirect
|
github.com/sagernet/sing-vmess v0.2.7 // indirect
|
||||||
github.com/sagernet/smux v1.5.34-mod.2 // indirect
|
github.com/sagernet/smux v1.5.34-mod.2 // indirect
|
||||||
github.com/sagernet/tailscale v1.80.3-sing-box-1.12-mod.1 // indirect
|
github.com/sagernet/tailscale v1.80.3-sing-box-1.12-mod.1 // indirect
|
||||||
|
|||||||
@@ -214,24 +214,24 @@ github.com/sagernet/nftables v0.3.0-beta.4/go.mod h1:OQXAjvjNGGFxaTgVCSTRIhYB5/l
|
|||||||
github.com/sagernet/quic-go v0.52.0-beta.1 h1:hWkojLg64zjV+MJOvJU/kOeWndm3tiEfBLx5foisszs=
|
github.com/sagernet/quic-go v0.52.0-beta.1 h1:hWkojLg64zjV+MJOvJU/kOeWndm3tiEfBLx5foisszs=
|
||||||
github.com/sagernet/quic-go v0.52.0-beta.1/go.mod h1:OV+V5kEBb8kJS7k29MzDu6oj9GyMc7HA07sE1tedxz4=
|
github.com/sagernet/quic-go v0.52.0-beta.1/go.mod h1:OV+V5kEBb8kJS7k29MzDu6oj9GyMc7HA07sE1tedxz4=
|
||||||
github.com/sagernet/sing v0.6.9/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak=
|
github.com/sagernet/sing v0.6.9/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak=
|
||||||
github.com/sagernet/sing v0.7.6-0.20250825114712-2aeec120ce28 h1:C8Lnqd0Q+C15kwaMiDsfq5S45rhhaQMBG91TT+6oFVo=
|
github.com/sagernet/sing v0.7.10 h1:2yPhZFx+EkyHPH8hXNezgyRSHyGY12CboId7CtwLROw=
|
||||||
github.com/sagernet/sing v0.7.6-0.20250825114712-2aeec120ce28/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak=
|
github.com/sagernet/sing v0.7.10/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak=
|
||||||
github.com/sagernet/sing-box v1.12.4 h1:FaKRKIorsior0nzjCoPSESonjHnmSOD/moKIA56OkLM=
|
github.com/sagernet/sing-box v1.12.8 h1:XnDRmD5tT5PsBPvMQ6zmLtbAKD3/l/6mHUfCJYa+L2g=
|
||||||
github.com/sagernet/sing-box v1.12.4/go.mod h1:sYGo3cT+O9YwEucIqz+2JBrNTnvuU2F/+vpnbhuV3Qc=
|
github.com/sagernet/sing-box v1.12.8/go.mod h1:HRB+cgvwOMnoNmVhJm2DoFQPbJvDSRDaLonaMlT4tjo=
|
||||||
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.3 h1:YFgt9plMWzH994BMZLmyKL37PdIVaIilwP0Jg+EcLfw=
|
github.com/sagernet/sing-mux v0.3.3 h1:YFgt9plMWzH994BMZLmyKL37PdIVaIilwP0Jg+EcLfw=
|
||||||
github.com/sagernet/sing-mux v0.3.3/go.mod h1:pht8iFY4c9Xltj7rhVd208npkNaeCxzyXCgulDPLUDA=
|
github.com/sagernet/sing-mux v0.3.3/go.mod h1:pht8iFY4c9Xltj7rhVd208npkNaeCxzyXCgulDPLUDA=
|
||||||
github.com/sagernet/sing-quic v0.5.0 h1:jNLIyVk24lFPvu8A4x+ZNEnZdI+Tg1rp7eCJ6v0Csak=
|
github.com/sagernet/sing-quic v0.5.2-0.20250909083218-00a55617c0fb h1:5Wx3XeTiKrrrcrAky7Hc1bO3CGxrvho2Vu5b/adlEIM=
|
||||||
github.com/sagernet/sing-quic v0.5.0/go.mod h1:SAv/qdeDN+75msGG5U5ZIwG+3Ua50jVIKNrRSY8pkx0=
|
github.com/sagernet/sing-quic v0.5.2-0.20250909083218-00a55617c0fb/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=
|
||||||
github.com/sagernet/sing-shadowsocks2 v0.2.1/go.mod h1:RnXS0lExcDAovvDeniJ4IKa2IuChrdipolPYWBv9hWQ=
|
github.com/sagernet/sing-shadowsocks2 v0.2.1/go.mod h1:RnXS0lExcDAovvDeniJ4IKa2IuChrdipolPYWBv9hWQ=
|
||||||
github.com/sagernet/sing-shadowtls v0.2.1-0.20250503051639-fcd445d33c11 h1:tK+75l64tm9WvEFrYRE1t0YxoFdWQqw/h7Uhzj0vJ+w=
|
github.com/sagernet/sing-shadowtls v0.2.1-0.20250503051639-fcd445d33c11 h1:tK+75l64tm9WvEFrYRE1t0YxoFdWQqw/h7Uhzj0vJ+w=
|
||||||
github.com/sagernet/sing-shadowtls v0.2.1-0.20250503051639-fcd445d33c11/go.mod h1:sWqKnGlMipCHaGsw1sTTlimyUpgzP4WP3pjhCsYt9oA=
|
github.com/sagernet/sing-shadowtls v0.2.1-0.20250503051639-fcd445d33c11/go.mod h1:sWqKnGlMipCHaGsw1sTTlimyUpgzP4WP3pjhCsYt9oA=
|
||||||
github.com/sagernet/sing-tun v0.7.0-beta.1 h1:mBIFXYAnGO5ey/HcCYanqnBx61E7yF8zTFGRZonGYmY=
|
github.com/sagernet/sing-tun v0.7.2 h1:uJkAZM0KBqIYzrq077QGqdvj/+4i/pMOx6Pnx0jYqAs=
|
||||||
github.com/sagernet/sing-tun v0.7.0-beta.1/go.mod h1:AHJuRrLbNRJuivuFZ2VhXwDj4ViYp14szG5EkkKAqRQ=
|
github.com/sagernet/sing-tun v0.7.2/go.mod h1:pUEjh9YHQ2gJT6Lk0TYDklh3WJy7lz+848vleGM3JPM=
|
||||||
github.com/sagernet/sing-vmess v0.2.7 h1:2ee+9kO0xW5P4mfe6TYVWf9VtY8k1JhNysBqsiYj0sk=
|
github.com/sagernet/sing-vmess v0.2.7 h1:2ee+9kO0xW5P4mfe6TYVWf9VtY8k1JhNysBqsiYj0sk=
|
||||||
github.com/sagernet/sing-vmess v0.2.7/go.mod h1:5aYoOtYksAyS0NXDm0qKeTYW1yoE1bJVcv+XLcVoyJs=
|
github.com/sagernet/sing-vmess v0.2.7/go.mod h1:5aYoOtYksAyS0NXDm0qKeTYW1yoE1bJVcv+XLcVoyJs=
|
||||||
github.com/sagernet/smux v1.5.34-mod.2 h1:gkmBjIjlJ2zQKpLigOkFur5kBKdV6bNRoFu2WkltRQ4=
|
github.com/sagernet/smux v1.5.34-mod.2 h1:gkmBjIjlJ2zQKpLigOkFur5kBKdV6bNRoFu2WkltRQ4=
|
||||||
@@ -242,8 +242,8 @@ github.com/sagernet/wireguard-go v0.0.1-beta.7 h1:ltgBwYHfr+9Wz1eG59NiWnHrYEkDKH
|
|||||||
github.com/sagernet/wireguard-go v0.0.1-beta.7/go.mod h1:jGXij2Gn2wbrWuYNUmmNhf1dwcZtvyAvQoe8Xd8MbUo=
|
github.com/sagernet/wireguard-go v0.0.1-beta.7/go.mod h1:jGXij2Gn2wbrWuYNUmmNhf1dwcZtvyAvQoe8Xd8MbUo=
|
||||||
github.com/sagernet/ws v0.0.0-20231204124109-acfe8907c854 h1:6uUiZcDRnZSAegryaUGwPC/Fj13JSHwiTftrXhMmYOc=
|
github.com/sagernet/ws v0.0.0-20231204124109-acfe8907c854 h1:6uUiZcDRnZSAegryaUGwPC/Fj13JSHwiTftrXhMmYOc=
|
||||||
github.com/sagernet/ws v0.0.0-20231204124109-acfe8907c854/go.mod h1:LtfoSK3+NG57tvnVEHgcuBW9ujgE8enPSgzgwStwCAA=
|
github.com/sagernet/ws v0.0.0-20231204124109-acfe8907c854/go.mod h1:LtfoSK3+NG57tvnVEHgcuBW9ujgE8enPSgzgwStwCAA=
|
||||||
github.com/shirou/gopsutil/v4 v4.25.7 h1:bNb2JuqKuAu3tRlPv5piSmBZyMfecwQ+t/ILq+1JqVM=
|
github.com/shirou/gopsutil/v4 v4.25.8 h1:NnAsw9lN7587WHxjJA9ryDnqhJpFH6A+wagYWTOH970=
|
||||||
github.com/shirou/gopsutil/v4 v4.25.7/go.mod h1:XV/egmwJtd3ZQjBpJVY5kndsiOO4IRqy9TQnmm6VP7U=
|
github.com/shirou/gopsutil/v4 v4.25.8/go.mod h1:q9QdMmfAOVIw7a+eF86P7ISEU6ka+NLgkUxlopV4RwI=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||||
@@ -255,8 +255,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
|
|||||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||||
github.com/tailscale/certstore v0.1.1-0.20231202035212-d3fa0460f47e h1:PtWT87weP5LWHEY//SWsYkSO3RWRZo4OSWagh3YD2vQ=
|
github.com/tailscale/certstore v0.1.1-0.20231202035212-d3fa0460f47e h1:PtWT87weP5LWHEY//SWsYkSO3RWRZo4OSWagh3YD2vQ=
|
||||||
github.com/tailscale/certstore v0.1.1-0.20231202035212-d3fa0460f47e/go.mod h1:XrBNfAFN+pwoWuksbFS9Ccxnopa15zJGgXRFN90l3K4=
|
github.com/tailscale/certstore v0.1.1-0.20231202035212-d3fa0460f47e/go.mod h1:XrBNfAFN+pwoWuksbFS9Ccxnopa15zJGgXRFN90l3K4=
|
||||||
github.com/tailscale/go-winio v0.0.0-20231025203758-c4f33415bf55 h1:Gzfnfk2TWrk8Jj4P4c1a3CtQyMaTVCznlkLZI++hok4=
|
github.com/tailscale/go-winio v0.0.0-20231025203758-c4f33415bf55 h1:Gzfnfk2TWrk8Jj4P4c1a3CtQyMaTVCznlkLZI++hok4=
|
||||||
@@ -383,8 +383,8 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
|||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gorm.io/driver/sqlite v1.6.0 h1:WHRRrIiulaPiPFmDcod6prc4l2VGVWHz80KspNsxSfQ=
|
gorm.io/driver/sqlite v1.6.0 h1:WHRRrIiulaPiPFmDcod6prc4l2VGVWHz80KspNsxSfQ=
|
||||||
gorm.io/driver/sqlite v1.6.0/go.mod h1:AO9V1qIQddBESngQUKWL9yoH93HIeA1X6V633rBwyT8=
|
gorm.io/driver/sqlite v1.6.0/go.mod h1:AO9V1qIQddBESngQUKWL9yoH93HIeA1X6V633rBwyT8=
|
||||||
gorm.io/gorm v1.30.2 h1:f7bevlVoVe4Byu3pmbWPVHnPsLoWaMjEb7/clyr9Ivs=
|
gorm.io/gorm v1.31.0 h1:0VlycGreVhK7RF/Bwt51Fk8v0xLiiiFdbGDPIZQ7mJY=
|
||||||
gorm.io/gorm v1.30.2/go.mod h1:8Z33v652h4//uMA76KjeDH8mJXPm1QNCYrMeatR0DOE=
|
gorm.io/gorm v1.31.0/go.mod h1:XyQVbO2k6YkOis7C2437jSit3SsDK72s7n7rsSHd+Gs=
|
||||||
lukechampine.com/blake3 v1.4.1 h1:I3Smz7gso8w4/TunLKec6K2fn+kyKtDxr/xcQEN84Wg=
|
lukechampine.com/blake3 v1.4.1 h1:I3Smz7gso8w4/TunLKec6K2fn+kyKtDxr/xcQEN84Wg=
|
||||||
lukechampine.com/blake3 v1.4.1/go.mod h1:QFosUxmjB8mnrWFSNwKmvxHpfY72bmD2tQ0kBMM3kwo=
|
lukechampine.com/blake3 v1.4.1/go.mod h1:QFosUxmjB8mnrWFSNwKmvxHpfY72bmD2tQ0kBMM3kwo=
|
||||||
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
|
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
|
||||||
|
|||||||
+1
-1
@@ -283,7 +283,7 @@ func (s *ClientService) UpdateLinksByInboundChange(tx *gorm.DB, inbounds *[]mode
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
for _, clientLink := range clientLinks {
|
for _, clientLink := range clientLinks {
|
||||||
if clientLink["remark"] != inbound.Tag && clientLink["remark"] != oldTag {
|
if clientLink["type"] != "local" || (clientLink["remark"] != inbound.Tag && clientLink["remark"] != oldTag) {
|
||||||
newClientLinks = append(newClientLinks, clientLink)
|
newClientLinks = append(newClientLinks, clientLink)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -142,7 +142,8 @@ func (s *ConfigService) Save(obj string, act string, data json.RawMessage, initU
|
|||||||
|
|
||||||
switch obj {
|
switch obj {
|
||||||
case "clients":
|
case "clients":
|
||||||
inboundIds, err := s.ClientService.Save(tx, act, data, hostname)
|
var inboundIds []uint
|
||||||
|
inboundIds, err = s.ClientService.Save(tx, act, data, hostname)
|
||||||
if err == nil && len(inboundIds) > 0 {
|
if err == nil && len(inboundIds) > 0 {
|
||||||
objs = append(objs, "inbounds")
|
objs = append(objs, "inbounds")
|
||||||
err = s.InboundService.RestartInbounds(tx, inboundIds)
|
err = s.InboundService.RestartInbounds(tx, inboundIds)
|
||||||
|
|||||||
+5
-1
@@ -73,8 +73,12 @@ func (s *ClashService) GetClash(subId string) (*string, []string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
links := s.LinkService.GetLinks(&client.Links, "external", "")
|
links := s.LinkService.GetLinks(&client.Links, "external", "")
|
||||||
|
tagNumEnable := 0
|
||||||
|
if len(links) > 1 {
|
||||||
|
tagNumEnable = 1
|
||||||
|
}
|
||||||
for index, link := range links {
|
for index, link := range links {
|
||||||
json, tag, err := util.GetOutbound(link, index)
|
json, tag, err := util.GetOutbound(link, (index+1)*tagNumEnable)
|
||||||
if err == nil && len(tag) > 0 {
|
if err == nil && len(tag) > 0 {
|
||||||
*outbounds = append(*outbounds, *json)
|
*outbounds = append(*outbounds, *json)
|
||||||
*outTags = append(*outTags, tag)
|
*outTags = append(*outTags, tag)
|
||||||
|
|||||||
+5
-1
@@ -61,8 +61,12 @@ func (j *JsonService) GetJson(subId string, format string) (*string, []string, e
|
|||||||
}
|
}
|
||||||
|
|
||||||
links := j.LinkService.GetLinks(&client.Links, "external", "")
|
links := j.LinkService.GetLinks(&client.Links, "external", "")
|
||||||
|
tagNumEnable := 0
|
||||||
|
if len(links) > 1 {
|
||||||
|
tagNumEnable = 1
|
||||||
|
}
|
||||||
for index, link := range links {
|
for index, link := range links {
|
||||||
json, tag, err := util.GetOutbound(link, index)
|
json, tag, err := util.GetOutbound(link, (index+1)*tagNumEnable)
|
||||||
if err == nil && len(tag) > 0 {
|
if err == nil && len(tag) > 0 {
|
||||||
*outbounds = append(*outbounds, *json)
|
*outbounds = append(*outbounds, *json)
|
||||||
*outTags = append(*outTags, tag)
|
*outTags = append(*outTags, tag)
|
||||||
|
|||||||
+74
-139
@@ -67,7 +67,9 @@ func LinkGenerator(clientConfig json.RawMessage, i *model.Inbound, hostname stri
|
|||||||
return httpLink(userConfig["http"], *inbound, Addrs)
|
return httpLink(userConfig["http"], *inbound, Addrs)
|
||||||
case "mixed":
|
case "mixed":
|
||||||
return append(
|
return append(
|
||||||
socksLink(userConfig["socks"], *inbound, Addrs), httpLink(userConfig["http"], *inbound, Addrs)...)
|
socksLink(userConfig["socks"], *inbound, Addrs),
|
||||||
|
httpLink(userConfig["http"], *inbound, Addrs)...,
|
||||||
|
)
|
||||||
case "shadowsocks":
|
case "shadowsocks":
|
||||||
return shadowsocksLink(userConfig, *inbound, Addrs)
|
return shadowsocksLink(userConfig, *inbound, Addrs)
|
||||||
case "naive":
|
case "naive":
|
||||||
@@ -157,7 +159,7 @@ func shadowsocksLink(
|
|||||||
var links []string
|
var links []string
|
||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
port, _ := addr["server_port"].(float64)
|
port, _ := addr["server_port"].(float64)
|
||||||
links = append(links, fmt.Sprintf("%s@%s:%d#%s", uriBase, addr["server"].(string), uint(port), addr["remark"].(string)))
|
links = append(links, fmt.Sprintf("%s@%s:%.0f#%s", uriBase, addr["server"].(string), port, addr["remark"].(string)))
|
||||||
}
|
}
|
||||||
return links
|
return links
|
||||||
}
|
}
|
||||||
@@ -198,7 +200,7 @@ func naiveLink(
|
|||||||
}
|
}
|
||||||
|
|
||||||
port, _ := addr["server_port"].(float64)
|
port, _ := addr["server_port"].(float64)
|
||||||
uri := baseUri + toBase64([]byte(fmt.Sprintf("%s:%s@%s:%d", username, password, addr["server"].(string), uint(port))))
|
uri := baseUri + toBase64([]byte(fmt.Sprintf("%s:%s@%s:%.0f", username, password, addr["server"].(string), port)))
|
||||||
links = append(links, addParams(uri, params, addr["remark"].(string)))
|
links = append(links, addParams(uri, params, addr["remark"].(string)))
|
||||||
}
|
}
|
||||||
return links
|
return links
|
||||||
@@ -214,29 +216,17 @@ func hysteriaLink(
|
|||||||
|
|
||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
params := map[string]string{}
|
params := map[string]string{}
|
||||||
if upmbps, ok := inbound["up_mbps"].(string); ok {
|
if upmbps, ok := inbound["up_mbps"].(float64); ok {
|
||||||
params["up_mbps"] = upmbps
|
params["downmbps"] = fmt.Sprintf("%.0f", upmbps)
|
||||||
}
|
}
|
||||||
if downmbps, ok := inbound["down_mbps"].(string); ok {
|
if downmbps, ok := inbound["down_mbps"].(float64); ok {
|
||||||
params["down_mbps"] = downmbps
|
params["upmbps"] = fmt.Sprintf("%.0f", downmbps)
|
||||||
}
|
}
|
||||||
if auth, ok := userConfig["auth_str"].(string); ok {
|
if auth, ok := userConfig["auth_str"].(string); ok {
|
||||||
params["auth"] = auth
|
params["auth"] = auth
|
||||||
}
|
}
|
||||||
if tls, ok := addr["tls"].(map[string]interface{}); ok {
|
if tls, ok := addr["tls"].(map[string]interface{}); ok {
|
||||||
if sni, ok := tls["server_name"].(string); ok {
|
getTlsParams(¶ms, tls, "insecure")
|
||||||
params["peer"] = sni
|
|
||||||
}
|
|
||||||
if alpn, ok := tls["alpn"].([]interface{}); ok {
|
|
||||||
alpnList := make([]string, len(alpn))
|
|
||||||
for i, v := range alpn {
|
|
||||||
alpnList[i] = v.(string)
|
|
||||||
}
|
|
||||||
params["alpn"] = strings.Join(alpnList, ",")
|
|
||||||
}
|
|
||||||
if insecure, ok := tls["insecure"].(bool); ok && insecure {
|
|
||||||
params["insecure"] = "1"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if obfs, ok := inbound["obfs"].(string); ok {
|
if obfs, ok := inbound["obfs"].(string); ok {
|
||||||
params["obfs"] = obfs
|
params["obfs"] = obfs
|
||||||
@@ -246,9 +236,18 @@ func hysteriaLink(
|
|||||||
} else {
|
} else {
|
||||||
params["fastopen"] = "0"
|
params["fastopen"] = "0"
|
||||||
}
|
}
|
||||||
|
var outJson map[string]interface{}
|
||||||
|
json.Unmarshal(inbound["out_json"].(json.RawMessage), &outJson)
|
||||||
|
if mport, ok := outJson["server_ports"].([]interface{}); ok {
|
||||||
|
mportList := make([]string, len(mport))
|
||||||
|
for i, v := range mport {
|
||||||
|
mportList[i] = v.(string)
|
||||||
|
}
|
||||||
|
params["mport"] = strings.Join(mportList, ",")
|
||||||
|
}
|
||||||
|
|
||||||
port, _ := addr["server_port"].(float64)
|
port, _ := addr["server_port"].(float64)
|
||||||
uri := fmt.Sprintf("%s%s:%d", baseUri, addr["server"].(string), uint(port))
|
uri := fmt.Sprintf("%s%s:%.0f", baseUri, addr["server"].(string), port)
|
||||||
links = append(links, addParams(uri, params, addr["remark"].(string)))
|
links = append(links, addParams(uri, params, addr["remark"].(string)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,26 +265,14 @@ func hysteria2Link(
|
|||||||
|
|
||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
params := map[string]string{}
|
params := map[string]string{}
|
||||||
if upmbps, ok := inbound["up_mbps"].(string); ok {
|
if upmbps, ok := inbound["up_mbps"].(float64); ok {
|
||||||
params["up_mbps"] = upmbps
|
params["downmbps"] = fmt.Sprintf("%.0f", upmbps)
|
||||||
}
|
}
|
||||||
if downmbps, ok := inbound["down_mbps"].(string); ok {
|
if downmbps, ok := inbound["down_mbps"].(float64); ok {
|
||||||
params["down_mbps"] = downmbps
|
params["upmbps"] = fmt.Sprintf("%.0f", downmbps)
|
||||||
}
|
}
|
||||||
if tls, ok := addr["tls"].(map[string]interface{}); ok {
|
if tls, ok := addr["tls"].(map[string]interface{}); ok {
|
||||||
if sni, ok := tls["server_name"].(string); ok {
|
getTlsParams(¶ms, tls, "insecure")
|
||||||
params["sni"] = sni
|
|
||||||
}
|
|
||||||
if alpn, ok := tls["alpn"].([]interface{}); ok {
|
|
||||||
alpnList := make([]string, len(alpn))
|
|
||||||
for i, v := range alpn {
|
|
||||||
alpnList[i] = v.(string)
|
|
||||||
}
|
|
||||||
params["alpn"] = strings.Join(alpnList, ",")
|
|
||||||
}
|
|
||||||
if insecure, ok := tls["insecure"].(bool); ok && insecure {
|
|
||||||
params["insecure"] = "1"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if obfs, ok := inbound["obfs"].(map[string]interface{}); ok {
|
if obfs, ok := inbound["obfs"].(map[string]interface{}); ok {
|
||||||
if obfsType, ok := obfs["type"].(string); ok {
|
if obfsType, ok := obfs["type"].(string); ok {
|
||||||
@@ -300,9 +287,18 @@ func hysteria2Link(
|
|||||||
} else {
|
} else {
|
||||||
params["fastopen"] = "0"
|
params["fastopen"] = "0"
|
||||||
}
|
}
|
||||||
|
var outJson map[string]interface{}
|
||||||
|
json.Unmarshal(inbound["out_json"].(json.RawMessage), &outJson)
|
||||||
|
if mport, ok := outJson["server_ports"].([]interface{}); ok {
|
||||||
|
mportList := make([]string, len(mport))
|
||||||
|
for i, v := range mport {
|
||||||
|
mportList[i] = v.(string)
|
||||||
|
}
|
||||||
|
params["mport"] = strings.Join(mportList, ",")
|
||||||
|
}
|
||||||
|
|
||||||
port, _ := addr["server_port"].(float64)
|
port, _ := addr["server_port"].(float64)
|
||||||
uri := fmt.Sprintf("%s%s:%d", baseUri, addr["server"].(string), uint(port))
|
uri := fmt.Sprintf("%s%s:%.0f", baseUri, addr["server"].(string), port)
|
||||||
links = append(links, addParams(uri, params, addr["remark"].(string)))
|
links = append(links, addParams(uri, params, addr["remark"].(string)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,23 +316,11 @@ func anytlsLink(
|
|||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
params := map[string]string{}
|
params := map[string]string{}
|
||||||
if tls, ok := addr["tls"].(map[string]interface{}); ok {
|
if tls, ok := addr["tls"].(map[string]interface{}); ok {
|
||||||
if sni, ok := tls["server_name"].(string); ok {
|
getTlsParams(¶ms, tls, "insecure")
|
||||||
params["sni"] = sni
|
|
||||||
}
|
|
||||||
if alpn, ok := tls["alpn"].([]interface{}); ok {
|
|
||||||
alpnList := make([]string, len(alpn))
|
|
||||||
for i, v := range alpn {
|
|
||||||
alpnList[i] = v.(string)
|
|
||||||
}
|
|
||||||
params["alpn"] = strings.Join(alpnList, ",")
|
|
||||||
}
|
|
||||||
if insecure, ok := tls["insecure"].(bool); ok && insecure {
|
|
||||||
params["insecure"] = "1"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
port, _ := addr["server_port"].(float64)
|
port, _ := addr["server_port"].(float64)
|
||||||
uri := fmt.Sprintf("%s%s:%d", baseUri, addr["server"].(string), uint(port))
|
uri := fmt.Sprintf("%s%s:%.0f", baseUri, addr["server"].(string), port)
|
||||||
links = append(links, addParams(uri, params, addr["remark"].(string)))
|
links = append(links, addParams(uri, params, addr["remark"].(string)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,29 +340,14 @@ func tuicLink(
|
|||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
params := map[string]string{}
|
params := map[string]string{}
|
||||||
if tls, ok := addr["tls"].(map[string]interface{}); ok {
|
if tls, ok := addr["tls"].(map[string]interface{}); ok {
|
||||||
if sni, ok := tls["server_name"].(string); ok {
|
getTlsParams(¶ms, tls, "insecure")
|
||||||
params["sni"] = sni
|
|
||||||
}
|
|
||||||
if alpn, ok := tls["alpn"].([]interface{}); ok {
|
|
||||||
alpnList := make([]string, len(alpn))
|
|
||||||
for i, v := range alpn {
|
|
||||||
alpnList[i] = v.(string)
|
|
||||||
}
|
|
||||||
params["alpn"] = strings.Join(alpnList, ",")
|
|
||||||
}
|
|
||||||
if insecure, ok := tls["insecure"].(bool); ok && insecure {
|
|
||||||
params["insecure"] = "1"
|
|
||||||
}
|
|
||||||
if disableSni, ok := tls["disable_sni"].(bool); ok && disableSni {
|
|
||||||
params["disable_sni"] = "1"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if congestionControl, ok := inbound["congestion_control"].(string); ok {
|
if congestionControl, ok := inbound["congestion_control"].(string); ok {
|
||||||
params["congestion_control"] = congestionControl
|
params["congestion_control"] = congestionControl
|
||||||
}
|
}
|
||||||
|
|
||||||
port, _ := addr["server_port"].(float64)
|
port, _ := addr["server_port"].(float64)
|
||||||
uri := fmt.Sprintf("%s%s:%d", baseUri, addr["server"].(string), uint(port))
|
uri := fmt.Sprintf("%s%s:%.0f", baseUri, addr["server"].(string), port)
|
||||||
links = append(links, addParams(uri, params, addr["remark"].(string)))
|
links = append(links, addParams(uri, params, addr["remark"].(string)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -397,39 +366,13 @@ func vlessLink(
|
|||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
params := baseParams
|
params := baseParams
|
||||||
if tls, ok := addr["tls"].(map[string]interface{}); ok && tls["enabled"].(bool) {
|
if tls, ok := addr["tls"].(map[string]interface{}); ok && tls["enabled"].(bool) {
|
||||||
if reality, ok := tls["reality"].(map[string]interface{}); ok && reality["enabled"].(bool) {
|
getTlsParams(¶ms, tls, "allowInsecure")
|
||||||
params["security"] = "reality"
|
|
||||||
if pbk, ok := reality["public_key"].(string); ok {
|
|
||||||
params["pbk"] = pbk
|
|
||||||
}
|
|
||||||
if sid, ok := reality["short_id"].(string); ok {
|
|
||||||
params["sid"] = sid
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
params["security"] = "tls"
|
|
||||||
if insecure, ok := tls["insecure"].(bool); ok && insecure {
|
|
||||||
params["allowInsecure"] = "1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if flow, ok := userConfig["flow"].(string); ok {
|
if flow, ok := userConfig["flow"].(string); ok {
|
||||||
params["flow"] = flow
|
params["flow"] = flow
|
||||||
}
|
}
|
||||||
if utls, ok := tls["utls"].(map[string]interface{}); ok {
|
|
||||||
params["fp"], _ = utls["fingerprint"].(string)
|
|
||||||
}
|
|
||||||
if sni, ok := tls["server_name"].(string); ok {
|
|
||||||
params["sni"] = sni
|
|
||||||
}
|
|
||||||
if alpn, ok := tls["alpn"].([]interface{}); ok {
|
|
||||||
alpnList := make([]string, len(alpn))
|
|
||||||
for i, v := range alpn {
|
|
||||||
alpnList[i] = v.(string)
|
|
||||||
}
|
|
||||||
params["alpn"] = strings.Join(alpnList, ",")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
port, _ := addr["server_port"].(float64)
|
port, _ := addr["server_port"].(float64)
|
||||||
uri := fmt.Sprintf("vless://%s@%s:%d", uuid, addr["server"].(string), uint(port))
|
uri := fmt.Sprintf("vless://%s@%s:%.0f", uuid, addr["server"].(string), port)
|
||||||
uri = addParams(uri, params, addr["remark"].(string))
|
uri = addParams(uri, params, addr["remark"].(string))
|
||||||
links = append(links, uri)
|
links = append(links, uri)
|
||||||
}
|
}
|
||||||
@@ -448,36 +391,10 @@ func trojanLink(
|
|||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
params := baseParams
|
params := baseParams
|
||||||
if tls, ok := addr["tls"].(map[string]interface{}); ok && tls["enabled"].(bool) {
|
if tls, ok := addr["tls"].(map[string]interface{}); ok && tls["enabled"].(bool) {
|
||||||
if reality, ok := tls["reality"].(map[string]interface{}); ok && reality["enabled"].(bool) {
|
getTlsParams(¶ms, tls, "allowInsecure")
|
||||||
params["security"] = "reality"
|
|
||||||
if pbk, ok := reality["public_key"].(string); ok {
|
|
||||||
params["pbk"] = pbk
|
|
||||||
}
|
|
||||||
if sid, ok := reality["short_id"].(string); ok {
|
|
||||||
params["sid"] = sid
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
params["security"] = "tls"
|
|
||||||
if insecure, ok := tls["insecure"].(bool); ok && insecure {
|
|
||||||
params["allowInsecure"] = "1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if utls, ok := tls["utls"].(map[string]interface{}); ok {
|
|
||||||
params["fp"], _ = utls["fingerprint"].(string)
|
|
||||||
}
|
|
||||||
if sni, ok := tls["server_name"].(string); ok {
|
|
||||||
params["sni"] = sni
|
|
||||||
}
|
|
||||||
if alpn, ok := tls["alpn"].([]interface{}); ok {
|
|
||||||
alpnList := make([]string, len(alpn))
|
|
||||||
for i, v := range alpn {
|
|
||||||
alpnList[i] = v.(string)
|
|
||||||
}
|
|
||||||
params["alpn"] = strings.Join(alpnList, ",")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
port, _ := addr["server_port"].(float64)
|
port, _ := addr["server_port"].(float64)
|
||||||
uri := fmt.Sprintf("trojan://%s@%s:%d", password, addr["server"].(string), uint(port))
|
uri := fmt.Sprintf("trojan://%s@%s:%.0f", password, addr["server"].(string), port)
|
||||||
uri = addParams(uri, params, addr["remark"].(string))
|
uri = addParams(uri, params, addr["remark"].(string))
|
||||||
links = append(links, uri)
|
links = append(links, uri)
|
||||||
}
|
}
|
||||||
@@ -556,11 +473,16 @@ func toBase64(d []byte) string {
|
|||||||
|
|
||||||
func addParams(uri string, params map[string]string, remark string) string {
|
func addParams(uri string, params map[string]string, remark string) string {
|
||||||
URL, _ := url.Parse(uri)
|
URL, _ := url.Parse(uri)
|
||||||
q := URL.Query()
|
var q []string
|
||||||
for k, v := range params {
|
for k, v := range params {
|
||||||
q.Add(k, v)
|
switch k {
|
||||||
|
case "mport", "alpn":
|
||||||
|
q = append(q, fmt.Sprintf("%s=%s", k, v))
|
||||||
|
default:
|
||||||
|
q = append(q, fmt.Sprintf("%s=%s", k, url.QueryEscape(v)))
|
||||||
}
|
}
|
||||||
URL.RawQuery = q.Encode()
|
}
|
||||||
|
URL.RawQuery = strings.Join(q, "&")
|
||||||
URL.Fragment = remark
|
URL.Fragment = remark
|
||||||
return URL.String()
|
return URL.String()
|
||||||
}
|
}
|
||||||
@@ -610,22 +532,35 @@ func getTransportParams(t interface{}) map[string]string {
|
|||||||
return params
|
return params
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTlsParams(t interface{}) map[string]string {
|
func getTlsParams(params *map[string]string, tls map[string]interface{}, insecureKey string) {
|
||||||
params := map[string]string{}
|
if reality, ok := tls["reality"].(map[string]interface{}); ok && reality["enabled"].(bool) {
|
||||||
if tls, hasTls := t.(map[string]interface{}); hasTls {
|
(*params)["security"] = "reality"
|
||||||
|
if pbk, ok := reality["public_key"].(string); ok {
|
||||||
|
(*params)["pbk"] = pbk
|
||||||
|
}
|
||||||
|
if sid, ok := reality["short_id"].(string); ok {
|
||||||
|
(*params)["sid"] = sid
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
(*params)["security"] = "tls"
|
||||||
|
if insecure, ok := tls["insecure"].(bool); ok && insecure {
|
||||||
|
(*params)[insecureKey] = "1"
|
||||||
|
}
|
||||||
|
if disableSni, ok := tls["disable_sni"].(bool); ok && disableSni {
|
||||||
|
(*params)["disable_sni"] = "1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if utls, ok := tls["utls"].(map[string]interface{}); ok {
|
||||||
|
(*params)["fp"], _ = utls["fingerprint"].(string)
|
||||||
|
}
|
||||||
if sni, ok := tls["server_name"].(string); ok {
|
if sni, ok := tls["server_name"].(string); ok {
|
||||||
params["sni"] = sni
|
(*params)["sni"] = sni
|
||||||
}
|
}
|
||||||
if alpn, ok := tls["alpn"].([]interface{}); ok {
|
if alpn, ok := tls["alpn"].([]interface{}); ok {
|
||||||
alpnList := make([]string, len(alpn))
|
alpnList := make([]string, len(alpn))
|
||||||
for i, v := range alpn {
|
for i, v := range alpn {
|
||||||
alpnList[i] = v.(string)
|
alpnList[i] = v.(string)
|
||||||
}
|
}
|
||||||
params["alpn"] = strings.Join(alpnList, ",")
|
(*params)["alpn"] = strings.Join(alpnList, ",")
|
||||||
}
|
}
|
||||||
if insecure, ok := tls["insecure"].(bool); ok && insecure {
|
|
||||||
params["insecure"] = "1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return params
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user