From e7fbc126a104653bc029205fd27bcbed2aa3ebaa Mon Sep 17 00:00:00 2001 From: spiritysdx Date: Sun, 30 Jun 2024 11:09:01 +0800 Subject: [PATCH] update --- go.mod | 4 +- go.sum | 14 ++--- goecs.go | 141 ++++++++++++++++++++++++++++++++------------ unlocktest/media.go | 7 --- 4 files changed, 109 insertions(+), 57 deletions(-) diff --git a/go.mod b/go.mod index d735bbdb..e35008e0 100644 --- a/go.mod +++ b/go.mod @@ -3,11 +3,11 @@ module github.com/oneclickvirt/ecs go 1.22.4 require ( - github.com/oneclickvirt/CommonMediaTests v0.0.1-20240624094420 + github.com/oneclickvirt/CommonMediaTests v0.0.2-20240630023003 github.com/oneclickvirt/UnlockTests v0.0.7-20240624115527 github.com/oneclickvirt/backtrace v0.0.4-20240624090335 github.com/oneclickvirt/basics v0.0.3-20240625075226 - github.com/oneclickvirt/cputest v0.0.4-20240629151354 + github.com/oneclickvirt/cputest v0.0.5-20240630022206 github.com/oneclickvirt/defaultset v0.0.2-20240624082446 github.com/oneclickvirt/disktest v0.0.3-20240629152513 github.com/oneclickvirt/memorytest v0.0.1-20240624151629 diff --git a/go.sum b/go.sum index 553c0a8f..ba6eecbb 100644 --- a/go.sum +++ b/go.sum @@ -85,22 +85,18 @@ github.com/moul/http2curl v1.0.0 h1:dRMWoAtb+ePxMlLkrCbAqh4TlPHXvoGUSQ323/9Zahs= github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= github.com/nxtrace/NTrace-core v1.3.1 h1:f4z5UaZEuhUP/g6xElpZ2bo+guWITJVrMKrJTqd27oc= github.com/nxtrace/NTrace-core v1.3.1/go.mod h1:0Px/Zc60qk6cssmP+yv4kstFxvX9sXqDduoVqBO+qf8= -github.com/oneclickvirt/CommonMediaTests v0.0.1-20240624094420 h1:CBsjuTpAtangTNkfLQDWEDPz3VcBjGHd8WCtifCmTlI= -github.com/oneclickvirt/CommonMediaTests v0.0.1-20240624094420/go.mod h1:DAmFPRjFV5p9fEzUUSml5jJGn2f1NZJQCzTxITHDjc4= +github.com/oneclickvirt/CommonMediaTests v0.0.2-20240630023003 h1:8jQFqDK5m7V9xlLBk8rSUYDyi3u5xzf5kqwEx5b+/7g= +github.com/oneclickvirt/CommonMediaTests v0.0.2-20240630023003/go.mod h1:DAmFPRjFV5p9fEzUUSml5jJGn2f1NZJQCzTxITHDjc4= github.com/oneclickvirt/UnlockTests v0.0.7-20240624115527 h1:rMC+aLDkvOe9K+AXjUt/IMAOx1LieyBv6DN/0/2ww7Q= github.com/oneclickvirt/UnlockTests v0.0.7-20240624115527/go.mod h1:HP3CvAS+AJWxxY+BVbxIOlvaQ87YOSge89vAMG52b5o= github.com/oneclickvirt/backtrace v0.0.4-20240624090335 h1:0LP5KyA6GLlqQAtOF0uyBSAykHJrzOA96Eb87qUhGQw= github.com/oneclickvirt/backtrace v0.0.4-20240624090335/go.mod h1:zvsC7xY/WZqs5KL2JB967OVnuqjNbxu9bW6wXRLo5h8= github.com/oneclickvirt/basics v0.0.3-20240625075226 h1:K9VriCHIYnXPZXBSn9PRQX+jBS6AIFH8tBVb/i8VGAw= github.com/oneclickvirt/basics v0.0.3-20240625075226/go.mod h1:dTB+/oyFQYfTYX55rFJVWatum5F9g62zjfmHCM6Vj1s= -github.com/oneclickvirt/cputest v0.0.2-20240624103336 h1:7rrVqE1ODzuItuAXcU1/w4lUOxD7hXXB+c2weoO4eZk= -github.com/oneclickvirt/cputest v0.0.2-20240624103336/go.mod h1:wh4fGT3KFG9qztew5eBL9EfWr8WeZPBLsq60ZzudU4g= -github.com/oneclickvirt/cputest v0.0.4-20240629151354 h1:UkczgwTdBQUAzmyTUslwqOXSzEwNpBYIQF3RPcSZiH8= -github.com/oneclickvirt/cputest v0.0.4-20240629151354/go.mod h1:wh4fGT3KFG9qztew5eBL9EfWr8WeZPBLsq60ZzudU4g= +github.com/oneclickvirt/cputest v0.0.5-20240630022206 h1:L+Su9CNpERf7ZwJZPhvasZdXrlEt6VfqZQpuaPntzkI= +github.com/oneclickvirt/cputest v0.0.5-20240630022206/go.mod h1:wh4fGT3KFG9qztew5eBL9EfWr8WeZPBLsq60ZzudU4g= github.com/oneclickvirt/defaultset v0.0.2-20240624082446 h1:5Pg3mK/u/vQvSz7anu0nxzrNdELi/AcDAU1mMsmPzyc= github.com/oneclickvirt/defaultset v0.0.2-20240624082446/go.mod h1:e9Jt4tf2sbemCtc84/XgKcHy9EZ2jkc5x2sW1NiJS+E= -github.com/oneclickvirt/disktest v0.0.2-20240624145436 h1:c3bt6kB3FKtrMP/tGUIQWTadoiZwP9zcUkaSdsPF9mQ= -github.com/oneclickvirt/disktest v0.0.2-20240624145436/go.mod h1:x7VAJF0Ks05FyE4BI5xedXNKmwbeXfp8GCRALAIlueI= github.com/oneclickvirt/disktest v0.0.3-20240629152513 h1:ZW7MBMd2HxQi1ktg/ztVI2A10JzF4ZI6I7ATZvcK9w8= github.com/oneclickvirt/disktest v0.0.3-20240629152513/go.mod h1:x7VAJF0Ks05FyE4BI5xedXNKmwbeXfp8GCRALAIlueI= github.com/oneclickvirt/gostun v0.0.2-20240625025941 h1:h+ZL8jkjXR6QE0qEX34FjWTv89+lNj2fEkWx5Agpgzc= @@ -113,8 +109,6 @@ github.com/oneclickvirt/portchecker v0.0.1-20240624155429 h1:+wapaOcFrg1iWJDhBKT github.com/oneclickvirt/portchecker v0.0.1-20240624155429/go.mod h1:HQxSTrqM8/QFqHMTBZ7S8H9eEO5FkUXU1eb7ZX5Mk+k= github.com/oneclickvirt/security v0.0.1-20240625075931 h1:Vj1Wq/JVcqYpfqUWRtsITbz3zM4HxnLC0iPxxA6akP0= github.com/oneclickvirt/security v0.0.1-20240625075931/go.mod h1:6bjZjpYJ8M3aRIcLP61b0mjYRwvtWbYkvoGjS28Bdy4= -github.com/oneclickvirt/speedtest v0.0.3-20240629093211 h1:SU1aGYLpszp3csg599PjlrI/u32KNlHC/FiCx2ucn6w= -github.com/oneclickvirt/speedtest v0.0.3-20240629093211/go.mod h1:JNIxUbEJD12w81b7754RLHD55fsH6wHj+fCV2PqBDhk= github.com/oneclickvirt/speedtest v0.0.4-20240629100548 h1:DQA0R/EdtmLJrQBb9JvQBaBpcMgiGDvIHq+0quNZQQM= github.com/oneclickvirt/speedtest v0.0.4-20240629100548/go.mod h1:JNIxUbEJD12w81b7754RLHD55fsH6wHj+fCV2PqBDhk= github.com/onsi/ginkgo/v2 v2.16.0 h1:7q1w9frJDzninhXxjZd+Y/x54XNjG/UlRLIYPZafsPM= diff --git a/goecs.go b/goecs.go index e50d1a5d..116c1dc8 100644 --- a/goecs.go +++ b/goecs.go @@ -3,6 +3,7 @@ package main import ( "flag" "fmt" + "github.com/oneclickvirt/UnlockTests/uts" "github.com/oneclickvirt/ecs/backtrace" "github.com/oneclickvirt/ecs/basic" "github.com/oneclickvirt/ecs/commediatest" @@ -11,15 +12,29 @@ import ( "github.com/oneclickvirt/ecs/memorytest" "github.com/oneclickvirt/ecs/network" "github.com/oneclickvirt/ecs/ntrace" - "github.com/oneclickvirt/ecs/port" "github.com/oneclickvirt/ecs/speedtest" "github.com/oneclickvirt/ecs/unlocktest" + "github.com/oneclickvirt/portchecker/email" "runtime" "strings" + "sync" "time" "unicode/utf8" ) +var ( + ecsVersion = "2024.06.30" + showVersion bool + language string + cpuTestMethod, cpuTestThread string + memoryTestMethod string + diskTestMethod, diskTestPath string + diskMultiCheck bool + nt3CheckType, nt3Location string + spNum int + width = 84 +) + func printCenteredTitle(title string, width int) { titleLength := utf8.RuneCountInString(title) // 计算字符串的字符数 totalPadding := width - titleLength @@ -28,19 +43,52 @@ func printCenteredTitle(title string, width int) { fmt.Println(paddingStr + title + paddingStr + strings.Repeat("-", totalPadding%2)) } +func securityCheck() string { + ipInfo, securityInfo, _ := network.NetworkCheck("both", true, language) + if strings.Contains(ipInfo, "IPV4") && strings.Contains(ipInfo, "IPV6") { + uts.IPV4 = true + uts.IPV6 = true + if nt3CheckType == "" { + nt3CheckType = "ipv4" + } + } else if strings.Contains(ipInfo, "IPV4") { + uts.IPV4 = true + uts.IPV6 = false + if nt3CheckType == "" { + nt3CheckType = "ipv4" + } + } else if strings.Contains(ipInfo, "IPV6") { + uts.IPV6 = true + uts.IPV4 = false + if nt3CheckType == "" { + nt3CheckType = "ipv6" + } + } + if nt3CheckType == "ipv4" && !strings.Contains(ipInfo, "IPV4") && strings.Contains(ipInfo, "IPV6") { + nt3CheckType = "ipv6" + } else if nt3CheckType == "ipv6" && !strings.Contains(ipInfo, "IPV6") && strings.Contains(ipInfo, "IPV4") { + nt3CheckType = "ipv4" + } + return securityInfo +} + +func printHead() { + if language == "zh" { + printCenteredTitle("融合怪测试", width) + fmt.Printf("版本:%s\n", ecsVersion) + fmt.Println("测评频道: https://t.me/vps_reviews\n" + + "Go项目地址:https://github.com/oneclickvirt/ecs\n" + + "Shell项目地址:https://github.com/spiritLHLS/ecs") + } else { + printCenteredTitle("Fusion Monster Test", width) + fmt.Printf("Version: %s\n", ecsVersion) + fmt.Println("Review Channel: https://t.me/vps_reviews\n" + + "Go Project URL: https://github.com/oneclickvirt/ecs\n" + + "Shell Project URL: https://github.com/spiritLHLS/ecs") + } +} + func main() { - var ( - ecsVersion = "2024.06.29" - showVersion bool - language string - cpuTestMethod, cpuTestThread string - memoryTestMethod string - diskTestMethod, diskTestPath string - diskMultiCheck bool - nt3CheckType, nt3Location string - spNum int - width = 84 - ) flag.BoolVar(&showVersion, "v", false, "Show version information") flag.StringVar(&language, "l", "zh", "Specify language (supported: en, zh)") flag.StringVar(&cpuTestMethod, "cpum", "sysbench", "Specify CPU test method (supported: sysbench, geekbench, winsat)") @@ -61,43 +109,48 @@ func main() { return } startTime := time.Now() + var wg sync.WaitGroup + var securityInfo, emailInfo string if language == "zh" { - printCenteredTitle("融合怪测试", width) - fmt.Printf("版本:%s\n", ecsVersion) - fmt.Println("测评频道: https://t.me/vps_reviews\nGo项目地址:https://github.com/oneclickvirt/ecs\nShell项目地址:https://github.com/spiritLHLS/ecs") + printHead() printCenteredTitle("基础信息", width) - basic.Basic(language) + wg.Add(2) + go func() { + defer wg.Done() + basic.Basic(language) + }() + go func() { + defer wg.Done() + securityInfo = securityCheck() + }() + wg.Wait() printCenteredTitle(fmt.Sprintf("CPU测试-通过%s测试", cpuTestMethod), width) cputest.CpuTest(language, cpuTestMethod, cpuTestThread) printCenteredTitle(fmt.Sprintf("内存测试-通过%s测试", cpuTestMethod), width) memorytest.MemoryTest(language, memoryTestMethod) printCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", diskTestMethod), width) disktest.DiskTest(language, diskTestMethod, diskTestPath, diskMultiCheck) + wg.Add(1) + go func() { + defer wg.Done() + emailInfo = email.EmailCheck() + }() printCenteredTitle("御三家流媒体解锁", width) commediatest.ComMediaTest(language) printCenteredTitle("跨国流媒体解锁", width) unlocktest.MediaTest(language) printCenteredTitle("IP质量检测", width) - ipInfo, securityInfo, _ := network.NetworkCheck("both", true, language) fmt.Printf(securityInfo) printCenteredTitle("邮件端口检测", width) - port.EmailCheck() + wg.Wait() + fmt.Println(emailInfo) + printCenteredTitle("三网回程", width) + backtrace.BackTrace() if runtime.GOOS != "windows" { // nexttrace 在win上不支持检测,报错 bind: An invalid argument was supplied. - printCenteredTitle("三网回程", width) - backtrace.BackTrace() + printCenteredTitle("路由检测", width) + ntrace.TraceRoute3(language, nt3Location, nt3CheckType) } - printCenteredTitle("三网回程路由", width) - if nt3CheckType == "" && strings.Contains(ipInfo, "IPV4") { - nt3CheckType = "ipv4" - } else if nt3CheckType == "" && strings.Contains(ipInfo, "IPV6") { - nt3CheckType = "ipv6" - } else if nt3CheckType == "ipv4" && !strings.Contains(ipInfo, "IPV4") && strings.Contains(ipInfo, "IPV6") { - nt3CheckType = "ipv6" - } else if nt3CheckType == "ipv6" && !strings.Contains(ipInfo, "IPV6") && strings.Contains(ipInfo, "IPV4") { - nt3CheckType = "ipv4" - } - ntrace.TraceRoute3(language, nt3Location, nt3CheckType) printCenteredTitle("就近节点测速", width) speedtest.ShowHead(language) speedtest.NearbySP() @@ -115,26 +168,38 @@ func main() { fmt.Printf("时间 : %s\n", currentTime) printCenteredTitle("", width) } else if language == "en" { - printCenteredTitle("Fusion Monster Test", width) - fmt.Printf("Version: %s\n", ecsVersion) - fmt.Println("Review Channel: https://t.me/vps_reviews\nGo Project URL: https://github.com/oneclickvirt/ecs\nShell Project URL: https://github.com/spiritLHLS/ecs") + printHead() printCenteredTitle("Basic Information", width) - basic.Basic(language) + wg.Add(2) + go func() { + defer wg.Done() + basic.Basic(language) + }() + go func() { + defer wg.Done() + securityInfo = securityCheck() + }() + wg.Wait() printCenteredTitle(fmt.Sprintf("CPU Test - %s Method", cpuTestMethod), width) cputest.CpuTest(language, cpuTestMethod, cpuTestThread) printCenteredTitle(fmt.Sprintf("Memory Test - %s Method", memoryTestMethod), width) memorytest.MemoryTest(language, memoryTestMethod) printCenteredTitle(fmt.Sprintf("Disk Test - %s Method", diskTestMethod), width) disktest.DiskTest(language, diskTestMethod, diskTestPath, diskMultiCheck) + wg.Add(1) + go func() { + defer wg.Done() + emailInfo = email.EmailCheck() + }() printCenteredTitle("The Three Families Streaming Media Unlock", width) commediatest.ComMediaTest(language) printCenteredTitle("Cross-Border Streaming Media Unlock", width) unlocktest.MediaTest(language) printCenteredTitle("IP Quality Check", width) - _, securityInfo, _ := network.NetworkCheck("both", true, language) fmt.Printf(securityInfo) printCenteredTitle("Email Port Check", width) - port.EmailCheck() + wg.Wait() + fmt.Println(emailInfo) //printCenteredTitle("Return Path Routing", width) printCenteredTitle("Nearby Node Speed Test", width) speedtest.ShowHead(language) diff --git a/unlocktest/media.go b/unlocktest/media.go index a260191a..471ba694 100644 --- a/unlocktest/media.go +++ b/unlocktest/media.go @@ -8,17 +8,10 @@ import ( ) func MediaTest(language string) { - uts.GetIpv4Info(false) - uts.GetIpv6Info(false) readStatus := uts.ReadSelect(language, "0") if !readStatus { return } - //if language == "zh" { - // fmt.Println("测试时间: ", defaultset.Yellow(time.Now().Format("2006-01-02 15:04:05"))) - //} else { - // fmt.Println("Test time: ", defaultset.Yellow(time.Now().Format("2006-01-02 15:04:05"))) - //} if uts.IPV4 { fmt.Println(defaultset.Blue("IPV4:")) uts.RunTests(utils.Ipv4HttpClient, "ipv4", language)