Compare commits

...

38 Commits

Author SHA1 Message Date
spiritsoul
9c9dbc6200 增加对应的子网掩码检测调用 2024-11-08 22:19:57 +08:00
spiritsoul
20c8063e5e v0.0.83 增加IPV6子网掩码检测所需的依赖 2024-11-08 20:55:14 +08:00
spiritsoul
fbe5eb8e58 v0.0.83 增加IPV6子网掩码检测 2024-11-08 20:21:17 +08:00
spiritlhl
290f0d8d8c Update 2024-10-20 11:37:06 +08:00
spiritlhl
140347c2a6 v0.0.81
优化在按ctrl+c终止程序时依然生成分享链接
2024-10-06 21:22:14 +08:00
spiritlhl
aeda7a6e88 Update goecs.sh 2024-10-06 21:04:23 +08:00
spiritlhl
a205ca38be v0.0.80
修复选项识别错误以及测速识别错误的问题
修正终止命令的检测和退出机制
pingtest优化日志记录
2024-10-06 20:41:36 +08:00
spiritlhl
43bf9c81ed Update goecs.sh 2024-10-06 19:13:22 +08:00
spiritlhl
d47f8987a7 Update goecs.sh 2024-10-06 19:00:18 +08:00
spiritlhl
ffbe5a539a Update goecs.sh 2024-10-06 16:09:26 +08:00
spiritsoul
4b8ae06df8 v0.0.79 2024-10-06 00:50:52 +08:00
spiritsoul
859e783241 v0.0.78 2024-10-06 00:03:28 +08:00
spiritsoul
3cd912219e v0.0.77 临时修复测速BUG,未完全修复
v0.0.77 临时修复测速BUG,未完全修复
2024-10-05 23:26:09 +08:00
spiritsoul
a85a06b440 v0.0.76
调整输出文本
2024-10-04 23:53:57 +08:00
spiritsoul
681da08f01 v0.0.75
修复终止命令在选项选择时不可用的问题
展示分享链接时同时展示http和https协议的链接
2024-10-04 23:30:06 +08:00
spiritsoul
bdd00d46f8 v0.0.74 2024-08-25 18:01:24 +08:00
spiritsoul
1f213bb788 update 2024-08-22 20:33:39 +08:00
spiritsoul
1dec7c323b update 2024-08-20 17:22:12 +08:00
spiritsoul
391cc351c4 update 2024-08-20 17:05:54 +08:00
spiritsoul
282a947156 update 2024-08-15 21:47:56 +08:00
spiritsoul
73916d324a v0.0.72 2024-08-14 20:34:24 +08:00
spiritsoul
6cce2a7e8e Add https://hub.docker.com/r/spiritlhl/goecs 2024-08-14 18:01:29 +08:00
spiritsoul
2a653930a8 update 2024-08-14 17:54:20 +08:00
spiritsoul
2295035706 v0.0.71 2024-08-14 17:32:21 +08:00
spiritsoul
3e8c7112a0 Merge branch 'master' of https://github.com/oneclickvirt/ecs 2024-08-14 17:09:25 +08:00
spiritsoul
a8175219d5 v0.0.70 2024-08-14 17:09:02 +08:00
spiritlhl
a827583b76 Update build_docker.yaml 2024-08-14 15:37:48 +08:00
spiritlhl
82a1d19c6c Update build_docker.yaml 2024-08-14 13:12:23 +08:00
spiritsoul
4ef0ac8d5a update 2024-08-14 13:10:44 +08:00
spiritsoul
3bb70191e7 update 2024-08-14 13:09:59 +08:00
spiritsoul
1bca0052c5 update 2024-08-14 13:05:54 +08:00
spiritsoul
7c06d278e0 Build Dockerfile 2024-08-14 13:00:35 +08:00
spiritlhl
5cec395f3c Create build_docker.yaml 2024-08-14 12:49:54 +08:00
spiritsoul
4994994d4f v0.0.69 2024-08-13 21:46:30 +08:00
spiritsoul
91ad962b13 更新部分说明 2024-08-09 23:31:43 +08:00
spiritsoul
8356d95566 update 2024-08-09 23:28:45 +08:00
spiritsoul
1428087818 v0.0.68 - 修复fio测试索引结果错误的问题 2024-08-09 13:38:39 +08:00
spiritsoul
7b1e78fb7e remove 2024-08-08 14:04:30 +08:00
12 changed files with 468 additions and 314 deletions

35
.github/workflows/build_docker.yaml vendored Normal file
View File

@@ -0,0 +1,35 @@
name: Build and Push Docker Image
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: all
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/riscv64
# linux/mips,linux/mipsle 暂不支持 alpine, linux/s390x 编译卡死
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/goecs:latest

17
Dockerfile Normal file
View File

@@ -0,0 +1,17 @@
# syntax=docker/dockerfile:1
FROM alpine:latest
# 安装必要的工具
RUN apk add --no-cache wget curl bash
RUN apk add --no-cache bind-tools --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main
RUN apk add --no-cache grep openssl ca-certificates uuidgen
# 下载并执行 goecs.sh 脚本
RUN curl -L https://raw.githubusercontent.com/oneclickvirt/ecs/master/goecs.sh -o goecs.sh && \
chmod +x goecs.sh && \
bash goecs.sh env && \
bash goecs.sh install
# 设置 goecs 为入口点
ENTRYPOINT ["goecs"]

View File

