mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-10-09 11:16:37 +08:00
优化gost执行诊断时计入DNS解析时间的问题
This commit is contained in:
+1
-1
@@ -119,7 +119,7 @@ func main() {
|
|||||||
log := xlogger.NewLogger()
|
log := xlogger.NewLogger()
|
||||||
logger.SetDefault(log)
|
logger.SetDefault(log)
|
||||||
|
|
||||||
wsReporter := socket.StartWebSocketReporterWithConfig(config.Addr, config.Secret, config.Http, config.Tls, config.Socks, "2.0.1")
|
wsReporter := socket.StartWebSocketReporterWithConfig(config.Addr, config.Secret, config.Http, config.Tls, config.Socks, "2.0.2")
|
||||||
defer wsReporter.Stop()
|
defer wsReporter.Stop()
|
||||||
service.SetHTTPReportURL(config.Addr, config.Secret)
|
service.SetHTTPReportURL(config.Addr, config.Secret)
|
||||||
|
|
||||||
|
|||||||
@@ -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"
|
||||||
@@ -1133,7 +1133,6 @@ 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,避免每次连接都重新解析导致延迟累加
|
// 如果是域名,先解析一次DNS,避免每次连接都重新解析导致延迟累加
|
||||||
var resolvedIPs []string
|
|
||||||
if net.ParseIP(ip) == nil {
|
if net.ParseIP(ip) == nil {
|
||||||
// 是域名,需要解析
|
// 是域名,需要解析
|
||||||
fmt.Printf("🔍 检测到域名,正在解析DNS...\n")
|
fmt.Printf("🔍 检测到域名,正在解析DNS...\n")
|
||||||
@@ -1149,7 +1148,6 @@ func tcpPingHost(ip string, port int, count int, timeoutMs int) (float64, float6
|
|||||||
return 0, 100.0, fmt.Errorf("DNS解析未返回任何IP地址")
|
return 0, 100.0, fmt.Errorf("DNS解析未返回任何IP地址")
|
||||||
}
|
}
|
||||||
|
|
||||||
resolvedIPs = addrs
|
|
||||||
fmt.Printf("✅ DNS解析完成 (%.2fms),解析到 %d 个IP: %v\n",
|
fmt.Printf("✅ DNS解析完成 (%.2fms),解析到 %d 个IP: %v\n",
|
||||||
dnsDuration.Seconds()*1000, len(addrs), addrs)
|
dnsDuration.Seconds()*1000, len(addrs), addrs)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user