修复稳定版面板显示屏蔽协议状态不一致问题

This commit is contained in:
qaq
2025-11-25 09:18:40 +08:00
parent b83f6c0023
commit f3a9684be4
8 changed files with 128 additions and 77 deletions
+1 -1
View File
@@ -2,7 +2,7 @@ name: Build and Push Images Based on Version
# 在这里定义统一版本号 # 在这里定义统一版本号
env: env:
VERSION: "1.4.2" VERSION: "1.4.3"
on: on:
push: push:
+2 -2
View File
@@ -26,7 +26,7 @@ services:
retries: 10 retries: 10
backend: backend:
image: bqlpfy/springboot-backend:1.4.2 image: bqlpfy/springboot-backend:1.4.3
container_name: springboot-backend container_name: springboot-backend
restart: unless-stopped restart: unless-stopped
environment: environment:
@@ -54,7 +54,7 @@ services:
start_period: 90s start_period: 90s
frontend: frontend:
image: bqlpfy/vite-frontend:1.4.2 image: bqlpfy/vite-frontend:1.4.3
container_name: vite-frontend container_name: vite-frontend
restart: unless-stopped restart: unless-stopped
ports: ports:
+2 -2
View File
@@ -26,7 +26,7 @@ services:
retries: 10 retries: 10
backend: backend:
image: bqlpfy/springboot-backend:1.4.2 image: bqlpfy/springboot-backend:1.4.3
container_name: springboot-backend container_name: springboot-backend
restart: unless-stopped restart: unless-stopped
environment: environment:
@@ -54,7 +54,7 @@ services:
start_period: 90s start_period: 90s
frontend: frontend:
image: bqlpfy/vite-frontend:1.4.2 image: bqlpfy/vite-frontend:1.4.3
container_name: vite-frontend container_name: vite-frontend
restart: unless-stopped restart: unless-stopped
ports: ports:
+55 -4
View File
@@ -14,8 +14,8 @@ import (
"time" "time"
"github.com/go-gost/x/config" "github.com/go-gost/x/config"
"github.com/go-gost/x/service"
"github.com/go-gost/x/internal/util/crypto" "github.com/go-gost/x/internal/util/crypto"
"github.com/go-gost/x/service"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"github.com/shirou/gopsutil/v3/cpu" "github.com/shirou/gopsutil/v3/cpu"
"github.com/shirou/gopsutil/v3/host" "github.com/shirou/gopsutil/v3/host"
@@ -87,6 +87,9 @@ type TcpPingResponse struct {
type WebSocketReporter struct { type WebSocketReporter struct {
url string url string
addr string // 保存服务器地址
secret string // 保存密钥
version string // 保存版本号
conn *websocket.Conn conn *websocket.Conn
reconnectTime time.Duration reconnectTime time.Duration
pingInterval time.Duration pingInterval time.Duration
@@ -195,7 +198,25 @@ func (w *WebSocketReporter) connect() error {
w.connecting = false w.connecting = false
}() }()
u, err := url.Parse(w.url) // 重新读取 config.json 获取最新的协议配置
type LocalConfig struct {
Addr string `json:"addr"`
Secret string `json:"secret"`
Http int `json:"http"`
Tls int `json:"tls"`
Socks int `json:"socks"`
}
var cfg LocalConfig
if b, err := os.ReadFile("config.json"); err == nil {
json.Unmarshal(b, &cfg)
}
// 使用最新的配置重新构建 URL
currentURL := "ws://" + w.addr + "/system-info?type=1&secret=" + w.secret + "&version=" + w.version +
"&http=" + strconv.Itoa(cfg.Http) + "&tls=" + strconv.Itoa(cfg.Tls) + "&socks=" + strconv.Itoa(cfg.Socks)
u, err := url.Parse(currentURL)
if err != nil { if err != nil {
return fmt.Errorf("解析URL失败: %v", err) return fmt.Errorf("解析URL失败: %v", err)
} }
@@ -225,7 +246,7 @@ func (w *WebSocketReporter) connect() error {
return nil return nil
}) })
fmt.Printf("✅ WebSocket连接建立成功\n") fmt.Printf("✅ WebSocket连接建立成功 (http=%d, tls=%d, socks=%d)\n", cfg.Http, cfg.Tls, cfg.Socks)
return nil return nil
} }
@@ -1021,12 +1042,16 @@ func getMemoryInfo() MemoryInfo {
// StartWebSocketReporterWithConfig 使用配置字段启动WebSocket报告器 // StartWebSocketReporterWithConfig 使用配置字段启动WebSocket报告器
func StartWebSocketReporterWithConfig(addr string, secret string, http int, tls int, socks int, version string) *WebSocketReporter { func StartWebSocketReporterWithConfig(addr string, secret string, http int, tls int, socks int, version string) *WebSocketReporter {
// 构建包含本机IP的WebSocket URL // 构建初始 WebSocket URL
fullURL := "ws://" + addr + "/system-info?type=1&secret=" + secret + "&version=" + version + "&http=" + strconv.Itoa(http) + "&tls=" + strconv.Itoa(tls) + "&socks=" + strconv.Itoa(socks) fullURL := "ws://" + addr + "/system-info?type=1&secret=" + secret + "&version=" + version + "&http=" + strconv.Itoa(http) + "&tls=" + strconv.Itoa(tls) + "&socks=" + strconv.Itoa(socks)
fmt.Printf("🔗 WebSocket连接URL: %s\n", fullURL) fmt.Printf("🔗 WebSocket连接URL: %s\n", fullURL)
reporter := NewWebSocketReporter(fullURL, secret) reporter := NewWebSocketReporter(fullURL, secret)
// 保存 addr, secret, version 供重连时使用
reporter.addr = addr
reporter.secret = secret
reporter.version = version
reporter.Start() reporter.Start()
return reporter return reporter
} }
@@ -1107,6 +1132,32 @@ func tcpPingHost(ip string, port int, count int, timeoutMs int) (float64, float6
fmt.Printf("🔍 开始TCP ping测试: %s,次数: %d,超时: %dms\n", target, count, timeoutMs) fmt.Printf("🔍 开始TCP ping测试: %s,次数: %d,超时: %dms\n", target, count, timeoutMs)
// 如果是域名,先解析一次DNS,避免每次连接都重新解析导致延迟累加
if net.ParseIP(ip) == nil {
// 是域名,需要解析
fmt.Printf("🔍 检测到域名,正在解析DNS...\n")
dnsStart := time.Now()
addrs, err := net.LookupHost(ip)
dnsDuration := time.Since(dnsStart)
if err != nil {
return 0, 100.0, fmt.Errorf("DNS解析失败: %v", err)
}
if len(addrs) == 0 {
return 0, 100.0, fmt.Errorf("DNS解析未返回任何IP地址")
}
fmt.Printf("✅ DNS解析完成 (%.2fms),解析到 %d 个IP: %v\n",
dnsDuration.Seconds()*1000, len(addrs), addrs)
// 使用第一个解析到的IP进行测试
target = net.JoinHostPort(addrs[0], fmt.Sprintf("%d", port))
fmt.Printf("🎯 使用IP地址进行测试: %s\n", target)
} else {
fmt.Printf("🎯 使用IP地址进行测试: %s\n", target)
}
for i := 0; i < count; i++ { for i := 0; i < count; i++ {
start := time.Now() start := time.Now()
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# 下载地址 # 下载地址
DOWNLOAD_URL="https://github.com/bqlpfy/flux-panel/releases/download/1.4.2/gost" DOWNLOAD_URL="https://github.com/bqlpfy/flux-panel/releases/download/1.4.3/gost"
INSTALL_DIR="/etc/gost" INSTALL_DIR="/etc/gost"
COUNTRY=$(curl -s https://ipinfo.io/country) COUNTRY=$(curl -s https://ipinfo.io/country)
if [ "$COUNTRY" = "CN" ]; then if [ "$COUNTRY" = "CN" ]; then
+3 -3
View File
@@ -8,9 +8,9 @@ export LC_ALL=C
# 全局下载地址配置 # 全局下载地址配置
DOCKER_COMPOSEV4_URL="https://github.com/bqlpfy/flux-panel/releases/download/1.4.2/docker-compose-v4.yml" DOCKER_COMPOSEV4_URL="https://github.com/bqlpfy/flux-panel/releases/download/1.4.3/docker-compose-v4.yml"
DOCKER_COMPOSEV6_URL="https://github.com/bqlpfy/flux-panel/releases/download/1.4.2/docker-compose-v6.yml" DOCKER_COMPOSEV6_URL="https://github.com/bqlpfy/flux-panel/releases/download/1.4.3/docker-compose-v6.yml"
GOST_SQL_URL="https://github.com/bqlpfy/flux-panel/releases/download/1.4.2/gost.sql" GOST_SQL_URL="https://github.com/bqlpfy/flux-panel/releases/download/1.4.3/gost.sql"
COUNTRY=$(curl -s https://ipinfo.io/country) COUNTRY=$(curl -s https://ipinfo.io/country)
if [ "$COUNTRY" = "CN" ]; then if [ "$COUNTRY" = "CN" ]; then
@@ -363,7 +363,7 @@ public class NodeServiceImpl extends ServiceImpl<NodeMapper, Node> implements No
StringBuilder command = new StringBuilder(); StringBuilder command = new StringBuilder();
// 第一部分:下载安装脚本 // 第一部分:下载安装脚本
command.append("curl -L https://github.com/bqlpfy/flux-panel/releases/download/1.4.2/install.sh") command.append("curl -L https://github.com/bqlpfy/flux-panel/releases/download/1.4.3/install.sh")
.append(" -o ./install.sh && chmod +x ./install.sh && "); .append(" -o ./install.sh && chmod +x ./install.sh && ");
// 处理服务器地址,如果是IPv6需要添加方括号 // 处理服务器地址,如果是IPv6需要添加方括号
+1 -1
View File
@@ -4,7 +4,7 @@ export type SiteConfig = typeof siteConfig;
// 缓存相关常量 // 缓存相关常量
const CACHE_PREFIX = 'vite_config_'; const CACHE_PREFIX = 'vite_config_';
const VERSION = "1.4.2"; const VERSION = "1.4.3";
const APP_VERSION = "1.0.3"; const APP_VERSION = "1.0.3";
const getInitialConfig = () => { const getInitialConfig = () => {