package app import ( "douyu_go/internal/client" "douyu_go/internal/logger" "douyu_go/internal/types" ) // TestProxy 测试指定代理的连通性、出口公网 IP 与往返延迟。 func (a *App) TestProxy(proxyURL string) types.ProxyTestResult { res := client.TestProxyConnection(proxyURL) if res.Success { logger.LogEvent("代理", "success", "代理测试成功: IP=%s 归属=%s 延迟=%dms", res.IP, res.Region, res.Latency) } else { logger.LogEvent("代理", "warn", "代理测试失败: %s", res.Error) } return res } // FetchProxy 从指定 API 提取一个代理 IP。 func (a *App) FetchProxy(apiURL string) types.ProxyFetchResult { res, err := client.FetchProxyFromAPI(apiURL) if err != nil { logger.LogEvent("代理", "warn", "代理提取失败: %v", err) return types.ProxyFetchResult{ Success: false, Error: err.Error(), } } logger.LogEvent("代理", "success", "代理提取成功: %s (IP=%s 端口=%s 地区=%s)", res.ProxyURL, res.IP, res.Port, res.Region) return *res }