Compare commits

...

33 Commits

Author SHA1 Message Date
spiritlhl
8f41c37203 fix: 修复windows下的Admin权限检测 2025-06-30 14:18:42 +00:00
github-actions[bot]
12b1ae0702 chore: update ECS_VERSION to 0.1.44 in goecs.sh 2025-06-30 13:43:29 +00:00
spiritlhl
653cd75a97 fix: 修复内存测试在无root环境下测试的权限问题,添加无权限的内存测试方法mbw 2025-06-30 13:32:20 +00:00
github-actions[bot]
ea36e88c9f chore: update ECS_VERSION to 0.1.43 in goecs.sh 2025-06-29 08:49:03 +00:00
spiritlhl
c81ebb3c7a fix: 异步函数传值需要指针传递,值传递可能会出现同步问题 2025-06-29 08:45:15 +00:00
github-actions[bot]
7896b3ead5 chore: update ECS_VERSION to 0.1.42 in goecs.sh 2025-06-29 08:33:10 +00:00
spiritlhl
eb98a7b857 fix: 更加严格的启动条件,同时避免死锁等待 2025-06-29 08:29:24 +00:00
github-actions[bot]
d4d86229de chore: update ECS_VERSION to 0.1.41 in goecs.sh 2025-06-29 07:59:30 +00:00
spiritlhl
651a183382 fix: 修复版本号 2025-06-29 15:55:56 +08:00
spiritlhl
afc313a2a8 fix: 同步流媒体检测的判断逻辑 2025-06-29 15:44:16 +08:00
github-actions[bot]
39ac8d198d chore: update ECS_VERSION to 0.1.40 in goecs.sh 2025-06-29 07:36:33 +00:00
spiritlhl
a70dc2bab1 fix: 更新版本号至 v0.1.40 2025-06-29 07:26:48 +00:00
spiritlhl
5041a16a9a fix: 修复同步机制问题,保护最终输出不出现数据竞争 2025-06-29 07:22:27 +00:00
github-actions[bot]
21deb3587e chore: update ECS_VERSION to 0.1.39 in goecs.sh 2025-06-29 07:07:10 +00:00
spiritlhl
3bac30edc2 fix: 修复协程部分等待位置错误的问题 2025-06-29 07:02:10 +00:00
github-actions[bot]
9ef2ec4a9e chore: update ECS_VERSION to 0.1.38 in goecs.sh 2025-06-29 06:39:24 +00:00
spiritlhl
ac33e00e0a fix: 拆分main函数,分函数方便后续维护,添加前置检测自动切换离线模式 2025-06-29 06:27:59 +00:00
spiritlhl
7a439f7095 fix: 优化编译文件的大小 2025-06-29 10:55:39 +08:00
spiritlhl
e3bfa65f66 Merge pull request #12 from fossabot/add-license-scan-badge
Add license scan report and status
2025-06-29 09:36:58 +08:00
fossabot
74e33a212c Add license scan report and status
Signed off by: fossabot <badges@fossa.com>
2025-06-28 21:22:21 -04:00
spiritlhl
bba8595033 fix: 统一致谢图标大小 2025-06-29 01:00:05 +00:00
spiritlhl
530181be87 feat: 添加zmto对本开源项目的支持 2025-06-29 00:57:46 +00:00
github-actions[bot]
7deb986209 chore: update ECS_VERSION to 0.1.37 in goecs.sh 2025-06-28 14:02:18 +00:00
spiritlhl
ea8e5efbd3 fix: 修复部分失效的流媒体检测,基础信息检测适配MACOS系统 2025-06-28 13:50:54 +00:00
spiritlhl
db88ee8479 fix: 添加sysbench的天梯图: https://sysbench.spiritlhl.net/ 2025-06-15 12:44:45 +00:00
spiritlhl
67a3bfdaad fix: 修复自动更新安装版本中的版本提取代码 2025-06-05 20:45:51 +08:00
spiritlhl
e57ce05c0c fix: 回退修改 2025-06-05 20:39:52 +08:00
spiritlhl
62137f0bb1 fix: 修复仅安装本体时,可能宿主机连curl/unzip都没有的问他 2025-06-05 20:38:56 +08:00
spiritlhl
f9d8c9ee4c fix: 修复step匹配规则 2025-06-03 23:19:46 +08:00
spiritlhl
913a1725c1 fix: 修复版本号问题 2025-06-03 22:17:12 +08:00
spiritlhl
f1acbd361b fix: 自动替换和更新goecs.sh脚本中的最新tag 2025-06-03 22:13:41 +08:00
spiritlhl
d6f62f8624 fix: 添加部分说明 2025-05-23 15:41:48 +08:00
spiritlhl
94da890522 fix: 修复可能的测速延迟显示异常和CPU频率显示异常的问题 2025-05-22 03:16:02 +00:00
15 changed files with 888 additions and 512 deletions

View File

@@ -40,3 +40,34 @@ jobs:
env: env:
GITHUB_TOKEN: ${{ secrets.GHT }} GITHUB_TOKEN: ${{ secrets.GHT }}
GOPRIVATE: github.com/oneclickvirt/security GOPRIVATE: github.com/oneclickvirt/security
- name: Update goecs.sh with new version
run: |
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
VERSION="${GITHUB_REF#refs/tags/v}"
else
VERSION=$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || echo "0.1.37")
fi
echo "Using version: $VERSION"
FILE="goecs.sh"
BRANCH="master"
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global --unset url."git@github.com:".insteadOf || true
git fetch origin $BRANCH
git checkout $BRANCH
if [ ! -f "$FILE" ]; then
echo "Error: $FILE not found"
exit 1
fi
sed -i "s/\(_yellow \"Unable to get version info, using default version \).*\(\".*\)/\1$VERSION\2/" "$FILE"
sed -i "s/\(ECS_VERSION=\"\).*\(\"\)/\1$VERSION\2/" "$FILE"
if git diff --quiet "$FILE"; then
echo "No changes detected in $FILE"
exit 0
fi
git add "$FILE"
git commit -m "chore: update ECS_VERSION to $VERSION in goecs.sh"
git push origin $BRANCH
env:
GITHUB_TOKEN: ${{ secrets.GHT }}

View File

@@ -6,7 +6,9 @@ builds:
env: env:
- CGO_ENABLED=0 - CGO_ENABLED=0
ldflags: ldflags:
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 - -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 -extldflags=-static
flags:
- -trimpath
goos: goos:
- linux - linux
- windows - windows
@@ -34,6 +36,8 @@ builds:
- CXX=o64-clang++ - CXX=o64-clang++
ldflags: ldflags:
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 - -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
flags:
- -trimpath
goos: goos:
- darwin - darwin
goarch: goarch:
@@ -47,6 +51,8 @@ builds:
- CXX=oa64-clang++ - CXX=oa64-clang++
ldflags: ldflags:
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 - -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
flags:
- -trimpath
goos: goos:
- darwin - darwin
goarch: goarch:
@@ -75,4 +81,4 @@ changelog:
- Merge pull request - Merge pull request
- Merge branch - Merge branch
- go mod tidy - go mod tidy
- New translations - New translations

View File

