Compare commits

...

11 Commits

8 changed files with 99 additions and 62 deletions

View File

@@ -62,6 +62,7 @@ Shell 版本:[https://github.com/spiritLHLS/ecs](https://github.com/spiritLHLS
- 三网路由测试:基于 [NTrace-core](https://github.com/nxtrace/NTrace-core),二次开发至 [nt3](https://github.com/oneclickvirt/nt3) - 三网路由测试:基于 [NTrace-core](https://github.com/nxtrace/NTrace-core),二次开发至 [nt3](https://github.com/oneclickvirt/nt3)
- 网速测试:基于 [speedtest.net](https://github.com/spiritLHLS/speedtest.net-CN-ID) 和 [speedtest.cn](https://github.com/spiritLHLS/speedtest.cn-CN-ID) 数据,开发至 [oneclickvirt/speedtest](https://github.com/oneclickvirt/speedtest) - 网速测试:基于 [speedtest.net](https://github.com/spiritLHLS/speedtest.net-CN-ID) 和 [speedtest.cn](https://github.com/spiritLHLS/speedtest.cn-CN-ID) 数据,开发至 [oneclickvirt/speedtest](https://github.com/oneclickvirt/speedtest)
- 三网 Ping 值测试:借鉴 [ecsspeed](https://github.com/spiritLHLS/ecsspeed),二次开发至 [pingtest](https://github.com/oneclickvirt/pingtest) - 三网 Ping 值测试:借鉴 [ecsspeed](https://github.com/spiritLHLS/ecsspeed),二次开发至 [pingtest](https://github.com/oneclickvirt/pingtest)
- 支持root或admin环境下测试也支持非root或非admin环境下测试半支持离线环境下进行测试未支持无DNS环境下进行测试
**本项目初次使用建议查看说明:[跳转](https://github.com/oneclickvirt/ecs/blob/master/README_NEW_USER.md)** **本项目初次使用建议查看说明:[跳转](https://github.com/oneclickvirt/ecs/blob/master/README_NEW_USER.md)**
@@ -368,7 +369,7 @@ GOOS=darwin GOARCH=amd64 go build -o goecs_darwin
## 致谢 ## 致谢
感谢 [he.net](https://he.net) [bgp.tools](https://bgp.tools) [ipinfo.io](https://ipinfo.io) [ip.sb](https://ip.sb) [cheervision.co](https://cheervision.co) [scamalytics.com](https://scamalytics.com) [abuseipdb.com](https://www.abuseipdb.com/) [virustotal.com](https://www.virustotal.com/) [ip2location.com](https://ip2location.com/) [ip-api.com](https://ip-api.com) [ipregistry.co](https://ipregistry.co/) [ipdata.co](https://ipdata.co/) [ipgeolocation.io](https://ipgeolocation.io) [ipwhois.io](https://ipwhois.io) [ipapi.com](https://ipapi.com/) [ipapi.is](https://ipapi.is/) [ipqualityscore.com](https://www.ipqualityscore.com/) [bigdatacloud.com](https://www.bigdatacloud.com/) 等网站提供的API进行检测感谢互联网各网站提供的查询资源 感谢 [he.net](https://he.net) [bgp.tools](https://bgp.tools) [ipinfo.io](https://ipinfo.io) [maxmind.com](https://www.maxmind.com/en/home) [cloudflare.com](https://www.cloudflare.com/) [ip.sb](https://ip.sb) [scamalytics.com](https://scamalytics.com) [abuseipdb.com](https://www.abuseipdb.com/) [ip2location.com](https://ip2location.com/) [ip-api.com](https://ip-api.com) [ipregistry.co](https://ipregistry.co/) [ipdata.co](https://ipdata.co/) [ipgeolocation.io](https://ipgeolocation.io) [ipwhois.io](https://ipwhois.io) [ipapi.com](https://ipapi.com/) [ipapi.is](https://ipapi.is/) [ipqualityscore.com](https://www.ipqualityscore.com/) [bigdatacloud.com](https://www.bigdatacloud.com/) [dkly.net](https://data.dkly.net) [virustotal.com](https://www.virustotal.com/) 等网站提供的API进行检测感谢互联网各网站提供的查询资源
感谢 感谢

View File

@@ -58,6 +58,7 @@ Shell version: [https://github.com/spiritLHLS/ecs/blob/main/README_EN.md](https:
- Three-network route test: Modified from [NTrace-core](https://github.com/nxtrace/NTrace-core) to [nt3](https://github.com/oneclickvirt/nt3) - Three-network route test: Modified from [NTrace-core](https://github.com/nxtrace/NTrace-core) to [nt3](https://github.com/oneclickvirt/nt3)
- Speed test: Based on data from [speedtest.net](https://github.com/spiritLHLS/speedtest.net-CN-ID) and [speedtest.cn](https://github.com/spiritLHLS/speedtest.cn-CN-ID), developed to [oneclickvirt/speedtest](https://github.com/oneclickvirt/speedtest) - Speed test: Based on data from [speedtest.net](https://github.com/spiritLHLS/speedtest.net-CN-ID) and [speedtest.cn](https://github.com/spiritLHLS/speedtest.cn-CN-ID), developed to [oneclickvirt/speedtest](https://github.com/oneclickvirt/speedtest)
- Three-network Ping test: Modified from [ecsspeed](https://github.com/spiritLHLS/ecsspeed) to [pingtest](https://github.com/oneclickvirt/pingtest) - Three-network Ping test: Modified from [ecsspeed](https://github.com/spiritLHLS/ecsspeed) to [pingtest](https://github.com/oneclickvirt/pingtest)
- Support root or admin environment testing, also support non-root or non-admin environment testing, semi-support offline environment for testing, not support no DNS environment for testing
**For first-time users of this project, it is recommended to check the instructions: [Jump to](https://github.com/oneclickvirt/ecs/blob/master/README_NEW_USER.md)** **For first-time users of this project, it is recommended to check the instructions: [Jump to](https://github.com/oneclickvirt/ecs/blob/master/README_NEW_USER.md)**
@@ -362,7 +363,7 @@ Note that `goecs` allows you to specify CPU test method via parameters. The defa
## Thanks ## Thanks
Thank [he.net](https://he.net) [bgp.tools](https://bgp.tools) [ipinfo.io](https://ipinfo.io) [ip.sb](https://ip.sb) [cheervision.co](https://cheervision.co) [scamalytics.com](https://scamalytics.com) [abuseipdb.com](https://www.abuseipdb.com/) [virustotal.com](https://www.virustotal.com/) [ip2location.com](https://ip2location.com/) [ip-api.com](https://ip-api.com) [ipregistry.co](https://ipregistry.co/) [ipdata.co](https://ipdata.co/) [ipgeolocation.io](https://ipgeolocation.io) [ipwhois.io](https://ipwhois.io) [ipapi.com](https://ipapi.com/) [ipapi.is](https://ipapi.is/) [ipqualityscore.com](https://www.ipqualityscore.com/) [bigdatacloud.com](https://www.bigdatacloud.com/) and others for providing APIs for testing, and thanks to various websites on the Internet for providing query resources. Thank [he.net](https://he.net) [bgp.tools](https://bgp.tools) [ipinfo.io](https://ipinfo.io) [maxmind.com](https://www.maxmind.com/en/home) [cloudflare.com](https://www.cloudflare.com/) [ip.sb](https://ip.sb) [scamalytics.com](https://scamalytics.com) [abuseipdb.com](https://www.abuseipdb.com/) [ip2location.com](https://ip2location.com/) [ip-api.com](https://ip-api.com) [ipregistry.co](https://ipregistry.co/) [ipdata.co](https://ipdata.co/) [ipgeolocation.io](https://ipgeolocation.io) [ipwhois.io](https://ipwhois.io) [ipapi.com](https://ipapi.com/) [ipapi.is](https://ipapi.is/) [ipqualityscore.com](https://www.ipqualityscore.com/) [bigdatacloud.com](https://www.bigdatacloud.com/) [dkly.net](https://data.dkly.net) [virustotal.com](https://www.virustotal.com/) and others for providing APIs for testing, and thanks to various websites on the Internet for providing query resources.
Thank Thank

View File

@@ -250,9 +250,9 @@ Load: Displays system load.
Virtualization Architecture: Shows what virtualization architecture the host machine uses. Generally speaking, the recommended order is `Dedicated > KVM > Xen` virtualization. Other virtualization will have performance losses, leading to shared/degraded performance during use. However, this is not definitive. Only dedicated servers have completely independent resource usage; other virtualization methods basically all have resource sharing, depending on whether the host machine seller has a conscience. The specific performance merits still depend on the specialized tests that follow. Virtualization Architecture: Shows what virtualization architecture the host machine uses. Generally speaking, the recommended order is `Dedicated > KVM > Xen` virtualization. Other virtualization will have performance losses, leading to shared/degraded performance during use. However, this is not definitive. Only dedicated servers have completely independent resource usage; other virtualization methods basically all have resource sharing, depending on whether the host machine seller has a conscience. The specific performance merits still depend on the specialized tests that follow.
NAT Type: Displays NAT type. Specifically recommended in order: `Full Cone > Restricted Cone > Port Restricted Cone > Symmetric`. When not detectable, it will show `Inconclusive`. Generally speaking, if you're not using it for special purposes (related to special proxy and real-time communication needs), you don't need to pay attention to this metric. NAT Type: Displays NAT type. Specifically recommended in order: ```Full Cone > Restricted Cone > Port Restricted Cone > Symmetric```. When not detectable, it will show ```Inconclusive```. Generally speaking, if you're not using it for special purposes (related to special proxy and real-time communication needs), you don't need to pay attention to this metric.
TCP Acceleration Method: Generally this is the `cubic/bbr` congestion control protocol. Generally speaking, using bbr for proxy servers can improve network speed; for ordinary purposes, you don't need to pay attention to this indicator. TCP Acceleration Method: Generally this is the ```cubic/bbr``` congestion control protocol. Generally speaking, using bbr for proxy servers can improve network speed; for ordinary purposes, you don't need to pay attention to this indicator.
IPv4/IPv6 ASN: Displays the ASN organization ID and name that the host machine's IP belongs to. The same IDC may have multiple ASNs, and an ASN may have multiple vendors selling servers with different IP segments. The specific upstream and downstream relationships are complex and can be further viewed using bgp.tool. IPv4/IPv6 ASN: Displays the ASN organization ID and name that the host machine's IP belongs to. The same IDC may have multiple ASNs, and an ASN may have multiple vendors selling servers with different IP segments. The specific upstream and downstream relationships are complex and can be further viewed using bgp.tool.
@@ -273,17 +273,17 @@ Supports selecting `GeekBench` and `Sysbench` for testing through command line p
| Test Content | Only tests computational performance, based on prime number calculation | Covers multiple performance tests, weighted score calculation, but some tests are not commonly used in practice | | Test Content | Only tests computational performance, based on prime number calculation | Covers multiple performance tests, weighted score calculation, but some tests are not commonly used in practice |
| Applicable Scenarios | Suitable for quick testing, only tests computational performance | Suitable for comprehensive testing | | Applicable Scenarios | Suitable for quick testing, only tests computational performance | Suitable for comprehensive testing |
By default, `Sysbench` is used for testing, with the baseline roughly as follows: By default, ```Sysbench``` is used for testing, with the baseline roughly as follows:
CPU test single-core `Sysbench` scores above 5000 can be considered first tier, 4000 to 5000 points second tier, with roughly one tier per 1000 points. CPU test single-core ```Sysbench``` scores above 5000 can be considered first tier, 4000 to 5000 points second tier, with roughly one tier per 1000 points.
AMD's 7950x single-core full performance score is around 6500, AMD's 5950x single-core full performance score is around 5700, Intel's ordinary CPUs (E5 series, etc.) are around 1000~800, and single-core CPUs scoring below 500 can be said to have relatively poor performance. AMD's 7950x single-core full performance score is around 6500, AMD's 5950x single-core full performance score is around 5700, Intel's ordinary CPUs (E5 series, etc.) are around 1000~800, and single-core CPUs scoring below 500 can be said to have relatively poor performance.
Sometimes multi-core scores are the same as single-core scores, proving that the vendor is limiting program concurrent use of CPU, a typical example being Tencent Cloud. Sometimes multi-core scores are the same as single-core scores, proving that the vendor is limiting program concurrent use of CPU, a typical example being Tencent Cloud.
Benchmarks for ```Sysbench`` can be found in the [CPU Performance Ladder For Sysbench](https://sysbench.spiritlhl.net/) ladder chart, with specific scores regardless of the version of sysbench tested. Benchmarks for ```Sysbench``` can be found in the [CPU Performance Ladder For Sysbench](https://sysbench.spiritlhl.net/) ladder chart, with specific scores regardless of the version of sysbench tested.
For `GeekBench` baselines, see the [official website](https://browser.geekbench.com/processor-benchmarks/) ladder chart. Specific scores differ for each `GeekBench` version, so note which `GeekBench` version is being used when testing. For ```GeekBench``` baselines, see the [official website](https://browser.geekbench.com/processor-benchmarks/) ladder chart. Specific scores differ for each ```GeekBench``` version, so note which ```GeekBench``` version is being used when testing.
As an additional note, many things tested by `GeekBench` are not actually used in server usage processes, so the test is for reference only. Of course, `Sysbench` is very incomplete, but it can roughly compare CPU performance based on the most basic computational performance. As an additional note, many things tested by `GeekBench` are not actually used in server usage processes, so the test is for reference only. Of course, `Sysbench` is very incomplete, but it can roughly compare CPU performance based on the most basic computational performance.

View File

@@ -1,17 +1,17 @@
package cputest package cputest
import ( import (
"fmt"
"github.com/oneclickvirt/cputest/cpu"
"runtime" "runtime"
"strings" "strings"
"github.com/oneclickvirt/cputest/cpu"
) )
func CpuTest(language, testMethod, testThread string) { func CpuTest(language, testMethod, testThread string) (realTestMethod, res string) {
var res string
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
if testMethod != "winsat" && testMethod != "" { if testMethod != "winsat" && testMethod != "" {
res = "Detected host is Windows, using Winsat for testing.\n" // res = "Detected host is Windows, using Winsat for testing.\n"
realTestMethod = "winsat"
} }
res += cpu.WinsatTest(language, testThread) res += cpu.WinsatTest(language, testThread)
} else { } else {
@@ -19,14 +19,20 @@ func CpuTest(language, testMethod, testThread string) {
case "sysbench": case "sysbench":
res = cpu.SysBenchTest(language, testThread) res = cpu.SysBenchTest(language, testThread)
if res == "" { if res == "" {
res = "Sysbench test failed, switching to Geekbench for testing.\n" // res = "Sysbench test failed, switching to Geekbench for testing.\n"
realTestMethod = "geekbench"
res += cpu.GeekBenchTest(language, testThread) res += cpu.GeekBenchTest(language, testThread)
} else {
realTestMethod = "sysbench"
} }
case "geekbench": case "geekbench":
res = cpu.GeekBenchTest(language, testThread) res = cpu.GeekBenchTest(language, testThread)
if res == "" { if res == "" {
res = "Geekbench test failed, switching to Sysbench for testing.\n" // res = "Geekbench test failed, switching to Sysbench for testing.\n"
realTestMethod = "sysbench"
res += cpu.SysBenchTest(language, testThread) res += cpu.SysBenchTest(language, testThread)
} else {
realTestMethod = "geekbench"
} }
default: default:
res = "Invalid test method specified.\n" res = "Invalid test method specified.\n"
@@ -35,5 +41,5 @@ func CpuTest(language, testMethod, testThread string) {
if !strings.Contains(res, "\n") && res != "" { if !strings.Contains(res, "\n") && res != "" {
res += "\n" res += "\n"
} }
fmt.Print(res) return
} }

4
go.mod
View File

@@ -9,7 +9,7 @@ require (
github.com/oneclickvirt/CommonMediaTests v0.0.4-20250329123841 github.com/oneclickvirt/CommonMediaTests v0.0.4-20250329123841
github.com/oneclickvirt/UnlockTests v0.0.27-20250628125053 github.com/oneclickvirt/UnlockTests v0.0.27-20250628125053
github.com/oneclickvirt/backtrace v0.0.5-20250629024536 github.com/oneclickvirt/backtrace v0.0.5-20250629024536
github.com/oneclickvirt/basics v0.0.13-20250629023612 github.com/oneclickvirt/basics v0.0.15-20250714163009
github.com/oneclickvirt/cputest v0.0.10-20250404151448 github.com/oneclickvirt/cputest v0.0.10-20250404151448
github.com/oneclickvirt/defaultset v0.0.2-20240624082446 github.com/oneclickvirt/defaultset v0.0.2-20240624082446
github.com/oneclickvirt/disktest v0.0.8-20250701092629 github.com/oneclickvirt/disktest v0.0.8-20250701092629
@@ -18,7 +18,7 @@ require (
github.com/oneclickvirt/nt3 v0.0.5-20250416131047 github.com/oneclickvirt/nt3 v0.0.5-20250416131047
github.com/oneclickvirt/pingtest v0.0.8-20250701125637 github.com/oneclickvirt/pingtest v0.0.8-20250701125637
github.com/oneclickvirt/portchecker v0.0.3-20250329125750 github.com/oneclickvirt/portchecker v0.0.3-20250329125750
github.com/oneclickvirt/security v0.0.4-20250629033626 github.com/oneclickvirt/security v0.0.6-20250715102027
github.com/oneclickvirt/speedtest v0.0.10-20250701123931 github.com/oneclickvirt/speedtest v0.0.10-20250701123931
) )

8
go.sum
View File

@@ -103,8 +103,8 @@ github.com/oneclickvirt/UnlockTests v0.0.27-20250628125053 h1:Ug8kySZR1weRUcsnGO
github.com/oneclickvirt/UnlockTests v0.0.27-20250628125053/go.mod h1:yXWIZB6iLS88pEd9m4QJi1GENn+7I91zA72y5ONz2Oc= github.com/oneclickvirt/UnlockTests v0.0.27-20250628125053/go.mod h1:yXWIZB6iLS88pEd9m4QJi1GENn+7I91zA72y5ONz2Oc=
github.com/oneclickvirt/backtrace v0.0.5-20250629024536 h1:caHCa0DHmbYWBFN1bqKxpvPnN0wOxDEqJv1VDvDdLWs= github.com/oneclickvirt/backtrace v0.0.5-20250629024536 h1:caHCa0DHmbYWBFN1bqKxpvPnN0wOxDEqJv1VDvDdLWs=
github.com/oneclickvirt/backtrace v0.0.5-20250629024536/go.mod h1:5AH00bo41hH3d2/JVuCTlBkZUs3AXX4nlKVXb6piZcI= github.com/oneclickvirt/backtrace v0.0.5-20250629024536/go.mod h1:5AH00bo41hH3d2/JVuCTlBkZUs3AXX4nlKVXb6piZcI=
github.com/oneclickvirt/basics v0.0.13-20250629023612 h1:cQg+cGBt2NMRrjhJPH+CbevZrwtMU8pIZIY2Lp6zmt4= github.com/oneclickvirt/basics v0.0.15-20250714163009 h1:7I1lU7N91kClw6Cb6o+vGfScc/HngrjhsaaW10AbBFs=
github.com/oneclickvirt/basics v0.0.13-20250629023612/go.mod h1:yN1IEOXN6v/GJqJSA70Pooo6nXBI/6rq72vTY72wJMQ= github.com/oneclickvirt/basics v0.0.15-20250714163009/go.mod h1:yN1IEOXN6v/GJqJSA70Pooo6nXBI/6rq72vTY72wJMQ=
github.com/oneclickvirt/cputest v0.0.10-20250404151448 h1:ovGtCwFXG0qmpyNDRqcNDIiAmhrtemCjIUXTJ1fPH0o= github.com/oneclickvirt/cputest v0.0.10-20250404151448 h1:ovGtCwFXG0qmpyNDRqcNDIiAmhrtemCjIUXTJ1fPH0o=
github.com/oneclickvirt/cputest v0.0.10-20250404151448/go.mod h1:MmaHN9+XMntI3rLycwj8Ne31fG18IfNoa8N2utDK1CY= github.com/oneclickvirt/cputest v0.0.10-20250404151448/go.mod h1:MmaHN9+XMntI3rLycwj8Ne31fG18IfNoa8N2utDK1CY=
github.com/oneclickvirt/dd v0.0.2-20250701085922 h1:WiWZwcnCPhRc8hLZdvkjD2kOEpnqn1S31z1j0x3V4l0= github.com/oneclickvirt/dd v0.0.2-20250701085922 h1:WiWZwcnCPhRc8hLZdvkjD2kOEpnqn1S31z1j0x3V4l0=
@@ -127,8 +127,8 @@ github.com/oneclickvirt/pingtest v0.0.8-20250701125637 h1:J28Ai5miTq1J0I4gdT8rew
github.com/oneclickvirt/pingtest v0.0.8-20250701125637/go.mod h1:d3Ntx5m9lMll3a/k3+2B+5emj//vgDh4/NHTxs2qQE8= github.com/oneclickvirt/pingtest v0.0.8-20250701125637/go.mod h1:d3Ntx5m9lMll3a/k3+2B+5emj//vgDh4/NHTxs2qQE8=
github.com/oneclickvirt/portchecker v0.0.3-20250329125750 h1:TTNL0pnQlRsn046kW59I/9UWRpihttFHWnU7Ixycggk= github.com/oneclickvirt/portchecker v0.0.3-20250329125750 h1:TTNL0pnQlRsn046kW59I/9UWRpihttFHWnU7Ixycggk=
github.com/oneclickvirt/portchecker v0.0.3-20250329125750/go.mod h1:HQxSTrqM8/QFqHMTBZ7S8H9eEO5FkUXU1eb7ZX5Mk+k= github.com/oneclickvirt/portchecker v0.0.3-20250329125750/go.mod h1:HQxSTrqM8/QFqHMTBZ7S8H9eEO5FkUXU1eb7ZX5Mk+k=
github.com/oneclickvirt/security v0.0.4-20250629033626 h1:DEchQ7WKKz4CzQpMlweoqA993BGncvmp1rL1ICNDJ2g= github.com/oneclickvirt/security v0.0.6-20250715102027 h1:lOaFxORBT/9nBlof7EU36YP+ZIbqkhCLGyOpYQTY1qs=
github.com/oneclickvirt/security v0.0.4-20250629033626/go.mod h1:/5eVnZLvP7RUjwhoI6d8iIMP7msbkHC5So3ZxM+A7Zg= github.com/oneclickvirt/security v0.0.6-20250715102027/go.mod h1:SDFBXV0sDo8pSIcGaaJ2gfCCW+NKy4pO1q9i4SIX2jc=
github.com/oneclickvirt/speedtest v0.0.10-20250701123931 h1:IMUM0F3trrlCdl9JTO+FBIJ9zc8mbi+oyd66IkO/8mI= github.com/oneclickvirt/speedtest v0.0.10-20250701123931 h1:IMUM0F3trrlCdl9JTO+FBIJ9zc8mbi+oyd66IkO/8mI=
github.com/oneclickvirt/speedtest v0.0.10-20250701123931/go.mod h1:zd5ZgIGslmtQLQehEfRjyumlvgDHTpCSMchKfKXoASI= github.com/oneclickvirt/speedtest v0.0.10-20250701123931/go.mod h1:zd5ZgIGslmtQLQehEfRjyumlvgDHTpCSMchKfKXoASI=
github.com/onsi/ginkgo/v2 v2.22.1 h1:QW7tbJAUDyVDVOM5dFa7qaybo+CRfR7bemlQUN6Z8aM= github.com/onsi/ginkgo/v2 v2.22.1 h1:QW7tbJAUDyVDVOM5dFa7qaybo+CRfR7bemlQUN6Z8aM=

103
goecs.go
View File

@@ -39,7 +39,7 @@ import (
) )
var ( var (
ecsVersion = "v0.1.50" ecsVersion = "v0.1.53"
menuMode bool menuMode bool
onlyChinaTest bool onlyChinaTest bool
input, choice string input, choice string
@@ -347,6 +347,7 @@ func setUnlockOnlyTestStatus() {
} }
func setHardwareOnlyTestStatus(preCheck utils.NetCheckResult) { func setHardwareOnlyTestStatus(preCheck utils.NetCheckResult) {
_ = preCheck
basicStatus = true basicStatus = true
cpuTestStatus = true cpuTestStatus = true
memoryTestStatus = true memoryTestStatus = true
@@ -397,52 +398,63 @@ func handleSignalInterrupt(sig chan os.Signal, startTime *time.Time, output *str
outputMutex.Lock() outputMutex.Lock()
*output = utils.PrintAndCapture(func() { *output = utils.PrintAndCapture(func() {
utils.PrintCenteredTitle("", width) utils.PrintCenteredTitle("", width)
fmt.Printf("Cost Time : %d min %d sec\n", minutes, seconds) if language == "zh" {
fmt.Printf("Current Time : %s\n", currentTime) fmt.Printf("花费 : %d 分 %d 秒\n", minutes, seconds)
fmt.Printf("时间 : %s\n", currentTime)
} else {
fmt.Printf("Cost Time : %d min %d sec\n", minutes, seconds)
fmt.Printf("Current Time : %s\n", currentTime)
}
utils.PrintCenteredTitle("", width) utils.PrintCenteredTitle("", width)
}, tempOutput, *output) }, tempOutput, *output)
finalOutput := *output
outputMutex.Unlock() outputMutex.Unlock()
resultChan := make(chan struct { resultChan := make(chan struct {
httpURL string httpURL string
httpsURL string httpsURL string
}, 1) }, 1)
go func() { if enabelUpload {
outputMutex.Lock() go func() {
finalOutput := *output httpURL, httpsURL := utils.ProcessAndUpload(finalOutput, filePath, enabelUpload)
outputMutex.Unlock() resultChan <- struct {
httpURL, httpsURL := utils.ProcessAndUpload(finalOutput, filePath, enabelUpload) httpURL string
resultChan <- struct { httpsURL string
httpURL string }{httpURL, httpsURL}
httpsURL string uploadDone <- true
}{httpURL, httpsURL} }()
uploadDone <- true select {
}() case result := <-resultChan:
select { if result.httpURL != "" || result.httpsURL != "" {
case result := <-resultChan: if language == "en" {
if result.httpURL != "" || result.httpsURL != "" { fmt.Printf("Upload successfully!\nHttp URL: %s\nHttps URL: %s\n", result.httpURL, result.httpsURL)
if language == "en" { } else {
fmt.Printf("Upload successfully!\nHttp URL: %s\nHttps URL: %s\n", result.httpURL, result.httpsURL) fmt.Printf("上传成功!\nHttp URL: %s\nHttps URL: %s\n", result.httpURL, result.httpsURL)
} else { }
fmt.Printf("上传成功!\nHttp URL: %s\nHttps URL: %s\n", result.httpURL, result.httpsURL)
} }
time.Sleep(100 * time.Millisecond)
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
fmt.Println("Press Enter to exit...")
fmt.Scanln()
}
os.Exit(0)
case <-time.After(30 * time.Second):
if language == "en" {
fmt.Println("Upload timeout, program exit")
} else {
fmt.Println("上传超时,程序退出")
}
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
fmt.Println("Press Enter to exit...")
fmt.Scanln()
}
os.Exit(1)
} }
time.Sleep(100 * time.Millisecond) } else {
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" { if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
fmt.Println("Press Enter to exit...") fmt.Println("Press Enter to exit...")
fmt.Scanln() fmt.Scanln()
} }
os.Exit(0) os.Exit(0)
case <-time.After(30 * time.Second):
if language == "en" {
fmt.Println("Upload timeout, program exit")
} else {
fmt.Println("上传超时,程序退出")
}
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
fmt.Println("Press Enter to exit...")
fmt.Scanln()
}
os.Exit(1)
} }
} }
os.Exit(0) os.Exit(0)
@@ -518,6 +530,7 @@ func runEnglishTests(preCheck utils.NetCheckResult, wg1, wg2 *sync.WaitGroup, ba
} }
func runBasicTests(preCheck utils.NetCheckResult, basicInfo, securityInfo *string, output, tempOutput string, outputMutex *sync.Mutex) string { func runBasicTests(preCheck utils.NetCheckResult, basicInfo, securityInfo *string, output, tempOutput string, outputMutex *sync.Mutex) string {
_ = outputMutex
return utils.PrintAndCapture(func() { return utils.PrintAndCapture(func() {
utils.PrintHead(language, width, ecsVersion) utils.PrintHead(language, width, ecsVersion)
if basicStatus || securityTestStatus { if basicStatus || securityTestStatus {
@@ -554,19 +567,22 @@ func runBasicTests(preCheck utils.NetCheckResult, basicInfo, securityInfo *strin
} }
func runCPUTest(output, tempOutput string, outputMutex *sync.Mutex) string { func runCPUTest(output, tempOutput string, outputMutex *sync.Mutex) string {
_ = outputMutex
return utils.PrintAndCapture(func() { return utils.PrintAndCapture(func() {
if cpuTestStatus { if cpuTestStatus {
realTestMethod, res := cputest.CpuTest(language, cpuTestMethod, cpuTestThreadMode)
if language == "zh" { if language == "zh" {
utils.PrintCenteredTitle(fmt.Sprintf("CPU测试-通过%s测试", cpuTestMethod), width) utils.PrintCenteredTitle(fmt.Sprintf("CPU测试-通过%s测试", realTestMethod), width)
} else { } else {
utils.PrintCenteredTitle(fmt.Sprintf("CPU-Test--%s-Method", cpuTestMethod), width) utils.PrintCenteredTitle(fmt.Sprintf("CPU-Test--%s-Method", realTestMethod), width)
} }
cputest.CpuTest(language, cpuTestMethod, cpuTestThreadMode) fmt.Print(res)
} }
}, tempOutput, output) }, tempOutput, output)
} }
func runMemoryTest(output, tempOutput string, outputMutex *sync.Mutex) string { func runMemoryTest(output, tempOutput string, outputMutex *sync.Mutex) string {
_ = outputMutex
return utils.PrintAndCapture(func() { return utils.PrintAndCapture(func() {
if memoryTestStatus { if memoryTestStatus {
if language == "zh" { if language == "zh" {
@@ -580,6 +596,7 @@ func runMemoryTest(output, tempOutput string, outputMutex *sync.Mutex) string {
} }
func runDiskTest(output, tempOutput string, outputMutex *sync.Mutex) string { func runDiskTest(output, tempOutput string, outputMutex *sync.Mutex) string {
_ = outputMutex
return utils.PrintAndCapture(func() { return utils.PrintAndCapture(func() {
if diskTestStatus && autoChangeDiskTestMethod { if diskTestStatus && autoChangeDiskTestMethod {
if language == "zh" { if language == "zh" {
@@ -605,6 +622,7 @@ func runDiskTest(output, tempOutput string, outputMutex *sync.Mutex) string {
} }
func runStreamingTests(wg1 *sync.WaitGroup, mediaInfo *string, output, tempOutput string, outputMutex *sync.Mutex) string { func runStreamingTests(wg1 *sync.WaitGroup, mediaInfo *string, output, tempOutput string, outputMutex *sync.Mutex) string {
_ = outputMutex
return utils.PrintAndCapture(func() { return utils.PrintAndCapture(func() {
if language == "zh" { if language == "zh" {
if commTestStatus && !onlyChinaTest { if commTestStatus && !onlyChinaTest {
@@ -625,6 +643,7 @@ func runStreamingTests(wg1 *sync.WaitGroup, mediaInfo *string, output, tempOutpu
} }
func runSecurityTests(securityInfo, output, tempOutput string, outputMutex *sync.Mutex) string { func runSecurityTests(securityInfo, output, tempOutput string, outputMutex *sync.Mutex) string {
_ = outputMutex
return utils.PrintAndCapture(func() { return utils.PrintAndCapture(func() {
if securityTestStatus { if securityTestStatus {
if language == "zh" { if language == "zh" {
@@ -638,6 +657,7 @@ func runSecurityTests(securityInfo, output, tempOutput string, outputMutex *sync
} }
func runEmailTests(wg2 *sync.WaitGroup, emailInfo *string, output, tempOutput string, outputMutex *sync.Mutex) string { func runEmailTests(wg2 *sync.WaitGroup, emailInfo *string, output, tempOutput string, outputMutex *sync.Mutex) string {
_ = outputMutex
return utils.PrintAndCapture(func() { return utils.PrintAndCapture(func() {
if emailTestStatus { if emailTestStatus {
wg2.Wait() wg2.Wait()
@@ -652,6 +672,7 @@ func runEmailTests(wg2 *sync.WaitGroup, emailInfo *string, output, tempOutput st
} }
func runNetworkTests(wg3 *sync.WaitGroup, ptInfo *string, output, tempOutput string, outputMutex *sync.Mutex) string { func runNetworkTests(wg3 *sync.WaitGroup, ptInfo *string, output, tempOutput string, outputMutex *sync.Mutex) string {
_ = outputMutex
output = utils.PrintAndCapture(func() { output = utils.PrintAndCapture(func() {
if backtraceStatus && !onlyChinaTest { if backtraceStatus && !onlyChinaTest {
utils.PrintCenteredTitle("三网回程线路检测", width) utils.PrintCenteredTitle("三网回程线路检测", width)
@@ -678,6 +699,7 @@ func runNetworkTests(wg3 *sync.WaitGroup, ptInfo *string, output, tempOutput str
} }
func runSpeedTests(output, tempOutput string, outputMutex *sync.Mutex) string { func runSpeedTests(output, tempOutput string, outputMutex *sync.Mutex) string {
_ = outputMutex
return utils.PrintAndCapture(func() { return utils.PrintAndCapture(func() {
if speedTestStatus { if speedTestStatus {
utils.PrintCenteredTitle("就近节点测速", width) utils.PrintCenteredTitle("就近节点测速", width)
@@ -698,6 +720,7 @@ func runSpeedTests(output, tempOutput string, outputMutex *sync.Mutex) string {
} }
func runEnglishSpeedTests(output, tempOutput string, outputMutex *sync.Mutex) string { func runEnglishSpeedTests(output, tempOutput string, outputMutex *sync.Mutex) string {
_ = outputMutex
return utils.PrintAndCapture(func() { return utils.PrintAndCapture(func() {
if speedTestStatus { if speedTestStatus {
utils.PrintCenteredTitle("Speed-Test", width) utils.PrintCenteredTitle("Speed-Test", width)
@@ -709,6 +732,7 @@ func runEnglishSpeedTests(output, tempOutput string, outputMutex *sync.Mutex) st
} }
func appendTimeInfo(output, tempOutput string, startTime time.Time, outputMutex *sync.Mutex) string { func appendTimeInfo(output, tempOutput string, startTime time.Time, outputMutex *sync.Mutex) string {
_ = outputMutex
endTime := time.Now() endTime := time.Now()
duration := endTime.Sub(startTime) duration := endTime.Sub(startTime)
minutes := int(duration.Minutes()) minutes := int(duration.Minutes())
@@ -752,6 +776,9 @@ func main() {
handleMenuMode(preCheck) handleMenuMode(preCheck)
} }
handleLanguageSpecificSettings() handleLanguageSpecificSettings()
if !preCheck.Connected {
enabelUpload = false
}
var ( var (
wg1, wg2, wg3 sync.WaitGroup wg1, wg2, wg3 sync.WaitGroup
basicInfo, securityInfo, emailInfo, mediaInfo, ptInfo string basicInfo, securityInfo, emailInfo, mediaInfo, ptInfo string
@@ -771,7 +798,9 @@ func main() {
default: default:
fmt.Println("Unsupported language") fmt.Println("Unsupported language")
} }
handleUploadResults(output) if preCheck.Connected {
handleUploadResults(output)
}
finish = true finish = true
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" { if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
fmt.Println("Press Enter to exit...") fmt.Println("Press Enter to exit...")

View File

@@ -143,7 +143,7 @@ goecs_check() {
os=$(uname -s 2>/dev/null || echo "Unknown") os=$(uname -s 2>/dev/null || echo "Unknown")
arch=$(uname -m 2>/dev/null || echo "Unknown") arch=$(uname -m 2>/dev/null || echo "Unknown")
check_china check_china
ECS_VERSION="0.1.49" ECS_VERSION="0.1.52"
for api in \ for api in \
"https://api.github.com/repos/oneclickvirt/ecs/releases/latest" \ "https://api.github.com/repos/oneclickvirt/ecs/releases/latest" \
"https://githubapi.spiritlhl.workers.dev/repos/oneclickvirt/ecs/releases/latest" \ "https://githubapi.spiritlhl.workers.dev/repos/oneclickvirt/ecs/releases/latest" \
@@ -155,8 +155,8 @@ goecs_check() {
sleep 1 sleep 1
done done
if [ -z "$ECS_VERSION" ]; then if [ -z "$ECS_VERSION" ]; then
_yellow "Unable to get version info, using default version 0.1.49" _yellow "Unable to get version info, using default version 0.1.52"
ECS_VERSION="0.1.49" ECS_VERSION="0.1.52"
fi fi
version_output="" version_output=""
for cmd_path in "goecs" "./goecs" "/usr/bin/goecs" "/usr/local/bin/goecs"; do for cmd_path in "goecs" "./goecs" "/usr/bin/goecs" "/usr/local/bin/goecs"; do