Documentation
¶
Index ¶
- Constants
- func AppendTimeInfo(config *Config, output string, startTime time.Time) string
- func BasicsAndSecurityCheck(language, checkType string, securityTestStatus bool) (string, string, string, string, string)
- func CpuTest(language, testMethod, testThread string) (string, string)
- func DiskTest(language, testMethod, testPath string, isMultiCheck, autoChange bool) (string, string)
- func FormatGoecsNumber(num int) string
- func GetIPv4Address() string
- func GetIPv6Address() string
- func GetMenuChoice(language string) string
- func HandleMenuMode(preCheck utils.NetCheckResult, config *Config)
- func HandleUploadResults(config *Config, output string)
- func MediaTest(language, region, ipVersion string, showIP bool) string
- func MemoryTest(language, testMethod string) (string, string)
- func NextTrace3Check(language, location, checkType string)
- func OnlyBasicsIpInfo(language string) (string, string, string)
- func PrintAndCapture(fn func(), tempOutput, existingOutput string) string
- func PrintCenteredTitle(title string, width int)
- func PrintHead(language string, width int, version string)
- func PrintMenuOptions(preCheck utils.NetCheckResult, config *Config)
- func ProcessAndUpload(output, filePath string, enableUpload bool, language string) (string, string)
- func RunBasicTests(preCheck utils.NetCheckResult, config *Config) string
- func RunCPUTest(config *Config) string
- func RunDiskTest(config *Config) string
- func RunEmailTests(config *Config, emailInfo string) string
- func RunEnglishNetworkTests(config *Config, ptInfo string) string
- func RunEnglishSpeedTests(config *Config) string
- func RunIpInfoCheck(config *Config) string
- func RunMemoryTest(config *Config) string
- func RunNetworkTests(config *Config, ptInfo string) string
- func RunSecurityTests(config *Config, securityInfo string) string
- func RunSpeedTests(config *Config) string
- func RunStreamingTests(config *Config, mediaInfo string) string
- func SetIPv4Address(ipv4 string)
- func SetIPv6Address(ipv6 string)
- func SpeedTestCustom(platform, operator string, num int, language string)
- func SpeedTestNearby()
- func SpeedTestShowHead(language string)
- func UpstreamsCheck(language string)
- type Config
- type ConfigOption
- func WithAnalyzeResult(enable bool) ConfigOption
- func WithAutoChangeDiskMethod(enable bool) ConfigOption
- func WithBacktraceTest(enable bool) ConfigOption
- func WithBasicTest(enable bool) ConfigOption
- func WithChoice(choice string) ConfigOption
- func WithCpuTest(enable bool) ConfigOption
- func WithCpuTestMethod(method string) ConfigOption
- func WithCpuTestThreadMode(mode string) ConfigOption
- func WithDiskMultiCheck(enable bool) ConfigOption
- func WithDiskTest(enable bool) ConfigOption
- func WithDiskTestMethod(method string) ConfigOption
- func WithDiskTestPath(path string) ConfigOption
- func WithEmailTest(enable bool) ConfigOption
- func WithEnableLogger(enable bool) ConfigOption
- func WithEnableUpload(enable bool) ConfigOption
- func WithFilePath(path string) ConfigOption
- func WithLanguage(lang string) ConfigOption
- func WithMemoryTest(enable bool) ConfigOption
- func WithMemoryTestMethod(method string) ConfigOption
- func WithMenuMode(enable bool) ConfigOption
- func WithNt3CheckType(checkType string) ConfigOption
- func WithNt3Location(location string) ConfigOption
- func WithNt3Test(enable bool) ConfigOption
- func WithOnlyChinaTest(enable bool) ConfigOption
- func WithOnlyIpInfoCheck(enable bool) ConfigOption
- func WithPingTest(enable bool) ConfigOption
- func WithSecurityTest(enable bool) ConfigOption
- func WithSpeedTest(enable bool) ConfigOption
- func WithSpeedTestNum(num int) ConfigOption
- func WithTgdcTest(enable bool) ConfigOption
- func WithUnlockTest(enable bool) ConfigOption
- func WithUnlockTestIPVersion(ipVersion string) ConfigOption
- func WithUnlockTestRegion(region string) ConfigOption
- func WithUnlockTestShowIP(enable bool) ConfigOption
- func WithWebTest(enable bool) ConfigOption
- func WithWidth(width int) ConfigOption
- type GitHubRelease
- type NetCheckResult
- type RunResult
- type StatsResponse
- type TestResult
Constants ¶
const ( // Version API版本号 Version = "v1.0.0" // DefaultVersion 默认的ECS版本号 DefaultVersion = "v0.1.137" )
const ( // CPU测试方法 CpuMethodSysbench = "sysbench" CpuMethodGeekbench = "geekbench" CpuMethodWinsat = "winsat" // 内存测试方法 MemoryMethodAuto = "auto" MemoryMethodStream = "stream" MemoryMethodSysbench = "sysbench" MemoryMethodDD = "dd" MemoryMethodWinsat = "winsat" // 硬盘测试方法 DiskMethodFio = "fio" DiskMethodDD = "dd" DiskMethodWinsat = "winsat" // 线程模式 ThreadModeSingle = "single" ThreadModeMulti = "multi" // 语言选项 LanguageZH = "zh" LanguageEN = "en" // IP检测类型 CheckTypeIPv4 = "ipv4" CheckTypeIPv6 = "ipv6" CheckTypeAuto = "auto" CheckTypeBoth = "both" // 流媒体解锁测试 IP 版本 UnlockIPVersionAuto = "auto" UnlockIPVersionIPv4 = "ipv4" UnlockIPVersionIPv6 = "ipv6" // 测速平台 PlatformCN = "cn" PlatformNet = "net" // 运营商类型 OperatorCMCC = "cmcc" // 中国移动 OperatorCU = "cu" // 中国联通 OperatorCT = "ct" // 中国电信 OperatorGlobal = "global" // 全球节点 OperatorOther = "other" // 其他 OperatorHK = "hk" // 香港 OperatorTW = "tw" // 台湾 OperatorJP = "jp" // 日本 OperatorSG = "sg" // 新加坡 )
测试方法常量
Variables ¶
This section is empty.
Functions ¶
func AppendTimeInfo ¶
AppendTimeInfo 添加时间信息
func BasicsAndSecurityCheck ¶
func BasicsAndSecurityCheck(language, checkType string, securityTestStatus bool) (string, string, string, string, string)
BasicsAndSecurityCheck 基础信息和安全检查 language: 语言 checkType: 检查类型 securityTestStatus: 是否执行安全测试 返回: (IPv4地址, IPv6地址, 基础信息, 安全信息, 检查类型)
func CpuTest ¶
CpuTest CPU测试公共接口 language: 语言 ("zh" 或 "en") testMethod: 测试方法 ("sysbench", "geekbench" 或 "winsat") testThread: 线程模式 ("single" 或 "multi") 返回: (实际测试方法, 测试结果)
func DiskTest ¶
func DiskTest(language, testMethod, testPath string, isMultiCheck, autoChange bool) (string, string)
DiskTest 硬盘测试公共接口 language: 语言 ("zh" 或 "en") testMethod: 测试方法 ("fio", "dd" 或 "winsat") testPath: 测试路径 isMultiCheck: 是否多路径检测 autoChange: 是否自动切换方法 返回: (实际测试方法, 测试结果)
func FormatGoecsNumber ¶
FormatGoecsNumber 格式化数字显示 num: 数字 返回: 格式化后的字符串
func GetMenuChoice ¶
GetMenuChoice 获取用户菜单选择 language: 语言 ("zh" 或 "en") 返回: 用户选择的选项
func HandleMenuMode ¶
func HandleMenuMode(preCheck utils.NetCheckResult, config *Config)
HandleMenuMode 处理菜单模式 preCheck: 网络检查结果 config: 配置对象
func HandleUploadResults ¶
HandleUploadResults 处理上传结果
func MediaTest ¶
MediaTest 流媒体解锁测试公共接口 language: 语言 ("zh" 或 "en") region: 检测地区 ("0"=跨国平台, ..., "20"=全部平台) ipVersion: 测试的IP版本 ("auto"=全测, "ipv4", "ipv6") showIP: 是否在输出中显示 IPV4:/IPV6: 标签 返回: 测试结果
func MemoryTest ¶
MemoryTest 内存测试公共接口 language: 语言 ("zh" 或 "en") testMethod: 测试方法 ("stream", "sysbench", "dd", "winsat", "auto") 返回: (实际测试方法, 测试结果)
func NextTrace3Check ¶
func NextTrace3Check(language, location, checkType string)
NextTrace3Check 三网路由追踪测试 language: 语言 ("zh" 或 "en") location: 位置 checkType: 检测类型 ("ipv4", "ipv6", "both")
func OnlyBasicsIpInfo ¶
OnlyBasicsIpInfo 仅获取基础IP信息 language: 语言 返回: (IPv4地址, IPv6地址, IP信息)
func PrintAndCapture ¶
PrintAndCapture 打印并捕获输出 fn: 执行的函数 tempOutput: 临时输出 existingOutput: 现有输出 返回: 捕获的输出
func PrintCenteredTitle ¶
PrintCenteredTitle 打印居中标题 title: 标题文本 width: 显示宽度
func PrintMenuOptions ¶
func PrintMenuOptions(preCheck utils.NetCheckResult, config *Config)
PrintMenuOptions 打印菜单选项 preCheck: 网络检查结果 config: 配置对象
func ProcessAndUpload ¶
ProcessAndUpload 处理并上传结果 output: 输出内容 filePath: 文件路径 enableUpload: 是否启用上传 返回: (HTTP URL, HTTPS URL)
func RunBasicTests ¶
func RunBasicTests(preCheck utils.NetCheckResult, config *Config) string
RunBasicTests 运行基础信息测试
func RunEmailTests ¶
RunEmailTests 运行邮件端口测试
func RunEnglishNetworkTests ¶
RunEnglishNetworkTests 运行网络测试(英文模式)
func RunEnglishSpeedTests ¶
RunEnglishSpeedTests 运行测速测试(英文模式)
func RunNetworkTests ¶
RunNetworkTests 运行网络测试(中文模式)
func RunSecurityTests ¶
RunSecurityTests 运行安全测试
func RunStreamingTests ¶
RunStreamingTests 运行流媒体测试
func SpeedTestCustom ¶
SpeedTestCustom 自定义测速 platform: 平台 ("cn" 或 "net") operator: 运营商 ("cmcc", "cu", "ct", "global", "other" 等) num: 测试节点数量 language: 语言 ("zh" 或 "en")
func SpeedTestShowHead ¶
func SpeedTestShowHead(language string)
SpeedTestShowHead 显示测速表头 language: 语言 ("zh" 或 "en")
Types ¶
type Config ¶
Config 配置接口,导出用于外部调用
func ApplyOptions ¶
func ApplyOptions(config *Config, options ...ConfigOption) *Config
ApplyOptions 应用配置选项
type ConfigOption ¶
type ConfigOption func(*Config)
ConfigOption 配置选项函数类型
func WithAnalyzeResult ¶ added in v0.1.119
func WithAnalyzeResult(enable bool) ConfigOption
WithAnalyzeResult 设置是否启用测试后结果总结分析
func WithAutoChangeDiskMethod ¶
func WithAutoChangeDiskMethod(enable bool) ConfigOption
WithAutoChangeDiskMethod 设置是否自动切换硬盘测试方法
func WithBacktraceTest ¶
func WithBacktraceTest(enable bool) ConfigOption
WithBacktraceTest 设置是否执行回程路由测试
func WithCpuTestMethod ¶
func WithCpuTestMethod(method string) ConfigOption
WithCpuTestMethod 设置CPU测试方法 method: "sysbench", "geekbench" 或 "winsat"
func WithCpuTestThreadMode ¶
func WithCpuTestThreadMode(mode string) ConfigOption
WithCpuTestThreadMode 设置CPU测试线程模式 mode: "single" 或 "multi"
func WithDiskMultiCheck ¶
func WithDiskMultiCheck(enable bool) ConfigOption
WithDiskMultiCheck 设置是否进行硬盘多路径检测
func WithDiskTestMethod ¶
func WithDiskTestMethod(method string) ConfigOption
WithDiskTestMethod 设置硬盘测试方法 method: "fio", "dd" 或 "winsat"
func WithMemoryTestMethod ¶
func WithMemoryTestMethod(method string) ConfigOption
WithMemoryTestMethod 设置内存测试方法 method: "stream", "sysbench", "dd", "winsat" 或 "auto"
func WithNt3CheckType ¶
func WithNt3CheckType(checkType string) ConfigOption
WithNt3CheckType 设置三网路由检测类型 checkType: "ipv4", "ipv6" 或 "both"
func WithNt3Location ¶
func WithNt3Location(location string) ConfigOption
WithNt3Location 设置三网路由检测位置
func WithOnlyChinaTest ¶
func WithOnlyChinaTest(enable bool) ConfigOption
WithOnlyChinaTest 设置是否只进行国内测试
func WithOnlyIpInfoCheck ¶
func WithOnlyIpInfoCheck(enable bool) ConfigOption
WithOnlyIpInfoCheck 设置是否只进行IP信息检测
func WithSecurityTest ¶
func WithSecurityTest(enable bool) ConfigOption
WithSecurityTest 设置是否执行IP质量测试
func WithUnlockTestIPVersion ¶ added in v0.1.137
func WithUnlockTestIPVersion(ipVersion string) ConfigOption
WithUnlockTestIPVersion 设置流媒体解锁测试 IP 版本 ipVersion: "auto", "ipv4" 或 "ipv6"
func WithUnlockTestRegion ¶ added in v0.1.137
func WithUnlockTestRegion(region string) ConfigOption
WithUnlockTestRegion 设置流媒体解锁检测地区 region: "0" 到 "20"
func WithUnlockTestShowIP ¶ added in v0.1.137
func WithUnlockTestShowIP(enable bool) ConfigOption
WithUnlockTestShowIP 设置流媒体测试输出是否显示 IPV4:/IPV6: 标签
type GitHubRelease ¶
type GitHubRelease = utils.GitHubRelease
GitHubRelease GitHub发布信息
func GetLatestEcsRelease ¶
func GetLatestEcsRelease() (*GitHubRelease, error)
GetLatestEcsRelease 获取最新的ECS版本信息 返回: (GitHub发布信息, 错误)
type NetCheckResult ¶
type NetCheckResult = utils.NetCheckResult
NetCheckResult 网络检查结果
func CheckPublicAccess ¶
func CheckPublicAccess(timeout time.Duration) NetCheckResult
CheckPublicAccess 检查公网访问能力 timeout: 超时时间 返回: 网络检查结果
type RunResult ¶
type RunResult struct {
Output string // 完整输出
Duration time.Duration // 运行时长
StartTime time.Time // 开始时间
EndTime time.Time // 结束时间
}
RunResult 运行结果
func RunAllTests ¶
func RunAllTests(preCheck utils.NetCheckResult, config *Config) *RunResult
RunAllTests 执行所有测试(高级接口) preCheck: 网络检查结果 config: 配置对象 返回: 运行结果
type StatsResponse ¶
type StatsResponse = utils.StatsResponse
StatsResponse 统计信息响应
func GetGoescStats ¶
func GetGoescStats() (*StatsResponse, error)
GetGoescStats 获取goecs统计信息 返回: (统计响应, 错误)