mirror of
https://github.com/oneclickvirt/ecs.git
synced 2025-09-28 12:12:14 +08:00
Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4b8ae06df8 | ||
![]() |
859e783241 | ||
![]() |
3cd912219e | ||
![]() |
a85a06b440 | ||
![]() |
681da08f01 | ||
![]() |
bdd00d46f8 | ||
![]() |
1f213bb788 | ||
![]() |
1dec7c323b | ||
![]() |
391cc351c4 | ||
![]() |
282a947156 | ||
![]() |
73916d324a | ||
![]() |
6cce2a7e8e | ||
![]() |
2a653930a8 | ||
![]() |
2295035706 | ||
![]() |
3e8c7112a0 | ||
![]() |
a827583b76 |
4
.github/workflows/build_docker.yaml
vendored
4
.github/workflows/build_docker.yaml
vendored
@@ -29,7 +29,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: ./Dockerfile
|
file: ./Dockerfile
|
||||||
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/s390x,linux/riscv64
|
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/riscv64
|
||||||
# linux/mips,linux/mipsle 暂不支持 alpine
|
# linux/mips,linux/mipsle 暂不支持 alpine, linux/s390x 编译卡死
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ secrets.DOCKER_USERNAME }}/goecs:latest
|
tags: ${{ secrets.DOCKER_USERNAME }}/goecs:latest
|
||||||
|
@@ -163,7 +163,7 @@ Usage: goecs [options]
|
|||||||
-memory
|
-memory
|
||||||
Enable/Disable memory test (default true)
|
Enable/Disable memory test (default true)
|
||||||
-memorym string
|
-memorym string
|
||||||
Set memory test method (supported: sysbench, dd, winsat) (default "dd")
|
Set memory test method (supported: sysbench, dd, winsat) (default "sysbench")
|
||||||
-menu
|
-menu
|
||||||
Enable/Disable menu mode, disable example: -menu=false (default true)
|
Enable/Disable menu mode, disable example: -menu=false (default true)
|
||||||
-nt3
|
-nt3
|
||||||
@@ -199,6 +199,8 @@ windows测试无需进行环境安装
|
|||||||
|
|
||||||
## 在Docker中使用的说明
|
## 在Docker中使用的说明
|
||||||
|
|
||||||
|
地址:https://hub.docker.com/r/spiritlhl/goecs
|
||||||
|
|
||||||
请确保执行下述命令前本机已安装Docker
|
请确保执行下述命令前本机已安装Docker
|
||||||
|
|
||||||
特权模式+host网络
|
特权模式+host网络
|
||||||
|
@@ -151,7 +151,7 @@ Usage: goecs [options]
|
|||||||
-memory
|
-memory
|
||||||
Enable/Disable memory test (default true)
|
Enable/Disable memory test (default true)
|
||||||
-memorym string
|
-memorym string
|
||||||
Set memory test method (supported: sysbench, dd, winsat) (default "dd")
|
Set memory test method (supported: sysbench, dd, winsat) (default "sysbench")
|
||||||
-menu
|
-menu
|
||||||
Enable/Disable menu mode, disable example: -menu=false (default true)
|
Enable/Disable menu mode, disable example: -menu=false (default true)
|
||||||
-nt3
|
-nt3
|
||||||
@@ -187,6 +187,8 @@ No environment installation is required for Windows testing.
|
|||||||
|
|
||||||
## Instructions for Use in Docker
|
## Instructions for Use in Docker
|
||||||
|
|
||||||
|
Link: https://hub.docker.com/r/spiritlhl/goecs
|
||||||
|
|
||||||
Please make sure that Docker is installed on your machine before executing the following commands
|
Please make sure that Docker is installed on your machine before executing the following commands
|
||||||
|
|
||||||
Privileged Mode + host network
|
Privileged Mode + host network
|
||||||
@@ -195,7 +197,7 @@ Privileged Mode + host network
|
|||||||
docker run --rm --privileged --network host spiritlhl/goecs:latest -menu=false -l en
|
docker run --rm --privileged --network host spiritlhl/goecs:latest -menu=false -l en
|
||||||
```
|
```
|
||||||
|
|
||||||
Unprivileged mode + non-host network -menu=false -l en
|
Unprivileged mode + non-host network
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
docker run --rm spiritlhl/goecs:latest
|
docker run --rm spiritlhl/goecs:latest
|
||||||
|
8
go.mod
8
go.mod
@@ -5,19 +5,19 @@ go 1.22.4
|
|||||||
require (
|
require (
|
||||||
github.com/imroc/req/v3 v3.43.7
|
github.com/imroc/req/v3 v3.43.7
|
||||||
github.com/oneclickvirt/CommonMediaTests v0.0.4-20240704024502
|
github.com/oneclickvirt/CommonMediaTests v0.0.4-20240704024502
|
||||||
github.com/oneclickvirt/UnlockTests v0.0.15-20240814090726
|
github.com/oneclickvirt/UnlockTests v0.0.16-20240823051211
|
||||||
github.com/oneclickvirt/backtrace v0.0.4-20240702140722
|
github.com/oneclickvirt/backtrace v0.0.4-20240702140722
|
||||||
github.com/oneclickvirt/basics v0.0.7-20240801050316
|
github.com/oneclickvirt/basics v0.0.7-20240821160408
|
||||||
github.com/oneclickvirt/cputest v0.0.8-20240702070215
|
github.com/oneclickvirt/cputest v0.0.8-20240702070215
|
||||||
github.com/oneclickvirt/defaultset v0.0.2-20240624082446
|
github.com/oneclickvirt/defaultset v0.0.2-20240624082446
|
||||||
github.com/oneclickvirt/disktest v0.0.4-20240809053456
|
github.com/oneclickvirt/disktest v0.0.4-20240809053456
|
||||||
github.com/oneclickvirt/gostun v0.0.3-20240702054621
|
github.com/oneclickvirt/gostun v0.0.3-20240702054621
|
||||||
github.com/oneclickvirt/memorytest v0.0.4-20240814081347
|
github.com/oneclickvirt/memorytest v0.0.4-20240820095126
|
||||||
github.com/oneclickvirt/nt3 v0.0.3-20240809100110
|
github.com/oneclickvirt/nt3 v0.0.3-20240809100110
|
||||||
github.com/oneclickvirt/pingtest v0.0.5-20240804134050
|
github.com/oneclickvirt/pingtest v0.0.5-20240804134050
|
||||||
github.com/oneclickvirt/portchecker v0.0.2-20240803151204
|
github.com/oneclickvirt/portchecker v0.0.2-20240803151204
|
||||||
github.com/oneclickvirt/security v0.0.4-20240729065854
|
github.com/oneclickvirt/security v0.0.4-20240729065854
|
||||||
github.com/oneclickvirt/speedtest v0.0.7-20240704023701
|
github.com/oneclickvirt/speedtest v0.0.8-20241005164804
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
16
go.sum
16
go.sum
@@ -104,12 +104,12 @@ github.com/nxtrace/NTrace-core v1.3.2 h1:8aU/IQFmPnwbaWGVBIJHwwVIWk+roo+9+lG+U0O
|
|||||||
github.com/nxtrace/NTrace-core v1.3.2/go.mod h1:qCVsgSs982jw02BVjTtN8mjSg5OIXW9TaUdISQrMnTw=
|
github.com/nxtrace/NTrace-core v1.3.2/go.mod h1:qCVsgSs982jw02BVjTtN8mjSg5OIXW9TaUdISQrMnTw=
|
||||||
github.com/oneclickvirt/CommonMediaTests v0.0.4-20240704024502 h1:hRIYJ2uEp2N3AH5bP5X6bwfdwWfZQO/2WoqpUJ8+WsY=
|
github.com/oneclickvirt/CommonMediaTests v0.0.4-20240704024502 h1:hRIYJ2uEp2N3AH5bP5X6bwfdwWfZQO/2WoqpUJ8+WsY=
|
||||||
github.com/oneclickvirt/CommonMediaTests v0.0.4-20240704024502/go.mod h1:DAmFPRjFV5p9fEzUUSml5jJGn2f1NZJQCzTxITHDjc4=
|
github.com/oneclickvirt/CommonMediaTests v0.0.4-20240704024502/go.mod h1:DAmFPRjFV5p9fEzUUSml5jJGn2f1NZJQCzTxITHDjc4=
|
||||||
github.com/oneclickvirt/UnlockTests v0.0.15-20240814090726 h1:dwxFOF8AvnIIpMd7dmAOX0yqY6TZDAsRwpDM0SGGCGA=
|
github.com/oneclickvirt/UnlockTests v0.0.16-20240823051211 h1:oDYlAXbUSt6JYTC+wcFDVWTacGuyBtWNfJhpKkrqNkU=
|
||||||
github.com/oneclickvirt/UnlockTests v0.0.15-20240814090726/go.mod h1:UELwZDDiddSxe38boYOPl1FlrL0ptEZYSQwdE3MYvUM=
|
github.com/oneclickvirt/UnlockTests v0.0.16-20240823051211/go.mod h1:UELwZDDiddSxe38boYOPl1FlrL0ptEZYSQwdE3MYvUM=
|
||||||
github.com/oneclickvirt/backtrace v0.0.4-20240702140722 h1:UJ/VWf+ZbhGarc9HcHMIyenpmX+b2LxkXu0hlLk3Gxs=
|
github.com/oneclickvirt/backtrace v0.0.4-20240702140722 h1:UJ/VWf+ZbhGarc9HcHMIyenpmX+b2LxkXu0hlLk3Gxs=
|
||||||
github.com/oneclickvirt/backtrace v0.0.4-20240702140722/go.mod h1:zvsC7xY/WZqs5KL2JB967OVnuqjNbxu9bW6wXRLo5h8=
|
github.com/oneclickvirt/backtrace v0.0.4-20240702140722/go.mod h1:zvsC7xY/WZqs5KL2JB967OVnuqjNbxu9bW6wXRLo5h8=
|
||||||
github.com/oneclickvirt/basics v0.0.7-20240801050316 h1:LX0qJK5ZVL2WPQ2g6Yn15jOOyCeZeCXjyjJZe0gzJ48=
|
github.com/oneclickvirt/basics v0.0.7-20240821160408 h1:IOqa7bBAkjhfru6arDsOTKB7qZ36ojfOP73kE+cDaqc=
|
||||||
github.com/oneclickvirt/basics v0.0.7-20240801050316/go.mod h1:fUdVpU8gdjaZsTCyqnQBAbHc9BbbN8Fxr3sGPKooUpU=
|
github.com/oneclickvirt/basics v0.0.7-20240821160408/go.mod h1:fUdVpU8gdjaZsTCyqnQBAbHc9BbbN8Fxr3sGPKooUpU=
|
||||||
github.com/oneclickvirt/cputest v0.0.8-20240702070215 h1:CcFpyVPlQkJ6vjFP17BRuJhh/afiJhOhZ0BW+TtfVDg=
|
github.com/oneclickvirt/cputest v0.0.8-20240702070215 h1:CcFpyVPlQkJ6vjFP17BRuJhh/afiJhOhZ0BW+TtfVDg=
|
||||||
github.com/oneclickvirt/cputest v0.0.8-20240702070215/go.mod h1:MmaHN9+XMntI3rLycwj8Ne31fG18IfNoa8N2utDK1CY=
|
github.com/oneclickvirt/cputest v0.0.8-20240702070215/go.mod h1:MmaHN9+XMntI3rLycwj8Ne31fG18IfNoa8N2utDK1CY=
|
||||||
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=
|
||||||
@@ -118,8 +118,8 @@ github.com/oneclickvirt/disktest v0.0.4-20240809053456 h1:g6fKzvImIV8YQZKKEJ2Fdv
|
|||||||
github.com/oneclickvirt/disktest v0.0.4-20240809053456/go.mod h1:wIZy8G6Mbcy8Op8tc0HmJNpbJQQ5A15fvnUqMJXIdO0=
|
github.com/oneclickvirt/disktest v0.0.4-20240809053456/go.mod h1:wIZy8G6Mbcy8Op8tc0HmJNpbJQQ5A15fvnUqMJXIdO0=
|
||||||
github.com/oneclickvirt/gostun v0.0.3-20240702054621 h1:IE89eEYV9TJbF94SakQDAxTLIaqX+Tb6ZhJ/CCIP+90=
|
github.com/oneclickvirt/gostun v0.0.3-20240702054621 h1:IE89eEYV9TJbF94SakQDAxTLIaqX+Tb6ZhJ/CCIP+90=
|
||||||
github.com/oneclickvirt/gostun v0.0.3-20240702054621/go.mod h1:f7DPEXAxbmwXSW33dbxtb0/KzqvOBWhTs2Or5xBerQA=
|
github.com/oneclickvirt/gostun v0.0.3-20240702054621/go.mod h1:f7DPEXAxbmwXSW33dbxtb0/KzqvOBWhTs2Or5xBerQA=
|
||||||
github.com/oneclickvirt/memorytest v0.0.4-20240814081347 h1:xOlCh8IpcI0YtP0IU/+IID8ri/Jz6mQ3gGg6zIQ0D6g=
|
github.com/oneclickvirt/memorytest v0.0.4-20240820095126 h1:Il3rvWkrZy/6B2iO3HRe9039/qRllA4CzcZ/dI8aG2A=
|
||||||
github.com/oneclickvirt/memorytest v0.0.4-20240814081347/go.mod h1:+YNzy+NeVg61d0kNwSyVDqHyVtKzjuRe1NvMzsDLg0I=
|
github.com/oneclickvirt/memorytest v0.0.4-20240820095126/go.mod h1:+YNzy+NeVg61d0kNwSyVDqHyVtKzjuRe1NvMzsDLg0I=
|
||||||
github.com/oneclickvirt/nt3 v0.0.3-20240809100110 h1:UyF0jBDP0xpxSV9L/GYG83SKUMPSjHPru+3iPZHYG7U=
|
github.com/oneclickvirt/nt3 v0.0.3-20240809100110 h1:UyF0jBDP0xpxSV9L/GYG83SKUMPSjHPru+3iPZHYG7U=
|
||||||
github.com/oneclickvirt/nt3 v0.0.3-20240809100110/go.mod h1:4SDl5o83wbixk9YJqvG0eNo2w8aWt/QgntfPBi9wEpY=
|
github.com/oneclickvirt/nt3 v0.0.3-20240809100110/go.mod h1:4SDl5o83wbixk9YJqvG0eNo2w8aWt/QgntfPBi9wEpY=
|
||||||
github.com/oneclickvirt/pingtest v0.0.5-20240804134050 h1:ASiYr+IgWIPDhTiXEN1dbm1AEcxRkPnKi3NNn4mCkDE=
|
github.com/oneclickvirt/pingtest v0.0.5-20240804134050 h1:ASiYr+IgWIPDhTiXEN1dbm1AEcxRkPnKi3NNn4mCkDE=
|
||||||
@@ -128,8 +128,8 @@ github.com/oneclickvirt/portchecker v0.0.2-20240803151204 h1:ZruxRgyIv3d6Y8n0Ney
|
|||||||
github.com/oneclickvirt/portchecker v0.0.2-20240803151204/go.mod h1:HQxSTrqM8/QFqHMTBZ7S8H9eEO5FkUXU1eb7ZX5Mk+k=
|
github.com/oneclickvirt/portchecker v0.0.2-20240803151204/go.mod h1:HQxSTrqM8/QFqHMTBZ7S8H9eEO5FkUXU1eb7ZX5Mk+k=
|
||||||
github.com/oneclickvirt/security v0.0.4-20240729065854 h1:I27XtMUEHmXw1RN0jNDQmFqNdu6vL4v1g8UZtXiCuBY=
|
github.com/oneclickvirt/security v0.0.4-20240729065854 h1:I27XtMUEHmXw1RN0jNDQmFqNdu6vL4v1g8UZtXiCuBY=
|
||||||
github.com/oneclickvirt/security v0.0.4-20240729065854/go.mod h1:384ZpNE3H6T6rtl0QhA4eQn8xGw7tc0rLD8ZH47qNGc=
|
github.com/oneclickvirt/security v0.0.4-20240729065854/go.mod h1:384ZpNE3H6T6rtl0QhA4eQn8xGw7tc0rLD8ZH47qNGc=
|
||||||
github.com/oneclickvirt/speedtest v0.0.7-20240704023701 h1:F8ChZXf3U1/bUk+dCFt0Gc01LSPLhbBhCeHjkEJ6K88=
|
github.com/oneclickvirt/speedtest v0.0.8-20241005164804 h1:qguczGucxyRCRaeI2Av7+QpgYb6o8lTJJmOjPkmGiSg=
|
||||||
github.com/oneclickvirt/speedtest v0.0.7-20240704023701/go.mod h1:zd5ZgIGslmtQLQehEfRjyumlvgDHTpCSMchKfKXoASI=
|
github.com/oneclickvirt/speedtest v0.0.8-20241005164804/go.mod h1:zd5ZgIGslmtQLQehEfRjyumlvgDHTpCSMchKfKXoASI=
|
||||||
github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA=
|
github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA=
|
||||||
github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To=
|
github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To=
|
||||||
github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk=
|
github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk=
|
||||||
|
249
goecs.go
249
goecs.go
@@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"context"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/oneclickvirt/CommonMediaTests/commediatests"
|
"github.com/oneclickvirt/CommonMediaTests/commediatests"
|
||||||
@@ -38,7 +39,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ecsVersion = "v0.0.70"
|
ecsVersion = "v0.0.79"
|
||||||
menuMode bool
|
menuMode bool
|
||||||
onlyChinaTest bool
|
onlyChinaTest bool
|
||||||
input, choice string
|
input, choice string
|
||||||
@@ -62,6 +63,68 @@ var (
|
|||||||
goecsFlag = flag.NewFlagSet("goecs", flag.ContinueOnError)
|
goecsFlag = flag.NewFlagSet("goecs", flag.ContinueOnError)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func getMenuChoice(language string) string {
|
||||||
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
sigChan := make(chan os.Signal, 1)
|
||||||
|
signal.Notify(sigChan, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
|
||||||
|
defer signal.Stop(sigChan)
|
||||||
|
|
||||||
|
inputChan := make(chan string, 1)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
select {
|
||||||
|
case <-sigChan:
|
||||||
|
fmt.Println("\n程序在选择过程中被用户中断")
|
||||||
|
os.Exit(1)
|
||||||
|
case <-ctx.Done():
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
for {
|
||||||
|
go func() {
|
||||||
|
var input string
|
||||||
|
fmt.Print("请输入选项 / Please enter your choice: ")
|
||||||
|
fmt.Scanln(&input)
|
||||||
|
input = strings.TrimSpace(input)
|
||||||
|
input = strings.TrimRight(input, "\n")
|
||||||
|
select {
|
||||||
|
case inputChan <- input:
|
||||||
|
case <-ctx.Done():
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
select {
|
||||||
|
case input := <-inputChan:
|
||||||
|
re := regexp.MustCompile(`^\d+$`) // 正则表达式匹配纯数字
|
||||||
|
if re.MatchString(input) {
|
||||||
|
choice := input
|
||||||
|
switch choice {
|
||||||
|
case "1", "2", "3", "4", "5", "6", "7", "8", "9", "10":
|
||||||
|
return choice
|
||||||
|
default:
|
||||||
|
if language == "zh" {
|
||||||
|
fmt.Println("无效的选项")
|
||||||
|
} else {
|
||||||
|
fmt.Println("Invalid choice")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if language == "zh" {
|
||||||
|
fmt.Println("输入错误,请输入一个纯数字")
|
||||||
|
} else {
|
||||||
|
fmt.Println("Invalid input, please enter a number")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case <-ctx.Done():
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
goecsFlag.BoolVar(&help, "h", false, "Show help information")
|
goecsFlag.BoolVar(&help, "h", false, "Show help information")
|
||||||
goecsFlag.BoolVar(&showVersion, "v", false, "Display version information")
|
goecsFlag.BoolVar(&showVersion, "v", false, "Display version information")
|
||||||
@@ -80,7 +143,7 @@ func main() {
|
|||||||
goecsFlag.BoolVar(&speedTestStatus, "speed", true, "Enable/Disable speed test")
|
goecsFlag.BoolVar(&speedTestStatus, "speed", true, "Enable/Disable speed test")
|
||||||
goecsFlag.StringVar(&cpuTestMethod, "cpum", "sysbench", "Set CPU test method (supported: sysbench, geekbench, winsat)")
|
goecsFlag.StringVar(&cpuTestMethod, "cpum", "sysbench", "Set CPU test method (supported: sysbench, geekbench, winsat)")
|
||||||
goecsFlag.StringVar(&cpuTestThreadMode, "cput", "multi", "Set CPU test thread mode (supported: single, multi)")
|
goecsFlag.StringVar(&cpuTestThreadMode, "cput", "multi", "Set CPU test thread mode (supported: single, multi)")
|
||||||
goecsFlag.StringVar(&memoryTestMethod, "memorym", "dd", "Set memory test method (supported: sysbench, dd, winsat)")
|
goecsFlag.StringVar(&memoryTestMethod, "memorym", "sysbench", "Set memory test method (supported: sysbench, dd, winsat)")
|
||||||
goecsFlag.StringVar(&diskTestMethod, "diskm", "fio", "Set disk test method (supported: fio, dd, winsat)")
|
goecsFlag.StringVar(&diskTestMethod, "diskm", "fio", "Set disk test method (supported: fio, dd, winsat)")
|
||||||
goecsFlag.StringVar(&diskTestPath, "diskp", "", "Set disk test path, e.g., -diskp /root")
|
goecsFlag.StringVar(&diskTestPath, "diskp", "", "Set disk test path, e.g., -diskp /root")
|
||||||
goecsFlag.BoolVar(&diskMultiCheck, "diskmc", false, "Enable/Disable multiple disk checks, e.g., -diskmc=false")
|
goecsFlag.BoolVar(&diskMultiCheck, "diskmc", false, "Enable/Disable multiple disk checks, e.g., -diskmc=false")
|
||||||
@@ -95,8 +158,6 @@ func main() {
|
|||||||
goecsFlag.PrintDefaults()
|
goecsFlag.PrintDefaults()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
sig := make(chan os.Signal, 1)
|
|
||||||
signal.Notify(sig, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
|
|
||||||
if showVersion {
|
if showVersion {
|
||||||
fmt.Println(ecsVersion)
|
fmt.Println(ecsVersion)
|
||||||
return
|
return
|
||||||
@@ -149,103 +210,90 @@ func main() {
|
|||||||
}
|
}
|
||||||
Loop:
|
Loop:
|
||||||
for {
|
for {
|
||||||
fmt.Print("请输入选项 / Please enter your choice: ")
|
choice := getMenuChoice(language)
|
||||||
fmt.Scanln(&input)
|
switch choice {
|
||||||
input = strings.TrimSpace(input)
|
case "1":
|
||||||
input = strings.TrimRight(input, "\n")
|
basicStatus = true
|
||||||
re := regexp.MustCompile(`^\d+$`) // 正则表达式匹配纯数字
|
cpuTestStatus = true
|
||||||
if re.MatchString(input) {
|
memoryTestStatus = true
|
||||||
choice = input
|
diskTestStatus = true
|
||||||
switch choice {
|
commTestStatus = true
|
||||||
case "1":
|
utTestStatus = true
|
||||||
basicStatus = true
|
securityTestStatus = true
|
||||||
cpuTestStatus = true
|
emailTestStatus = true
|
||||||
memoryTestStatus = true
|
backtraceStatus = true
|
||||||
diskTestStatus = true
|
nt3Status = true
|
||||||
commTestStatus = true
|
speedTestStatus = true
|
||||||
utTestStatus = true
|
onlyChinaTest = utils.CheckChina(enableLogger)
|
||||||
securityTestStatus = true
|
break Loop
|
||||||
emailTestStatus = true
|
case "2":
|
||||||
backtraceStatus = true
|
basicStatus = true
|
||||||
nt3Status = true
|
cpuTestStatus = true
|
||||||
speedTestStatus = true
|
memoryTestStatus = true
|
||||||
onlyChinaTest = utils.CheckChina(enableLogger)
|
diskTestStatus = true
|
||||||
break Loop
|
speedTestStatus = true
|
||||||
case "2":
|
break Loop
|
||||||
basicStatus = true
|
case "3":
|
||||||
cpuTestStatus = true
|
basicStatus = true
|
||||||
memoryTestStatus = true
|
cpuTestStatus = true
|
||||||
diskTestStatus = true
|
memoryTestStatus = true
|
||||||
speedTestStatus = true
|
diskTestStatus = true
|
||||||
break Loop
|
utTestStatus = true
|
||||||
case "3":
|
nt3Status = true
|
||||||
basicStatus = true
|
speedTestStatus = true
|
||||||
cpuTestStatus = true
|
break Loop
|
||||||
memoryTestStatus = true
|
case "4":
|
||||||
diskTestStatus = true
|
basicStatus = true
|
||||||
utTestStatus = true
|
cpuTestStatus = true
|
||||||
nt3Status = true
|
memoryTestStatus = true
|
||||||
speedTestStatus = true
|
diskTestStatus = true
|
||||||
break Loop
|
backtraceStatus = true
|
||||||
case "4":
|
nt3Status = true
|
||||||
basicStatus = true
|
speedTestStatus = true
|
||||||
cpuTestStatus = true
|
break Loop
|
||||||
memoryTestStatus = true
|
case "5":
|
||||||
diskTestStatus = true
|
basicStatus = true
|
||||||
backtraceStatus = true
|
cpuTestStatus = true
|
||||||
nt3Status = true
|
memoryTestStatus = true
|
||||||
speedTestStatus = true
|
diskTestStatus = true
|
||||||
break Loop
|
commTestStatus = true
|
||||||
case "5":
|
utTestStatus = true
|
||||||
basicStatus = true
|
speedTestStatus = true
|
||||||
cpuTestStatus = true
|
break Loop
|
||||||
memoryTestStatus = true
|
case "6":
|
||||||
diskTestStatus = true
|
securityTestStatus = true
|
||||||
commTestStatus = true
|
speedTestStatus = true
|
||||||
utTestStatus = true
|
backtraceStatus = true
|
||||||
speedTestStatus = true
|
nt3Status = true
|
||||||
break Loop
|
break Loop
|
||||||
case "6":
|
case "7":
|
||||||
securityTestStatus = true
|
commTestStatus = true
|
||||||
speedTestStatus = true
|
utTestStatus = true
|
||||||
backtraceStatus = true
|
enabelUpload = false
|
||||||
nt3Status = true
|
break Loop
|
||||||
break Loop
|
case "8":
|
||||||
case "7":
|
basicStatus = true
|
||||||
commTestStatus = true
|
cpuTestStatus = true
|
||||||
utTestStatus = true
|
memoryTestStatus = true
|
||||||
enabelUpload = false
|
diskTestStatus = true
|
||||||
break Loop
|
securityTestStatus = false
|
||||||
case "8":
|
autoChangeDiskTestMethod = false
|
||||||
basicStatus = true
|
break Loop
|
||||||
cpuTestStatus = true
|
case "9":
|
||||||
memoryTestStatus = true
|
securityTestStatus = true
|
||||||
diskTestStatus = true
|
emailTestStatus = true
|
||||||
securityTestStatus = false
|
break Loop
|
||||||
autoChangeDiskTestMethod = false
|
case "10":
|
||||||
break Loop
|
backtraceStatus = true
|
||||||
case "9":
|
nt3Status = true
|
||||||
securityTestStatus = true
|
pingTestStatus = true
|
||||||
emailTestStatus = true
|
enabelUpload = false
|
||||||
break Loop
|
break Loop
|
||||||
case "10":
|
default:
|
||||||
backtraceStatus = true
|
|
||||||
nt3Status = true
|
|
||||||
pingTestStatus = true
|
|
||||||
enabelUpload = false
|
|
||||||
break Loop
|
|
||||||
default:
|
|
||||||
if language == "zh" {
|
|
||||||
fmt.Println("无效的选项")
|
|
||||||
} else {
|
|
||||||
fmt.Println("Invalid choice")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if language == "zh" {
|
if language == "zh" {
|
||||||
fmt.Println("输入错误,请输入一个纯数字")
|
fmt.Println("无效的选项")
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("Invalid input, please enter a number")
|
fmt.Println("Invalid choice")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -263,6 +311,9 @@ func main() {
|
|||||||
basicInfo, securityInfo, emailInfo, mediaInfo, ptInfo string
|
basicInfo, securityInfo, emailInfo, mediaInfo, ptInfo string
|
||||||
output, tempOutput string
|
output, tempOutput string
|
||||||
)
|
)
|
||||||
|
// 设置主程序的信号处理
|
||||||
|
sig := make(chan os.Signal, 1)
|
||||||
|
signal.Notify(sig, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
|
||||||
// 启动一个goroutine来等待信号,内置计时器
|
// 启动一个goroutine来等待信号,内置计时器
|
||||||
go func() {
|
go func() {
|
||||||
startTime = time.Now()
|
startTime = time.Now()
|
||||||
|
5
goecs.sh
5
goecs.sh
@@ -358,7 +358,10 @@ env_check() {
|
|||||||
fi
|
fi
|
||||||
if ! command -v dd >/dev/null 2>&1; then
|
if ! command -v dd >/dev/null 2>&1; then
|
||||||
_green "Installing dd"
|
_green "Installing dd"
|
||||||
${PACKAGE_INSTALL[int]} dd
|
${PACKAGE_INSTALL[int]} coreutils
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
${PACKAGE_INSTALL[int]} man
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if ! command -v fio >/dev/null 2>&1; then
|
if ! command -v fio >/dev/null 2>&1; then
|
||||||
_green "Installing fio"
|
_green "Installing fio"
|
||||||
|
@@ -238,7 +238,7 @@ func PrintAndCapture(f func(), tempOutput, output string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UploadText 上传文本内容到指定URL
|
// UploadText 上传文本内容到指定URL
|
||||||
func UploadText(absPath string) (string, error) {
|
func UploadText(absPath string) (string, string, error) {
|
||||||
primaryURL := "http://hpaste.spiritlhl.net/api/upload"
|
primaryURL := "http://hpaste.spiritlhl.net/api/upload"
|
||||||
backupURL := "https://paste.spiritlhl.net/api/upload"
|
backupURL := "https://paste.spiritlhl.net/api/upload"
|
||||||
token := network.SecurityUploadToken
|
token := network.SecurityUploadToken
|
||||||
@@ -250,10 +250,10 @@ func UploadText(absPath string) (string, error) {
|
|||||||
SetRetryFixedInterval(2 * time.Second)
|
SetRetryFixedInterval(2 * time.Second)
|
||||||
file, err := os.Open(absPath)
|
file, err := os.Open(absPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
upload := func(url string) (string, error) {
|
upload := func(url string) (string, string, error) {
|
||||||
resp, err := client.R().
|
resp, err := client.R().
|
||||||
SetHeader("Authorization", token).
|
SetHeader("Authorization", token).
|
||||||
SetHeader("Format", "RANDOM").
|
SetHeader("Format", "RANDOM").
|
||||||
@@ -264,23 +264,24 @@ func UploadText(absPath string) (string, error) {
|
|||||||
SetFileReader("file", "goecs.txt", file).
|
SetFileReader("file", "goecs.txt", file).
|
||||||
Post(url)
|
Post(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
if resp.StatusCode >= 200 && resp.StatusCode <= 299 {
|
if resp.StatusCode >= 200 && resp.StatusCode <= 299 {
|
||||||
return strings.ReplaceAll(resp.String(), "https://paste.spiritlhl.net/", "http://hpaste.spiritlhl.net/"), nil
|
return strings.ReplaceAll(resp.String(), "https://paste.spiritlhl.net/", "http://hpaste.spiritlhl.net/"),
|
||||||
|
strings.ReplaceAll(resp.String(), "http://hpaste.spiritlhl.net/", "https://paste.spiritlhl.net/"), nil
|
||||||
} else {
|
} else {
|
||||||
return "", fmt.Errorf("upload failed with status code: %d", resp.StatusCode)
|
return "", "", fmt.Errorf("upload failed with status code: %d", resp.StatusCode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result, err := upload(primaryURL)
|
http_url, https_url, err := upload(primaryURL)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return result, nil
|
return http_url, https_url, nil
|
||||||
}
|
}
|
||||||
result, err = upload(backupURL)
|
http_url, https_url, err = upload(backupURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
return result, nil
|
return http_url, https_url, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProcessAndUpload 创建结果文件并上传文件
|
// ProcessAndUpload 创建结果文件并上传文件
|
||||||
@@ -321,12 +322,12 @@ func ProcessAndUpload(output string, filePath string, enableUplaod bool) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 上传文件并生成短链接
|
// 上传文件并生成短链接
|
||||||
shorturl, err3 := UploadText(absPath)
|
http_url, https_url, err3 := UploadText(absPath)
|
||||||
if err3 != nil {
|
if err3 != nil {
|
||||||
fmt.Println("Upload failed, cannot generate short URL.")
|
fmt.Println("Upload failed, cannot generate short URL.")
|
||||||
fmt.Println(err3.Error())
|
fmt.Println(err3.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Println("Upload successful, short URL:", shorturl)
|
fmt.Printf("Upload successful!\nHttp URL: %s\nHttps URL: %s\n", http_url, https_url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user