@@ -12,7 +12,7 @@ Shell版本 https://github.com/spiritLHLS/ecs
## 适配系统和架构 ## 适配系统和架构
编译支持的架构: amd64、arm、arm64、386、s390x、mips、mipsle、s390x、riscv64 编译支持的架构: amd64、arm、arm64、386、mips、mipsle、s390x、riscv64
测试支持的架构: amd64、arm64 测试支持的架构: amd64、arm64
@@ -33,13 +33,13 @@ Shell版本 https://github.com/spiritLHLS/ecs
- [x] CPU测试[自研[cputest](https://github.com/oneclickvirt/cputest)支持sysbench、geekbench、winsat] - [x] CPU测试[自研[cputest](https://github.com/oneclickvirt/cputest)支持sysbench、geekbench、winsat]
- [x] 内存测试[自研[memorytest](https://github.com/oneclickvirt/memorytest)支持sysbench、dd] - [x] 内存测试[自研[memorytest](https://github.com/oneclickvirt/memorytest)支持sysbench、dd]
- [x] 硬盘测试[自研[disktest](https://github.com/oneclickvirt/disktest)支持dd、fio、winsat] - [x] 硬盘测试[自研[disktest](https://github.com/oneclickvirt/disktest)支持dd、fio、winsat]
- [x] 御三家流媒体解锁信息并发查询[借鉴[netflix-verify](https://github.com/sjlleo/netflix-verify)、[VerifyDisneyPlus](https://github.com/sjlleo/VerifyDisneyPlus)、[TubeCheck](https://github.com/sjlleo/TubeCheck)二次开发至于[CommonMediaTests](https://github.com/oneclickvirt/CommonMediaTests)] - [x] 御三家流媒体解锁信息并发查询[借鉴[netflix-verify](https://github.com/sjlleo/netflix-verify)、[VerifyDisneyPlus](https://github.com/sjlleo/VerifyDisneyPlus)、[TubeCheck](https://github.com/sjlleo/TubeCheck)逻辑开发至于[CommonMediaTests](https://github.com/oneclickvirt/CommonMediaTests)]
- [x] 常见流媒体测试并发查询[自研代码,逻辑借鉴[RegionRestrictionCheck](https://github.com/lmc999/RegionRestrictionCheck)、[MediaUnlockTest](https://github.com/HsukqiLee/MediaUnlockTest)并自行修复错漏至于[UnlockTests](https://github.com/oneclickvirt/UnlockTests)] - [x] 常见流媒体测试并发查询[自研至于[UnlockTests](https://github.com/oneclickvirt/UnlockTests),逻辑借鉴[RegionRestrictionCheck](https://github.com/lmc999/RegionRestrictionCheck)、[MediaUnlockTest](https://github.com/HsukqiLee/MediaUnlockTest)]
- [x] IP质量/安全信息并发查询[自研,由于测试含密钥信息,故而私有化开发,但二进制文件编译至于[securityCheck](https://github.com/oneclickvirt/securityCheck)] - [x] IP质量/安全信息并发查询[自研,由于测试含密钥信息,故而私有化开发,但二进制文件编译至于[securityCheck](https://github.com/oneclickvirt/securityCheck)]
- [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)二次开发至于[oneclickvirt/speedtest](https://github.com/oneclickvirt/speedtest)] - [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)]
- [x] 测试三网Ping值[借鉴[ecsspeed](https://github.com/spiritLHLS/ecsspeed)的逻辑二次开发至于[pingtest](https://github.com/oneclickvirt/pingtest)] - [x] 测试三网Ping值[借鉴[ecsspeed](https://github.com/spiritLHLS/ecsspeed)的逻辑二次开发至于[pingtest](https://github.com/oneclickvirt/pingtest)]
## Linux/FreeBSD/MacOS上使用的说明 ## Linux/FreeBSD/MacOS上使用的说明
@@ -104,6 +104,7 @@ shell脚本的说明
tar (几乎所有类 Unix 系统都有。) tar (几乎所有类 Unix 系统都有。)
unzip (几乎所有类 Unix 系统都有。) unzip (几乎所有类 Unix 系统都有。)
dd (几乎所有类 Unix 系统都有。) dd (几乎所有类 Unix 系统都有。)
iproute2 (几乎所有类 Unix 系统可以通过系统的包管理器安装。)
fio (几乎所有类 Unix 系统可以通过系统的包管理器安装。) fio (几乎所有类 Unix 系统可以通过系统的包管理器安装。)
sysbench (几乎所有类 Unix 系统可以通过系统的包管理器安装。) sysbench (几乎所有类 Unix 系统可以通过系统的包管理器安装。)
geekbench (geekbench5) (仅支持 IPV4 环境,且内存大于 1GB 并需要持续联网,仅支持 amd64 和 arm64 架构。) geekbench (geekbench5) (仅支持 IPV4 环境,且内存大于 1GB 并需要持续联网,仅支持 amd64 和 arm64 架构。)
@@ -163,7 +164,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
@@ -197,6 +198,26 @@ https://github.com/oneclickvirt/ecs/releases
windows测试无需进行环境安装 windows测试无需进行环境安装
## 在Docker中使用的说明
地址https://hub.docker.com/r/spiritlhl/goecs
请确保执行下述命令前本机已安装Docker
特权模式+host网络
```shell
docker run --rm --privileged --network host spiritlhl/goecs:latest -menu=false -l zh
```
非特权模式+非host网络
```shell
docker run --rm spiritlhl/goecs:latest -menu=false -l zh
```
使用Docker执行测试硬件测试会有一些偏差和虚拟化架构判断失效还是推荐直接测试而不使用Docker测试。
## QA ## QA
#### Q: 为什么默认使用sysbench而不是geekbench #### Q: 为什么默认使用sysbench而不是geekbench

View File

@@ -12,7 +12,7 @@ Shell version: https://github.com/spiritLHLS/ecs/blob/main/README_EN.md
## Supported Systems and Architectures ## Supported Systems and Architectures
Architectures supported for compilation: amd64、arm、arm64、386、s390x、mips、mipsle、s390x、riscv64 Architectures supported for compilation: amd64、arm、arm64、386、mips、mipsle、s390x、riscv64
Tested architectures: amd64, arm64 Tested architectures: amd64, arm64
@@ -93,6 +93,7 @@ Available commands:
unzip (Almost all unix-like systems have it.) unzip (Almost all unix-like systems have it.)
dd (Almost all unix-like systems have it.) dd (Almost all unix-like systems have it.)
fio (Almost all unix-like systems can be installed through the system's package manager.) fio (Almost all unix-like systems can be installed through the system's package manager.)
iproute2 (Almost all unix-like systems can be installed through the system's package manager.)
sysbench (Almost all unix-like systems can be installed through the system's package manager.) sysbench (Almost all unix-like systems can be installed through the system's package manager.)
geekbench (geekbench5)(Only support IPV4 environment, and memory greater than 1GB network detection, only support amd64 and arm64 architecture.) geekbench (geekbench5)(Only support IPV4 environment, and memory greater than 1GB network detection, only support amd64 and arm64 architecture.)
speedtest (Use the officially provided binaries for more accurate test results.) speedtest (Use the officially provided binaries for more accurate test results.)
@@ -151,7 +152,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
@@ -183,4 +184,26 @@ Find the latest version, download the .zip file corresponding to your architectu
Right-click the exe file and select Run as administrator (running without administrator mode will not allow hardware testing), and invoke the menu to choose. Right-click the exe file and select Run as administrator (running without administrator mode will not allow hardware testing), and invoke the menu to choose.
No environment installation is required for Windows testing. No environment installation is required for Windows testing.
## 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
Privileged Mode + host network
```shell
docker run --rm --privileged --network host spiritlhl/goecs:latest -menu=false -l en
```
Unprivileged mode + non-host network
```shell
docker run --rm spiritlhl/goecs:latest
```
Using Docker to execute tests, hardware testing will have some bias and virtualization architecture to determine the failure.
Recommended direct testing without using Docker testing.

View File

@@ -7,7 +7,7 @@ import (
"strings" "strings"
) )
// 本包不在main中使用仅做测试使用 // 本包不在main中使用仅做测试使用,真正调用的在 utils 中的 BasicsAndSecurityCheck
func Basic(language string) { func Basic(language string) {
ipInfo, _, _ := network.NetworkCheck("both", false, language) ipInfo, _, _ := network.NetworkCheck("both", false, language)
systemInfo := system.CheckSystemInfo(language) systemInfo := system.CheckSystemInfo(language)

0
go
View File

24
go.mod
View File

@@ -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.14-20240808055601 github.com/oneclickvirt/UnlockTests v0.0.17-20241020033546
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.8-20241108124433
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-20240805115156 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-20240805062017 github.com/oneclickvirt/memorytest v0.0.4-20240820095126
github.com/oneclickvirt/nt3 v0.0.3-20240702132013 github.com/oneclickvirt/nt3 v0.0.3-20240809100110
github.com/oneclickvirt/pingtest v0.0.5-20240804134050 github.com/oneclickvirt/pingtest v0.0.5-20241006123443
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 (
@@ -35,7 +35,7 @@ require (
github.com/google/gopacket v1.1.19 // indirect github.com/google/gopacket v1.1.19 // indirect
github.com/google/pprof v0.0.0-20240625030939-27f56978b8b0 // indirect github.com/google/pprof v0.0.0-20240625030939-27f56978b8b0 // indirect
github.com/google/uuid v1.6.0 // indirect github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.5.1 // indirect github.com/gorilla/websocket v1.5.2 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect
@@ -60,9 +60,9 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/nxtrace/NTrace-core v1.3.1 // indirect github.com/nxtrace/NTrace-core v1.3.2 // indirect
github.com/onsi/ginkgo/v2 v2.19.0 // indirect github.com/onsi/ginkgo/v2 v2.19.0 // indirect
github.com/oschwald/maxminddb-golang v1.12.0 // indirect github.com/oschwald/maxminddb-golang v1.13.1 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pion/dtls/v2 v2.2.7 // indirect github.com/pion/dtls/v2 v2.2.7 // indirect
github.com/pion/logging v0.2.2 // indirect github.com/pion/logging v0.2.2 // indirect
@@ -77,7 +77,7 @@ require (
github.com/refraction-networking/utls v1.6.6 // indirect github.com/refraction-networking/utls v1.6.6 // indirect
github.com/rivo/uniseg v0.4.7 // indirect github.com/rivo/uniseg v0.4.7 // indirect
github.com/rodaine/table v1.2.0 // indirect github.com/rodaine/table v1.2.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/locafero v0.6.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/schollz/progressbar/v3 v3.14.4 // indirect github.com/schollz/progressbar/v3 v3.14.4 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect github.com/shirou/gopsutil v3.21.11+incompatible // indirect
@@ -88,7 +88,7 @@ require (
github.com/spf13/afero v1.11.0 // indirect github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.18.2 // indirect github.com/spf13/viper v1.19.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect
github.com/tidwall/gjson v1.17.1 // indirect github.com/tidwall/gjson v1.17.1 // indirect
github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/match v1.1.1 // indirect

48
go.sum
View File

@@ -39,8 +39,8 @@ github.com/google/pprof v0.0.0-20240625030939-27f56978b8b0 h1:e+8XbKB6IMn8A4OAyZ
github.com/google/pprof v0.0.0-20240625030939-27f56978b8b0/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo= github.com/google/pprof v0.0.0-20240625030939-27f56978b8b0/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= github.com/gorilla/websocket v1.5.2 h1:qoW6V1GT3aZxybsbC6oLnailWnB+qTMVwMreOso9XUw=
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= github.com/gorilla/websocket v1.5.2/go.mod h1:0n9H61RBAcf5/38py2MCYbxzPIY9rOkpvvMT24Rqs30=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
@@ -100,42 +100,42 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/nxtrace/NTrace-core v1.3.1 h1:f4z5UaZEuhUP/g6xElpZ2bo+guWITJVrMKrJTqd27oc= github.com/nxtrace/NTrace-core v1.3.2 h1:8aU/IQFmPnwbaWGVBIJHwwVIWk+roo+9+lG+U0OFZ+o=
github.com/nxtrace/NTrace-core v1.3.1/go.mod h1:0Px/Zc60qk6cssmP+yv4kstFxvX9sXqDduoVqBO+qf8= 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.14-20240808055601 h1:jRP557k5nbC/dZTLRp/W9t3BTw3IiOlzcIEeqNmL6bU= github.com/oneclickvirt/UnlockTests v0.0.17-20241020033546 h1:KXRNdYPnZ10vi0+6WwrNK5E8GHvGRjaVAv5z7XEfb9Q=
github.com/oneclickvirt/UnlockTests v0.0.14-20240808055601/go.mod h1:UELwZDDiddSxe38boYOPl1FlrL0ptEZYSQwdE3MYvUM= github.com/oneclickvirt/UnlockTests v0.0.17-20241020033546/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.8-20241108124433 h1:eKZcoNoa9uLWmfisk+qN/QOvSGT4ajCmZdZfIAcHG+o=
github.com/oneclickvirt/basics v0.0.7-20240801050316/go.mod h1:fUdVpU8gdjaZsTCyqnQBAbHc9BbbN8Fxr3sGPKooUpU= github.com/oneclickvirt/basics v0.0.8-20241108124433/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=
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.4-20240805115156 h1:wyc7zDKfFtEjeos6Tqpxd3/5wH9z/dI2bDUKRHPD4KA= github.com/oneclickvirt/disktest v0.0.4-20240809053456 h1:g6fKzvImIV8YQZKKEJ2FdvooL+EUf9NndAU8c4aGCX4=
github.com/oneclickvirt/disktest v0.0.4-20240805115156/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-20240805062017 h1:GEGeNrIbf9Q6fS6P7+uEKZrd3bEHVqPjaH5lRI41uFE= github.com/oneclickvirt/memorytest v0.0.4-20240820095126 h1:Il3rvWkrZy/6B2iO3HRe9039/qRllA4CzcZ/dI8aG2A=
github.com/oneclickvirt/memorytest v0.0.4-20240805062017/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-20240702132013 h1:zPI/zqqCraIVwRnYz07hMkBKDRJVkEBb6gZpZ4M9CjI= github.com/oneclickvirt/nt3 v0.0.3-20240809100110 h1:UyF0jBDP0xpxSV9L/GYG83SKUMPSjHPru+3iPZHYG7U=
github.com/oneclickvirt/nt3 v0.0.3-20240702132013/go.mod h1:UojPmtangn17TiQaDccVrZbn6sZwJOtzBgg3idp68cA= 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-20241006123443 h1:Ywrh0Yd/PYXOKGE8VaNiKGWlIqdgLLgsthAzxy0t7s8=
github.com/oneclickvirt/pingtest v0.0.5-20240804134050/go.mod h1:d3Ntx5m9lMll3a/k3+2B+5emj//vgDh4/NHTxs2qQE8= github.com/oneclickvirt/pingtest v0.0.5-20241006123443/go.mod h1:d3Ntx5m9lMll3a/k3+2B+5emj//vgDh4/NHTxs2qQE8=
github.com/oneclickvirt/portchecker v0.0.2-20240803151204 h1:ZruxRgyIv3d6Y8n0Ney5FHhQtcQLxCvs+xJmGsh9/7E= github.com/oneclickvirt/portchecker v0.0.2-20240803151204 h1:ZruxRgyIv3d6Y8n0Ney5FHhQtcQLxCvs+xJmGsh9/7E=
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=
github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0= github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0=
github.com/oschwald/maxminddb-golang v1.12.0 h1:9FnTOD0YOhP7DGxGsq4glzpGy5+w7pq50AS6wALUMYs= github.com/oschwald/maxminddb-golang v1.13.1 h1:G3wwjdN9JmIK2o/ermkHM+98oX5fS+k5MbwsmL4MRQE=
github.com/oschwald/maxminddb-golang v1.12.0/go.mod h1:q0Nob5lTCqyQ8WT6FYgS1L7PXKVVbgiymefNwIjPzgY= github.com/oschwald/maxminddb-golang v1.13.1/go.mod h1:K4pgV9N/GcK694KSTmVSDTODk4IsCNThNdTmnaBZ/F8=
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
github.com/pion/dtls/v2 v2.2.7 h1:cSUBsETxepsCSFSxC3mc/aDo14qQLMSL+O6IjG28yV8= github.com/pion/dtls/v2 v2.2.7 h1:cSUBsETxepsCSFSxC3mc/aDo14qQLMSL+O6IjG28yV8=
@@ -170,8 +170,8 @@ github.com/rodaine/table v1.2.0 h1:38HEnwK4mKSHQJIkavVj+bst1TEY7j9zhLMWu4QJrMA=
github.com/rodaine/table v1.2.0/go.mod h1:wejb/q/Yd4T/SVmBSRMr7GCq3KlcZp3gyNYdLSBhkaE= github.com/rodaine/table v1.2.0/go.mod h1:wejb/q/Yd4T/SVmBSRMr7GCq3KlcZp3gyNYdLSBhkaE=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= github.com/sagikazarmark/locafero v0.6.0 h1:ON7AQg37yzcRPU69mt7gwhFEBwxI6P9T4Qu3N51bwOk=
github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= github.com/sagikazarmark/locafero v0.6.0/go.mod h1:77OmuIc6VTraTXKXIs/uvUxKGUXjE1GbemJYHqdNjX0=
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
github.com/schollz/progressbar/v3 v3.14.4 h1:W9ZrDSJk7eqmQhd3uxFNNcTr0QL+xuGNI9dEMrw0r74= github.com/schollz/progressbar/v3 v3.14.4 h1:W9ZrDSJk7eqmQhd3uxFNNcTr0QL+xuGNI9dEMrw0r74=
@@ -194,8 +194,8 @@ github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ= github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI=
github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk= github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=

285
goecs.go
View File

@@ -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.67" ecsVersion = "v0.0.84"
menuMode bool menuMode bool
onlyChinaTest bool onlyChinaTest bool
input, choice string input, choice string
@@ -60,8 +61,67 @@ var (
enabelUpload = true enabelUpload = true
help bool help bool
goecsFlag = flag.NewFlagSet("goecs", flag.ContinueOnError) goecsFlag = flag.NewFlagSet("goecs", flag.ContinueOnError)
finish bool
) )
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(0)
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) {
inChoice := input
switch inChoice {
case "1", "2", "3", "4", "5", "6", "7", "8", "9", "10":
return inChoice
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 +140,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 +155,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 +207,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,24 +308,29 @@ 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()
// 等待信号 // 等待信号
<-sig <-sig
endTime := time.Now() if !finish {
duration := endTime.Sub(startTime) endTime := time.Now()
minutes := int(duration.Minutes()) duration := endTime.Sub(startTime)
seconds := int(duration.Seconds()) % 60 minutes := int(duration.Minutes())
currentTime := time.Now().Format("Mon Jan 2 15:04:05 MST 2006") seconds := int(duration.Seconds()) % 60
output = utils.PrintAndCapture(func() { currentTime := time.Now().Format("Mon Jan 2 15:04:05 MST 2006")
utils.PrintCenteredTitle("", width) output = utils.PrintAndCapture(func() {
fmt.Printf("Cost Time : %d min %d sec\n", minutes, seconds) utils.PrintCenteredTitle("", width)
fmt.Printf("Current Time : %s\n", currentTime) fmt.Printf("Cost Time : %d min %d sec\n", minutes, seconds)
utils.PrintCenteredTitle("", width) fmt.Printf("Current Time : %s\n", currentTime)
}, tempOutput, output) utils.PrintCenteredTitle("", width)
utils.ProcessAndUpload(output, filePath, enabelUpload) }, tempOutput, output)
os.Exit(1) // 使用非零状态码退出,表示意外退出 utils.ProcessAndUpload(output, filePath, enabelUpload)
}
os.Exit(0)
}() }()
switch language { switch language {
case "zh": case "zh":
@@ -290,7 +340,7 @@ func main() {
if basicStatus { if basicStatus {
utils.PrintCenteredTitle("系统基础信息", width) utils.PrintCenteredTitle("系统基础信息", width)
} }
basicInfo, securityInfo, nt3CheckType = utils.SecurityCheck(language, nt3CheckType, securityTestStatus) basicInfo, securityInfo, nt3CheckType = utils.BasicsAndSecurityCheck(language, nt3CheckType, securityTestStatus)
if basicStatus { if basicStatus {
fmt.Printf(basicInfo) fmt.Printf(basicInfo)
} else if (input == "6" || input == "9") && securityTestStatus { } else if (input == "6" || input == "9") && securityTestStatus {
@@ -400,14 +450,16 @@ func main() {
if speedTestStatus { if speedTestStatus {
utils.PrintCenteredTitle("就近节点测速", width) utils.PrintCenteredTitle("就近节点测速", width)
speedtest.ShowHead(language) speedtest.ShowHead(language)
if (menuMode && choice == "1") || !menuMode { if choice == "1" || !menuMode {
speedtest.NearbySP() speedtest.NearbySP()
speedtest.CustomSP("net", "global", 2, language) speedtest.CustomSP("net", "global", 2, language)
speedtest.CustomSP("net", "cu", spNum, language) speedtest.CustomSP("net", "cu", spNum, language)
speedtest.CustomSP("net", "ct", spNum, language) speedtest.CustomSP("net", "ct", spNum, language)
speedtest.CustomSP("net", "cmcc", spNum, language) speedtest.CustomSP("net", "cmcc", spNum, language)
} else if menuMode && choice == "2" || choice == "3" || choice == "4" || choice == "5" { } else if choice == "2" || choice == "3" || choice == "4" || choice == "5" {
speedtest.CustomSP("net", "global", 4, language) speedtest.CustomSP("net", "global", 4, language)
} else if choice == "6" {
speedtest.CustomSP("net", "global", 11, language)
} }
} }
}, tempOutput, output) }, tempOutput, output)
@@ -429,7 +481,7 @@ func main() {
if basicStatus { if basicStatus {
utils.PrintCenteredTitle("System-Basic-Information", width) utils.PrintCenteredTitle("System-Basic-Information", width)
} }
basicInfo, securityInfo, nt3CheckType = utils.SecurityCheck(language, nt3CheckType, securityTestStatus) basicInfo, securityInfo, nt3CheckType = utils.BasicsAndSecurityCheck(language, nt3CheckType, securityTestStatus)
if basicStatus { if basicStatus {
fmt.Printf(basicInfo) fmt.Printf(basicInfo)
} else if (input == "6" || input == "9") && securityTestStatus { } else if (input == "6" || input == "9") && securityTestStatus {
@@ -523,6 +575,7 @@ func main() {
fmt.Println("Unsupported language") fmt.Println("Unsupported language")
} }
utils.ProcessAndUpload(output, filePath, enabelUpload) utils.ProcessAndUpload(output, filePath, enabelUpload)
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...")
fmt.Scanln() fmt.Scanln()

234
goecs.sh
View File

@@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
#From https://github.com/oneclickvirt/ecs # From https://github.com/oneclickvirt/ecs
#2024.07.21 # 2024.10.06
# curl -L https://raw.githubusercontent.com/oneclickvirt/ecs/master/goecs.sh -o goecs.sh && chmod +x goecs.sh # curl -L https://raw.githubusercontent.com/oneclickvirt/ecs/master/goecs.sh -o goecs.sh && chmod +x goecs.sh
@@ -93,59 +93,72 @@ goecs_check() {
cdn_urls=("https://cdn0.spiritlhl.top/" "http://cdn3.spiritlhl.net/" "http://cdn1.spiritlhl.net/" "http://cdn2.spiritlhl.net/") cdn_urls=("https://cdn0.spiritlhl.top/" "http://cdn3.spiritlhl.net/" "http://cdn1.spiritlhl.net/" "http://cdn2.spiritlhl.net/")
check_cdn_file check_cdn_file
case $os in case $os in
Linux) Linux)
case $arch in case $arch in
"x86_64" | "x86" | "amd64" | "x64") "x86_64" | "x86" | "amd64" | "x64")
download_file "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/v${ECS_VERSION}/goecs_linux_amd64.zip" "goecs.zip" download_file "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/v${ECS_VERSION}/goecs_linux_amd64.zip" "goecs.zip"
;;
"i386" | "i686")
download_file "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/v${ECS_VERSION}/goecs_linux_386.zip" "goecs.zip"
;;
"armv7l" | "armv8" | "armv8l" | "aarch64" | "arm64")
download_file "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/v${ECS_VERSION}/goecs_linux_arm64.zip" "goecs.zip"
;;
"mips")
download_file "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/v${ECS_VERSION}/goecs_linux_mips.zip" "goecs.zip"
;;
"mipsle")
download_file "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/v${ECS_VERSION}/goecs_linux_mipsle.zip" "goecs.zip"
;;
"s390x")
download_file "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/v${ECS_VERSION}/goecs_linux_s390x.zip" "goecs.zip"
;;
"riscv64")
download_file "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/v${ECS_VERSION}/goecs_linux_riscv64.zip" "goecs.zip"
;;
*)
_red "Unsupported architecture: $arch , please check https://github.com/oneclickvirt/ecs/releases to download the zip for yourself and unzip it to use the binary for testing."
exit 1
;;
esac
;; ;;
"i386" | "i686") FreeBSD)
download_file "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/v${ECS_VERSION}/goecs_linux_386.zip" "goecs.zip" case $arch in
"x86_64" | "x86" | "amd64" | "x64")
download_file "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/v${ECS_VERSION}/goecs_freebsd_amd64.zip" "goecs.zip"
;;
"i386" | "i686")
download_file "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/v${ECS_VERSION}/goecs_freebsd_386.zip" "goecs.zip"
;;
"armv7l" | "armv8" | "armv8l" | "aarch64" | "arm64")
download_file "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/v${ECS_VERSION}/goecs_freebsd_arm64.zip" "goecs.zip"
;;
*)
_red "Unsupported architecture: $arch , please check https://github.com/oneclickvirt/ecs/releases to download the zip for yourself and unzip it to use the binary for testing."
exit 1
;;
esac
;; ;;
"armv7l" | "armv8" | "armv8l" | "aarch64" | "arm64") Darwin)
download_file "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/v${ECS_VERSION}/goecs_linux_arm64.zip" "goecs.zip" case $arch in
"x86_64" | "x86" | "amd64" | "x64")
download_file "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/v${ECS_VERSION}/goecs_amd64.zip" "goecs.zip"
;;
"armv7l" | "armv8" | "armv8l" | "aarch64" | "arm64")
download_file "${cdn_success_url}https://github.com/oneclickvirt/ ecs/releases/download/v${ECS_VERSION}/goecs_arm64.zip" "goecs.zip"
;;
*)
_red "Unsupported architecture: $arch , please check https://github.com/oneclickvirt/ecs/releases to download the zip for yourself and unzip it to use the binary for testing."
exit 1
;;
esac
;; ;;
*) *)
_red "Unsupported architecture: $arch , please check https://github.com/oneclickvirt/ecs/releases to download the zip for yourself and unzip it to use the binary for testing." _red "Unsupported operating system: $os , please check https://github.com/oneclickvirt/ecs/releases to download the zip for yourself and unzip it to use the binary for testing."
exit 1 exit 1
;; ;;
esac
;;
FreeBSD)
case $arch in
"x86_64" | "x86" | "amd64" | "x64")
download_file "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/v${ECS_VERSION}/goecs_freebsd_amd64.zip" "goecs.zip"
;;
"i386" | "i686")
download_file "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/v${ECS_VERSION}/goecs_freebsd_386.zip" "goecs.zip"
;;
"armv7l" | "armv8" | "armv8l" | "aarch64" | "arm64")
download_file "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/v${ECS_VERSION}/goecs_freebsd_arm64.zip" "goecs.zip"
;;
*)
_red "Unsupported architecture: $arch , please check https://github.com/oneclickvirt/ecs/releases to download the zip for yourself and unzip it to use the binary for testing."
exit 1
;;
esac
;;
Darwin)
case $arch in
"x86_64" | "x86" | "amd64" | "x64")
download_file "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/v${ECS_VERSION}/goecs_amd64.zip" "goecs.zip"
;;
"armv7l" | "armv8" | "armv8l" | "aarch64" | "arm64")
download_file "${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/v${ECS_VERSION}/goecs_arm64.zip" "goecs.zip"
;;
*)
_red "Unsupported architecture: $arch , please check https://github.com/oneclickvirt/ecs/releases to download the zip for yourself and unzip it to use the binary for testing."
exit 1
;;
esac
;;
*)
_red "Unsupported operating system: $os , please check https://github.com/oneclickvirt/ecs/releases to download the zip for yourself and unzip it to use the binary for testing."
exit 1
;;
esac esac
unzip goecs.zip unzip goecs.zip
rm -rf goecs.zip rm -rf goecs.zip
rm -rf README.md rm -rf README.md
@@ -175,7 +188,9 @@ goecs_check() {
} }
InstallSysbench() { InstallSysbench() {
if [ -f "/etc/centos-release" ]; then # CentOS if [ -f "/etc/opencloudos-release" ]; then # OpenCloudOS
Var_OSRelease="opencloudos"
elif [ -f "/etc/centos-release" ]; then # CentOS
Var_OSRelease="centos" Var_OSRelease="centos"
elif [ -f "/etc/fedora-release" ]; then # Fedora elif [ -f "/etc/fedora-release" ]; then # Fedora
Var_OSRelease="fedora" Var_OSRelease="fedora"
@@ -191,7 +206,6 @@ InstallSysbench() {
Var_OSRelease="alpinelinux" Var_OSRelease="alpinelinux"
elif [ -f "/etc/almalinux-release" ]; then # almalinux elif [ -f "/etc/almalinux-release" ]; then # almalinux
Var_OSRelease="almalinux" Var_OSRelease="almalinux"
# rockylinux
elif [ -f "/etc/arch-release" ]; then # archlinux elif [ -f "/etc/arch-release" ]; then # archlinux
Var_OSRelease="arch" Var_OSRelease="arch"
elif [ -f "/etc/freebsd-update.conf" ]; then # freebsd elif [ -f "/etc/freebsd-update.conf" ]; then # freebsd
@@ -199,14 +213,22 @@ InstallSysbench() {
else else
Var_OSRelease="unknown" # 未知系统分支 Var_OSRelease="unknown" # 未知系统分支
fi fi
case "$Var_OSRelease" in 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 ;; ubuntu | debian | astra)
centos | rhel | almalinux | redhat) (yum -y install epel-release && yum -y install sysbench) || (dnf install epel-release -y && dnf install sysbench -y) ;; ! apt-get install -y sysbench && apt-get --fix-broken install -y && apt-get install --no-install-recommends -y sysbench ;;
fedora) dnf -y install sysbench ;; centos | rhel | almalinux | redhat | opencloudos)
arch) pacman -S --needed --noconfirm sysbench && pacman -S --needed --noconfirm libaio && ldconfig ;; (yum -y install epel-release && yum -y install sysbench) || (dnf install epel-release -y && dnf install sysbench -y) ;;
freebsd) pkg install -y sysbench ;; fedora)
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" ;; dnf -y install sysbench ;;
*) _red "Sysbench Install Error: Unknown OS release: $os_release" ;; 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" ;;
*)
_red "Sysbench Install Error: Unknown OS release: $Var_OSRelease" ;;
esac esac
} }
@@ -236,6 +258,9 @@ Check_Sysbench_InstantBuild() {
if [ "$os_sysbench" = "astra" ]; then if [ "$os_sysbench" = "astra" ]; then
os_sysbench="debian" os_sysbench="debian"
fi fi
if [ "$os_sysbench" = "opencloudos" ]; then
os_sysbench="centos"
fi
echo -e "${Msg_Info}Release Detected: ${os_sysbench}" echo -e "${Msg_Info}Release Detected: ${os_sysbench}"
echo -e "${Msg_Info}Preparing compile enviorment ..." echo -e "${Msg_Info}Preparing compile enviorment ..."
prepare_compile_env "${os_sysbench}" prepare_compile_env "${os_sysbench}"
@@ -270,15 +295,15 @@ prepare_compile_env() {
} }
env_check() { env_check() {
REGEX=("debian|astra" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'" "fedora" "arch" "freebsd" "alpine" "openbsd") REGEX=("debian|astra" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'" "fedora" "arch" "freebsd" "alpine" "openbsd" "opencloudos")
RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS" "Fedora" "Arch" "FreeBSD" "Alpine" "OpenBSD") RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS" "Fedora" "Arch" "FreeBSD" "Alpine" "OpenBSD" "OpenCloudOS")
PACKAGE_UPDATE=("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_UPDATE=("apt-get update" "apt-get update" "yum -y update" "yum -y update" "yum -y update" "yum -y update" "pacman -Sy" "pkg update" "apk update" "yum -y update")
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_INSTALL=("apt-get -y install" "apt-get -y install" "yum -y install" "yum -y install" "yum -y install" "yum -y install" "pacman -Sy --noconfirm --needed" "pkg install -y" "apk add" "yum -y install")
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_REMOVE=("apt-get -y remove" "apt-get -y remove" "yum -y remove" "yum -y remove" "yum -y remove" "yum -y remove" "pacman -Rsc --noconfirm" "pkg delete" "apk del" "yum -y remove")
PACKAGE_UNINSTALL=("apt-get -y autoremove" "apt-get -y autoremove" "yum -y autoremove" "yum -y autoremove" "yum -y autoremove" "" "pkg autoremove" "apk autoremove") PACKAGE_UNINSTALL=("apt-get -y autoremove" "apt-get -y autoremove" "yum -y autoremove" "yum -y autoremove" "yum -y autoremove" "yum -y autoremove" "pacman -Rns --noconfirm" "pkg autoremove" "apk autoremove" "yum -y autoremove")
# 检查系统信息 # 检查系统信息
if [ -f /etc/alpine-release ]; then if [ -f /etc/opencloudos-release ]; then
SYS="alpine" SYS="opencloudos"
elif [ -s /etc/os-release ]; then elif [ -s /etc/os-release ]; then
SYS="$(grep -i pretty_name /etc/os-release | cut -d \" -f2)" SYS="$(grep -i pretty_name /etc/os-release | cut -d \" -f2)"
elif [ -x "$(type -p hostnamectl)" ]; then elif [ -x "$(type -p hostnamectl)" ]; then
@@ -295,6 +320,7 @@ env_check() {
SYS="$(uname -s)" SYS="$(uname -s)"
fi fi
[[ -n $SYS ]] || exit 1 [[ -n $SYS ]] || exit 1
# 匹配操作系统 # 匹配操作系统
for ((int = 0; int < ${#REGEX[@]}; int++)); do for ((int = 0; int < ${#REGEX[@]}; int++)); do
if [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]]; then if [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]]; then
@@ -302,65 +328,41 @@ env_check() {
[[ -n $SYSTEM ]] && break [[ -n $SYSTEM ]] && break
fi fi
done done
# 检查是否成功匹配 # 检查是否成功匹配
[[ -n $SYSTEM ]] || exit 1 [[ -n $SYSTEM ]] || exit 1
# 根据 SYSTEM 设置相应的包管理命令 # 根据 SYSTEM 设置相应的包管理命令
UPDATE_CMD=${PACKAGE_UPDATE[int]} UPDATE_CMD=${PACKAGE_UPDATE[int]}
INSTALL_CMD=${PACKAGE_INSTALL[int]} INSTALL_CMD=${PACKAGE_INSTALL[int]}
REMOVE_CMD=${PACKAGE_REMOVE[int]} REMOVE_CMD=${PACKAGE_REMOVE[int]}
UNINSTALL_CMD=${PACKAGE_UNINSTALL[int]} UNINSTALL_CMD=${PACKAGE_UNINSTALL[int]}
echo "System: $SYSTEM" echo "System: $SYSTEM"
echo "Update command: $UPDATE_CMD" echo "Update command: $UPDATE_CMD"
echo "Install command: $INSTALL_CMD" echo "Install command: $INSTALL_CMD"
echo "Remove command: $REMOVE_CMD" echo "Remove command: $REMOVE_CMD"
echo "Uninstall command: $UNINSTALL_CMD" echo "Uninstall command: $UNINSTALL_CMD"
cdn_urls=("https://cdn0.spiritlhl.top/" "http://cdn3.spiritlhl.net/" "http://cdn1.spiritlhl.net/" "http://cdn2.spiritlhl.net/") cdn_urls=("https://cdn0.spiritlhl.top/" "http://cdn3.spiritlhl.net/" "http://cdn1.spiritlhl.net/" "http://cdn2.spiritlhl.net/")
check_cdn_file check_cdn_file
_green "Update system manager." _green "Update system manager."
${PACKAGE_UPDATE[int]} 2>/dev/null ${PACKAGE_UPDATE[int]} 2>/dev/null
if ! command -v sudo >/dev/null 2>&1; then
_green "Installing sudo" # 安装必要的命令
${PACKAGE_INSTALL[int]} sudo for cmd in sudo wget tar unzip iproute2 systemd-detect-virt dd fio; do
fi if ! command -v "$cmd" >/dev/null 2>&1; then
if ! command -v wget >/dev/null 2>&1; then _green "Installing $cmd"
_green "Installing wget" ${PACKAGE_INSTALL[int]} "$cmd"
${PACKAGE_INSTALL[int]} wget
fi
if ! command -v tar >/dev/null 2>&1; then
_green "Installing tar"
${PACKAGE_INSTALL[int]} tar
fi
if ! command -v unzip >/dev/null 2>&1; then
_green "Installing unzip"
${PACKAGE_INSTALL[int]} unzip
fi
if ! command -v systemd-detect-virt >/dev/null 2>&1; then
_green "Installing systemd-detect-virt"
${PACKAGE_INSTALL[int]} systemd-detect-virt
if [ $? -ne 0 ]; then
if ! command -v dmidecode >/dev/null 2>&1; then
_green "Installing dmidecode"
${PACKAGE_INSTALL[int]} dmidecode
fi
fi fi
fi done
if ! command -v dd >/dev/null 2>&1; then
_green "Installing dd" if ! command -v sysbench >/dev/null 2>&1; then
${PACKAGE_INSTALL[int]} dd
fi
if ! command -v fio >/dev/null 2>&1; then
_green "Installing fio"
${PACKAGE_INSTALL[int]} fio
fi
if ! command -v sysbench >/dev/null 2>&1 && [ "${REGEX[int]}" != "freebsd" ]; then
_green "Installing sysbench" _green "Installing sysbench"
${PACKAGE_INSTALL[int]} sysbench ${PACKAGE_INSTALL[int]} sysbench
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Unable to download sysbench through the system's package manager, speak to try compiling and installing it..." echo "Unable to download sysbench through the system's package manager, trying to compile and install it..."
if ! wget -O /tmp/sysbench.zip "${cdn_success_url}https://github.com/akopytov/sysbench/archive/1.0.20.zip"; then wget -O /tmp/sysbench.zip "${cdn_success_url}https://github.com/akopytov/sysbench/archive/1.0.20.zip" || curl -Lk -o /tmp/sysbench.zip "${cdn_success_url}https://github.com/akopytov/sysbench/archive/1.0.20.zip"
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 if [ ! -f /tmp/sysbench.zip ]; then
wget -q -O /tmp/sysbench.zip "https://hub.fgit.cf/akopytov/sysbench/archive/1.0.20.zip" wget -q -O /tmp/sysbench.zip "https://hub.fgit.cf/akopytov/sysbench/archive/1.0.20.zip"
fi fi
@@ -369,11 +371,12 @@ env_check() {
Check_SysBench Check_SysBench
fi fi
fi fi
if ! command -v geekbench >/dev/null 2>&1; then if ! command -v geekbench >/dev/null 2>&1; then
_green "Installing geekbench" _green "Installing geekbench"
curl -L "${cdn_success_url}https://raw.githubusercontent.com/oneclickvirt/cputest/main/dgb.sh" -o dgb.sh && chmod +x dgb.sh 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 bash dgb.sh -v gb5
_blue "If you not want to use geekbench5, you can use" _blue "If you do not want to use geekbench5, you can use"
echo "bash dgb.sh -v gb6" echo "bash dgb.sh -v gb6"
echo "bash dgb.sh -v gb4" echo "bash dgb.sh -v gb4"
_blue "to change version, or use" _blue "to change version, or use"
@@ -381,26 +384,28 @@ env_check() {
_blue "to uninstall geekbench" _blue "to uninstall geekbench"
rm -rf dgb.sh rm -rf dgb.sh
fi fi
if ! command -v speedtest >/dev/null 2>&1; then if ! command -v speedtest >/dev/null 2>&1; then
_green "Installing geekbench" _green "Installing speedtest"
curl -L "${cdn_success_url}https://raw.githubusercontent.com/oneclickvirt/speedtest/main/dspt.sh" -o dspt.sh && chmod +x dspt.sh curl -L "${cdn_success_url}https://raw.githubusercontent.com/oneclickvirt/speedtest/main/dspt.sh" -o dspt.sh && chmod +x dspt.sh
bash dspt.sh bash dspt.sh
rm -rf dspt.sh rm -rf dspt.sh
rm -rf speedtest.tar.gz rm -rf speedtest.tar.gz
_blue "if you want to use golang origin speedtest, you can use" _blue "if you want to use golang original speedtest, you can use"
echo "rm -rf /usr/bin/speedtest" echo "rm -rf /usr/bin/speedtest"
echo "rm -rf /usr/bin/speedtest-go" echo "rm -rf /usr/bin/speedtest-go"
_blue "to uninstall speedtest and speedtest-go" _blue "to uninstall speedtest and speedtest-go"
fi fi
if ! command -v ping >/dev/null 2>&1; then if ! command -v ping >/dev/null 2>&1; then
_green "Installing ping" _green "Installing ping"
${PACKAGE_INSTALL[int]} iputils-ping >/dev/null 2>&1 ${PACKAGE_INSTALL[int]} iputils-ping >/dev/null 2>&1
${PACKAGE_INSTALL[int]} ping >/dev/null 2>&1 ${PACKAGE_INSTALL[int]} ping >/dev/null 2>&1
fi fi
if [ "$(uname -s)" = "Darwin" ]; then if [ "$(uname -s)" = "Darwin" ]; then
echo "Detected MacOS. Installing sysbench and fio..." echo "Detected MacOS. Installing sysbench iproute2mac fio..."
brew install --force sysbench fio dd brew install --force sysbench iproute2mac fio
# 有问题需要修复root环境不能brewbrew安装完毕后可能路径不在环境变量中
else else
if ! grep -q "^net.ipv4.ping_group_range = 0 2147483647$" /etc/sysctl.conf; then if ! grep -q "^net.ipv4.ping_group_range = 0 2147483647$" /etc/sysctl.conf; then
echo "net.ipv4.ping_group_range = 0 2147483647" >> /etc/sysctl.conf echo "net.ipv4.ping_group_range = 0 2147483647" >> /etc/sysctl.conf
@@ -412,9 +417,9 @@ env_check() {
} }
uninstall_goecs() { uninstall_goecs() {
rm -rf /root/goecs rm -rf /root/goecs
rm -rf /usr/bin/goecs rm -rf /usr/bin/goecs
_green "The command (goecs) has been uninstalled." _green "The command (goecs) has been uninstalled."
} }
show_help() { show_help() {
@@ -451,7 +456,7 @@ Available commands:
speedtest (Use the officially provided binaries for more accurate test results.) speedtest (Use the officially provided binaries for more accurate test results.)
ping (Use the officially provided binaries for more accurate test results.) ping (Use the officially provided binaries for more accurate test results.)
systemd-detect-virt OR dmidecode (Almost all unix-like systems have it, for more accurate test results.) systemd-detect-virt OR dmidecode (Almost all unix-like systems have it, for more accurate test results.)
In fact, sysbench/geekbench is the only one of the above dependencies that must be installed, without which the CPU score cannot be tested. In fact, sysbench/geekbench is the only one of the above dependencies that must be installed, without which the CPU score cannot be tested without which the CPU score cannot be tested.
./goecs.sh install Install goecs command ./goecs.sh install Install goecs command
./goecs.sh upgrade Upgrade goecs command ./goecs.sh upgrade Upgrade goecs command
./goecs.sh uninstall Uninstall goecs command ./goecs.sh uninstall Uninstall goecs command
@@ -478,3 +483,4 @@ case "$1" in
show_help show_help
;; ;;
esac esac

View File

@@ -1,20 +0,0 @@
@echo off
setlocal enabledelayedexpansion
set repo_path=C:\Users\spiritlhl\Documents\GoWorks\ecs
git add -A
git commit -am"update"
:push
cd %repo_path%
git push -f origin master
if errorlevel 1 (
echo Push failed. Retrying in 3 seconds...
timeout /nobreak /t 3 >nul
goto push
)
echo Push successful.
endlocal

View File

@@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"github.com/imroc/req/v3" "github.com/imroc/req/v3"
"github.com/oneclickvirt/UnlockTests/uts" "github.com/oneclickvirt/UnlockTests/uts"
"github.com/oneclickvirt/basics/ipv6"
"github.com/oneclickvirt/basics/system" "github.com/oneclickvirt/basics/system"
. "github.com/oneclickvirt/defaultset" . "github.com/oneclickvirt/defaultset"
"github.com/oneclickvirt/security/network" "github.com/oneclickvirt/security/network"
@@ -128,12 +129,12 @@ func CheckChina(enableLogger bool) bool {
return selectChina return selectChina
} }
// SecurityCheck 执行安全检查 // BasicsAndSecurityCheck 执行安全检查
func SecurityCheck(language, nt3CheckType string, securtyCheckStatus bool) (string, string, string) { func BasicsAndSecurityCheck(language, nt3CheckType string, securtyCheckStatus bool) (string, string, string) {
var wgt sync.WaitGroup var wgt sync.WaitGroup
var ipInfo, securityInfo, systemInfo string var ipInfo, securityInfo, systemInfo string
var err error var err error
wgt.Add(2) wgt.Add(1)
go func() { go func() {
defer wgt.Done() defer wgt.Done()
ipInfo, securityInfo, err = network.NetworkCheck("both", securtyCheckStatus, language) ipInfo, securityInfo, err = network.NetworkCheck("both", securtyCheckStatus, language)
@@ -141,12 +142,17 @@ func SecurityCheck(language, nt3CheckType string, securtyCheckStatus bool) (stri
fmt.Println(err.Error()) fmt.Println(err.Error())
} }
}() }()
wgt.Add(1)
go func() { go func() {
defer wgt.Done() defer wgt.Done()
systemInfo = system.CheckSystemInfo(language) systemInfo = system.CheckSystemInfo(language)
}() }()
wgt.Wait() wgt.Wait()
ipv6Info, errv6 := ipv6.GetIPv6Mask(language)
basicInfo := systemInfo + ipInfo basicInfo := systemInfo + ipInfo
if errv6 == nil && ipv6Info != "" {
basicInfo += ipv6Info
}
if strings.Contains(ipInfo, "IPV4") && strings.Contains(ipInfo, "IPV6") { if strings.Contains(ipInfo, "IPV4") && strings.Contains(ipInfo, "IPV6") {
uts.IPV4 = true uts.IPV4 = true
uts.IPV6 = true uts.IPV6 = true
@@ -238,22 +244,33 @@ 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
client := req.DefaultClient() client := req.C().SetTimeout(6 * time.Second)
client.SetTimeout(6 * time.Second)
client.R(). client.R().
SetRetryCount(2). SetRetryCount(2).
SetRetryBackoffInterval(1*time.Second, 5*time.Second). SetRetryBackoffInterval(1*time.Second, 5*time.Second).
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 "", "", fmt.Errorf("failed to open file: %w", err)
} }
defer file.Close() defer file.Close()
upload := func(url string) (string, error) { upload := func(url string) (string, string, error) {
// 重新打开文件,以确保我们总是从文件开头读取
file, err := os.Open(absPath)
if err != nil {
return "", "", fmt.Errorf("failed to re-open file for %s: %w", url, err)
}
defer file.Close()
// 读取文件内容
content, err := io.ReadAll(file)
if err != nil {
return "", "", fmt.Errorf("failed to read file content for %s: %w", url, err)
}
resp, err := client.R(). resp, err := client.R().
SetHeader("Authorization", token). SetHeader("Authorization", token).
SetHeader("Format", "RANDOM"). SetHeader("Format", "RANDOM").
@@ -261,26 +278,28 @@ func UploadText(absPath string) (string, error) {
SetHeader("UploadText", "true"). SetHeader("UploadText", "true").
SetHeader("Content-Type", "multipart/form-data"). SetHeader("Content-Type", "multipart/form-data").
SetHeader("No-JSON", "true"). SetHeader("No-JSON", "true").
SetFileReader("file", "goecs.txt", file). SetFileBytes("file", "goecs.txt", content).
Post(url) Post(url)
if err != nil { if err != nil {
return "", err return "", "", fmt.Errorf("failed to make request to %s: %w", url, 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 http_url := strings.ReplaceAll(resp.String(), "https://paste.spiritlhl.net/", "http://hpaste.spiritlhl.net/")
https_url := strings.ReplaceAll(resp.String(), "http://hpaste.spiritlhl.net/", "https://paste.spiritlhl.net/")
return http_url, https_url, nil
} else { } else {
return "", fmt.Errorf("upload failed with status code: %d", resp.StatusCode) return "", "", fmt.Errorf("upload failed for %s with status code: %d", url, 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 "", "", fmt.Errorf("failed to upload to both primary and backup URLs: %w", err)
} }
return result, nil return http_url, https_url, nil
} }
// ProcessAndUpload 创建结果文件并上传文件 // ProcessAndUpload 创建结果文件并上传文件
@@ -321,12 +340,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)
} }
} }