@@ -1,6 +1,8 @@
# ECS # ECS
[![release](https://github.com/oneclickvirt/ecs/actions/workflows/main.yaml/badge.svg)](https://github.com/oneclickvirt/ecs/actions/workflows/main.yaml) [![release](https://github.com/oneclickvirt/ecs/actions/workflows/main.yaml/badge.svg)](https://github.com/oneclickvirt/ecs/actions/workflows/main.yaml)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Foneclickvirt%2Fecs.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Foneclickvirt%2Fecs?ref=badge_shield)
[![Hits](https://hits.spiritlhl.net/goecs.svg?action=hit&title=Hits&title_bg=%23555555&count_bg=%230eecf8&edge_flat=false)](https://hits.spiritlhl.net) [![Hits](https://hits.spiritlhl.net/goecs.svg?action=hit&title=Hits&title_bg=%23555555&count_bg=%230eecf8&edge_flat=false)](https://hits.spiritlhl.net)
@@ -40,9 +42,10 @@ Shell 版本:[https://github.com/spiritLHLS/ecs](https://github.com/spiritLHLS
> 更多架构与系统请自行测试,如有问题请开 issues。 > 更多架构与系统请自行测试,如有问题请开 issues。
### **待支持的系统** ### **待支持的系统**
| 系统 | 说明 | | 系统 | 说明 |
|-----|--------------------------| |-----|---------------------------|
| MacOS | 存在硬件测试 BUG 未修复,存在环境依赖未修复 | | MacOS | 存在硬件测试 BUG 未修复,存在环境依赖未修复 |
| Android(arm64) | 存在权限问题未修复非安卓系统的ARM架构无问题 |
--- ---
@@ -136,19 +139,19 @@ Shell 版本:[https://github.com/spiritLHLS/ecs](https://github.com/spiritLHLS
export noninteractive=true && ./goecs.sh env export noninteractive=true && ./goecs.sh env
``` ```
3. **安装 `goecs`** 3. **安装 `goecs` 本体(仅下载二进制文件无依赖安装)**
```bash ```bash
./goecs.sh install ./goecs.sh install
``` ```
4. **升级 `goecs`** 4. **升级 `goecs` 本体**
```bash ```bash
./goecs.sh upgrade ./goecs.sh upgrade
``` ```
5. **卸载 `goecs`** 5. **卸载 `goecs` 本体**
```bash ```bash
./goecs.sh uninstall ./goecs.sh uninstall
@@ -340,6 +343,7 @@ GOOS=darwin GOARCH=amd64 go build -o goecs_darwin
| 测试稳定性 | 核心测试组件10年以上未变 | 每个大版本更新测试项,分数不同版本间难以对比(每个版本对标当前最好的CPU) | | 测试稳定性 | 核心测试组件10年以上未变 | 每个大版本更新测试项,分数不同版本间难以对比(每个版本对标当前最好的CPU) |
| 测试内容 | 仅测试计算性能 | 覆盖多种性能测试,分数加权计算,但部分测试实际不常用 | | 测试内容 | 仅测试计算性能 | 覆盖多种性能测试,分数加权计算,但部分测试实际不常用 |
| 适用场景 | 适合快速测试,仅测试计算性能 | 适合综合全面的测试 | | 适用场景 | 适合快速测试,仅测试计算性能 | 适合综合全面的测试 |
| 排行榜 | [sysbench.spiritlhl.net](https://sysbench.spiritlhl.net/) | [browser.geekbench.com](https://browser.geekbench.com/) |
且```goecs```测试使用何种CPU测试方式可使用参数指定默认只是为了更多用户快速测试的需求 且```goecs```测试使用何种CPU测试方式可使用参数指定默认只是为了更多用户快速测试的需求
@@ -370,7 +374,7 @@ GOOS=darwin GOARCH=amd64 go build -o goecs_darwin
感谢 感谢
<a href="https://h501.io/?from=69" target="_blank"> <a href="https://h501.io/?from=69" target="_blank">
<img src="https://github.com/spiritLHLS/ecs/assets/103393591/dfd47230-2747-4112-be69-b5636b34f07f" alt="h501"> <img src="https://github.com/spiritLHLS/ecs/assets/103393591/dfd47230-2747-4112-be69-b5636b34f07f" alt="h501" style="height: 50px;">
</a> </a>
提供的免费托管支持本开源项目的共享测试结果存储 提供的免费托管支持本开源项目的共享测试结果存储
@@ -378,13 +382,20 @@ GOOS=darwin GOARCH=amd64 go build -o goecs_darwin
同时感谢以下平台提供编辑和测试支持 同时感谢以下平台提供编辑和测试支持
<a href="https://www.jetbrains.com/go/" target="_blank"> <a href="https://www.jetbrains.com/go/" target="_blank">
<img src="https://resources.jetbrains.com/storage/products/company/brand/logos/GoLand.png" alt="goland"> <img src="https://resources.jetbrains.com/storage/products/company/brand/logos/GoLand.png" alt="goland" style="height: 50px;">
</a> </a>
<a href="https://community.ibm.com/zsystems/form/l1cc-oss-vm-request/" target="_blank"> <a href="https://community.ibm.com/zsystems/form/l1cc-oss-vm-request/" target="_blank">
<img src="https://linuxone.cloud.marist.edu/oss/resources/images/linuxonelogo03.png" alt="ibm"> <img src="https://linuxone.cloud.marist.edu/oss/resources/images/linuxonelogo03.png" alt="ibm" style="height: 50px;">
</a>
<a href="https://console.zmto.com/?affid=1524" target="_blank">
<img src="https://console.zmto.com/templates/2019/dist/images/logo_dark.svg" alt="zmto" style="height: 50px;">
</a> </a>
## Stargazers over time ## Stargazers over time
[![Stargazers over time](https://starchart.cc/oneclickvirt/ecs.svg?variant=adaptive)](https://starchart.cc/oneclickvirt/ecs) [![Stargazers over time](https://starchart.cc/oneclickvirt/ecs.svg?variant=adaptive)](https://www.spiritlhl.net)
## License
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Foneclickvirt%2Fecs.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Foneclickvirt%2Fecs?ref=badge_large)

View File

@@ -39,10 +39,10 @@ Shell version: [https://github.com/spiritLHLS/ecs/blob/main/README_EN.md](https:
> Please test additional architectures and systems yourself. If you encounter any issues, please open an issue. > Please test additional architectures and systems yourself. If you encounter any issues, please open an issue.
### **Systems Pending Support** ### **Systems Pending Support**
| OS | Notes | | OS | Notes |
|--------|--------------------------------------------------------| |--------|-------------------------------------------------------------------------------------------------|
| MacOS | Hardware testing bugs and environment dependencies unresolved | | MacOS | Hardware testing bugs and environment dependencies unresolved |
| Android(arm64) | Permission issues that are not fixed, no problems with ARM architecture for non-Android systems |
--- ---
## **Features** ## **Features**
@@ -90,6 +90,12 @@ Shell version: [https://github.com/spiritLHLS/ecs/blob/main/README_EN.md](https:
export noninteractive=true && curl -L https://cnb.cool/oneclickvirt/ecs/-/git/raw/main/goecs.sh -o goecs.sh && chmod +x goecs.sh && bash goecs.sh env && bash goecs.sh install && goecs -l en export noninteractive=true && curl -L https://cnb.cool/oneclickvirt/ecs/-/git/raw/main/goecs.sh -o goecs.sh && chmod +x goecs.sh && bash goecs.sh env && bash goecs.sh install && goecs -l en
``` ```
- **Short Link:**
```bash
export noninteractive=true && curl -L https://bash.spiritlhl.net/goecs -o goecs.sh && chmod +x goecs.sh && bash goecs.sh env && bash goecs.sh install && goecs
``
#### **Detailed instructions** #### **Detailed instructions**
**Detailed description** of the commands in **Command **Controls whether to install dependencies**, **Whether to update the package manager**, **Default interaction mode can be selected*** **Detailed description** of the commands in **Command **Controls whether to install dependencies**, **Whether to update the package manager**, **Default interaction mode can be selected***
@@ -362,7 +368,7 @@ Thank [he.net](https://he.net) [bgp.tools](https://bgp.tools) [ipinfo.io](https:
Thank Thank
<a href="https://h501.io/?from=69" target="_blank"> <a href="https://h501.io/?from=69" target="_blank">
<img src="https://github.com/spiritLHLS/ecs/assets/103393591/dfd47230-2747-4112-be69-b5636b34f07f" alt="h501"> <img src="https://github.com/spiritLHLS/ecs/assets/103393591/dfd47230-2747-4112-be69-b5636b34f07f" alt="h501" style="height: 50px;">
</a> </a>
provided free hosting support for this open source project's shared test results storage provided free hosting support for this open source project's shared test results storage
@@ -370,13 +376,17 @@ provided free hosting support for this open source project's shared test results
Thanks also to the following platforms for editorial and testing support Thanks also to the following platforms for editorial and testing support
<a href="https://www.jetbrains.com/go/" target="_blank"> <a href="https://www.jetbrains.com/go/" target="_blank">
<img src="https://resources.jetbrains.com/storage/products/company/brand/logos/GoLand.png" alt="goland"> <img src="https://resources.jetbrains.com/storage/products/company/brand/logos/GoLand.png" alt="goland" style="height: 50px;">
</a> </a>
<a href="https://community.ibm.com/zsystems/form/l1cc-oss-vm-request/" target="_blank"> <a href="https://community.ibm.com/zsystems/form/l1cc-oss-vm-request/" target="_blank">
<img src="https://linuxone.cloud.marist.edu/oss/resources/images/linuxonelogo03.png" alt="ibm"> <img src="https://linuxone.cloud.marist.edu/oss/resources/images/linuxonelogo03.png" alt="ibm" style="height: 50px;">
</a>
<a href="https://console.zmto.com/?affid=1524" target="_blank">
<img src="https://console.zmto.com/templates/2019/dist/images/logo_dark.svg" alt="zmto" style="height: 50px;">
</a> </a>
## Stargazers over time ## Stargazers over time
[![Stargazers over time](https://starchart.cc/oneclickvirt/ecs.svg?variant=adaptive)](https://starchart.cc/oneclickvirt/ecs) [![Stargazers over time](https://starchart.cc/oneclickvirt/ecs.svg?variant=adaptive)](https://www.spiritlhl.net)

View File

@@ -110,6 +110,8 @@ AMD的7950x单核满血性能得分在6500左右AMD的5950x单核满血性能
有时候多核得分和单核得分一样证明商家在限制程序并发使用CPU典型例子腾讯云。 有时候多核得分和单核得分一样证明商家在限制程序并发使用CPU典型例子腾讯云。
```Sysbench```的基准可见 [CPU Performance Ladder For Sysbench](https://sysbench.spiritlhl.net/) 天梯图具体得分不分测试的sysbench的版本。
```GeekBench```的基准可见 [官方网站](https://browser.geekbench.com/processor-benchmarks/) 天梯图,具体得分每个```GeekBench```版本都不一样,注意使用时测试的```GeekBench```版本是什么。 ```GeekBench```的基准可见 [官方网站](https://browser.geekbench.com/processor-benchmarks/) 天梯图,具体得分每个```GeekBench```版本都不一样,注意使用时测试的```GeekBench```版本是什么。
多说一句,```GeekBench```测的很多内容,实际在服务器使用过程中根本用不到,测试仅供参考。当然```Sysbench```非常不全面但它基于最基础的计算性能可以大致比较CPU的性能。 多说一句,```GeekBench```测的很多内容,实际在服务器使用过程中根本用不到,测试仅供参考。当然```Sysbench```非常不全面但它基于最基础的计算性能可以大致比较CPU的性能。
@@ -279,6 +281,8 @@ AMD's 7950x single-core full performance score is around 6500, AMD's 5950x singl
Sometimes multi-core scores are the same as single-core scores, proving that the vendor is limiting program concurrent use of CPU, a typical example being Tencent Cloud. Sometimes multi-core scores are the same as single-core scores, proving that the vendor is limiting program concurrent use of CPU, a typical example being Tencent Cloud.
Benchmarks for ```Sysbench`` can be found in the [CPU Performance Ladder For Sysbench](https://sysbench.spiritlhl.net/) ladder chart, with specific scores regardless of the version of sysbench tested.
For `GeekBench` baselines, see the [official website](https://browser.geekbench.com/processor-benchmarks/) ladder chart. Specific scores differ for each `GeekBench` version, so note which `GeekBench` version is being used when testing. For `GeekBench` baselines, see the [official website](https://browser.geekbench.com/processor-benchmarks/) ladder chart. Specific scores differ for each `GeekBench` version, so note which `GeekBench` version is being used when testing.
As an additional note, many things tested by `GeekBench` are not actually used in server usage processes, so the test is for reference only. Of course, `Sysbench` is very incomplete, but it can roughly compare CPU performance based on the most basic computational performance. As an additional note, many things tested by `GeekBench` are not actually used in server usage processes, so the test is for reference only. Of course, `Sysbench` is very incomplete, but it can roughly compare CPU performance based on the most basic computational performance.
@@ -424,6 +428,8 @@ AMDの7950xシングルコアのフルパフォーマンススコアは約6500
時々、マルチコアスコアとシングルコアスコアが同じ場合があります。これは販売者がプログラムの並列CPU使用を制限していることを示しています。典型的な例はTencent Cloudです。 時々、マルチコアスコアとシングルコアスコアが同じ場合があります。これは販売者がプログラムの並列CPU使用を制限していることを示しています。典型的な例はTencent Cloudです。
Sysbenchのベンチマークは[CPU Performance Ladder For Sysbench](https://sysbench.spiritlhl.net/)のラダーチャートで見ることができる。
```GeekBench```の基準は[公式ウェブサイト](https://browser.geekbench.com/processor-benchmarks/)の階層チャートを参照してください。具体的なスコアは各```GeekBench```バージョンで異なるため、テスト時の```GeekBench```バージョンに注意してください。 ```GeekBench```の基準は[公式ウェブサイト](https://browser.geekbench.com/processor-benchmarks/)の階層チャートを参照してください。具体的なスコアは各```GeekBench```バージョンで異なるため、テスト時の```GeekBench```バージョンに注意してください。
補足ですが、```GeekBench```がテストする多くの内容は、サーバー使用過程で実際には必要ないことが多いです。テストは参考程度にしてください。もちろん```Sysbench```は非常に包括的ではありませんが、基本的な計算性能に基づいてCPUのパフォーマンスを大まかに比較できます。 補足ですが、```GeekBench```がテストする多くの内容は、サーバー使用過程で実際には必要ないことが多いです。テストは参考程度にしてください。もちろん```Sysbench```は非常に包括的ではありませんが、基本的な計算性能に基づいてCPUのパフォーマンスを大まかに比較できます。

View File

@@ -36,6 +36,6 @@ func DiskTest(language, testMethod, testPath string, isMultiCheck bool, autoChan
if !strings.Contains(res, "\n") && res != "" { if !strings.Contains(res, "\n") && res != "" {
res += "\n" res += "\n"
} }
fmt.Printf(res) fmt.Printf("%s", res)
//fmt.Println("--------------------------------------------------") //fmt.Println("--------------------------------------------------")
} }

View File

@@ -3,5 +3,5 @@ package disktest
import "testing" import "testing"
func TestDiskIoTest(t *testing.T) { func TestDiskIoTest(t *testing.T) {
DiskTest("zh", "sysbench", "", false) DiskTest("zh", "sysbench", "", false, false)
} }

15
go.mod
View File

@@ -7,19 +7,19 @@ toolchain go1.24.2
require ( require (
github.com/imroc/req/v3 v3.50.0 github.com/imroc/req/v3 v3.50.0
github.com/oneclickvirt/CommonMediaTests v0.0.4-20250329123841 github.com/oneclickvirt/CommonMediaTests v0.0.4-20250329123841
github.com/oneclickvirt/UnlockTests v0.0.26-20250329125926 github.com/oneclickvirt/UnlockTests v0.0.27-20250628125053
github.com/oneclickvirt/backtrace v0.0.5-20250517095024 github.com/oneclickvirt/backtrace v0.0.5-20250629024536
github.com/oneclickvirt/basics v0.0.12-20250517101807 github.com/oneclickvirt/basics v0.0.13-20250629023612
github.com/oneclickvirt/cputest v0.0.10-20250404151448 github.com/oneclickvirt/cputest v0.0.10-20250404151448
github.com/oneclickvirt/defaultset v0.0.2-20240624082446 github.com/oneclickvirt/defaultset v0.0.2-20240624082446
github.com/oneclickvirt/disktest v0.0.8-20250425015826 github.com/oneclickvirt/disktest v0.0.8-20250425015826
github.com/oneclickvirt/gostun v0.0.3-20250329105202 github.com/oneclickvirt/gostun v0.0.3-20250329105202
github.com/oneclickvirt/memorytest v0.0.5-20250406063420 github.com/oneclickvirt/memorytest v0.0.6-20250630141424
github.com/oneclickvirt/nt3 v0.0.5-20250416131047 github.com/oneclickvirt/nt3 v0.0.5-20250416131047
github.com/oneclickvirt/pingtest v0.0.7-20250413051539 github.com/oneclickvirt/pingtest v0.0.7-20250413051539
github.com/oneclickvirt/portchecker v0.0.3-20250329125750 github.com/oneclickvirt/portchecker v0.0.3-20250329125750
github.com/oneclickvirt/security v0.0.4-20250519011733 github.com/oneclickvirt/security v0.0.4-20250629033626
github.com/oneclickvirt/speedtest v0.0.9-20250329130205 github.com/oneclickvirt/speedtest v0.0.9-20250521034111
) )
require ( require (
@@ -63,6 +63,7 @@ require (
github.com/nxtrace/NTrace-core v1.4.0 // indirect github.com/nxtrace/NTrace-core v1.4.0 // indirect
github.com/oneclickvirt/dd v0.0.1-20250406062523 // indirect github.com/oneclickvirt/dd v0.0.1-20250406062523 // indirect
github.com/oneclickvirt/fio v0.0.1-20250406060851 // indirect github.com/oneclickvirt/fio v0.0.1-20250406060851 // indirect
github.com/oneclickvirt/mbw v0.0.1-20250630140849 // indirect
github.com/onsi/ginkgo/v2 v2.22.1 // indirect github.com/onsi/ginkgo/v2 v2.22.1 // indirect
github.com/oschwald/maxminddb-golang v1.13.1 // indirect github.com/oschwald/maxminddb-golang v1.13.1 // indirect
github.com/pelletier/go-toml/v2 v2.2.4 // indirect github.com/pelletier/go-toml/v2 v2.2.4 // indirect
@@ -106,7 +107,7 @@ require (
golang.org/x/mod v0.22.0 // indirect golang.org/x/mod v0.22.0 // indirect
golang.org/x/net v0.39.0 // indirect golang.org/x/net v0.39.0 // indirect
golang.org/x/sync v0.13.0 // indirect golang.org/x/sync v0.13.0 // indirect
golang.org/x/sys v0.32.0 // indirect golang.org/x/sys v0.33.0 // indirect
golang.org/x/term v0.31.0 // indirect golang.org/x/term v0.31.0 // indirect
golang.org/x/text v0.24.0 // indirect golang.org/x/text v0.24.0 // indirect
golang.org/x/tools v0.29.0 // indirect golang.org/x/tools v0.29.0 // indirect

30
go.sum
View File

@@ -99,12 +99,12 @@ github.com/nxtrace/NTrace-core v1.4.0 h1:pDN2BqxIYjedDKCDDOFBcDNOBnavGcx+4wbiG65
github.com/nxtrace/NTrace-core v1.4.0/go.mod h1:0AWqbqiIJbpbFG6W48vtJ6pWM8PPF+lQ1fi2371y+zA= github.com/nxtrace/NTrace-core v1.4.0/go.mod h1:0AWqbqiIJbpbFG6W48vtJ6pWM8PPF+lQ1fi2371y+zA=
github.com/oneclickvirt/CommonMediaTests v0.0.4-20250329123841 h1:Zef93z9UiZQwRAKnnZYALmpBKvvuVaq34MEsuWwk6nc= github.com/oneclickvirt/CommonMediaTests v0.0.4-20250329123841 h1:Zef93z9UiZQwRAKnnZYALmpBKvvuVaq34MEsuWwk6nc=
github.com/oneclickvirt/CommonMediaTests v0.0.4-20250329123841/go.mod h1:DAmFPRjFV5p9fEzUUSml5jJGn2f1NZJQCzTxITHDjc4= github.com/oneclickvirt/CommonMediaTests v0.0.4-20250329123841/go.mod h1:DAmFPRjFV5p9fEzUUSml5jJGn2f1NZJQCzTxITHDjc4=
github.com/oneclickvirt/UnlockTests v0.0.26-20250329125926 h1:H5//xwVjDR02bQ1hLa3G7LnwccsudPMjBVt7WCx2y/U= github.com/oneclickvirt/UnlockTests v0.0.27-20250628125053 h1:Ug8kySZR1weRUcsnGOv+f3HAl791AfkA7EWV3JmiMQA=
github.com/oneclickvirt/UnlockTests v0.0.26-20250329125926/go.mod h1:yXWIZB6iLS88pEd9m4QJi1GENn+7I91zA72y5ONz2Oc= github.com/oneclickvirt/UnlockTests v0.0.27-20250628125053/go.mod h1:yXWIZB6iLS88pEd9m4QJi1GENn+7I91zA72y5ONz2Oc=
github.com/oneclickvirt/backtrace v0.0.5-20250517095024 h1:j912aga/17znOqMB2VAxWOQYa4GL6YMFBhv+6c7jkvA= github.com/oneclickvirt/backtrace v0.0.5-20250629024536 h1:caHCa0DHmbYWBFN1bqKxpvPnN0wOxDEqJv1VDvDdLWs=
github.com/oneclickvirt/backtrace v0.0.5-20250517095024/go.mod h1:5AH00bo41hH3d2/JVuCTlBkZUs3AXX4nlKVXb6piZcI= github.com/oneclickvirt/backtrace v0.0.5-20250629024536/go.mod h1:5AH00bo41hH3d2/JVuCTlBkZUs3AXX4nlKVXb6piZcI=
github.com/oneclickvirt/basics v0.0.12-20250517101807 h1:5glhEre4BhttiE3uUTrMy9iwd3OQfK7qjQFTTfhKVIA= github.com/oneclickvirt/basics v0.0.13-20250629023612 h1:cQg+cGBt2NMRrjhJPH+CbevZrwtMU8pIZIY2Lp6zmt4=
github.com/oneclickvirt/basics v0.0.12-20250517101807/go.mod h1:yN1IEOXN6v/GJqJSA70Pooo6nXBI/6rq72vTY72wJMQ= github.com/oneclickvirt/basics v0.0.13-20250629023612/go.mod h1:yN1IEOXN6v/GJqJSA70Pooo6nXBI/6rq72vTY72wJMQ=
github.com/oneclickvirt/cputest v0.0.10-20250404151448 h1:ovGtCwFXG0qmpyNDRqcNDIiAmhrtemCjIUXTJ1fPH0o= github.com/oneclickvirt/cputest v0.0.10-20250404151448 h1:ovGtCwFXG0qmpyNDRqcNDIiAmhrtemCjIUXTJ1fPH0o=
github.com/oneclickvirt/cputest v0.0.10-20250404151448/go.mod h1:MmaHN9+XMntI3rLycwj8Ne31fG18IfNoa8N2utDK1CY= github.com/oneclickvirt/cputest v0.0.10-20250404151448/go.mod h1:MmaHN9+XMntI3rLycwj8Ne31fG18IfNoa8N2utDK1CY=
github.com/oneclickvirt/dd v0.0.1-20250406062523 h1:jegTww4fuoFEqwFozvGJEqUNI/5ew3QJ0XcKZZ/zuTs= github.com/oneclickvirt/dd v0.0.1-20250406062523 h1:jegTww4fuoFEqwFozvGJEqUNI/5ew3QJ0XcKZZ/zuTs=
@@ -117,18 +117,20 @@ github.com/oneclickvirt/fio v0.0.1-20250406060851 h1:b7xHKpPmU4q0NmvigRCEr3tQuAV
github.com/oneclickvirt/fio v0.0.1-20250406060851/go.mod h1:NIq+XYTey68KNERGIy/oRDlzpwLzBVoHOCiqX8didsE= github.com/oneclickvirt/fio v0.0.1-20250406060851/go.mod h1:NIq+XYTey68KNERGIy/oRDlzpwLzBVoHOCiqX8didsE=
github.com/oneclickvirt/gostun v0.0.3-20250329105202 h1:aJ6E91Lp94lq8iWRcCaxpXTjqOOaWvufr5oras6cFtM= github.com/oneclickvirt/gostun v0.0.3-20250329105202 h1:aJ6E91Lp94lq8iWRcCaxpXTjqOOaWvufr5oras6cFtM=
github.com/oneclickvirt/gostun v0.0.3-20250329105202/go.mod h1:f7DPEXAxbmwXSW33dbxtb0/KzqvOBWhTs2Or5xBerQA= github.com/oneclickvirt/gostun v0.0.3-20250329105202/go.mod h1:f7DPEXAxbmwXSW33dbxtb0/KzqvOBWhTs2Or5xBerQA=
github.com/oneclickvirt/memorytest v0.0.5-20250406063420 h1:eHqpqFIx8Ss062uyNf7Ruv7FC4AdZbElR7u9vX2Oj3g= github.com/oneclickvirt/mbw v0.0.1-20250630140849 h1:p6RMhOPBnQKAm9+VEQ2axAFsidrdSdrhXMyheIyv2a8=
github.com/oneclickvirt/memorytest v0.0.5-20250406063420/go.mod h1:HTd0sSxRjT4BcV8kcCh4fF2Nia0xgZNaVjhefsnypic= github.com/oneclickvirt/mbw v0.0.1-20250630140849/go.mod h1:0Vq6NRpyLmGUdfHfL3uDcFsuZhi7KlG+OCs5ky2757Y=
github.com/oneclickvirt/memorytest v0.0.6-20250630141424 h1:nFDaWWr9BR7uGrpDBVNhzIbQDqy0VFzSMboE8yIZFXY=
github.com/oneclickvirt/memorytest v0.0.6-20250630141424/go.mod h1:7xMacjQobvFAtODht2hxTsB9hM2IFS7vZk3gxx+bsjo=
github.com/oneclickvirt/nt3 v0.0.5-20250416131047 h1:KL0xowq19cW+FMBGMJxdqpRNoeyR+eEmb+jYSubmlTk= github.com/oneclickvirt/nt3 v0.0.5-20250416131047 h1:KL0xowq19cW+FMBGMJxdqpRNoeyR+eEmb+jYSubmlTk=
github.com/oneclickvirt/nt3 v0.0.5-20250416131047/go.mod h1:CVsDJEaIdyyZHn3WKbhU8Wn6GOfmBNvJlC/dDLRqcSQ= github.com/oneclickvirt/nt3 v0.0.5-20250416131047/go.mod h1:CVsDJEaIdyyZHn3WKbhU8Wn6GOfmBNvJlC/dDLRqcSQ=
github.com/oneclickvirt/pingtest v0.0.7-20250413051539 h1:mYOsEmMtwKr40hwM2NimVLpnbR2cjwuOh1c/9fQr2Dw= github.com/oneclickvirt/pingtest v0.0.7-20250413051539 h1:mYOsEmMtwKr40hwM2NimVLpnbR2cjwuOh1c/9fQr2Dw=
github.com/oneclickvirt/pingtest v0.0.7-20250413051539/go.mod h1:d3Ntx5m9lMll3a/k3+2B+5emj//vgDh4/NHTxs2qQE8= github.com/oneclickvirt/pingtest v0.0.7-20250413051539/go.mod h1:d3Ntx5m9lMll3a/k3+2B+5emj//vgDh4/NHTxs2qQE8=
github.com/oneclickvirt/portchecker v0.0.3-20250329125750 h1:TTNL0pnQlRsn046kW59I/9UWRpihttFHWnU7Ixycggk= github.com/oneclickvirt/portchecker v0.0.3-20250329125750 h1:TTNL0pnQlRsn046kW59I/9UWRpihttFHWnU7Ixycggk=
github.com/oneclickvirt/portchecker v0.0.3-20250329125750/go.mod h1:HQxSTrqM8/QFqHMTBZ7S8H9eEO5FkUXU1eb7ZX5Mk+k= github.com/oneclickvirt/portchecker v0.0.3-20250329125750/go.mod h1:HQxSTrqM8/QFqHMTBZ7S8H9eEO5FkUXU1eb7ZX5Mk+k=
github.com/oneclickvirt/security v0.0.4-20250519011733 h1:/APm2eD1SUKAA201WTQNjlKwWEun8F/0lYRh4tPtwuM= github.com/oneclickvirt/security v0.0.4-20250629033626 h1:DEchQ7WKKz4CzQpMlweoqA993BGncvmp1rL1ICNDJ2g=
github.com/oneclickvirt/security v0.0.4-20250519011733/go.mod h1:T6TjdM4ixug+fOsgKPYZTD6l1qdLz9kpgdW8xuSAUig= github.com/oneclickvirt/security v0.0.4-20250629033626/go.mod h1:/5eVnZLvP7RUjwhoI6d8iIMP7msbkHC5So3ZxM+A7Zg=
github.com/oneclickvirt/speedtest v0.0.9-20250329130205 h1:XWM6FhObi+2bEkntPcAAKkiS9w7r6j79DOtmlbq4hhs= github.com/oneclickvirt/speedtest v0.0.9-20250521034111 h1:yygDk+s5qFhPMDRzdMfyopm1xU512peNqY6WYyvYcfY=
github.com/oneclickvirt/speedtest v0.0.9-20250329130205/go.mod h1:zd5ZgIGslmtQLQehEfRjyumlvgDHTpCSMchKfKXoASI= github.com/oneclickvirt/speedtest v0.0.9-20250521034111/go.mod h1:zd5ZgIGslmtQLQehEfRjyumlvgDHTpCSMchKfKXoASI=
github.com/onsi/ginkgo/v2 v2.22.1 h1:QW7tbJAUDyVDVOM5dFa7qaybo+CRfR7bemlQUN6Z8aM= github.com/onsi/ginkgo/v2 v2.22.1 h1:QW7tbJAUDyVDVOM5dFa7qaybo+CRfR7bemlQUN6Z8aM=
github.com/onsi/ginkgo/v2 v2.22.1/go.mod h1:S6aTpoRsSq2cZOd+pssHAlKW/Q/jZt6cPrPlnj4a1xM= github.com/onsi/ginkgo/v2 v2.22.1/go.mod h1:S6aTpoRsSq2cZOd+pssHAlKW/Q/jZt6cPrPlnj4a1xM=
github.com/onsi/gomega v1.36.1 h1:bJDPBO7ibjxcbHMgSCoo4Yj18UWbKDlLwX1x9sybDcw= github.com/onsi/gomega v1.36.1 h1:bJDPBO7ibjxcbHMgSCoo4Yj18UWbKDlLwX1x9sybDcw=
@@ -278,8 +280,8 @@ golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=

970
goecs.go

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# From https://github.com/oneclickvirt/ecs # From https://github.com/oneclickvirt/ecs
# 2025.04.07 # 2025.06.29
# 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
# 或 # 或
@@ -119,13 +119,31 @@ cleanup_epel() {
} }
goecs_check() { goecs_check() {
# Get system and architecture info with error handling if command -v apt-get >/dev/null 2>&1; then
INSTALL_CMD="apt-get -y install"
elif command -v yum >/dev/null 2>&1; then
INSTALL_CMD="yum -y install"
elif command -v dnf >/dev/null 2>&1; then
INSTALL_CMD="dnf -y install"
elif command -v pacman >/dev/null 2>&1; then
INSTALL_CMD="pacman -S --noconfirm"
elif command -v apk >/dev/null 2>&1; then
INSTALL_CMD="apk add"
elif command -v zypper >/dev/null 2>&1; then
INSTALL_CMD="zypper install -y"
fi
if ! command -v unzip >/dev/null 2>&1; then
_green "Installing unzip"
${INSTALL_CMD} unzip
fi
if ! command -v curl >/dev/null 2>&1; then
_green "Installing curl"
${INSTALL_CMD} curl
fi
os=$(uname -s 2>/dev/null || echo "Unknown") os=$(uname -s 2>/dev/null || echo "Unknown")
arch=$(uname -m 2>/dev/null || echo "Unknown") arch=$(uname -m 2>/dev/null || echo "Unknown")
# First check for China IP
check_china check_china
# Get latest version number with multiple backup sources ECS_VERSION="0.1.44"
ECS_VERSION=""
for api in \ for api in \
"https://api.github.com/repos/oneclickvirt/ecs/releases/latest" \ "https://api.github.com/repos/oneclickvirt/ecs/releases/latest" \
"https://githubapi.spiritlhl.workers.dev/repos/oneclickvirt/ecs/releases/latest" \ "https://githubapi.spiritlhl.workers.dev/repos/oneclickvirt/ecs/releases/latest" \
@@ -137,10 +155,9 @@ goecs_check() {
sleep 1 sleep 1
done done
if [ -z "$ECS_VERSION" ]; then if [ -z "$ECS_VERSION" ]; then
_yellow "Unable to get version info, using default version 0.1.33" _yellow "Unable to get version info, using default version 0.1.44"
ECS_VERSION="0.1.33" ECS_VERSION="0.1.44"
fi fi
# Check if original goecs command exists
version_output="" version_output=""
for cmd_path in "goecs" "./goecs" "/usr/bin/goecs" "/usr/local/bin/goecs"; do for cmd_path in "goecs" "./goecs" "/usr/bin/goecs" "/usr/local/bin/goecs"; do
if [ -x "$(command -v $cmd_path 2>/dev/null)" ]; then if [ -x "$(command -v $cmd_path 2>/dev/null)" ]; then
@@ -164,7 +181,6 @@ goecs_check() {
_green "goecs not found, installation needed, starting in 5 seconds" _green "goecs not found, installation needed, starting in 5 seconds"
fi fi
sleep 5 sleep 5
# Download corresponding version with error handling
if [[ "$CN" == true ]]; then if [[ "$CN" == true ]]; then
_yellow "Using China mirror for download..." _yellow "Using China mirror for download..."
base_url="https://cnb.cool/oneclickvirt/ecs/-/git/raw/main" base_url="https://cnb.cool/oneclickvirt/ecs/-/git/raw/main"
@@ -177,7 +193,6 @@ goecs_check() {
base_url="https://github.com/oneclickvirt/ecs/releases/download/v${ECS_VERSION}" base_url="https://github.com/oneclickvirt/ecs/releases/download/v${ECS_VERSION}"
fi fi
fi fi
# Build download URL with architecture support
local zip_file="" local zip_file=""
case $os in case $os in
Linux|linux|LINUX) Linux|linux|LINUX)
@@ -215,7 +230,6 @@ goecs_check() {
esac esac
download_url="${base_url}/${zip_file}" download_url="${base_url}/${zip_file}"
_green "Downloading $download_url" _green "Downloading $download_url"
# Download file with retry mechanism
local max_retries=3 local max_retries=3
local retry_count=0 local retry_count=0
while [ $retry_count -lt $max_retries ]; do while [ $retry_count -lt $max_retries ]; do
@@ -230,29 +244,11 @@ goecs_check() {
_red "Download failed, please check your network connection or download manually" _red "Download failed, please check your network connection or download manually"
return 1 return 1
fi fi
if ! command -v unzip >/dev/null 2>&1; then
_green "Installing $cmd"
if command -v apt-get >/dev/null 2>&1; then
INSTALL_CMD="apt-get -y install"
elif command -v yum >/dev/null 2>&1; then
INSTALL_CMD="yum -y install"
elif command -v dnf >/dev/null 2>&1; then
INSTALL_CMD="dnf -y install"
elif command -v pacman >/dev/null 2>&1; then
INSTALL_CMD="pacman -S --noconfirm"
elif command -v apk >/dev/null 2>&1; then
INSTALL_CMD="apk add"
elif command -v zypper >/dev/null 2>&1; then
INSTALL_CMD="zypper install -y"
fi
${INSTALL_CMD} "$cmd"
fi
if ! unzip -o goecs.zip >/dev/null 2>&1; then if ! unzip -o goecs.zip >/dev/null 2>&1; then
_red "Extraction failed" _red "Extraction failed"
return 1 return 1
fi fi
rm -f goecs.zip README.md LICENSE README_EN.md rm -f goecs.zip README.md LICENSE README_EN.md
# Set execution permissions and install
chmod 777 goecs chmod 777 goecs
for install_path in "/usr/bin" "/usr/local/bin"; do for install_path in "/usr/bin" "/usr/local/bin"; do
if [ -d "$install_path" ]; then if [ -d "$install_path" ]; then
@@ -260,7 +256,6 @@ goecs_check() {
break break
fi fi
done done
# Set system parameters
if [ "$os" != "Darwin" ]; then if [ "$os" != "Darwin" ]; then
PARAM="net.ipv4.ping_group_range" PARAM="net.ipv4.ping_group_range"
NEW_VALUE="0 2147483647" NEW_VALUE="0 2147483647"
@@ -273,7 +268,6 @@ goecs_check() {
sysctl -p >/dev/null 2>&1 sysctl -p >/dev/null 2>&1
fi fi
fi fi
# Set special permissions
setcap cap_net_raw=+ep goecs 2>/dev/null setcap cap_net_raw=+ep goecs 2>/dev/null
setcap cap_net_raw=+ep /usr/bin/goecs 2>/dev/null setcap cap_net_raw=+ep /usr/bin/goecs 2>/dev/null
setcap cap_net_raw=+ep /usr/local/bin/goecs 2>/dev/null setcap cap_net_raw=+ep /usr/local/bin/goecs 2>/dev/null
@@ -320,15 +314,15 @@ InstallSysbench() {
fi fi
fi fi
case "$Var_OSRelease" in case "$Var_OSRelease" in
ubuntu | debian | astra) ubuntu | debian | astra)
! apt-get install -y sysbench && apt-get --fix-broken install -y && apt-get install --no-install-recommends -y sysbench ;; ! apt-get install -y sysbench && apt-get --fix-broken install -y && apt-get install --no-install-recommends -y sysbench ;;
centos | rhel | almalinux | redhat | opencloudos) centos | rhel | almalinux | redhat | opencloudos)
(yum -y install epel-release && yum -y install sysbench) || (dnf install epel-release -y && dnf install sysbench -y) ;; (yum -y install epel-release && yum -y install sysbench) || (dnf install epel-release -y && dnf install sysbench -y) ;;
fedora) fedora)
dnf -y install sysbench ;; dnf -y install sysbench ;;
arch) arch)
pacman -S --needed --noconfirm sysbench && pacman -S --needed --noconfirm libaio && ldconfig ;; pacman -S --needed --noconfirm sysbench && pacman -S --needed --noconfirm libaio && ldconfig ;;
freebsd) freebsd)
pkg install -y sysbench ;; pkg install -y sysbench ;;
alpinelinux) alpinelinux)
if [ "$noninteractive" != "true" ]; then if [ "$noninteractive" != "true" ]; then
@@ -359,7 +353,7 @@ InstallSysbench() {
echo -e "${Msg_Success}Sysbench installed successfully." echo -e "${Msg_Success}Sysbench installed successfully."
fi fi
fi ;; fi ;;
*) *)
_red "Sysbench Install Error: Unknown OS release: $Var_OSRelease" ;; _red "Sysbench Install Error: Unknown OS release: $Var_OSRelease" ;;
esac esac
if [[ $SYSTEM =~ ^(CentOS|RHEL|AlmaLinux)$ ]]; then if [[ $SYSTEM =~ ^(CentOS|RHEL|AlmaLinux)$ ]]; then
@@ -442,7 +436,6 @@ env_check() {
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 --no-cache" "pkg_add -I" "yum -y install") 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 --no-cache" "pkg_add -I" "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" "pkg_delete -I" "yum -y remove") 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" "pkg_delete -I" "yum -y remove")
PACKAGE_UNINSTALL=("apt-get -y autoremove" "apt-get -y autoremove" "yum -y autoremove" "yum -y autoremove" "yum -y autoremove" "pacman -Rns --noconfirm" "pkg autoremove" "apk autoremove" "pkg_delete -a" "yum -y autoremove") PACKAGE_UNINSTALL=("apt-get -y autoremove" "apt-get -y autoremove" "yum -y autoremove" "yum -y autoremove" "yum -y autoremove" "pacman -Rns --noconfirm" "pkg autoremove" "apk autoremove" "pkg_delete -a" "yum -y autoremove")
# Check system information
if [ -f /etc/opencloudos-release ]; then if [ -f /etc/opencloudos-release ]; then
SYS="opencloudos" SYS="opencloudos"
elif [ -s /etc/os-release ]; then elif [ -s /etc/os-release ]; then
@@ -460,7 +453,6 @@ env_check() {
else else
SYS="$(uname -s)" SYS="$(uname -s)"
fi fi
# Match operating system
SYSTEM="" SYSTEM=""
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
@@ -472,7 +464,6 @@ env_check() {
break break
fi fi
done done
# If system is unrecognized, try common package managers
if [ -z "$SYSTEM" ]; then if [ -z "$SYSTEM" ]; then
_yellow "Unable to recognize system, trying common package managers..." _yellow "Unable to recognize system, trying common package managers..."
if command -v apt-get >/dev/null 2>&1; then if command -v apt-get >/dev/null 2>&1; then
@@ -539,14 +530,12 @@ env_check() {
fi fi
fi fi
fi fi
# Install necessary commands
for cmd in sudo wget tar unzip iproute2 systemd-detect-virt dd fio; do for cmd in sudo wget tar unzip iproute2 systemd-detect-virt dd fio; do
if ! command -v "$cmd" >/dev/null 2>&1; then if ! command -v "$cmd" >/dev/null 2>&1; then
_green "Installing $cmd" _green "Installing $cmd"
${INSTALL_CMD} "$cmd" ${INSTALL_CMD} "$cmd"
fi fi
done done
# sysbench installation
if ! command -v sysbench >/dev/null 2>&1; then if ! command -v sysbench >/dev/null 2>&1; then
_green "Installing sysbench" _green "Installing sysbench"
${INSTALL_CMD} sysbench ${INSTALL_CMD} sysbench
@@ -561,7 +550,6 @@ env_check() {
Check_SysBench Check_SysBench
fi fi
fi fi
# geekbench and speedtest installation
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
@@ -580,7 +568,6 @@ env_check() {
${INSTALL_CMD} iputils-ping >/dev/null 2>&1 ${INSTALL_CMD} iputils-ping >/dev/null 2>&1
${INSTALL_CMD} ping >/dev/null 2>&1 ${INSTALL_CMD} ping >/dev/null 2>&1
fi fi
# MacOS support
if [ "$(uname -s)" = "Darwin" ]; then if [ "$(uname -s)" = "Darwin" ]; then
echo "Detected MacOS, installing sysbench iproute2mac..." echo "Detected MacOS, installing sysbench iproute2mac..."
brew install --force sysbench iproute2mac brew install --force sysbench iproute2mac
@@ -616,7 +603,7 @@ show_help() {
3. 关键服务失败 3. 关键服务失败
推荐: 推荐:
环境依赖安装过程中挂起执行 环境依赖安装过程中挂起执行
可选组件: 可选组件:
sysbench/geekbench (CPU性能测试) sysbench/geekbench (CPU性能测试)
sudo, tar, unzip, dd, fio sudo, tar, unzip, dd, fio
@@ -643,7 +630,7 @@ Available commands:
3. Critical service failures 3. Critical service failures
Recommended: Recommended:
Hanging execution during environment dependency installation Hanging execution during environment dependency installation
Optional components: Optional components:
sysbench/geekbench (CPU testing) sysbench/geekbench (CPU testing)
sudo, tar, unzip, dd, fio sudo, tar, unzip, dd, fio
@@ -677,4 +664,3 @@ case "$1" in
show_help show_help
;; ;;
esac esac

View File

@@ -31,5 +31,5 @@ func MemoryTest(language, testMethod string) {
if !strings.Contains(res, "\n") && res != "" { if !strings.Contains(res, "\n") && res != "" {
res += "\n" res += "\n"
} }
fmt.Printf(res) fmt.Printf("%s", res)
} }

View File

@@ -6,5 +6,5 @@ import (
) )
func Test(t *testing.T) { func Test(t *testing.T) {
fmt.Printf(MediaTest("zh")) fmt.Printf("%s", MediaTest("zh"))
} }

View File

@@ -3,13 +3,11 @@ package utils
import ( import (
"bufio" "bufio"
"bytes" "bytes"
"context"
"fmt" "fmt"
"github.com/imroc/req/v3"
"github.com/oneclickvirt/UnlockTests/uts"
"github.com/oneclickvirt/basics/system"
. "github.com/oneclickvirt/defaultset"
"github.com/oneclickvirt/security/network"
"io" "io"
"net"
"net/http"
"os" "os"
"path/filepath" "path/filepath"
"regexp" "regexp"
@@ -17,6 +15,12 @@ import (
"sync" "sync"
"time" "time"
"unicode/utf8" "unicode/utf8"
"github.com/imroc/req/v3"
"github.com/oneclickvirt/UnlockTests/uts"
"github.com/oneclickvirt/basics/system"
. "github.com/oneclickvirt/defaultset"
"github.com/oneclickvirt/security/network"
) )
// PrintCenteredTitle 根据指定的宽度打印居中标题 // PrintCenteredTitle 根据指定的宽度打印居中标题
@@ -95,14 +99,14 @@ func CheckChina(enableLogger bool) bool {
} }
// BasicsAndSecurityCheck 执行安全检查 // BasicsAndSecurityCheck 执行安全检查
func BasicsAndSecurityCheck(language, nt3CheckType string, securtyCheckStatus bool) (string, string, string) { func BasicsAndSecurityCheck(language, nt3CheckType string, securityCheckStatus 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(1) 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", securityCheckStatus, language)
if err != nil { if err != nil {
fmt.Println(err.Error()) fmt.Println(err.Error())
} }
@@ -330,3 +334,159 @@ func ProcessAndUpload(output string, filePath string, enableUplaod bool) (string
} }
return "", "" return "", ""
} }
// ============================= 前置联网能力检测 =============================
var StackType string
type NetCheckResult struct {
HasIPv4 bool
HasIPv6 bool
Connected bool
StackType string // "IPv4", "IPv6", "DualStack", "None"
}
func makeResolver(proto, dnsAddr string) *net.Resolver {
return &net.Resolver{
PreferGo: true,
Dial: func(ctx context.Context, network, address string) (net.Conn, error) {
d := net.Dialer{
Timeout: 5 * time.Second,
}
return d.DialContext(ctx, proto, dnsAddr)
},
}
}
func CheckPublicAccess(timeout time.Duration) NetCheckResult {
if timeout < 2*time.Second {
timeout = 2 * time.Second
}
var wg sync.WaitGroup
resultChan := make(chan string, 8)
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
checks := []struct {
Tag string
Addr string
Kind string // udp4, udp6, http4, http6
}{
// UDP DNS
{"IPv4", "223.5.5.5:53", "udp4"}, // 阿里 DNS
{"IPv4", "8.8.8.8:53", "udp4"}, // Google DNS
{"IPv6", "[2400:3200::1]:53", "udp6"}, // 阿里 IPv6 DNS
{"IPv6", "[2001:4860:4860::8888]:53", "udp6"}, // Google IPv6 DNS
// HTTP HEAD
{"IPv4", "https://www.baidu.com", "http4"}, // 百度
{"IPv4", "https://1.1.1.1", "http4"}, // Cloudflare
{"IPv6", "https://[2400:3200::1]", "http6"}, // 阿里 IPv6
{"IPv6", "https://[2606:4700::1111]", "http6"}, // Cloudflare IPv6
}
for _, check := range checks {
wg.Add(1)
go func(tag, addr, kind string) {
defer wg.Done()
defer func() {
if r := recover(); r != nil {
}
}()
switch kind {
case "udp4", "udp6":
dialer := &net.Dialer{
Timeout: timeout / 4,
}
conn, err := dialer.DialContext(ctx, kind, addr)
if err == nil && conn != nil {
conn.Close()
select {
case resultChan <- tag:
case <-ctx.Done():
return
}
}
case "http4", "http6":
var resolver *net.Resolver
if kind == "http4" {
resolver = makeResolver("udp4", "223.5.5.5:53")
} else {
resolver = makeResolver("udp6", "[2400:3200::1]:53")
}
dialer := &net.Dialer{
Timeout: timeout / 4,
Resolver: resolver,
}
transport := &http.Transport{
DialContext: dialer.DialContext,
MaxIdleConns: 1,
MaxIdleConnsPerHost: 1,
IdleConnTimeout: time.Second,
TLSHandshakeTimeout: timeout / 4,
ResponseHeaderTimeout: timeout / 4,
DisableKeepAlives: true,
}
client := &http.Client{
Timeout: timeout / 4,
Transport: transport,
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
},
}
req, err := http.NewRequestWithContext(ctx, "HEAD", addr, nil)
if err != nil {
return
}
resp, err := client.Do(req)
if err == nil && resp != nil {
if resp.Body != nil {
resp.Body.Close()
}
if resp.StatusCode < 500 {
select {
case resultChan <- tag:
case <-ctx.Done():
return
}
}
}
}
}(check.Tag, check.Addr, check.Kind)
}
go func() {
wg.Wait()
close(resultChan)
}()
hasV4 := false
hasV6 := false
for {
select {
case res, ok := <-resultChan:
if !ok {
goto result
}
if res == "IPv4" {
hasV4 = true
}
if res == "IPv6" {
hasV6 = true
}
case <-ctx.Done():
goto result
}
}
result:
stack := "None"
if hasV4 && hasV6 {
stack = "DualStack"
} else if hasV4 {
stack = "IPv4"
} else if hasV6 {
stack = "IPv6"
}
StackType = stack
return NetCheckResult{
HasIPv4: hasV4,
HasIPv6: hasV6,
Connected: hasV4 || hasV6,
StackType: stack,
}
}

17
utils/utils_test.go Normal file
View File

@@ -0,0 +1,17 @@
package utils
import (
"fmt"
"testing"
"time"
)
func TestCheckPublicAccess(t *testing.T) {
timeout := 3 * time.Second
result := CheckPublicAccess(timeout)
if result.Connected {
fmt.Printf("✅ 本机有公网连接,类型: %s\n", result.StackType)
} else {
fmt.Println("❌ 本机未检测到公网连接")
}
}