mirror of
https://github.com/oneclickvirt/ecs.git
synced 2025-10-04 15:02:49 +08:00
Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
f7b00cf621 | ||
![]() |
9f956f6e8c | ||
![]() |
b33598b847 | ||
![]() |
e7fbc126a1 | ||
![]() |
b92025f26c | ||
![]() |
8ffd121261 | ||
![]() |
ab33d841fe | ||
![]() |
384622176a | ||
![]() |
7744902183 | ||
![]() |
c73f240d86 | ||
![]() |
7f1103a031 | ||
![]() |
c4e9f569b7 | ||
![]() |
8af8d4ccaa | ||
![]() |
c13e68eccd | ||
![]() |
57e2aa57f8 |
3
.github/workflows/ci.yaml
vendored
3
.github/workflows/ci.yaml
vendored
@@ -1,6 +1,7 @@
|
|||||||
name: go-ci
|
name: go-ci
|
||||||
|
|
||||||
on: [push]
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
setup:
|
setup:
|
||||||
|
1
.github/workflows/main.yaml
vendored
1
.github/workflows/main.yaml
vendored
@@ -35,3 +35,4 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GHT }}
|
GITHUB_TOKEN: ${{ secrets.GHT }}
|
||||||
GOPRIVATE: github.com/oneclickvirt/security
|
GOPRIVATE: github.com/oneclickvirt/security
|
||||||
|
CGO_ENABLED: 0 # 禁用 CGO,强制静态链接
|
||||||
|
@@ -19,7 +19,7 @@ Shell版本: https://github.com/spiritLHLS/ecs
|
|||||||
- [x] 邮件端口测试[自研[portchecker](https://github.com/oneclickvirt/portchecker)]
|
- [x] 邮件端口测试[自研[portchecker](https://github.com/oneclickvirt/portchecker)]
|
||||||
- [x] 三网回程测试[借鉴[zhanghanyun/backtrace](https://github.com/zhanghanyun/backtrace)二次开发至于[oneclickvirt/backtrace](https://github.com/oneclickvirt/backtrace)]
|
- [x] 三网回程测试[借鉴[zhanghanyun/backtrace](https://github.com/zhanghanyun/backtrace)二次开发至于[oneclickvirt/backtrace](https://github.com/oneclickvirt/backtrace)]
|
||||||
- [x] 三网路由测试[借鉴[NTrace-core](https://github.com/nxtrace/NTrace-core)二次开发至于[nt3](https://github.com/oneclickvirt/nt3)]
|
- [x] 三网路由测试[借鉴[NTrace-core](https://github.com/nxtrace/NTrace-core)二次开发至于[nt3](https://github.com/oneclickvirt/nt3)]
|
||||||
- [x] 测试网速[基于[speedtest.net-爬虫](https://github.com/spiritLHLS/speedtest.net-CN-ID)、[speedtest.cn-爬虫](https://github.com/spiritLHLS/speedtest.cn-CN-ID)的数据,借鉴[speedtest-go](https://github.com/showwin/speedtest-go)二次开发]
|
- [x] 测试网速[基于[speedtest.net-爬虫](https://github.com/spiritLHLS/speedtest.net-CN-ID)、[speedtest.cn-爬虫](https://github.com/spiritLHLS/speedtest.cn-CN-ID)的数据,借鉴[speedtest-go](https://github.com/showwin/speedtest-go)二次开发至于[oneclickvirt/speedtest](https://github.com/oneclickvirt/speedtest)]
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
|
10
go.mod
10
go.mod
@@ -3,18 +3,18 @@ module github.com/oneclickvirt/ecs
|
|||||||
go 1.22.4
|
go 1.22.4
|
||||||
|
|
||||||
require (
|
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/UnlockTests v0.0.10-20240630044930
|
||||||
github.com/oneclickvirt/backtrace v0.0.4-20240624090335
|
github.com/oneclickvirt/backtrace v0.0.4-20240624090335
|
||||||
github.com/oneclickvirt/basics v0.0.3-20240625075226
|
github.com/oneclickvirt/basics v0.0.3-20240625075226
|
||||||
github.com/oneclickvirt/cputest v0.0.2-20240624103336
|
github.com/oneclickvirt/cputest v0.0.5-20240630022206
|
||||||
github.com/oneclickvirt/defaultset v0.0.2-20240624082446
|
github.com/oneclickvirt/defaultset v0.0.2-20240624082446
|
||||||
github.com/oneclickvirt/disktest v0.0.2-20240624145436
|
github.com/oneclickvirt/disktest v0.0.3-20240629152513
|
||||||
github.com/oneclickvirt/memorytest v0.0.1-20240624151629
|
github.com/oneclickvirt/memorytest v0.0.1-20240624151629
|
||||||
github.com/oneclickvirt/nt3 v0.0.1-20240627070009
|
github.com/oneclickvirt/nt3 v0.0.1-20240627070009
|
||||||
github.com/oneclickvirt/portchecker v0.0.1-20240624155429
|
github.com/oneclickvirt/portchecker v0.0.1-20240624155429
|
||||||
github.com/oneclickvirt/security v0.0.1-20240625075931
|
github.com/oneclickvirt/security v0.0.1-20240625075931
|
||||||
github.com/oneclickvirt/speedtest v0.0.4-20240629100548
|
github.com/oneclickvirt/speedtest v0.0.5-20240630045424
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
22
go.sum
22
go.sum
@@ -85,20 +85,26 @@ 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/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 h1:f4z5UaZEuhUP/g6xElpZ2bo+guWITJVrMKrJTqd27oc=
|
||||||
github.com/nxtrace/NTrace-core v1.3.1/go.mod h1:0Px/Zc60qk6cssmP+yv4kstFxvX9sXqDduoVqBO+qf8=
|
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.2-20240630023003 h1:8jQFqDK5m7V9xlLBk8rSUYDyi3u5xzf5kqwEx5b+/7g=
|
||||||
github.com/oneclickvirt/CommonMediaTests v0.0.1-20240624094420/go.mod h1:DAmFPRjFV5p9fEzUUSml5jJGn2f1NZJQCzTxITHDjc4=
|
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 h1:rMC+aLDkvOe9K+AXjUt/IMAOx1LieyBv6DN/0/2ww7Q=
|
||||||
github.com/oneclickvirt/UnlockTests v0.0.7-20240624115527/go.mod h1:HP3CvAS+AJWxxY+BVbxIOlvaQ87YOSge89vAMG52b5o=
|
github.com/oneclickvirt/UnlockTests v0.0.7-20240624115527/go.mod h1:HP3CvAS+AJWxxY+BVbxIOlvaQ87YOSge89vAMG52b5o=
|
||||||
|
github.com/oneclickvirt/UnlockTests v0.0.9-20240630032239 h1:b2tf2AVZtTmDvOOtm7tmeOCqFJPm7fe2mF/0Kk15Mhk=
|
||||||
|
github.com/oneclickvirt/UnlockTests v0.0.9-20240630032239/go.mod h1:HP3CvAS+AJWxxY+BVbxIOlvaQ87YOSge89vAMG52b5o=
|
||||||
|
github.com/oneclickvirt/UnlockTests v0.0.10-20240630041851 h1:YC/Phn7I4hxlj+WvNfO7uHfKOSiNvd+3JA1vVkqKv1M=
|
||||||
|
github.com/oneclickvirt/UnlockTests v0.0.10-20240630041851/go.mod h1:HP3CvAS+AJWxxY+BVbxIOlvaQ87YOSge89vAMG52b5o=
|
||||||
|
github.com/oneclickvirt/UnlockTests v0.0.10-20240630044930 h1:/Sc4Eas1Pso18ak93wlazkuMKRRElCntITja/0opOpM=
|
||||||
|
github.com/oneclickvirt/UnlockTests v0.0.10-20240630044930/go.mod h1:HP3CvAS+AJWxxY+BVbxIOlvaQ87YOSge89vAMG52b5o=
|
||||||
github.com/oneclickvirt/backtrace v0.0.4-20240624090335 h1:0LP5KyA6GLlqQAtOF0uyBSAykHJrzOA96Eb87qUhGQw=
|
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/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 h1:K9VriCHIYnXPZXBSn9PRQX+jBS6AIFH8tBVb/i8VGAw=
|
||||||
github.com/oneclickvirt/basics v0.0.3-20240625075226/go.mod h1:dTB+/oyFQYfTYX55rFJVWatum5F9g62zjfmHCM6Vj1s=
|
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.5-20240630022206 h1:L+Su9CNpERf7ZwJZPhvasZdXrlEt6VfqZQpuaPntzkI=
|
||||||
github.com/oneclickvirt/cputest v0.0.2-20240624103336/go.mod h1:wh4fGT3KFG9qztew5eBL9EfWr8WeZPBLsq60ZzudU4g=
|
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 h1:5Pg3mK/u/vQvSz7anu0nxzrNdELi/AcDAU1mMsmPzyc=
|
||||||
github.com/oneclickvirt/defaultset v0.0.2-20240624082446/go.mod h1:e9Jt4tf2sbemCtc84/XgKcHy9EZ2jkc5x2sW1NiJS+E=
|
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.3-20240629152513 h1:ZW7MBMd2HxQi1ktg/ztVI2A10JzF4ZI6I7ATZvcK9w8=
|
||||||
github.com/oneclickvirt/disktest v0.0.2-20240624145436/go.mod h1:x7VAJF0Ks05FyE4BI5xedXNKmwbeXfp8GCRALAIlueI=
|
github.com/oneclickvirt/disktest v0.0.3-20240629152513/go.mod h1:x7VAJF0Ks05FyE4BI5xedXNKmwbeXfp8GCRALAIlueI=
|
||||||
github.com/oneclickvirt/gostun v0.0.2-20240625025941 h1:h+ZL8jkjXR6QE0qEX34FjWTv89+lNj2fEkWx5Agpgzc=
|
github.com/oneclickvirt/gostun v0.0.2-20240625025941 h1:h+ZL8jkjXR6QE0qEX34FjWTv89+lNj2fEkWx5Agpgzc=
|
||||||
github.com/oneclickvirt/gostun v0.0.2-20240625025941/go.mod h1:f7DPEXAxbmwXSW33dbxtb0/KzqvOBWhTs2Or5xBerQA=
|
github.com/oneclickvirt/gostun v0.0.2-20240625025941/go.mod h1:f7DPEXAxbmwXSW33dbxtb0/KzqvOBWhTs2Or5xBerQA=
|
||||||
github.com/oneclickvirt/memorytest v0.0.1-20240624151629 h1:2rJAB3gFGlFPocIb/WRVWYqs4nr2jGYokfDOgqFicD4=
|
github.com/oneclickvirt/memorytest v0.0.1-20240624151629 h1:2rJAB3gFGlFPocIb/WRVWYqs4nr2jGYokfDOgqFicD4=
|
||||||
@@ -109,10 +115,10 @@ 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/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 h1:Vj1Wq/JVcqYpfqUWRtsITbz3zM4HxnLC0iPxxA6akP0=
|
||||||
github.com/oneclickvirt/security v0.0.1-20240625075931/go.mod h1:6bjZjpYJ8M3aRIcLP61b0mjYRwvtWbYkvoGjS28Bdy4=
|
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 h1:DQA0R/EdtmLJrQBb9JvQBaBpcMgiGDvIHq+0quNZQQM=
|
||||||
github.com/oneclickvirt/speedtest v0.0.4-20240629100548/go.mod h1:JNIxUbEJD12w81b7754RLHD55fsH6wHj+fCV2PqBDhk=
|
github.com/oneclickvirt/speedtest v0.0.4-20240629100548/go.mod h1:JNIxUbEJD12w81b7754RLHD55fsH6wHj+fCV2PqBDhk=
|
||||||
|
github.com/oneclickvirt/speedtest v0.0.5-20240630045424 h1:LXvoAgCAJVGci0Tzm3cDgvNaezncS8R5nOn8s+p+kNA=
|
||||||
|
github.com/oneclickvirt/speedtest v0.0.5-20240630045424/go.mod h1:zd5ZgIGslmtQLQehEfRjyumlvgDHTpCSMchKfKXoASI=
|
||||||
github.com/onsi/ginkgo/v2 v2.16.0 h1:7q1w9frJDzninhXxjZd+Y/x54XNjG/UlRLIYPZafsPM=
|
github.com/onsi/ginkgo/v2 v2.16.0 h1:7q1w9frJDzninhXxjZd+Y/x54XNjG/UlRLIYPZafsPM=
|
||||||
github.com/onsi/ginkgo/v2 v2.16.0/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs=
|
github.com/onsi/ginkgo/v2 v2.16.0/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs=
|
||||||
github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8=
|
github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8=
|
||||||
|
161
goecs.go
161
goecs.go
@@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/oneclickvirt/UnlockTests/uts"
|
||||||
"github.com/oneclickvirt/ecs/backtrace"
|
"github.com/oneclickvirt/ecs/backtrace"
|
||||||
"github.com/oneclickvirt/ecs/basic"
|
"github.com/oneclickvirt/ecs/basic"
|
||||||
"github.com/oneclickvirt/ecs/commediatest"
|
"github.com/oneclickvirt/ecs/commediatest"
|
||||||
@@ -11,15 +12,29 @@ import (
|
|||||||
"github.com/oneclickvirt/ecs/memorytest"
|
"github.com/oneclickvirt/ecs/memorytest"
|
||||||
"github.com/oneclickvirt/ecs/network"
|
"github.com/oneclickvirt/ecs/network"
|
||||||
"github.com/oneclickvirt/ecs/ntrace"
|
"github.com/oneclickvirt/ecs/ntrace"
|
||||||
"github.com/oneclickvirt/ecs/port"
|
|
||||||
"github.com/oneclickvirt/ecs/speedtest"
|
"github.com/oneclickvirt/ecs/speedtest"
|
||||||
"github.com/oneclickvirt/ecs/unlocktest"
|
"github.com/oneclickvirt/ecs/unlocktest"
|
||||||
|
"github.com/oneclickvirt/portchecker/email"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
"unicode/utf8"
|
"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) {
|
func printCenteredTitle(title string, width int) {
|
||||||
titleLength := utf8.RuneCountInString(title) // 计算字符串的字符数
|
titleLength := utf8.RuneCountInString(title) // 计算字符串的字符数
|
||||||
totalPadding := width - titleLength
|
totalPadding := width - titleLength
|
||||||
@@ -28,19 +43,56 @@ func printCenteredTitle(title string, width int) {
|
|||||||
fmt.Println(paddingStr + title + paddingStr + strings.Repeat("-", totalPadding%2))
|
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 mediatest(language string) string {
|
||||||
|
return unlocktest.MediaTest(language)
|
||||||
|
}
|
||||||
|
|
||||||
|
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() {
|
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.BoolVar(&showVersion, "v", false, "Show version information")
|
||||||
flag.StringVar(&language, "l", "zh", "Specify language (supported: en, zh)")
|
flag.StringVar(&language, "l", "zh", "Specify language (supported: en, zh)")
|
||||||
flag.StringVar(&cpuTestMethod, "cpum", "sysbench", "Specify CPU test method (supported: sysbench, geekbench, winsat)")
|
flag.StringVar(&cpuTestMethod, "cpum", "sysbench", "Specify CPU test method (supported: sysbench, geekbench, winsat)")
|
||||||
@@ -49,11 +101,8 @@ func main() {
|
|||||||
flag.StringVar(&diskTestMethod, "diskm", "fio", "Specify Disk test method (supported: fio, dd, winsat)")
|
flag.StringVar(&diskTestMethod, "diskm", "fio", "Specify Disk test method (supported: fio, dd, winsat)")
|
||||||
flag.StringVar(&diskTestPath, "diskp", "", "Specify Disk test path, example: -diskp /root")
|
flag.StringVar(&diskTestPath, "diskp", "", "Specify Disk test path, example: -diskp /root")
|
||||||
flag.BoolVar(&diskMultiCheck, "diskmc", false, "Enable multiple disk checks, example: -diskmc=false")
|
flag.BoolVar(&diskMultiCheck, "diskmc", false, "Enable multiple disk checks, example: -diskmc=false")
|
||||||
flag.Parse()
|
flag.StringVar(&nt3Location, "nt3loc", "GZ", "指定三网回程路由检测的地址,支持 GZ, SH, BJ, CD 对应 广州,上海,北京,成都")
|
||||||
if language == "zh" {
|
flag.StringVar(&nt3CheckType, "nt3t", "ipv4", "指定三网回程路由检测的类型,支持 both, ipv4, ipv6")
|
||||||
flag.StringVar(&nt3Location, "nt3loc", "GZ", "指定三网回程路由检测的地址,支持 GZ, SH, BJ, CD 对应 广州,上海,北京,成都")
|
|
||||||
flag.StringVar(&nt3CheckType, "nt3t", "ipv4", "指定三网回程路由检测的类型,支持 both, ipv4, ipv6")
|
|
||||||
}
|
|
||||||
flag.IntVar(&spNum, "spnum", 2, "Specify speedtest each operator servers num")
|
flag.IntVar(&spNum, "spnum", 2, "Specify speedtest each operator servers num")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
if showVersion {
|
if showVersion {
|
||||||
@@ -61,43 +110,54 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
|
var wg sync.WaitGroup
|
||||||
|
var securityInfo, emailInfo, mediaInfo string
|
||||||
if language == "zh" {
|
if language == "zh" {
|
||||||
printCenteredTitle("融合怪测试", width)
|
printHead()
|
||||||
fmt.Printf("版本:%s\n", ecsVersion)
|
|
||||||
fmt.Println("测评频道: https://t.me/vps_reviews\nGo项目地址:https://github.com/oneclickvirt/ecs\nShell项目地址:https://github.com/spiritLHLS/ecs")
|
|
||||||
printCenteredTitle("基础信息", width)
|
printCenteredTitle("基础信息", width)
|
||||||
basic.Basic(language)
|
go func() {
|
||||||
|
wg.Add(1)
|
||||||
|
defer wg.Done()
|
||||||
|
basic.Basic(language)
|
||||||
|
}()
|
||||||
|
go func() {
|
||||||
|
wg.Add(1)
|
||||||
|
defer wg.Done()
|
||||||
|
securityInfo = securityCheck()
|
||||||
|
}()
|
||||||
|
wg.Wait()
|
||||||
printCenteredTitle(fmt.Sprintf("CPU测试-通过%s测试", cpuTestMethod), width)
|
printCenteredTitle(fmt.Sprintf("CPU测试-通过%s测试", cpuTestMethod), width)
|
||||||
cputest.CpuTest(language, cpuTestMethod, cpuTestThread)
|
cputest.CpuTest(language, cpuTestMethod, cpuTestThread)
|
||||||
printCenteredTitle(fmt.Sprintf("内存测试-通过%s测试", cpuTestMethod), width)
|
printCenteredTitle(fmt.Sprintf("内存测试-通过%s测试", cpuTestMethod), width)
|
||||||
memorytest.MemoryTest(language, memoryTestMethod)
|
memorytest.MemoryTest(language, memoryTestMethod)
|
||||||
printCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", diskTestMethod), width)
|
printCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", diskTestMethod), width)
|
||||||
disktest.DiskTest(language, diskTestMethod, diskTestPath, diskMultiCheck)
|
disktest.DiskTest(language, diskTestMethod, diskTestPath, diskMultiCheck)
|
||||||
|
go func() {
|
||||||
|
wg.Add(1)
|
||||||
|
defer wg.Done()
|
||||||
|
emailInfo = email.EmailCheck()
|
||||||
|
}()
|
||||||
|
go func() {
|
||||||
|
wg.Add(1)
|
||||||
|
defer wg.Done()
|
||||||
|
mediaInfo = mediatest(language)
|
||||||
|
}()
|
||||||
printCenteredTitle("御三家流媒体解锁", width)
|
printCenteredTitle("御三家流媒体解锁", width)
|
||||||
commediatest.ComMediaTest(language)
|
commediatest.ComMediaTest(language)
|
||||||
printCenteredTitle("跨国流媒体解锁", width)
|
printCenteredTitle("跨国流媒体解锁", width)
|
||||||
unlocktest.MediaTest(language)
|
wg.Wait()
|
||||||
|
fmt.Printf(mediaInfo)
|
||||||
printCenteredTitle("IP质量检测", width)
|
printCenteredTitle("IP质量检测", width)
|
||||||
ipInfo, securityInfo, _ := network.NetworkCheck("both", true, language)
|
|
||||||
fmt.Printf(securityInfo)
|
fmt.Printf(securityInfo)
|
||||||
printCenteredTitle("邮件端口检测", width)
|
printCenteredTitle("邮件端口检测", width)
|
||||||
port.EmailCheck()
|
fmt.Println(emailInfo)
|
||||||
|
printCenteredTitle("三网回程", width)
|
||||||
|
backtrace.BackTrace()
|
||||||
if runtime.GOOS != "windows" {
|
if runtime.GOOS != "windows" {
|
||||||
// nexttrace 在win上不支持检测,报错 bind: An invalid argument was supplied.
|
// nexttrace 在win上不支持检测,报错 bind: An invalid argument was supplied.
|
||||||
printCenteredTitle("三网回程", width)
|
printCenteredTitle("路由检测", width)
|
||||||
backtrace.BackTrace()
|
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)
|
printCenteredTitle("就近节点测速", width)
|
||||||
speedtest.ShowHead(language)
|
speedtest.ShowHead(language)
|
||||||
speedtest.NearbySP()
|
speedtest.NearbySP()
|
||||||
@@ -115,26 +175,39 @@ func main() {
|
|||||||
fmt.Printf("时间 : %s\n", currentTime)
|
fmt.Printf("时间 : %s\n", currentTime)
|
||||||
printCenteredTitle("", width)
|
printCenteredTitle("", width)
|
||||||
} else if language == "en" {
|
} else if language == "en" {
|
||||||
printCenteredTitle("Fusion Monster Test", width)
|
printHead()
|
||||||
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")
|
|
||||||
printCenteredTitle("Basic Information", width)
|
printCenteredTitle("Basic Information", width)
|
||||||
basic.Basic(language)
|
go func() {
|
||||||
|
wg.Add(1)
|
||||||
|
defer wg.Done()
|
||||||
|
basic.Basic(language)
|
||||||
|
}()
|
||||||
|
go func() {
|
||||||
|
wg.Add(1)
|
||||||
|
defer wg.Done()
|
||||||
|
securityInfo = securityCheck()
|
||||||
|
}()
|
||||||
|
wg.Wait()
|
||||||
printCenteredTitle(fmt.Sprintf("CPU Test - %s Method", cpuTestMethod), width)
|
printCenteredTitle(fmt.Sprintf("CPU Test - %s Method", cpuTestMethod), width)
|
||||||
cputest.CpuTest(language, cpuTestMethod, cpuTestThread)
|
cputest.CpuTest(language, cpuTestMethod, cpuTestThread)
|
||||||
printCenteredTitle(fmt.Sprintf("Memory Test - %s Method", memoryTestMethod), width)
|
printCenteredTitle(fmt.Sprintf("Memory Test - %s Method", memoryTestMethod), width)
|
||||||
memorytest.MemoryTest(language, memoryTestMethod)
|
memorytest.MemoryTest(language, memoryTestMethod)
|
||||||
printCenteredTitle(fmt.Sprintf("Disk Test - %s Method", diskTestMethod), width)
|
printCenteredTitle(fmt.Sprintf("Disk Test - %s Method", diskTestMethod), width)
|
||||||
disktest.DiskTest(language, diskTestMethod, diskTestPath, diskMultiCheck)
|
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)
|
printCenteredTitle("The Three Families Streaming Media Unlock", width)
|
||||||
commediatest.ComMediaTest(language)
|
commediatest.ComMediaTest(language)
|
||||||
printCenteredTitle("Cross-Border Streaming Media Unlock", width)
|
printCenteredTitle("Cross-Border Streaming Media Unlock", width)
|
||||||
unlocktest.MediaTest(language)
|
unlocktest.MediaTest(language)
|
||||||
printCenteredTitle("IP Quality Check", width)
|
printCenteredTitle("IP Quality Check", width)
|
||||||
_, securityInfo, _ := network.NetworkCheck("both", true, language)
|
|
||||||
fmt.Printf(securityInfo)
|
fmt.Printf(securityInfo)
|
||||||
printCenteredTitle("Email Port Check", width)
|
printCenteredTitle("Email Port Check", width)
|
||||||
port.EmailCheck()
|
wg.Wait()
|
||||||
|
fmt.Println(emailInfo)
|
||||||
//printCenteredTitle("Return Path Routing", width)
|
//printCenteredTitle("Return Path Routing", width)
|
||||||
printCenteredTitle("Nearby Node Speed Test", width)
|
printCenteredTitle("Nearby Node Speed Test", width)
|
||||||
speedtest.ShowHead(language)
|
speedtest.ShowHead(language)
|
||||||
|
303
goecs.sh
Normal file
303
goecs.sh
Normal file
@@ -0,0 +1,303 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#From https://github.com/oneclickvirt/ecs
|
||||||
|
#2024.06.29
|
||||||
|
|
||||||
|
# curl -L https://raw.githubusercontent.com/oneclickvirt/ecs/master/goecs.sh -o goecs.sh && chmod +x goecs.sh
|
||||||
|
|
||||||
|
cat <<"EOF"
|
||||||
|
GGG OOO EEEE CCCC SSS
|
||||||
|
G G O O E C S
|
||||||
|
G O O EEE C SSS
|
||||||
|
G GG O O E C S
|
||||||
|
GGG OOO EEEE CCCC SSS
|
||||||
|
EOF
|
||||||
|
cd /root >/dev/null 2>&1
|
||||||
|
|
||||||
|
_red() { echo -e "\033[31m\033[01m$@\033[0m"; }
|
||||||
|
_green() { echo -e "\033[32m\033[01m$@\033[0m"; }
|
||||||
|
_yellow() { echo -e "\033[33m\033[01m$@\033[0m"; }
|
||||||
|
_blue() { echo -e "\033[36m\033[01m$@\033[0m"; }
|
||||||
|
|
||||||
|
check_cdn() {
|
||||||
|
local o_url=$1
|
||||||
|
for cdn_url in "${cdn_urls[@]}"; do
|
||||||
|
if curl -sL -k "$cdn_url$o_url" --max-time 6 | grep -q "success" >/dev/null 2>&1; then
|
||||||
|
export cdn_success_url="$cdn_url"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
sleep 0.5
|
||||||
|
done
|
||||||
|
export cdn_success_url=""
|
||||||
|
}
|
||||||
|
|
||||||
|
check_cdn_file() {
|
||||||
|
check_cdn "https://raw.githubusercontent.com/spiritLHLS/ecs/main/back/test"
|
||||||
|
if [ -n "$cdn_success_url" ]; then
|
||||||
|
echo "CDN available, using CDN"
|
||||||
|
else
|
||||||
|
echo "No CDN available, no use CDN"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
goecs_check() {
|
||||||
|
os=$(uname -s)
|
||||||
|
arch=$(uname -m)
|
||||||
|
ECS_VERSION=$(curl -m 6 -sSL "https://api.github.com/repos/oneclickvirt/ecs/releases/latest" | awk -F \" '/tag_name/{gsub(/^v/,"",$4); print $4}')
|
||||||
|
# 如果 https://api.github.com/ 请求失败,则使用 https://githubapi.spiritlhl.workers.dev/ ,此时可能宿主机无IPV4网络
|
||||||
|
if [ -z "$ECS_VERSION" ]; then
|
||||||
|
ECS_VERSION=$(curl -m 6 -sSL "https://githubapi.spiritlhl.workers.dev/repos/oneclickvirt/ecs/releases/latest" | awk -F \" '/tag_name/{gsub(/^v/,"",$4); print $4}')
|
||||||
|
fi
|
||||||
|
# 如果 https://githubapi.spiritlhl.workers.dev/ 请求失败,则使用 https://githubapi.spiritlhl.top/ ,此时可能宿主机在国内
|
||||||
|
if [ -z "$ECS_VERSION" ]; then
|
||||||
|
ECS_VERSION=$(curl -m 6 -sSL "https://githubapi.spiritlhl.top/repos/oneclickvirt/ecs/releases/latest" | awk -F \" '/tag_name/{gsub(/^v/,"",$4); print $4}')
|
||||||
|
fi
|
||||||
|
# 检测原始goecs命令是否存在,若存在则升级,不存在则安装
|
||||||
|
version_output=$(goecs -v || ./goecs -v)
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
extracted_version=$(echo "$version_output" | grep -oP '^v\d+(\.\d+)+')
|
||||||
|
if [ -n "$extracted_version" ]; then
|
||||||
|
current_version=$(echo "$extracted_version" | cut -c 2-)
|
||||||
|
ecs_version=$ECS_VERSION
|
||||||
|
if [[ "$(echo -e "$current_version\n$ecs_version" | sort -V | tail -n 1)" == "$current_version" ]]; then
|
||||||
|
echo "goecs version ($current_version) is latest, no need to upgrade."
|
||||||
|
return
|
||||||
|
else
|
||||||
|
echo "goecs version ($current_version) < $ecs_version, need to upgrade, 5 seconds later will start to upgrade"
|
||||||
|
rm -rf /usr/bin/goecs
|
||||||
|
rm -rf goecs
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Can not find goecs, need to download and install, 5 seconds later will start to install"
|
||||||
|
fi
|
||||||
|
sleep 5
|
||||||
|
cdn_urls=("https://cdn0.spiritlhl.top/" "http://cdn3.spiritlhl.net/" "http://cdn1.spiritlhl.net/" "http://cdn2.spiritlhl.net/")
|
||||||
|
check_cdn_file
|
||||||
|
case $os in
|
||||||
|
Linux)
|
||||||
|
case $arch in
|
||||||
|
"x86_64" | "x86" | "amd64" | "x64")
|
||||||
|
wget -O goecs.tar.gz "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/v${ECS_VERSION}/ecs_${ECS_VERSION}_linux_amd64.tar.gz"
|
||||||
|
;;
|
||||||
|
"i386" | "i686")
|
||||||
|
wget -O goecs.tar.gz "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/v${ECS_VERSION}/ecs_${ECS_VERSION}_linux_386.tar.gz"
|
||||||
|
;;
|
||||||
|
"armv7l" | "armv8" | "armv8l" | "aarch64" | "arm64")
|
||||||
|
wget -O goecs.tar.gz "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/v${ECS_VERSION}/ecs_${ECS_VERSION}_linux_arm64.tar.gz"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unsupported architecture: $arch"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
Darwin)
|
||||||
|
case $arch in
|
||||||
|
"x86_64" | "x86" | "amd64" | "x64")
|
||||||
|
wget -O goecs.tar.gz "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/v${ECS_VERSION}/ecs_${ECS_VERSION}_linux_amd64.tar.gz"
|
||||||
|
;;
|
||||||
|
"armv7l" | "armv8" | "armv8l" | "aarch64" | "arm64")
|
||||||
|
wget -O goecs.tar.gz "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/v${ECS_VERSION}/ecs_${ECS_VERSION}_linux_arm64.tar.gz"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unsupported architecture: $arch"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unsupported operating system: $os"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
tar -xvf goecs.tar.gz
|
||||||
|
rm -rf goecs.tar.gz
|
||||||
|
rm -rf README.md
|
||||||
|
rm -rf LICENSE
|
||||||
|
mv ecs goecs
|
||||||
|
chmod 777 goecs
|
||||||
|
cp goecs /usr/bin/goecs
|
||||||
|
echo "goecs version:"
|
||||||
|
goecs -v || ./goecs -v
|
||||||
|
}
|
||||||
|
|
||||||
|
InstallSysbench() {
|
||||||
|
if [ -f "/etc/centos-release" ]; then # CentOS
|
||||||
|
Var_OSRelease="centos"
|
||||||
|
elif [ -f "/etc/fedora-release" ]; then # Fedora
|
||||||
|
Var_OSRelease="fedora"
|
||||||
|
elif [ -f "/etc/redhat-release" ]; then # RedHat
|
||||||
|
Var_OSRelease="rhel"
|
||||||
|
elif [ -f "/etc/astra_version" ]; then # Astra
|
||||||
|
Var_OSRelease="astra"
|
||||||
|
elif [ -f "/etc/lsb-release" ]; then # Ubuntu
|
||||||
|
Var_OSRelease="ubuntu"
|
||||||
|
elif [ -f "/etc/debian_version" ]; then # Debian
|
||||||
|
Var_OSRelease="debian"
|
||||||
|
elif [ -f "/etc/alpine-release" ]; then # Alpine Linux
|
||||||
|
Var_OSRelease="alpinelinux"
|
||||||
|
elif [ -f "/etc/almalinux-release" ]; then # almalinux
|
||||||
|
Var_OSRelease="almalinux"
|
||||||
|
elif [ -f "/etc/arch-release" ]; then # archlinux
|
||||||
|
Var_OSRelease="arch"
|
||||||
|
elif [ -f "/etc/freebsd-update.conf" ]; then # freebsd
|
||||||
|
Var_OSRelease="freebsd"
|
||||||
|
else
|
||||||
|
Var_OSRelease="unknown" # 未知系统分支
|
||||||
|
fi
|
||||||
|
case "$Var_OSRelease" in
|
||||||
|
ubuntu | debian | astra) ! apt-get install -y sysbench && apt-get --fix-broken install -y && apt-get install --no-install-recommends -y sysbench ;;
|
||||||
|
centos | rhel | almalinux | redhat) (yum -y install epel-release && yum -y install sysbench) || (dnf install epel-release -y && dnf install sysbench -y) ;;
|
||||||
|
fedora) dnf -y install sysbench ;;
|
||||||
|
arch) pacman -S --needed --noconfirm sysbench && pacman -S --needed --noconfirm libaio && ldconfig ;;
|
||||||
|
freebsd) pkg install -y sysbench ;;
|
||||||
|
alpinelinux) echo -e "${Msg_Warning}Sysbench Module not found, installing ..." && echo -e "${Msg_Warning}SysBench Current not support Alpine Linux, Skipping..." && Var_Skip_SysBench="1" ;;
|
||||||
|
*) echo "Error: Unknown OS release: $os_release" && exit 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
Check_SysBench() {
|
||||||
|
if [ ! -f "/usr/bin/sysbench" ] && [ ! -f "/usr/local/bin/sysbench" ]; then
|
||||||
|
InstallSysbench
|
||||||
|
fi
|
||||||
|
# 尝试编译安装
|
||||||
|
if [ ! -f "/usr/bin/sysbench" ] && [ ! -f "/usr/local/bin/sysbench" ]; then
|
||||||
|
echo -e "${Msg_Warning}Sysbench Module install Failure, trying compile modules ..."
|
||||||
|
Check_Sysbench_InstantBuild
|
||||||
|
fi
|
||||||
|
source ~/.bashrc
|
||||||
|
# 最终检测
|
||||||
|
if [ "$(command -v sysbench)" ] || [ -f "/usr/bin/sysbench" ] || [ -f "/usr/local/bin/sysbench" ]; then
|
||||||
|
_yellow "Install sysbench successfully!"
|
||||||
|
else
|
||||||
|
_red "SysBench Moudle install Failure! Try Restart Bench or Manually install it! (/usr/bin/sysbench)"
|
||||||
|
_blue "Will try to test with geekbench5 instead later on"
|
||||||
|
test_cpu_type="gb5"
|
||||||
|
fi
|
||||||
|
sleep 3
|
||||||
|
}
|
||||||
|
|
||||||
|
Check_Sysbench_InstantBuild() {
|
||||||
|
if [ "${Var_OSRelease}" = "centos" ] || [ "${Var_OSRelease}" = "rhel" ] || [ "${Var_OSRelease}" = "almalinux" ] || [ "${Var_OSRelease}" = "ubuntu" ] || [ "${Var_OSRelease}" = "debian" ] || [ "${Var_OSRelease}" = "fedora" ] || [ "${Var_OSRelease}" = "arch" ] || [ "${Var_OSRelease}" = "astra" ]; then
|
||||||
|
local os_sysbench=${Var_OSRelease}
|
||||||
|
if [ "$os_sysbench" = "astra" ]; then
|
||||||
|
os_sysbench="debian"
|
||||||
|
fi
|
||||||
|
echo -e "${Msg_Info}Release Detected: ${os_sysbench}"
|
||||||
|
echo -e "${Msg_Info}Preparing compile enviorment ..."
|
||||||
|
prepare_compile_env "${os_sysbench}"
|
||||||
|
echo -e "${Msg_Info}Downloading Source code (Version 1.0.20)..."
|
||||||
|
mkdir -p /tmp/sysbench_install/src/
|
||||||
|
mv /tmp/sysbench-1.0.20 /tmp/sysbench_install/src/
|
||||||
|
echo -e "${Msg_Info}Compiling Sysbench Module ..."
|
||||||
|
cd /tmp/sysbench_install/src/sysbench-1.0.20
|
||||||
|
./autogen.sh && ./configure --without-mysql && make -j8 && make install
|
||||||
|
echo -e "${Msg_Info}Cleaning up ..."
|
||||||
|
cd /tmp && rm -rf /tmp/sysbench_install/src/sysbench*
|
||||||
|
else
|
||||||
|
echo -e "${Msg_Warning}Unsupported operating system: ${Var_OSRelease}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
prepare_compile_env() {
|
||||||
|
local system="$1"
|
||||||
|
if [ "${system}" = "centos" ] || [ "${system}" = "rhel" ] || [ "${system}" = "almalinux" ]; then
|
||||||
|
yum install -y epel-release
|
||||||
|
yum install -y wget curl make gcc gcc-c++ make automake libtool pkgconfig libaio-devel
|
||||||
|
elif [ "${system}" = "ubuntu" ] || [ "${system}" = "debian" ]; then
|
||||||
|
! apt-get update && apt-get --fix-broken install -y && apt-get update
|
||||||
|
! apt-get -y install --no-install-recommends curl wget make automake libtool pkg-config libaio-dev unzip && apt-get --fix-broken install -y && apt-get -y install --no-install-recommends curl wget make automake libtool pkg-config libaio-dev unzip
|
||||||
|
elif [ "${system}" = "fedora" ]; then
|
||||||
|
dnf install -y wget curl gcc gcc-c++ make automake libtool pkgconfig libaio-devel
|
||||||
|
elif [ "${system}" = "arch" ]; then
|
||||||
|
pacman -S --needed --noconfirm wget curl gcc gcc make automake libtool pkgconfig libaio lib32-libaio
|
||||||
|
else
|
||||||
|
echo -e "${Msg_Warning}Unsupported operating system: ${system}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
env_check() {
|
||||||
|
REGEX=("debian|astra" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'" "fedora" "arch" "freebsd" "alpine" "openbsd")
|
||||||
|
RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS" "Fedora" "Arch" "FreeBSD" "Alpine" "OpenBSD")
|
||||||
|
PACKAGE_UPDATE=("! apt-get update && apt-get --fix-broken install -y && apt-get update" "apt-get update" "yum -y update" "yum -y update" "yum -y update" "pacman -Sy" "pkg update" "apk update" "pkg_add -u")
|
||||||
|
PACKAGE_INSTALL=("apt-get -y install" "apt-get -y install" "yum -y install" "yum -y install" "yum -y install" "pacman -Sy --noconfirm --needed" "pkg install -y" "apk add")
|
||||||
|
PACKAGE_REMOVE=("apt-get -y remove" "apt-get -y remove" "yum -y remove" "yum -y remove" "yum -y remove" "pacman -Rsc --noconfirm" "pkg delete" "apk del")
|
||||||
|
PACKAGE_UNINSTALL=("apt-get -y autoremove" "apt-get -y autoremove" "yum -y autoremove" "yum -y autoremove" "yum -y autoremove" "" "pkg autoremove" "apk autoremove")
|
||||||
|
CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')" "$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(uname -s)" "$(uname -s)")
|
||||||
|
SYS="${CMD[0]}"
|
||||||
|
[[ -n $SYS ]] || exit 1
|
||||||
|
for ((int = 0; int < ${#REGEX[@]}; int++)); do
|
||||||
|
if [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]]; then
|
||||||
|
SYSTEM="${RELEASE[int]}"
|
||||||
|
[[ -n $SYSTEM ]] && break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
cdn_urls=("https://cdn0.spiritlhl.top/" "http://cdn3.spiritlhl.net/" "http://cdn1.spiritlhl.net/" "http://cdn2.spiritlhl.net/")
|
||||||
|
check_cdn_file
|
||||||
|
if ! command -v dd >/dev/null 2>&1; then
|
||||||
|
_green "Installing dd"
|
||||||
|
$PACKAGE_INSTALL dd
|
||||||
|
fi
|
||||||
|
if ! command -v fio >/dev/null 2>&1; then
|
||||||
|
_green "Installing fio"
|
||||||
|
$PACKAGE_INSTALL fio
|
||||||
|
fi
|
||||||
|
if ! command -v sysbench >/dev/null 2>&1; then
|
||||||
|
_green "Installing sysbench"
|
||||||
|
$PACKAGE_INSTALL sysbench
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Unable to download sysbench through the system's package manager, speak to try compiling and installing it..."
|
||||||
|
if ! wget -O /tmp/sysbench.zip "${cdn_success_url}https://github.com/akopytov/sysbench/archive/1.0.20.zip"; then
|
||||||
|
echo "wget failed, trying with curl"
|
||||||
|
curl -Lk -o /tmp/sysbench.zip "${cdn_success_url}https://github.com/akopytov/sysbench/archive/1.0.20.zip"
|
||||||
|
fi
|
||||||
|
if [ ! -f /tmp/sysbench.zip ]; then
|
||||||
|
wget -q -O /tmp/sysbench.zip "https://hub.fgit.cf/akopytov/sysbench/archive/1.0.20.zip"
|
||||||
|
fi
|
||||||
|
chmod +x /tmp/sysbench.zip
|
||||||
|
unzip /tmp/sysbench.zip -d /tmp
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if ! commadn -v geekbench >/dev/null 2>&1; then
|
||||||
|
_green "Installing geekbench"
|
||||||
|
curl -L "${cdn_success_url}https://raw.githubusercontent.com/oneclickvirt/cputest/main/dgb.sh" -o dgb.sh && chmod +x dgb.sh
|
||||||
|
bash dgb.sh -v gb5
|
||||||
|
_blue "If you not want to use geekbench5, you can use"
|
||||||
|
echo "bash dgb.sh -v gb6"
|
||||||
|
echo "bash dgb.sh -v gb4"
|
||||||
|
_blue "to change version, or use"
|
||||||
|
echo "rm -rf /usr/bin/geekbench*"
|
||||||
|
_blue "to uninstall geekbench"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
show_help() {
|
||||||
|
cat <<"EOF"
|
||||||
|
Available commands:
|
||||||
|
|
||||||
|
env Check and install dd fio sysbench geekbench5
|
||||||
|
install Install goecs command
|
||||||
|
help Show this message
|
||||||
|
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
"help")
|
||||||
|
show_help
|
||||||
|
;;
|
||||||
|
"env")
|
||||||
|
env_check
|
||||||
|
;;
|
||||||
|
"install")
|
||||||
|
goecs_check
|
||||||
|
;;
|
||||||
|
"upgrade")
|
||||||
|
goecs_check
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "No command found."
|
||||||
|
echo
|
||||||
|
show_help
|
||||||
|
;;
|
||||||
|
esac
|
@@ -1,93 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#From https://github.com/oneclickvirt/ecs
|
|
||||||
#2024.06.29
|
|
||||||
|
|
||||||
rm -rf /usr/bin/goecs
|
|
||||||
rm -rf goecs
|
|
||||||
os=$(uname -s)
|
|
||||||
arch=$(uname -m)
|
|
||||||
|
|
||||||
check_cdn() {
|
|
||||||
local o_url=$1
|
|
||||||
for cdn_url in "${cdn_urls[@]}"; do
|
|
||||||
if curl -sL -k "$cdn_url$o_url" --max-time 6 | grep -q "success" >/dev/null 2>&1; then
|
|
||||||
export cdn_success_url="$cdn_url"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
sleep 0.5
|
|
||||||
done
|
|
||||||
export cdn_success_url=""
|
|
||||||
}
|
|
||||||
|
|
||||||
check_cdn_file() {
|
|
||||||
check_cdn "https://raw.githubusercontent.com/spiritLHLS/ecs/main/back/test"
|
|
||||||
if [ -n "$cdn_success_url" ]; then
|
|
||||||
echo "CDN available, using CDN"
|
|
||||||
else
|
|
||||||
echo "No CDN available, no use CDN"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
cdn_urls=("https://cdn0.spiritlhl.top/" "http://cdn3.spiritlhl.net/" "http://cdn1.spiritlhl.net/" "http://cdn2.spiritlhl.net/")
|
|
||||||
check_cdn_file
|
|
||||||
|
|
||||||
case $os in
|
|
||||||
Linux)
|
|
||||||
case $arch in
|
|
||||||
"x86_64" | "x86" | "amd64" | "x64")
|
|
||||||
wget -O goecs "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/output/ecs-linux-amd64"
|
|
||||||
;;
|
|
||||||
"i386" | "i686")
|
|
||||||
wget -O goecs "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/output/ecs-linux-386"
|
|
||||||
;;
|
|
||||||
"armv7l" | "armv8" | "armv8l" | "aarch64" | "arm64")
|
|
||||||
wget -O goecs "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/output/ecs-linux-arm64"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Unsupported architecture: $arch"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
Darwin)
|
|
||||||
case $arch in
|
|
||||||
"x86_64" | "x86" | "amd64" | "x64")
|
|
||||||
wget -O goecs "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/output/ecs-darwin-amd64"
|
|
||||||
;;
|
|
||||||
"i386" | "i686")
|
|
||||||
wget -O goecs "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/output/ecs-darwin-386"
|
|
||||||
;;
|
|
||||||
"armv7l" | "armv8" | "armv8l" | "aarch64" | "arm64")
|
|
||||||
wget -O goecs "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/output/ecs-darwin-arm64"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Unsupported architecture: $arch"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
FreeBSD)
|
|
||||||
case $arch in
|
|
||||||
amd64)
|
|
||||||
wget -O goecs "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/output/ecs-freebsd-amd64"
|
|
||||||
;;
|
|
||||||
"i386" | "i686")
|
|
||||||
wget -O goecs "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/output/ecs-freebsd-386"
|
|
||||||
;;
|
|
||||||
"armv7l" | "armv8" | "armv8l" | "aarch64" | "arm64")
|
|
||||||
wget -O goecs "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/output/ecs-freebsd-arm64"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Unsupported architecture: $arch"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Unsupported operating system: $os"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
chmod 777 goecs
|
|
||||||
cp goecs /usr/bin/goecs
|
|
@@ -1,30 +1,26 @@
|
|||||||
package unlocktest
|
package unlocktest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"github.com/oneclickvirt/UnlockTests/utils"
|
"github.com/oneclickvirt/UnlockTests/utils"
|
||||||
"github.com/oneclickvirt/UnlockTests/uts"
|
"github.com/oneclickvirt/UnlockTests/uts"
|
||||||
"github.com/oneclickvirt/defaultset"
|
"github.com/oneclickvirt/defaultset"
|
||||||
)
|
)
|
||||||
|
|
||||||
func MediaTest(language string) {
|
func MediaTest(language string) string {
|
||||||
uts.GetIpv4Info(false)
|
var res string
|
||||||
uts.GetIpv6Info(false)
|
|
||||||
readStatus := uts.ReadSelect(language, "0")
|
readStatus := uts.ReadSelect(language, "0")
|
||||||
if !readStatus {
|
if !readStatus {
|
||||||
return
|
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 {
|
if uts.IPV4 {
|
||||||
fmt.Println(defaultset.Blue("IPV4:"))
|
res += defaultset.Blue("IPV4:") + "\n"
|
||||||
uts.RunTests(utils.Ipv4HttpClient, "ipv4", language)
|
res += uts.RunTests(utils.Ipv4HttpClient, "ipv4", language, false)
|
||||||
|
return res
|
||||||
}
|
}
|
||||||
if uts.IPV6 {
|
if uts.IPV6 {
|
||||||
fmt.Println(defaultset.Blue("IPV6:"))
|
res += defaultset.Blue("IPV6:") + "\n"
|
||||||
uts.RunTests(utils.Ipv6HttpClient, "ipv6", language)
|
res += uts.RunTests(utils.Ipv6HttpClient, "ipv6", language, false)
|
||||||
|
return res
|
||||||
}
|
}
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,10 @@
|
|||||||
package unlocktest
|
package unlocktest
|
||||||
|
|
||||||
import "testing"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
func Test(t *testing.T) {
|
func Test(t *testing.T) {
|
||||||
MediaTest("zh")
|
fmt.Printf(MediaTest("zh"))
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user