├── .github └── workflows │ ├── build_docker.yaml │ ├── main.yaml │ ├── public-build.yml │ └── sync.yaml ├── .gitignore ├── .goreleaser.yaml ├── Dockerfile ├── LICENSE ├── README.md ├── README_EN.md ├── README_NEW_USER.md ├── back ├── backtrace │ ├── backtrace.go │ └── backtrace_test.go ├── basic │ ├── basic_test.go │ └── basiccheck.go ├── commediatest │ ├── media.go │ └── media_test.go ├── network │ ├── network.go │ └── network_test.go ├── ntrace │ ├── ntrace.go │ └── ntrace_test.go └── port │ ├── port.go │ └── port_test.go ├── cputest ├── cputest.go └── cputest_test.go ├── disktest ├── disktest.go └── disktest_test.go ├── go.mod ├── go.sum ├── goecs.go ├── goecs.sh ├── goecs_test.go ├── memorytest ├── memorytest.go └── memorytest_test.go ├── speedtest ├── sp.go └── sp_test.go ├── unlocktest ├── media.go └── media_test.go └── utils └── utils.go /.github/workflows/build_docker.yaml: -------------------------------------------------------------------------------- 1 | name: Build and Push Docker Image 2 | 3 | on: 4 | release: 5 | types: [ published ] 6 | workflow_dispatch: 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Checkout repository 13 | uses: actions/checkout@v2 14 | 15 | - name: Set up QEMU 16 | uses: docker/setup-qemu-action@v2 17 | with: 18 | platforms: all 19 | 20 | - name: Set up Docker Buildx 21 | uses: docker/setup-buildx-action@v2 22 | 23 | - name: Log in to Docker Hub 24 | uses: docker/login-action@v2 25 | with: 26 | username: ${{ secrets.DOCKER_USERNAME }} 27 | password: ${{ secrets.DOCKER_PASSWORD }} 28 | 29 | - name: Login to CNB Registry 30 | uses: docker/login-action@v2 31 | with: 32 | registry: ${{ secrets.CNB_DOCKER_REGISTRY }} 33 | username: ${{ secrets.CNB_USERNAME }} 34 | password: ${{ secrets.CNB_TOKEN }} 35 | 36 | - name: Build and push Docker images 37 | uses: docker/build-push-action@v4 38 | with: 39 | context: . 40 | file: ./Dockerfile 41 | platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/riscv64 42 | # linux/mips,linux/mipsle 暂不支持 alpine, linux/s390x 编译卡死 43 | push: true 44 | tags: | 45 | ${{ secrets.DOCKER_USERNAME }}/goecs:latest 46 | ${{ secrets.CNB_DOCKER_REGISTRY }}/oneclickvirt/ecs:latest 47 | -------------------------------------------------------------------------------- /.github/workflows/main.yaml: -------------------------------------------------------------------------------- 1 | name: goreleaser 2 | 3 | on: 4 | workflow_dispatch: 5 | tags: 6 | - "v*.*.*" 7 | 8 | jobs: 9 | goreleaser: 10 | runs-on: ubuntu-latest 11 | container: 12 | # 1.20 是 Windows 7/8 Server 2008/2012 最后一个支持版本 13 | image: goreleaser/goreleaser-cross:v1.20 14 | steps: 15 | - run: | 16 | git config --global --add safe.directory /__w/ecs/ecs 17 | - name: Checkout 18 | uses: actions/checkout@v3 19 | with: 20 | fetch-depth: 0 21 | 22 | - name: Set up Go 23 | uses: actions/setup-go@v4 24 | with: 25 | go-version: 1.23.4 26 | 27 | - name: Configure Git for Private Modules 28 | run: | 29 | git config --global url."https://${{ secrets.GHT }}@github.com/".insteadOf "https://github.com/" 30 | git config --global url."git@github.com:".insteadOf "https://github.com/" 31 | env: 32 | GITHUB_TOKEN: ${{ secrets.GHT }} 33 | 34 | - name: Run GoReleaser 35 | uses: goreleaser/goreleaser-action@v2 36 | with: 37 | distribution: goreleaser 38 | version: latest 39 | args: release 40 | env: 41 | GITHUB_TOKEN: ${{ secrets.GHT }} 42 | GOPRIVATE: github.com/oneclickvirt/security 43 | -------------------------------------------------------------------------------- /.github/workflows/public-build.yml: -------------------------------------------------------------------------------- 1 | name: Public Build 2 | 3 | on: 4 | release: 5 | types: [ published ] 6 | workflow_dispatch: 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/checkout@v4 14 | with: 15 | fetch-depth: 0 16 | 17 | - name: Set up Go 18 | uses: actions/setup-go@v5 19 | with: 20 | go-version: '1.23.4' 21 | 22 | - name: Create public branch 23 | run: | 24 | git config --global user.name 'GitHub Actions' 25 | git config --global user.email 'actions@github.com' 26 | git checkout -b public || git checkout public 27 | git merge ${{ github.ref_name }} --no-edit || true 28 | 29 | - name: Remove security package references 30 | run: | 31 | # 移除 network 包中对 security 的引用 32 | find . -type f -name "*.go" -exec sed -i 's|"github.com/oneclickvirt/security/network"|"github.com/oneclickvirt/basics/network"|g' {} + 33 | # 修改 back/network/network.go 34 | cat > back/network/network.go << 'EOF' 35 | package network1 36 | 37 | import "github.com/oneclickvirt/basics/network" 38 | 39 | func NetworkCheck(checkType string, enableSecurityCheck bool, language string) (string, string, error) { 40 | ipInfo, _, err := network.NetworkCheck(checkType, false, language) 41 | return ipInfo, "", err 42 | } 43 | EOF 44 | 45 | # 修改 utils/utils.go 中的 BasicsAndSecurityCheck 函数 46 | sed -i '/SecurityUploadToken/d' utils/utils.go 47 | sed -i 's|"github.com/oneclickvirt/security/network"|"github.com/oneclickvirt/basics/network"|g' utils/utils.go 48 | 49 | # 在 utils/utils.go 中添加 token 常量(在 import 语句之后) 50 | sed -i '/^import/,/^)/{/^)/a\'$'\n''const token = "OvwKx5qgJtf7PZgCKbtyojSU.MTcwMTUxNzY1MTgwMw"'$'\n''}' utils/utils.go 51 | 52 | # 修改 go.mod,移除私有仓库依赖 53 | sed -i '/github.com\/oneclickvirt\/security/d' go.mod 54 | 55 | # 修改 goecs.go,禁用 security 检测 56 | sed -i 's|var securityFlag = flag.Bool("security", true,|var securityFlag = flag.Bool("security", false,|g' goecs.go 57 | 58 | # 更新依赖 59 | go mod tidy 60 | 61 | # 修改 README.md 和 README_EN.md 中的敏感信息 62 | sed -i 's|但二进制文件编译至 \[securityCheck\].*)|但已开源|g' README.md 63 | sed -i 's|but binary files compiled in \[securityCheck\].*)|but open sourced|g' README_EN.md 64 | 65 | # 修改命令行帮助信息 66 | sed -i 's|security.*Enable/Disable security test (default true)|security Enable/Disable security test (default false)|g' README.md 67 | sed -i 's|security.*Enable/Disable security test (default true)|security Enable/Disable security test (default false)|g' README_EN.md 68 | 69 | - name: Build and Test 70 | run: | 71 | # 构建二进制文件 72 | go build -o maintest 73 | # 测试无菜单模式是否正常运行(禁用 security 检测) 74 | ./maintest -menu=false -l en -security=false -upload=false || exit 1 75 | rm -rf maintest 76 | 77 | - name: Commit and push changes 78 | run: | 79 | git add . 80 | git commit -m "Auto update public version (no security package)" || echo "No changes to commit" 81 | git push -f origin public 82 | -------------------------------------------------------------------------------- /.github/workflows/sync.yaml: -------------------------------------------------------------------------------- 1 | name: Sync Latest Release 2 | 3 | on: 4 | release: 5 | types: [published] 6 | workflow_dispatch: 7 | 8 | jobs: 9 | sync-release: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Checkout source repository 13 | uses: actions/checkout@v4 14 | with: 15 | fetch-depth: 0 16 | 17 | - name: Get latest release 18 | id: get_release 19 | run: | 20 | echo "RELEASE_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV 21 | 22 | - name: Create temporary directory 23 | run: | 24 | mkdir -p temp_repo 25 | cd temp_repo 26 | git init 27 | git config --local user.name "GitHub Action" 28 | git config --local user.email "action@github.com" 29 | 30 | - name: Copy repository files 31 | run: | 32 | cp goecs.sh temp_repo/ 33 | cp README_EN.md temp_repo/ 34 | cp README.md temp_repo/ 35 | cp LICENSE temp_repo/ 36 | 37 | - name: Download release assets 38 | run: | 39 | cd temp_repo 40 | gh release download ${{ env.RELEASE_TAG }} --repo ${{ github.repository }} --dir . 41 | env: 42 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 43 | 44 | - name: Push to target repository 45 | run: | 46 | cd temp_repo 47 | git add . 48 | git commit -m "Sync release ${{ env.RELEASE_TAG }} from ${{ github.repository }}" 49 | git branch -M main 50 | git remote add target https://cnb.cool/oneclickvirt/ecs.git 51 | echo "machine cnb.cool login ${{ secrets.CNB_USERNAME }} password ${{ secrets.CNB_TOKEN }}" > ~/.netrc 52 | chmod 600 ~/.netrc 53 | git push -f target main 54 | env: 55 | CNB_USERNAME: ${{ secrets.CNB_USERNAME }} 56 | CNB_TOKEN: ${{ secrets.CNB_TOKEN }} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | vendor/ 2 | .idea/ -------------------------------------------------------------------------------- /.goreleaser.yaml: -------------------------------------------------------------------------------- 1 | before: 2 | hooks: 3 | - go mod tidy -v 4 | builds: 5 | - id: universal 6 | env: 7 | - CGO_ENABLED=0 8 | ldflags: 9 | - -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 10 | goos: 11 | - linux 12 | - windows 13 | - freebsd 14 | goarch: 15 | - arm 16 | - arm64 17 | - 386 18 | - amd64 19 | - mips 20 | - mipsle 21 | - s390x 22 | - riscv64 23 | gomips: 24 | - softfloat 25 | ignore: 26 | - goos: windows 27 | goarch: arm 28 | main: ./ 29 | binary: goecs 30 | - id: darwin-amd64 31 | env: 32 | - CGO_ENABLED=1 33 | - CC=o64-clang 34 | - CXX=o64-clang++ 35 | ldflags: 36 | - -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 37 | goos: 38 | - darwin 39 | goarch: 40 | - amd64 41 | main: ./ 42 | binary: goecs 43 | - id: darwin-arm64 44 | env: 45 | - CGO_ENABLED=1 46 | - CC=oa64-clang 47 | - CXX=oa64-clang++ 48 | ldflags: 49 | - -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 50 | goos: 51 | - darwin 52 | goarch: 53 | - arm64 54 | main: ./ 55 | binary: goecs 56 | universal_binaries: 57 | - name_template: "goecs" 58 | replace: false 59 | checksum: 60 | name_template: "checksums.txt" 61 | snapshot: 62 | name_template: "goecs" 63 | archives: 64 | - name_template: "goecs_{{ .Os }}_{{ .Arch }}" 65 | format: zip 66 | files: 67 | - none* 68 | changelog: 69 | sort: asc 70 | filters: 71 | exclude: 72 | - "^docs:" 73 | - "^test:" 74 | - "^chore" 75 | - Merge pull request 76 | - Merge branch 77 | - go mod tidy 78 | - New translations -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1 2 | FROM alpine:latest 3 | # 安装必要的工具 4 | RUN apk add --no-cache wget curl bash 5 | RUN apk add --no-cache bind-tools 6 | # --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main 7 | RUN apk add --no-cache grep openssl ca-certificates uuidgen 8 | RUN export noninteractive=true 9 | # 下载并执行 goecs.sh 脚本 10 | RUN curl -L https://raw.githubusercontent.com/oneclickvirt/ecs/master/goecs.sh -o goecs.sh && \ 11 | chmod +x goecs.sh && \ 12 | bash goecs.sh env && \ 13 | bash goecs.sh install 14 | # 设置 goecs 为入口点 15 | ENTRYPOINT ["goecs"] 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ECS 2 | 3 | [![release](https://github.com/oneclickvirt/ecs/actions/workflows/main.yaml/badge.svg)](https://github.com/oneclickvirt/ecs/actions/workflows/main.yaml) 4 | 5 | [![Hits](https://hits.spiritlhl.net/goecs.svg?action=hit&title=Hits&title_bg=%23555555&count_bg=%230eecf8&edge_flat=false)](https://hits.spiritlhl.net) 6 | 7 | 融合怪测评项目 - GO版本 8 | 9 | (环境安装[非必须]使用shell外无额外shell文件依赖,环境安装只是为了测的更准,极端情况下无环境依赖安装也可全测项目) 10 | 11 | 如有问题请 [issues](https://github.com/oneclickvirt/ecs/issues) 反馈。 12 | 13 | Go 版本:[https://github.com/oneclickvirt/ecs](https://github.com/oneclickvirt/ecs) 14 | 15 | Shell 版本:[https://github.com/spiritLHLS/ecs](https://github.com/spiritLHLS/ecs) 16 | 17 | --- 18 | 19 | ## **语言** 20 | 21 | [中文文档](README.md) | [English Docs](README_EN.md) 22 | 23 | --- 24 | 25 | ## **适配系统和架构** 26 | 27 | ### **编译与测试支持情况** 28 | | 编译支持的架构 | 测试支持的架构 | 编译支持的系统 | 测试支持的系统 | 29 | |---------------------------|-----------|---------|-----------| 30 | | amd64 | amd64 | Linux | Linux | 31 | | arm | arm | Windows | Windows | 32 | | arm64 | arm64 | FreeBSD | FreeBSD | 33 | | 386 | 386 | OpenBSD | | 34 | | mips | | MacOS | | 35 | | mipsle | | | | 36 | | s390x | s390x | | | 37 | | riscv64 | | | | 38 | 39 | 40 | > 更多架构与系统请自行测试,如有问题请开 issues。 41 | 42 | ### **待支持的系统** 43 | | 系统 | 说明 | 44 | |-----|---------------------------| 45 | | MacOS | 存在硬件测试 BUG 未修复,存在环境依赖未修复 | 46 | | Android(arm64) | 存在权限问题未修复,非安卓系统的ARM架构无问题 | 47 | 48 | --- 49 | 50 | ## **功能** 51 | 52 | - 系统基础信息查询,IP基础信息并发查询:[basics](https://github.com/oneclickvirt/basics)、[gostun](https://github.com/oneclickvirt/gostun) 53 | - CPU 测试:[cputest](https://github.com/oneclickvirt/cputest),支持 sysbench(lua/golang版本)、geekbench、winsat 54 | - 内存测试:[memorytest](https://github.com/oneclickvirt/memorytest),支持 sysbench、dd 55 | - 硬盘测试:[disktest](https://github.com/oneclickvirt/disktest),支持 dd、fio、winsat 56 | - 流媒体解锁信息并发查询:[netflix-verify](https://github.com/sjlleo/netflix-verify) 等逻辑,开发至 [CommonMediaTests](https://github.com/oneclickvirt/CommonMediaTests) 57 | - 常见流媒体测试并发查询:[UnlockTests](https://github.com/oneclickvirt/UnlockTests),逻辑借鉴 [RegionRestrictionCheck](https://github.com/lmc999/RegionRestrictionCheck) 等 58 | - IP 质量/安全信息并发查询:二进制文件编译至 [securityCheck](https://github.com/oneclickvirt/securityCheck) 59 | - 邮件端口测试:[portchecker](https://github.com/oneclickvirt/portchecker) 60 | - 三网回程测试:借鉴 [zhanghanyun/backtrace](https://github.com/zhanghanyun/backtrace),二次开发至 [oneclickvirt/backtrace](https://github.com/oneclickvirt/backtrace) 61 | - 三网路由测试:基于 [NTrace-core](https://github.com/nxtrace/NTrace-core),二次开发至 [nt3](https://github.com/oneclickvirt/nt3) 62 | - 网速测试:基于 [speedtest.net](https://github.com/spiritLHLS/speedtest.net-CN-ID) 和 [speedtest.cn](https://github.com/spiritLHLS/speedtest.cn-CN-ID) 数据,开发至 [oneclickvirt/speedtest](https://github.com/oneclickvirt/speedtest) 63 | - 三网 Ping 值测试:借鉴 [ecsspeed](https://github.com/spiritLHLS/ecsspeed),二次开发至 [pingtest](https://github.com/oneclickvirt/pingtest) 64 | 65 | **本项目初次使用建议查看说明:[跳转](https://github.com/oneclickvirt/ecs/blob/master/README_NEW_USER.md)** 66 | 67 | --- 68 | 69 | ## **使用说明** 70 | 71 | ### **Linux/FreeBSD/OpenBSD/MacOS** 72 | 73 | #### **一键命令** 74 | 75 | **一键命令**将**默认安装依赖**,**默认更新包管理器**,**默认非互动模式** 76 | 77 | - **国际用户无加速:** 78 | 79 | ```bash 80 | export noninteractive=true && 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 81 | ``` 82 | 83 | - **国际/国内使用 CDN 加速:** 84 | 85 | ```bash 86 | export noninteractive=true && curl -L https://cdn.spiritlhl.net/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 87 | ``` 88 | 89 | - **国内用户使用 CNB 加速:** 90 | 91 | ```bash 92 | 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 93 | ``` 94 | 95 | - **短链接:** 96 | 97 | ```bash 98 | 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 99 | ``` 100 | 101 | #### **详细说明** 102 | 103 | **详细说明**中的命令**可控制是否安装依赖**,**是否更新包管理器**,**默认互动模式可进行选择** 104 | 105 |
106 | 展开查看详细说明 107 | 108 | 1. **下载脚本** 109 | 110 | **国际用户无加速:** 111 | 112 | ```bash 113 | curl -L https://raw.githubusercontent.com/oneclickvirt/ecs/master/goecs.sh -o goecs.sh && chmod +x goecs.sh 114 | ``` 115 | 116 | **国际/国内使用 CDN 加速:** 117 | 118 | ```bash 119 | curl -L https://cdn.spiritlhl.net/https://raw.githubusercontent.com/oneclickvirt/ecs/master/goecs.sh -o goecs.sh && chmod +x goecs.sh 120 | ``` 121 | 122 | **国内用户使用 CNB 加速:** 123 | 124 | ```bash 125 | curl -L https://cnb.cool/oneclickvirt/ecs/-/git/raw/main/goecs.sh -o goecs.sh && chmod +x goecs.sh 126 | ``` 127 | 128 | 2. **更新包管理器(可选择)并安装环境** 129 | 130 | ```bash 131 | ./goecs.sh env 132 | ``` 133 | 134 | **非互动模式:** 135 | 136 | ```bash 137 | export noninteractive=true && ./goecs.sh env 138 | ``` 139 | 140 | 3. **安装 `goecs`** 141 | 142 | ```bash 143 | ./goecs.sh install 144 | ``` 145 | 146 | 4. **升级 `goecs`** 147 | 148 | ```bash 149 | ./goecs.sh upgrade 150 | ``` 151 | 152 | 5. **卸载 `goecs`** 153 | 154 | ```bash 155 | ./goecs.sh uninstall 156 | ``` 157 | 158 | 6. **帮助命令** 159 | 160 | ```bash 161 | ./goecs.sh -h 162 | ``` 163 | 164 | 7. **唤起菜单** 165 | 166 | ```bash 167 | goecs 168 | ``` 169 | 170 |
171 | 172 | --- 173 | 174 | #### **命令参数化** 175 | 176 |
177 | 展开查看各参数说明 178 | 179 | ```bash 180 | Usage: goecs [options] 181 | -backtrace 182 | Enable/Disable backtrace test (in 'en' language or on windows it always false) (default true) 183 | -basic 184 | Enable/Disable basic test (default true) 185 | -comm 186 | Enable/Disable common media test (default true) 187 | -cpu 188 | Enable/Disable CPU test (default true) 189 | -cpum string 190 | Set CPU test method (supported: sysbench, geekbench, winsat) (default "sysbench") 191 | -cput string 192 | Set CPU test thread mode (supported: single, multi) (default "multi") 193 | -disk 194 | Enable/Disable disk test (default true) 195 | -diskm string 196 | Set disk test method (supported: fio, dd, winsat) (default "fio") 197 | -diskmc 198 | Enable/Disable multiple disk checks, e.g., -diskmc=false 199 | -diskp string 200 | Set disk test path, e.g., -diskp /root 201 | -email 202 | Enable/Disable email port test (default true) 203 | -h Show help information 204 | -l string 205 | Set language (supported: en, zh) (default "zh") 206 | -log 207 | Enable/Disable logging in the current path 208 | -memory 209 | Enable/Disable memory test (default true) 210 | -memorym string 211 | Set memory test method (supported: sysbench, dd, winsat) (default "sysbench") 212 | -menu 213 | Enable/Disable menu mode, disable example: -menu=false (default true) 214 | -nt3 215 | Enable/Disable NT3 test (in 'en' language or on windows it always false) (default true) 216 | -nt3loc string 217 | Specify NT3 test location (supported: GZ, SH, BJ, CD for Guangzhou, Shanghai, Beijing, Chengdu) (default "GZ") 218 | -nt3t string 219 | Set NT3 test type (supported: both, ipv4, ipv6) (default "ipv4") 220 | -security 221 | Enable/Disable security test (default true) 222 | -speed 223 | Enable/Disable speed test (default true) 224 | -spnum int 225 | Set the number of servers per operator for speed test (default 2) 226 | -upload 227 | Enable/Disable upload the result (default true) 228 | -ut 229 | Enable/Disable unlock media test (default true) 230 | -v Display version information 231 | ``` 232 |
233 | 234 | --- 235 | 236 | ### **Windows** 237 | 238 | 1. 下载带 exe 文件的压缩包:[Releases](https://github.com/oneclickvirt/ecs/releases) 239 | 2. 解压后,右键以管理员模式运行。 240 | 241 | --- 242 | 243 | ### **Docker** 244 | 245 |
246 | 展开查看使用说明 247 | 248 | 国际镜像地址:https://hub.docker.com/r/spiritlhl/goecs 249 | 250 | 请确保执行下述命令前本机已安装Docker 251 | 252 | 特权模式+host网络 253 | 254 | ```shell 255 | docker run --rm --privileged --network host spiritlhl/goecs:latest -menu=false -l zh 256 | ``` 257 | 258 | 非特权模式+非host网络 259 | 260 | ```shell 261 | docker run --rm spiritlhl/goecs:latest -menu=false -l zh 262 | ``` 263 | 264 | 使用Docker执行测试,硬件测试会有一些偏差和虚拟化架构判断失效,还是推荐直接测试而不使用Docker测试。 265 | 266 | 国内镜像地址:https://cnb.cool/oneclickvirt/ecs/-/packages/docker/ecs 267 | 268 | 请确保执行下述命令前本机已安装Docker 269 | 270 | 特权模式+host网络 271 | 272 | ```shell 273 | docker run --rm --privileged --network host docker.cnb.cool/oneclickvirt/ecs:latest -menu=false -l zh 274 | ``` 275 | 276 | 非特权模式+非host网络 277 | 278 | ```shell 279 | docker run --rm docker.cnb.cool/oneclickvirt/ecs:latest -menu=false -l zh 280 | ``` 281 | 282 |
283 | 284 | --- 285 | 286 | ### 从源码进行编译 287 | 288 |
289 | 展开查看编译说明 290 | 291 | 1. 克隆仓库的 public 分支(不含私有依赖) 292 | ```bash 293 | git clone -b public https://github.com/oneclickvirt/ecs.git 294 | cd ecs 295 | ``` 296 | 297 | 2. 安装 Go 环境(如已安装可跳过) 298 | ```bash 299 | # 下载并安装 Go 300 | wget https://go.dev/dl/go1.23.4.linux-amd64.tar.gz 301 | rm -rf /usr/local/go && tar -C /usr/local -xzf go1.23.4.linux-amd64.tar.gz 302 | export PATH=$PATH:/usr/local/go/bin 303 | ``` 304 | 305 | 3. 编译 306 | ```bash 307 | go build -o goecs 308 | ``` 309 | 310 | 4. 运行测试 311 | ```bash 312 | ./goecs -menu=false -l zh 313 | ``` 314 | 315 | 支持的编译参数: 316 | - GOOS:支持 linux、windows、darwin、freebsd、openbsd 317 | - GOARCH:支持 amd64、arm、arm64、386、mips、mipsle、s390x、riscv64 318 | 319 | 跨平台编译示例: 320 | ```bash 321 | # 编译 Windows 版本 322 | GOOS=windows GOARCH=amd64 go build -o goecs.exe 323 | # 编译 MacOS 版本 324 | GOOS=darwin GOARCH=amd64 go build -o goecs_darwin 325 | ``` 326 |
327 | 328 | --- 329 | 330 | ## QA 331 | 332 | #### Q: 为什么默认使用sysbench而不是geekbench 333 | 334 | #### A: 比较二者特点 335 | 336 | | 比较项 | sysbench | geekbench | 337 | |------------------|----------|-----------| 338 | | 适用范围 | 轻量级,几乎可在任何服务器上运行 | 重量级,小型机器无法运行 | 339 | | 测试要求 | 无需网络,无特殊硬件需求 | 需联网,IPV4环境,至少1G内存 | 340 | | 开源情况 | 基于LUA,开源,可自行编译各架构版本 | 官方二进制闭源代码,不支持自行编译 | 341 | | 测试稳定性 | 核心测试组件10年以上未变 | 每个大版本更新测试项,分数不同版本间难以对比(每个版本对标当前最好的CPU) | 342 | | 测试内容 | 仅测试计算性能 | 覆盖多种性能测试,分数加权计算,但部分测试实际不常用 | 343 | | 适用场景 | 适合快速测试,仅测试计算性能 | 适合综合全面的测试 | 344 | 345 | 且```goecs```测试使用何种CPU测试方式可使用参数指定,默认只是为了更多用户快速测试的需求 346 | 347 | #### Q: 为什么使用Golang而不是Rust重构 348 | 349 | #### A: 因为网络相关的项目目前以Golang语言为趋势,大多组件有开源生态维护,Rust很多得自己手搓,~~我懒得搞~~我没那个技术力 350 | 351 | #### Q: 为什么不继续开发Shell版本而是选择重构 352 | 353 | #### A: 因为太多千奇百怪的环境问题了,还是提前编译好测试的二进制文件比较容易解决环境问题(泛化性更好) 354 | 355 | #### Q: 每个测试项目的说明有吗? 356 | 357 | #### A: 每个测试项目有对应的维护仓库,自行点击查看仓库说明 358 | 359 | #### Q: 测试进行到一半如何手动终止? 360 | 361 | #### A: 按ctrl键和c键终止程序,终止后依然会在当前目录下生成goecs.txt文件和分享链接,里面是已经测试到的信息。 362 | 363 | #### Q: 非Root环境如何进行测试? 364 | 365 | #### A: 手动执行安装命令,实在装不上也没问题,直接在release中下载对应架构的压缩包解压后执行即可,只要你能执行的了文件。或者你能使用docker的话用docker执行。 366 | 367 | ## 致谢 368 | 369 | 感谢 [he.net](https://he.net) [bgp.tools](https://bgp.tools) [ipinfo.io](https://ipinfo.io) [ip.sb](https://ip.sb) [cheervision.co](https://cheervision.co) [scamalytics.com](https://scamalytics.com) [abuseipdb.com](https://www.abuseipdb.com/) [virustotal.com](https://www.virustotal.com/) [ip2location.com](https://ip2location.com/) [ip-api.com](https://ip-api.com) [ipregistry.co](https://ipregistry.co/) [ipdata.co](https://ipdata.co/) [ipgeolocation.io](https://ipgeolocation.io) [ipwhois.io](https://ipwhois.io) [ipapi.com](https://ipapi.com/) [ipapi.is](https://ipapi.is/) [ipqualityscore.com](https://www.ipqualityscore.com/) [bigdatacloud.com](https://www.bigdatacloud.com/) 等网站提供的API进行检测,感谢互联网各网站提供的查询资源 370 | 371 | 感谢 372 | 373 | 374 | h501 375 | 376 | 377 | 提供的免费托管支持本开源项目的共享测试结果存储 378 | 379 | 同时感谢以下平台提供编辑和测试支持 380 | 381 | 382 | goland 383 | 384 | 385 | 386 | ibm 387 | 388 | 389 | ## Stargazers over time 390 | 391 | [![Stargazers over time](https://starchart.cc/oneclickvirt/ecs.svg?variant=adaptive)](https://starchart.cc/oneclickvirt/ecs) 392 | -------------------------------------------------------------------------------- /README_EN.md: -------------------------------------------------------------------------------- 1 | # ecs 2 | 3 | [![release](https://github.com/oneclickvirt/ecs/actions/workflows/main.yaml/badge.svg)](https://github.com/oneclickvirt/ecs/actions/workflows/main.yaml) 4 | 5 | [![Hits](https://hits.spiritlhl.net/goecs.svg?action=hit&title=Hits&title_bg=%23555555&count_bg=%230eecf8&edge_flat=false)](https://hits.spiritlhl.net) 6 | 7 | Fusion Monster Evaluation Project - GO Version 8 | 9 | (No additional shell file dependencies unless necessary to install the environment using the shell, the environment is installed just to measure more accurately, in extreme cases no environment dependencies can also be fully measured project) 10 | 11 | Please report any issues via [issues](https://github.com/oneclickvirt/ecs/issues). 12 | 13 | Go version: [https://github.com/oneclickvirt/ecs](https://github.com/oneclickvirt/ecs) 14 | 15 | Shell version: [https://github.com/spiritLHLS/ecs/blob/main/README_EN.md](https://github.com/spiritLHLS/ecs/blob/main/README_EN.md) 16 | 17 | --- 18 | 19 | ## **Language** 20 | 21 | [中文文档](README.md) | [English Docs](README_EN.md) 22 | 23 | --- 24 | 25 | ## **Supported Systems and Architectures** 26 | 27 | ### **Compilation and Testing Support** 28 | | Supported for Compilation | Tested on | Supported OS for Compilation | Tested OS | 29 | |---------------------------|-----------|------------------------------|-----------| 30 | | amd64 | amd64 | Linux | Linux | 31 | | arm | arm | Windows | Windows | 32 | | arm64 | arm64 | FreeBSD | FreeBSD | 33 | | 386 | 386 | OpenBSD | | 34 | | mips | | MacOS | | 35 | | mipsle | | | | 36 | | s390x | s390x | | | 37 | | riscv64 | | | | 38 | 39 | > Please test additional architectures and systems yourself. If you encounter any issues, please open an issue. 40 | 41 | ### **Systems Pending Support** 42 | | OS | Notes | 43 | |--------|-------------------------------------------------------------------------------------------------| 44 | | MacOS | Hardware testing bugs and environment dependencies unresolved | 45 | | Android(arm64) | Permission issues that are not fixed, no problems with ARM architecture for non-Android systems | 46 | --- 47 | 48 | ## **Features** 49 | 50 | - System basic information query and concurrent IP basic information query: Self-developed [basics](https://github.com/oneclickvirt/basics), [gostun](https://github.com/oneclickvirt/gostun) 51 | - CPU test: Self-developed [cputest](https://github.com/oneclickvirt/cputest) supporting sysbench(lua/golang version), geekbench, winsat 52 | - Memory test: Self-developed [memorytest](https://github.com/oneclickvirt/memorytest) supporting sysbench, dd 53 | - Disk test: Self-developed [disktest](https://github.com/oneclickvirt/disktest) supporting dd, fio, winsat 54 | - Streaming media unlock information concurrent query: Modified from [netflix-verify](https://github.com/sjlleo/netflix-verify) and more to [CommonMediaTests](https://github.com/oneclickvirt/CommonMediaTests) 55 | - Common streaming media tests concurrent query: Self-developed to [UnlockTests](https://github.com/oneclickvirt/UnlockTests), logic modified from [RegionRestrictionCheck](https://github.com/lmc999/RegionRestrictionCheck) and others 56 | - IP quality/security information concurrent query: Self-developed, binary files compiled in [securityCheck](https://github.com/oneclickvirt/securityCheck) 57 | - Email port test: Self-developed [portchecker](https://github.com/oneclickvirt/portchecker) 58 | - Three-network return path test: Modified from [zhanghanyun/backtrace](https://github.com/zhanghanyun/backtrace) to [oneclickvirt/backtrace](https://github.com/oneclickvirt/backtrace) 59 | - Three-network route test: Modified from [NTrace-core](https://github.com/nxtrace/NTrace-core) to [nt3](https://github.com/oneclickvirt/nt3) 60 | - Speed test: Based on data from [speedtest.net](https://github.com/spiritLHLS/speedtest.net-CN-ID) and [speedtest.cn](https://github.com/spiritLHLS/speedtest.cn-CN-ID), developed to [oneclickvirt/speedtest](https://github.com/oneclickvirt/speedtest) 61 | - Three-network Ping test: Modified from [ecsspeed](https://github.com/spiritLHLS/ecsspeed) to [pingtest](https://github.com/oneclickvirt/pingtest) 62 | 63 | **For first-time users of this project, it is recommended to check the instructions: [Jump to](https://github.com/oneclickvirt/ecs/blob/master/README_NEW_USER.md)** 64 | 65 | --- 66 | 67 | ## **Instructions for Use** 68 | 69 | ### **Linux/FreeBSD/OpenBSD/MacOS** 70 | 71 | #### **One-click command** 72 | 73 | **One-Click Command** will **Install Dependencies by Default**, **Update Package Manager by Default**, **Default Non-Interactive Mode*** 74 | 75 | - **International users without acceleration:** 76 | 77 | ```bash 78 | export noninteractive=true && 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 -l en 79 | ``` 80 | 81 | - **International/domestic users with CDN acceleration:** 82 | 83 | ```bash 84 | export noninteractive=true && curl -L https://cdn.spiritlhl.net/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 -l en 85 | ``` 86 | 87 | - **Domestic users with CNB acceleration:** 88 | 89 | ```bash 90 | 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 91 | ``` 92 | 93 | - **Short Link:** 94 | 95 | ```bash 96 | 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 97 | `` 98 | 99 | #### **Detailed instructions** 100 | 101 | **Detailed description** of the commands in **Command **Controls whether to install dependencies**, **Whether to update the package manager**, **Default interaction mode can be selected*** 102 | 103 |
104 | Expand to view detailed instructions 105 | 106 | 1. **Download the script** 107 | 108 | **International users without acceleration:** 109 | 110 | ```bash 111 | curl -L https://raw.githubusercontent.com/oneclickvirt/ecs/master/goecs.sh -o goecs.sh && chmod +x goecs.sh 112 | ``` 113 | 114 | **International/domestic users with CDN acceleration:** 115 | 116 | ```bash 117 | curl -L https://cdn.spiritlhl.net/https://raw.githubusercontent.com/oneclickvirt/ecs/master/goecs.sh -o goecs.sh && chmod +x goecs.sh 118 | ``` 119 | 120 | **Domestic users with CNB acceleration:** 121 | 122 | ```bash 123 | curl -L https://cnb.cool/oneclickvirt/ecs/-/git/raw/main/goecs.sh -o goecs.sh && chmod +x goecs.sh 124 | ``` 125 | 126 | 2. **Update package manager (optional) and install environment** 127 | 128 | ```bash 129 | ./goecs.sh env 130 | ``` 131 | 132 | **Non-interactive mode:** 133 | 134 | ```bash 135 | export noninteractive=true && ./goecs.sh env 136 | ``` 137 | 138 | 3. **Install `goecs`** 139 | 140 | ```bash 141 | ./goecs.sh install 142 | ``` 143 | 144 | 4. **Upgrade `goecs`** 145 | 146 | ```bash 147 | ./goecs.sh upgrade 148 | ``` 149 | 150 | 5. **Uninstall `goecs`** 151 | 152 | ```bash 153 | ./goecs.sh uninstall 154 | 155 | 6. **help command** 156 | 157 | ```bash 158 | ./goecs.sh -h 159 | ``` 160 | 161 | 7. **Invoke the menu** 162 | 163 | ```bash 164 | goecs -l en 165 | ``` 166 | 167 |
168 | 169 | --- 170 | 171 | #### **Command parameterization** 172 | 173 |
174 | Expand to view parameter descriptions 175 | 176 | ```bash 177 | Usage: goecs [options] 178 | -backtrace 179 | Enable/Disable backtrace test (in 'en' language or on windows it always false) (default true) 180 | -basic 181 | Enable/Disable basic test (default true) 182 | -comm 183 | Enable/Disable common media test (default true) 184 | -cpu 185 | Enable/Disable CPU test (default true) 186 | -cpum string 187 | Set CPU test method (supported: sysbench, geekbench, winsat) (default "sysbench") 188 | -cput string 189 | Set CPU test thread mode (supported: single, multi) (default "multi") 190 | -disk 191 | Enable/Disable disk test (default true) 192 | -diskm string 193 | Set disk test method (supported: fio, dd, winsat) (default "fio") 194 | -diskmc 195 | Enable/Disable multiple disk checks, e.g., -diskmc=false 196 | -diskp string 197 | Set disk test path, e.g., -diskp /root 198 | -email 199 | Enable/Disable email port test (default true) 200 | -h Show help information 201 | -l string 202 | Set language (supported: en, zh) (default "zh") 203 | -log 204 | Enable/Disable logging in the current path 205 | -memory 206 | Enable/Disable memory test (default true) 207 | -memorym string 208 | Set memory test method (supported: sysbench, dd, winsat) (default "sysbench") 209 | -menu 210 | Enable/Disable menu mode, disable example: -menu=false (default true) 211 | -nt3 212 | Enable/Disable NT3 test (in 'en' language or on windows it always false) (default true) 213 | -nt3loc string 214 | Specify NT3 test location (supported: GZ, SH, BJ, CD for Guangzhou, Shanghai, Beijing, Chengdu) (default "GZ") 215 | -nt3t string 216 | Set NT3 test type (supported: both, ipv4, ipv6) (default "ipv4") 217 | -security 218 | Enable/Disable security test (default true) 219 | -speed 220 | Enable/Disable speed test (default true) 221 | -spnum int 222 | Set the number of servers per operator for speed test (default 2) 223 | -upload 224 | Enable/Disable upload the result (default true) 225 | -ut 226 | Enable/Disable unlock media test (default true) 227 | -v Display version information 228 | ``` 229 |
230 | 231 | --- 232 | 233 | ### **Windows** 234 | 235 | 1. Download the compressed file with the .exe file: [Releases](https://github.com/oneclickvirt/ecs/releases) 236 | 2. After unzipping, right-click and run as administrator. 237 | 238 | --- 239 | 240 | ### **Docker** 241 | 242 |
243 | Expand to view how to use it 244 | 245 | International image: https://hub.docker.com/r/spiritlhl/goecs 246 | 247 | Please ensure Docker is installed on your machine before executing the following commands 248 | 249 | Privileged mode + host network 250 | 251 | ```shell 252 | docker run --rm --privileged --network host spiritlhl/goecs:latest -menu=false -l en 253 | ``` 254 | 255 | Unprivileged mode + non-host network 256 | 257 | ```shell 258 | docker run --rm spiritlhl/goecs:latest -menu=false -l en 259 | ``` 260 | 261 | Using Docker to execute tests will result in some hardware testing bias and virtualization architecture detection failure. Direct testing is recommended over Docker testing. 262 | 263 | Mirror image: https://cnb.cool/oneclickvirt/ecs/-/packages/docker/ecs 264 | 265 | Please ensure Docker is installed on your machine before executing the following commands 266 | 267 | Privileged mode + host network 268 | 269 | ```shell 270 | docker run --rm --privileged --network host docker.cnb.cool/oneclickvirt/ecs:latest -menu=false -l en 271 | ``` 272 | 273 | Unprivileged mode + non-host network 274 | 275 | ```shell 276 | docker run --rm docker.cnb.cool/oneclickvirt/ecs:latest -menu=false -l en 277 | ``` 278 | 279 |
280 | 281 | --- 282 | 283 | ### Compiling from source code 284 | 285 |
286 | Expand to view compilation instructions 287 | 288 | 1. Clone the public branch of the repository (without private dependencies) 289 | ```bash 290 | git clone -b public https://github.com/oneclickvirt/ecs.git 291 | cd ecs 292 | ``` 293 | 294 | 2. Install Go environment (skip if already installed) 295 | ```bash 296 | # Download and install Go 297 | wget https://go.dev/dl/go1.23.4.linux-amd64.tar.gz 298 | rm -rf /usr/local/go && tar -C /usr/local -xzf go1.23.4.linux-amd64.tar.gz 299 | export PATH=$PATH:/usr/local/go/bin 300 | ``` 301 | 302 | 3. Compile 303 | ```bash 304 | go build -o goecs 305 | ``` 306 | 307 | 4. Run test 308 | ```bash 309 | ./goecs -menu=false -l en 310 | ``` 311 | 312 | Supported compilation parameters: 313 | - GOOS: supports linux, windows, darwin, freebsd, openbsd 314 | - GOARCH: supports amd64, arm, arm64, 386, mips, mipsle, s390x, riscv64 315 | 316 | Cross-platform compilation examples: 317 | ```bash 318 | # Compile Windows version 319 | GOOS=windows GOARCH=amd64 go build -o goecs.exe 320 | # Compile MacOS version 321 | GOOS=darwin GOARCH=amd64 go build -o goecs_darwin 322 | ``` 323 |
324 | 325 | --- 326 | 327 | ## QA 328 | 329 | #### Q: Why is sysbench used by default instead of geekbench? 330 | 331 | #### A: Comparing the characteristics of both: 332 | 333 | | Comparison | sysbench | geekbench | 334 | |------------|----------|-----------| 335 | | Application scope | Lightweight, runs on almost any server | Heavyweight, won't run on small machines | 336 | | Test requirements | No network needed, no special hardware requirements | Requires internet, IPv4 environment, minimum 1GB memory | 337 | | Open source status | Based on LUA, open source, can compile for various architectures | Official binaries are closed source, cannot compile your own version | 338 | | Test stability | Core test components unchanged for 10+ years | Each major version updates test items, making scores hard to compare between versions (each version benchmarks against current best CPUs) | 339 | | Test content | Only tests computing performance | Covers multiple performance aspects with weighted scores, though some tests aren't commonly used | 340 | | Suitable scenarios | Good for quick tests, focuses on computing performance | Good for comprehensive testing | 341 | 342 | Note that `goecs` allows you to specify CPU test method via parameters. The default is chosen for faster testing across more systems. 343 | 344 | #### Q: Why use Golang instead of Rust for refactoring? 345 | 346 | #### A: Because network-related projects currently trend toward Golang, with many components maintained by open source communities. Many Rust components would require building from scratch, ~~I'm too lazy~~ I don't have that technical capability. 347 | 348 | #### Q: Why not continue developing the Shell version instead of refactoring? 349 | 350 | #### A: Because there were too many varied environment issues. Pre-compiled binary files are easier for solving environment problems (better generalization). 351 | 352 | #### Q: Are there explanations for each test item? 353 | 354 | #### A: Each test project has its own maintenance repository. Click through to view the repository description. 355 | 356 | #### Q: How do I manually terminate a test halfway through? 357 | 358 | #### A: Press Ctrl+C to terminate the program. After termination, a goecs.txt file and share link will still be generated in the current directory containing information tested so far. 359 | 360 | #### Q: How do I test in a non-Root environment? 361 | 362 | #### A: Execute the installation command manually. If you can't install it, simply download the appropriate architecture package from releases, extract it, and run the file if you have execution permissions. Alternatively, use Docker if you can. 363 | 364 | ## Thanks 365 | 366 | Thank [he.net](https://he.net) [bgp.tools](https://bgp.tools) [ipinfo.io](https://ipinfo.io) [ip.sb](https://ip.sb) [cheervision.co](https://cheervision.co) [scamalytics.com](https://scamalytics.com) [abuseipdb.com](https://www.abuseipdb.com/) [virustotal.com](https://www.virustotal.com/) [ip2location.com](https://ip2location.com/) [ip-api.com](https://ip-api.com) [ipregistry.co](https://ipregistry.co/) [ipdata.co](https://ipdata.co/) [ipgeolocation.io](https://ipgeolocation.io) [ipwhois.io](https://ipwhois.io) [ipapi.com](https://ipapi.com/) [ipapi.is](https://ipapi.is/) [ipqualityscore.com](https://www.ipqualityscore.com/) [bigdatacloud.com](https://www.bigdatacloud.com/) and others for providing APIs for testing, and thanks to various websites on the Internet for providing query resources. 367 | 368 | Thank 369 | 370 | 371 | h501 372 | 373 | 374 | provided free hosting support for this open source project's shared test results storage 375 | 376 | Thanks also to the following platforms for editorial and testing support 377 | 378 | 379 | goland 380 | 381 | 382 | 383 | ibm 384 | 385 | 386 | ## Stargazers over time 387 | 388 | [![Stargazers over time](https://starchart.cc/oneclickvirt/ecs.svg?variant=adaptive)](https://starchart.cc/oneclickvirt/ecs) 389 | -------------------------------------------------------------------------------- /README_NEW_USER.md: -------------------------------------------------------------------------------- 1 | ## 目录 / Table of Contents / 目次 2 | 3 | [![Hits](https://hits.spiritlhl.net/goecs.svg?action=hit&title=Hits&title_bg=%23555555&count_bg=%230eecf8&edge_flat=false)](https://hits.spiritlhl.net) 4 | 5 | ## 语言 / Languages / 言語 6 | - [中文](#中文) 7 | - [English](#English) 8 | - [日本語](#日本語) 9 | 10 | ## 中文 11 | - [系统基础信息](#系统基础信息) 12 | - [CPU测试](#CPU测试) 13 | - [内存测试](#内存测试) 14 | - [硬盘测试](#硬盘测试) 15 | - [流媒体解锁](#流媒体解锁) 16 | - [IP质量检测](#IP质量检测) 17 | - [邮件端口检测](#邮件端口检测) 18 | - [三网回城线路检测](#三网回城线路检测) 19 | - [三网回程路由检测](#三网回程路由检测) 20 | - [就近测速](#就近测速) 21 | 22 | ## English 23 | - [Basic System Information](#Basic-System-Information) 24 | - [CPU Testing](#CPU-Testing) 25 | - [Memory Testing](#Memory-Testing) 26 | - [Disk Testing](#Disk-Testing) 27 | - [Streaming Media Unlocking](#Streaming-Media-Unlocking) 28 | - [IP Quality Detection](#IP-Quality-Detection) 29 | - [Email Port Detection](#Email-Port-Detection) 30 | 31 | ## 日本語 32 | - [システム基本情報](#システム基本情報) 33 | - [CPUテスト](#CPUテスト) 34 | - [メモリテスト](#メモリテスト) 35 | - [ディスクテスト](#ディスクテスト) 36 | - [ストリーミングメディアロック解除](#ストリーミングメディアロック解除) 37 | - [IP品質検出](#IP品質検出) 38 | - [メールポート検出](#メールポート検出) 39 | 40 | --- 41 | 42 | ## 中文 43 | 44 | ### **系统基础信息** 45 | 46 | CPU型号: 不必多说,大概的说,按CPU的发布时间,都是新款则AMD好于Intel,都是旧款则Intel好于AMD。 47 | 48 | CPU数量: 会检测是物理核心还是逻辑核心,优先展示物理核心,查不到物理核心才去展示逻辑核心。在服务器实际使用过程中,程序一般是按逻辑核心分配执行的,非视频转码和科学计算,物理核心一般都是开超线程成逻辑核心用,横向比较的时候,对应类型的核心数量才有比较的意义。 49 | 50 | CPU缓存:显示的宿主机的CPU三级缓存信息。 51 | 52 | AES-NI: 指令集是加密解密加速用的,有的话常规网络请求会更快一些,性能更高一些,没有的话会影响网络请求(含代理用途)。 53 | 54 | VM-x/AMD-V/Hyper-V: 是当前测试宿主机是否支持嵌套虚拟化的指标,如果测试环境是套在docker里测或者没有root权限,那么这个默认就是检测不到显示不支持嵌套虚拟化。这个指标在你需要在宿主机上开设虚拟机(如 KVM、VirtualBox、VMware)的时候有用,其他用途该指标用处不大。 55 | 56 | 内存: 显示内存 正在使用的大小/总大小 ,不含虚拟内存。 57 | 58 | 气球驱动: 显示宿主机是否使用了气球驱动,使用了证明母机有共享内存使用,需要结合下面的内存读写测试查看是否有超售/严格的限制。 59 | 60 | 内核页合并:显示宿主机是否使用了KSM内存融合,使用了证明母机有共享内存使用,需要结合下面的内存读写测试查看是否有超售/严格的限制。 61 | 62 | 虚拟内存: 显示 SWAP虚拟内存 63 | 64 | 硬盘空间: 显示硬盘 正在使用的大小/总大小 65 | 66 | 启动盘路径:显示启动盘的路径 67 | 68 | 系统: 显示系统名字和架构 69 | 70 | 内核: 显示系统内核版本 71 | 72 | 系统在线时间: 显示宿主机自从开机到测试时已在线时长 73 | 74 | 时区: 显示宿主机系统时区 75 | 76 | 负载: 显示系统负载 77 | 78 | 虚拟化架构: 显示宿主机来自什么虚拟化架构,一般来说推荐```Dedicated > KVM > Xen```虚拟化,其他虚拟化都会存在性能损耗,导致使用的时候存在性能共享/损耗,但这个也说不准,独立服务器才拥有完全独立的资源占用,其他虚拟化基本都会有资源共享,取决于宿主机的售卖者是否有良心,具体性能优劣还是得看后面的专项测试。 79 | 80 | NAT类型: 显示NAT类型,具体推荐```Full Cone > Restricted Cone > Port Restricted Cone > Symmetric```,测不出来时会显示```Inconclusive```,一般来说不拿来做特殊用途(有关于特殊的代理和实时通讯需求的),都不用关注本指标。 81 | 82 | TCP加速方式:一般是```cubic/bbr```拥塞控制协议,一般来说做代理服务器用bbr可以改善网速,普通用途不必关注此指标。 83 | 84 | IPV4/IPV6 ASN: 显示宿主机IP所属的ASN组织ID和名字,同一个IDC可能会有多个ASN,ASN下可能有多个商家售卖不同段的IP的服务器,具体的上下游关系错综复杂,可使用 bgp.tool 进一步查看。 85 | 86 | IPV4/IPV6 Location: 显示对应协议的IP在数据库中的地理位置。 87 | 88 | IPV4 Active IPs: 根据 bgp.tools 信息查询当前CIDR分块中 活跃邻居数量/总邻居数量 89 | 90 | IPV6 子网掩码:根据宿主机信息查询的本机IPV6子网大小 91 | 92 | ### **CPU测试** 93 | 94 | 支持通过命令行参数选择```GeekBench```和```Sysbench```进行测试: 95 | 96 | | 比较项 | sysbench | geekbench | 97 | |------------------|----------|-----------| 98 | | 适用范围 | 轻量级,几乎可在任何服务器上运行 | 重量级,小型机器无法运行 | 99 | | 测试要求 | 无需网络,无特殊硬件需求 | 需联网,IPV4环境,至少1G内存 | 100 | | 开源情况 | 基于LUA,开源,可自行编译各架构版本(本项目有重构为Go版本内置) | 官方二进制闭源代码,不支持自行编译 | 101 | | 测试稳定性 | 核心测试组件10年以上未变 | 每个大版本更新测试项,分数不同版本间难以对比(每个版本对标当前最好的CPU) | 102 | | 测试内容 | 仅测试计算性能,基于素数计算 | 覆盖多种性能测试,分数加权计算,但部分测试实际不常用 | 103 | | 适用场景 | 适合快速测试,仅测试计算性能 | 适合综合全面的测试 | 104 | 105 | 默认使用```Sysbench```进行测试,基准大致如下: 106 | 107 | CPU测试单核```Sysbench```得分在5000以上的可以算第一梯队,4000到5000分算第二梯队,每1000分大致算一档。 108 | 109 | AMD的7950x单核满血性能得分在6500左右,AMD的5950x单核满血性能得分5700左右,Intel普通的CPU(E5之类的)在1000~800左右,低于500的单核CPU可以说是性能比较差的了。 110 | 111 | 有时候多核得分和单核得分一样,证明商家在限制程序并发使用CPU,典型例子腾讯云。 112 | 113 | ```GeekBench```的基准可见 [官方网站](https://browser.geekbench.com/processor-benchmarks/) 天梯图,具体得分每个```GeekBench```版本都不一样,注意使用时测试的```GeekBench```版本是什么。 114 | 115 | 多说一句,```GeekBench```测的很多内容,实际在服务器使用过程中根本用不到,测试仅供参考。当然```Sysbench```非常不全面,但它基于最基础的计算性能可以大致比较CPU的性能。 116 | 117 | 实际上CPU性能测试够用就行,除非是科学计算以及视频转码,一般不需要特别追求高性能CPU。 118 | 119 | ### **内存测试** 120 | 121 | 一般来说,只需要判断IO速度是否低于```10240MB/s```,如果低于这个值那么证明内存性能不佳,极大概率存在超售超卖问题。 122 | 123 | 至于超开的原因可能是开了虚拟内存(硬盘当内存用)、可能是开了ZRAM(牺牲CPU性能)、可能是开了气球驱动、可能是开了KSM内存融合,原因多种多样。 124 | 125 | ### **硬盘测试** 126 | 127 | ```dd```测试可能误差偏大但测试速度快无硬盘大小限制,```fio```测试真实一些但测试速度慢有硬盘以及内存大小的最低需求。 128 | 129 | 同时,服务器可能有不同的文件系统,某些文件系统的IO引擎在同样的硬件条件下测试的读写速度更快,这是正常的。项目默认使用```fio```进行测试,测试使用的IO引擎优先级为```libaio > posixaio > psync```,备选项```dd```测试在```fio```测试不可用时自动替换。 130 | 131 | 以```fio```测试结果为例基准如下: 132 | 133 | | 操作系统类型 | 主要指标 | 次要指标 | 134 | |---------|-------------------|---------------------| 135 | | Windows/Mac | 4K读 → 64K读 → 写入测试 | 图形界面系统优先考虑读取性能 | 136 | | Linux (无图形界面) | 4K读 + 4K写 + 1M读写| 读/写值通常相似 | 137 | 138 | 以下硬盘类型对于指标值指 常规~满血 性能状态,指```libaio```作为IO测试引擎,指在```Linux```下进行测试 139 | 140 | | 驱动类型 | 4K(IOPS)性能 | 1M(IOPS)性能 | 141 | |------------|--------------------------|----------------------| 142 | | NVMe SSD | ≥ 200 MB/s | 5-10 GB/s | 143 | | 标准SSD | 50-100 MB/s | 2-3 GB/s | 144 | | HDD (机械硬盘) | 10-40 MB/s | 500-600 MB/s | 145 | | 性能不佳 | < 10 MB/s | < 200 MB/s | 146 | 147 | 快速评估: 148 | 149 | 1. **主要检查**: 4K读(IOPS) 4K写(IOPS) 150 | - 几乎相同差别不大 151 | - ≥ 200 MB/s = NVMe SSD 152 | - 50-100 MB/s = 标准SSD 153 | - 10-40 MB/s = HDD (机械硬盘) 154 | - < 10 MB/s = 垃圾性能,超售/限制严重 155 | 156 | 2. **次要检查**: 1M总和(IOPS) 157 | - 提供商设置的IO限制 158 | - 资源超开超售情况 159 | - 数值越高越好 160 | - NVMe SSD通常达到4-6 GB/s 161 | - 标准SSD通常达到1-2 GB/s 162 | 163 | 如果 NVMe SSD的1M(IOPS)值 < 1GB/s 表明存在严重的资源超开超售。 164 | 165 | 注意,这里测试的是真实的IO,仅限本项目,非本项目测试的IO不保证基准通用,因为他们测试的时候可能用的不是同样的参数,可能未设置IO直接读写,可能设置IO引擎不一致,可能设置测试时间不一致,都会导致基准有偏差。 166 | 167 | ### **流媒体解锁** 168 | 169 | 检索常见的流媒体平台解锁,当然也不全是流媒体,还有一些常见的别的平台的解锁也纳入了。一般来说,IP解锁地区都是一致的不会到处乱飘,如果发现多家平台解锁地区不一致,那么IP大概率是租赁的IPXO等平台的,各平台数据库识别缓慢,IP质量一般来说也好不到哪里去。 170 | 171 | ### **IP质量检测** 172 | 173 | 检测14个数据库的IP相关信息,一般来说看使用类型和公司类型还有安全信息的其他判别足矣,安全得分真的图一乐。多个平台比较对应检测项目都为对应值,证明当前IP确实如此,不要仅相信一个数据库源的信息。 174 | 175 | ### **邮件端口检测** 176 | 177 | - **SMTP(25)**:用于邮件服务器之间传输邮件(发送邮件)。 178 | - **SMTPS(465)**:用于加密的 SMTP 发送邮件(SSL/TLS 方式)。 179 | - **SMTP(587)**:用于客户端向邮件服务器发送邮件,支持 STARTTLS 加密。 180 | - **POP3(110)**:用于邮件客户端从服务器下载邮件,不加密。 181 | - **POP3S(995)**:用于加密的 POP3,安全地下载邮件(SSL/TLS 方式)。 182 | - **IMAP(143)**:用于邮件客户端在线管理邮件(查看、同步邮件),不加密。 183 | - **IMAPS(993)**:用于加密的 IMAP,安全地管理邮件(SSL/TLS 方式)。 184 | 185 | 具体当前宿主机不做邮局或者不收电子邮件,那么该项目指标不用理会。 186 | 187 | ### **三网回程线路检测** 188 | 189 | 检测当前的宿主机的IP地址 到 四个主要POP点城市的三个主要运营商的接入点的IP地址 的线路,具体来说 190 | 191 | 电信163、联通4837、移动CMI 是常见的线路 192 | 193 | 电信CN2GIA > 电信CN2GT 移动CMIN2 联通9929 算优质的线路 194 | 195 | 用什么运营商连宿主机的IP就看哪个运营商的线路就行了,具体线路的路由情况,看在下一个检测项看到对应的ICMP检测路由信息。 196 | 197 | ### **三网回程路由检测** 198 | 199 | 默认检测广州为目的地,实际可使用命令行参数指定目的地,见对应的说明。 200 | 201 | 主要就是看是不是直连,是不是延迟低,是不是没有隐藏路由信息。如果路由全球跑,延迟起飞,那么线路自然不会好到哪里去。 202 | 203 | ### **就近测速** 204 | 205 | 先测的官方推荐的测速点,然后测有代表性的国际测速点,最后测国内三大运营商ping值最低的测速点。 206 | 207 | 境内使用为主就看境内测速即可,境外使用看境外测速,官方测速点可以代表受测的宿主机本地带宽基准。 208 | 209 | 一般来说境外的服务器的带宽100Mbps起步,境内的服务器1Mbps带宽起步,具体看线路优劣,带宽特别大有时候未必用得上,够用就行了。 210 | 211 | --- 212 | 213 | ## English 214 | 215 | ### **Basic System Information** 216 | 217 | CPU Model: Simply put, generally speaking, based on CPU release dates, newer AMD models are better than Intel, while for older models, Intel is better than AMD. 218 | 219 | CPU Count: It will detect whether these are physical cores or logical cores, prioritizing display of physical cores, only showing logical cores if physical core information is unavailable. In actual server usage, programs are generally allocated by logical cores. Except for video transcoding and scientific computing, physical cores are usually enabled with hyperthreading to function as logical cores. When making comparisons, only cores of the corresponding type have meaningful comparison value. 220 | 221 | CPU Cache: Displays the host machine's three-level CPU cache information. 222 | 223 | AES-NI: This instruction set is used for encryption/decryption acceleration. With it, normal network requests will be faster and performance will be higher. Without it, network requests (including proxy usage) will be affected. 224 | 225 | VM-x/AMD-V/Hyper-V: This indicates whether the current host machine supports nested virtualization. If the test environment is running inside Docker or doesn't have root privileges, then by default this will be undetectable and will show as not supporting nested virtualization. This metric is useful when you need to set up virtual machines (such as KVM, VirtualBox, VMware) on the host machine; for other purposes, this metric is not very useful. 226 | 227 | Memory: Displays memory size in format "currently used size/total size", not including virtual memory. 228 | 229 | Balloon Driver: Shows whether the host machine is using a balloon driver. If used, it proves the parent machine has shared memory usage, which should be examined alongside the memory read/write test below to check for overselling/strict limitations. 230 | 231 | Kernel Same-page Merging: Shows whether the host machine is using KSM memory fusion. If used, it proves the parent machine has shared memory usage, which should be examined alongside the memory read/write test below to check for overselling/strict limitations. 232 | 233 | Virtual Memory: Displays SWAP virtual memory. 234 | 235 | Disk Space: Displays disk usage in format "currently used size/total size". 236 | 237 | Boot Disk Path: Shows the path of the boot disk. 238 | 239 | System: Displays system name and architecture. 240 | 241 | Kernel: Displays system kernel version. 242 | 243 | System Uptime: Shows how long the host machine has been online since boot until testing time. 244 | 245 | Timezone: Displays the host machine's system timezone. 246 | 247 | Load: Displays system load. 248 | 249 | Virtualization Architecture: Shows what virtualization architecture the host machine uses. Generally speaking, the recommended order is `Dedicated > KVM > Xen` virtualization. Other virtualization will have performance losses, leading to shared/degraded performance during use. However, this is not definitive. Only dedicated servers have completely independent resource usage; other virtualization methods basically all have resource sharing, depending on whether the host machine seller has a conscience. The specific performance merits still depend on the specialized tests that follow. 250 | 251 | NAT Type: Displays NAT type. Specifically recommended in order: `Full Cone > Restricted Cone > Port Restricted Cone > Symmetric`. When not detectable, it will show `Inconclusive`. Generally speaking, if you're not using it for special purposes (related to special proxy and real-time communication needs), you don't need to pay attention to this metric. 252 | 253 | TCP Acceleration Method: Generally this is the `cubic/bbr` congestion control protocol. Generally speaking, using bbr for proxy servers can improve network speed; for ordinary purposes, you don't need to pay attention to this indicator. 254 | 255 | IPv4/IPv6 ASN: Displays the ASN organization ID and name that the host machine's IP belongs to. The same IDC may have multiple ASNs, and an ASN may have multiple vendors selling servers with different IP segments. The specific upstream and downstream relationships are complex and can be further viewed using bgp.tool. 256 | 257 | IPv4/IPv6 Location: Shows the geographic location of the corresponding protocol's IP in the database. 258 | 259 | IPV4 Active IPs: Query the number of active neighbours/total number of neighbours in the current CIDR chunk based on the bgp.tools information. 260 | 261 | ### **CPU Testing** 262 | 263 | Supports selecting `GeekBench` and `Sysbench` for testing through command line parameters: 264 | 265 | | Comparison Item | sysbench | geekbench | 266 | |------------------|----------|-----------| 267 | | Application Range | Lightweight, can run on almost any server | Heavyweight, cannot run on small machines | 268 | | Test Requirements | No network needed, no special hardware requirements | Requires network, IPv4 environment, at least 1GB memory | 269 | | Open Source Status | Based on LUA, open source, can compile versions for various architectures (this project has been rebuilt in Go version built-in) | Official binary closed source code, does not support self-compilation | 270 | | Test Stability | Core test components unchanged for over 10 years | Test items updated with each major version, scores difficult to compare between different versions (each version benchmarks against current best CPUs) | 271 | | Test Content | Only tests computational performance, based on prime number calculation | Covers multiple performance tests, weighted score calculation, but some tests are not commonly used in practice | 272 | | Applicable Scenarios | Suitable for quick testing, only tests computational performance | Suitable for comprehensive testing | 273 | 274 | By default, `Sysbench` is used for testing, with the baseline roughly as follows: 275 | 276 | CPU test single-core `Sysbench` scores above 5000 can be considered first tier, 4000 to 5000 points second tier, with roughly one tier per 1000 points. 277 | 278 | AMD's 7950x single-core full performance score is around 6500, AMD's 5950x single-core full performance score is around 5700, Intel's ordinary CPUs (E5 series, etc.) are around 1000~800, and single-core CPUs scoring below 500 can be said to have relatively poor performance. 279 | 280 | 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. 281 | 282 | 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. 283 | 284 | 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. 285 | 286 | In practice, CPU performance just needs to be sufficient. Unless you're doing scientific computing or video transcoding, you generally don't need to pursue high-performance CPUs. 287 | 288 | ### **Memory Testing** 289 | 290 | Generally speaking, you only need to determine whether the IO speed is below `10240MB/s`. If it's below this value, it proves that memory performance is poor, with an extremely high probability of overselling issues. 291 | 292 | As for the reasons for oversubscription, it could be that virtual memory is enabled (using disk as memory), ZRAM might be enabled (sacrificing CPU performance), balloon drivers might be enabled, or KSM memory fusion might be enabled - there are various possible reasons. 293 | 294 | ### **Disk Testing** 295 | 296 | The `dd` test may have larger errors but is faster to test with no disk size limitations. The `fio` test is more realistic but slower to test and has minimum requirements for disk and memory size. 297 | 298 | At the same time, servers may have different file systems, and certain file systems' IO engines may test faster read/write speeds under the same hardware conditions, which is normal. The project uses `fio` for testing by default, with IO engine priority being `libaio > posixaio > psync`. The alternative `dd` test automatically replaces when `fio` testing is not available. 299 | 300 | Using `fio` test results as an example, the baseline is as follows: 301 | 302 | | OS Type | Primary Metrics | Secondary Metrics | 303 | |---------|-------------------|---------------------| 304 | | Windows/Mac | 4K read → 64K read → Write test | Graphical systems prioritize read performance | 305 | | Linux (without GUI) | 4K read + 4K write + 1M read/write | Read/write values usually similar | 306 | 307 | The following disk types refer to metric values indicating normal~full-power performance states, using `libaio` as the IO test engine, testing under `Linux` 308 | 309 | | Drive Type | 4K(IOPS) Performance | 1M(IOPS) Performance | 310 | |------------|--------------------------|----------------------| 311 | | NVMe SSD | ≥ 200 MB/s | 5-10 GB/s | 312 | | Standard SSD | 50-100 MB/s | 2-3 GB/s | 313 | | HDD (Mechanical) | 10-40 MB/s | 500-600 MB/s | 314 | | Poor Performance | < 10 MB/s | < 200 MB/s | 315 | 316 | Quick assessment: 317 | 318 | 1. **Primary Check**: 4K read(IOPS) 4K write(IOPS) 319 | - Almost identical with little difference 320 | - ≥ 200 MB/s = NVMe SSD 321 | - 50-100 MB/s = Standard SSD 322 | - 10-40 MB/s = HDD (Mechanical) 323 | - < 10 MB/s = Poor performance, severe overselling/restriction 324 | 325 | 2. **Secondary Check**: 1M total(IOPS) 326 | - IO limit set by provider 327 | - Resource overselling situation 328 | - Higher value is better 329 | - NVMe SSD typically reaches 4-6 GB/s 330 | - Standard SSD typically reaches 1-2 GB/s 331 | 332 | If NVMe SSD's 1M(IOPS) value < 1GB/s, it indicates severe resource overselling. 333 | 334 | Note that this is testing real IO, limited to this project only. The baseline may not be universal for tests not from this project, because they might not use the same parameters when testing, might not set direct IO reading/writing, might use inconsistent IO engines, or might set inconsistent test times, all of which will cause baseline deviations. 335 | 336 | ### **Streaming Media Unlocking** 337 | 338 | Checks common streaming media platform unlocking, though not all are streaming media - some other common platform unlocks are also included. Generally speaking, IP unlocking regions are consistent and don't randomly fluctuate. If you find that multiple platforms have inconsistent unlocking regions, then the IP is likely rented from platforms like IPXO, with slow recognition in various platform databases. Generally speaking, the IP quality won't be good either. 339 | 340 | ### **IP Quality Detection** 341 | 342 | Checks IP-related information from 14 databases. Generally speaking, it's sufficient to look at usage type, company type, and other security information judgments. The security score is really just for amusement. When multiple platforms compare corresponding detection items to corresponding values, it proves that the current IP is indeed as such. Don't just trust information from a single database source. 343 | 344 | ### **Email Port Detection** 345 | 346 | - **SMTP (25)**: Used for email transmission between mail servers (sending mail). 347 | - **SMTPS (465)**: Used for encrypted SMTP mail sending (SSL/TLS method). 348 | - **SMTP (587)**: Used for clients to send email to mail servers, supports STARTTLS encryption. 349 | - **POP3 (110)**: Used for email clients to download mail from servers, unencrypted. 350 | - **POP3S (995)**: Used for encrypted POP3, securely downloading mail (SSL/TLS method). 351 | - **IMAP (143)**: Used for email clients to manage mail online (view, sync mail), unencrypted. 352 | - **IMAPS (993)**: Used for encrypted IMAP, securely managing mail (SSL/TLS method). 353 | 354 | Specifically, if the current host machine is not being used as a mail server or not receiving electronic mail, then this project metric can be disregarded. 355 | 356 | --- 357 | 358 | ## 日本語 359 | 360 | ### **システム基本情報** 361 | 362 | CPU型番: 簡単に言えば、CPUの発売時期によって、新しいモデルならAMDがIntelより優れ、古いモデルならIntelがAMDより優れています。 363 | 364 | CPUコア数: 物理コアか論理コアかを検出し、優先的に物理コアを表示します。物理コアが検出できない場合のみ論理コアを表示します。サーバーの実際の使用では、プログラムは通常、論理コアに基づいて実行されます。ビデオエンコードや科学計算以外では、物理コアは通常ハイパースレッディングを有効にして論理コアとして使用されます。比較する際は、同じタイプのコア数を比較することが意味を持ちます。 365 | 366 | CPUキャッシュ:ホストマシンのCPU L1/L2/L3キャッシュ情報を表示します。 367 | 368 | AES-NI: 暗号化/復号化を高速化する命令セットです。これがあれば通常のネットワークリクエストがより速く、パフォーマンスが高くなります。ない場合はネットワークリクエスト(プロキシ用途を含む)に影響します。 369 | 370 | VM-x/AMD-V/Hyper-V: 現在のテスト環境がネステッド仮想化をサポートしているかどうかを示す指標です。テスト環境がDockerコンテナ内にあるか、root権限がない場合、デフォルトでは検出できず、ネステッド仮想化をサポートしていないと表示されます。この指標は、ホストマシン上で仮想マシン(KVM、VirtualBox、VMwareなど)を設定する必要がある場合に役立ちますが、他の用途ではあまり重要ではありません。 371 | 372 | メモリ: 使用中サイズ/総サイズ のメモリを表示します。仮想メモリは含まれません。 373 | 374 | バルーンドライバ: ホストマシンがバルーンドライバを使用しているかどうかを表示します。使用している場合は、親マシンがメモリを共有していることを示し、以下のメモリ読み書きテストと合わせて、オーバーセリング/厳しい制限があるかどうかを確認する必要があります。 375 | 376 | Kernel Same-page Merging: ホストマシンがKSMメモリマージを使用しているかどうかを表示します。使用している場合は、親マシンがメモリを共有していることを示し、以下のメモリ読み書きテストと合わせて、オーバーセリング/厳しい制限があるかどうかを確認する必要があります。 377 | 378 | 仮想メモリ: SWAP仮想メモリを表示します 379 | 380 | ディスク容量: 使用中サイズ/総サイズ のディスク容量を表示します 381 | 382 | ブートディスクパス:ブートディスクのパスを表示します 383 | 384 | OS: システム名とアーキテクチャを表示します 385 | 386 | カーネル: システムカーネルバージョンを表示します 387 | 388 | システム稼働時間: ホストマシンが起動してからテスト時までの稼働時間を表示します 389 | 390 | タイムゾーン: ホストマシンのシステムタイムゾーンを表示します 391 | 392 | 負荷: システム負荷を表示します 393 | 394 | 仮想化アーキテクチャ: ホストマシンがどの仮想化アーキテクチャから来ているかを表示します。一般的に ```Dedicated > KVM > Xen``` 仮想化が推奨されます。他の仮想化はパフォーマンス低下を引き起こし、使用時にパフォーマンス共有/損失が発生しますが、これも確実ではありません。専用サーバーのみが完全に独立したリソース占有を持ち、他の仮想化はほとんどリソース共有があります。これはホストマシンの販売者が良心的かどうかによって異なります。具体的なパフォーマンスの優劣は、後の専門テストを見る必要があります。 395 | 396 | NAT種類: NAT種類を表示します。具体的には ```Full Cone > Restricted Cone > Port Restricted Cone > Symmetric``` が推奨されます。検出できない場合は ```Inconclusive``` と表示されます。一般的に特別な用途(特殊なプロキシとリアルタイム通信の要件に関連する)に使用しない限り、この指標を気にする必要はありません。 397 | 398 | TCP加速方式:一般的に ```cubic/bbr``` 輻輳制御プロトコルです。一般的にプロキシサーバーとして使用する場合、bbrを使用するとネットワーク速度が改善されますが、通常の用途ではこの指標に注目する必要はありません。 399 | 400 | IPV4/IPV6 ASN: ホストマシンのIPが属するASN組織IDと名前を表示します。同じIDCに複数のASNがある可能性があり、1つのASNの下に異なるIPセグメントのサーバーを販売する複数の業者がいる可能性があります。具体的な上流/下流関係は複雑です。bgp.toolを使用してさらに詳しく調べることができます。 401 | 402 | IPV4/IPV6 ロケーション: データベース内の対応するプロトコルのIPの地理的位置を表示します。 403 | 404 | IPV4 アクティブIP: bgp.tools情報に基づいて、現在のCIDRチャンクのアクティブなネイバー数/総ネイバー数を照会する。 405 | 406 | ### **CPUテスト** 407 | 408 | コマンドラインパラメータを通じて```GeekBench```と```Sysbench```のテストを選択できます: 409 | 410 | | 比較項目 | sysbench | geekbench | 411 | |------------------|----------|-----------| 412 | | 適用範囲 | 軽量、ほぼすべてのサーバーで実行可能 | 重量級、小型マシンでは実行不可 | 413 | | テスト要件 | ネットワーク不要、特別なハードウェア要件なし | ネットワーク必要、IPV4環境、最低1Gメモリ | 414 | | オープンソース状況 | LUAベース、オープンソース、各アーキテクチャ版をコンパイル可能(本プロジェクトではGoに再構築して内蔵) | 公式バイナリはクローズドソース、自己コンパイル不可 | 415 | | テスト安定性 | コアテストコンポーネントは10年以上変更なし | 各メジャーバージョンでテスト項目更新、スコアはバージョン間で比較困難(各バージョンは当時最高のCPUを基準) | 416 | | テスト内容 | 計算性能のみテスト、素数計算ベース | 多様な性能テストカバー、スコアは重み付け計算、一部テストは実際にはあまり使用されない | 417 | | 適用シーン | 迅速なテストに適合、計算性能のみテスト | 総合的な全面テストに適合 | 418 | 419 | デフォルトでは```Sysbench```を使用してテストを行います。基準は概ね以下の通りです: 420 | 421 | CPUテストのシングルコア```Sysbench```スコアが5000以上なら第一ティア、4000〜5000点なら第二ティア、1000点ごとに大体一ランクと考えられます。 422 | 423 | AMDの7950xシングルコアのフルパフォーマンススコアは約6500、AMDの5950xシングルコアのフルパフォーマンススコアは約5700、Intelの通常のCPU(E5など)は約1000〜800、500未満のシングルコアCPUはパフォーマンスが比較的低いと言えます。 424 | 425 | 時々、マルチコアスコアとシングルコアスコアが同じ場合があります。これは販売者がプログラムの並列CPU使用を制限していることを示しています。典型的な例はTencent Cloudです。 426 | 427 | ```GeekBench```の基準は[公式ウェブサイト](https://browser.geekbench.com/processor-benchmarks/)の階層チャートを参照してください。具体的なスコアは各```GeekBench```バージョンで異なるため、テスト時の```GeekBench```バージョンに注意してください。 428 | 429 | 補足ですが、```GeekBench```がテストする多くの内容は、サーバー使用過程で実際には必要ないことが多いです。テストは参考程度にしてください。もちろん```Sysbench```は非常に包括的ではありませんが、基本的な計算性能に基づいてCPUのパフォーマンスを大まかに比較できます。 430 | 431 | 実際にはCPUパフォーマンスは十分であれば良く、科学計算やビデオエンコード以外では、特に高性能CPUを追求する必要はありません。 432 | 433 | ### **メモリテスト** 434 | 435 | 一般的に、IO速度が```10240MB/s```未満かどうかを判断するだけで十分です。この値を下回る場合、メモリパフォーマンスが良くなく、オーバーセリング/オーバーコミットの問題がある可能性が非常に高いです。 436 | 437 | オーバーコミットの原因は、仮想メモリの使用(ディスクをメモリとして使用)、ZRAM(CPUパフォーマンスを犠牲)、バルーンドライバの使用、KSMメモリマージの使用など、様々な可能性があります。 438 | 439 | ### **ディスクテスト** 440 | 441 | ```dd```テストは誤差が大きい可能性がありますが、テスト速度が速くディスクサイズ制限がありません。```fio```テストはより現実的ですが、テスト速度が遅く、ディスクおよびメモリサイズの最低要件があります。 442 | 443 | 同時に、サーバーには異なるファイルシステムがある可能性があり、特定のファイルシステムのIOエンジンは同じハードウェア条件下でも読み書き速度が速くなる場合があります。これは正常です。プロジェクトはデフォルトで```fio```を使用してテストを行います。テストに使用されるIOエンジンの優先順位は```libaio > posixaio > psync```です。代替オプションの```dd```テストは```fio```テストが利用できない場合に自動的に置き換えられます。 444 | 445 | ```fio```テスト結果を例に基準は以下の通りです: 446 | 447 | | OSタイプ | 主要指標 | 副次指標 | 448 | |---------|-------------------|---------------------| 449 | | Windows/Mac | 4K読み → 64K読み → 書き込みテスト | グラフィカルインターフェースシステムは読み取りパフォーマンスを優先 | 450 | | Linux (GUIなし) | 4K読み + 4K書き + 1M読み書き| 読み/書き値は通常類似 | 451 | 452 | 以下のディスクタイプの指標値は、通常〜フルパフォーマンス状態を示し、```libaio```をIOテストエンジンとして使用し、```Linux```でテストを実施した場合を指します: 453 | 454 | | ドライブタイプ | 4K(IOPS)パフォーマンス | 1M(IOPS)パフォーマンス | 455 | |------------|--------------------------|----------------------| 456 | | NVMe SSD | ≥ 200 MB/s | 5-10 GB/s | 457 | | 標準SSD | 50-100 MB/s | 2-3 GB/s | 458 | | HDD (機械式ハードディスク) | 10-40 MB/s | 500-600 MB/s | 459 | | 性能不良 | < 10 MB/s | < 200 MB/s | 460 | 461 | 迅速な評価: 462 | 463 | 1. **主要チェック**: 4K読み(IOPS) 4K書き(IOPS) 464 | - ほぼ同じで大きな差がない 465 | - ≥ 200 MB/s = NVMe SSD 466 | - 50-100 MB/s = 標準SSD 467 | - 10-40 MB/s = HDD (機械式ハードディスク) 468 | - < 10 MB/s = 性能不良、オーバーセリング/制限が深刻 469 | 470 | 2. **副次チェック**: 1M合計(IOPS) 471 | - プロバイダが設定したIO制限 472 | - リソースのオーバーコミット状況 473 | - 値が高いほど良い 474 | - NVMe SSDは通常4-6 GB/s達成 475 | - 標準SSDは通常1-2 GB/s達成 476 | 477 | NVMe SSDの1M(IOPS)値が< 1GB/sの場合、深刻なリソースオーバーコミットが存在することを示します。 478 | 479 | 注意:ここでテストされるのは実際のIOであり、本プロジェクトに限定されます。本プロジェクト以外のテストによるIOは基準の普遍性を保証できません。他のテストでは同じパラメータを使用していない可能性があり、IO直接読み書きを設定していない可能性、IOエンジンの設定が一致しない可能性、テスト時間の設定が一致しない可能性があり、これらはすべて基準にズレを生じさせる原因となります。 480 | 481 | ### **ストリーミングメディアロック解除** 482 | 483 | 一般的なストリーミングメディアプラットフォームのロック解除を検索します。もちろん、すべてがストリーミングメディアというわけではなく、他の一般的なプラットフォームのロック解除も含まれています。一般的に、IPのロック解除地域は一貫しており、あちこちに変動することはありません。複数のプラットフォームでロック解除地域が一致しない場合、そのIPはIPXOなどのプラットフォームからレンタルされている可能性が高く、各プラットフォームのデータベース識別が遅いため、IP品質も一般的に良くないと考えられます。 484 | 485 | ### **IP品質検出** 486 | 487 | 14のデータベースのIP関連情報を検出します。一般的に、使用タイプ、会社タイプ、およびその他のセキュリティ情報の判別を見るだけで十分です。セキュリティスコアは参考程度です。複数のプラットフォームで対応する検出項目が一致している場合、現在のIPが確かにそうであることを証明しています。単一のデータベースソースの情報だけを信頼しないでください。 488 | 489 | ### **メールポート検出** 490 | 491 | - **SMTP(25)**:メールサーバー間でメールを転送するために使用されます(メール送信)。 492 | - **SMTPS(465)**:暗号化されたSMTPメール送信(SSL/TLS方式)に使用されます。 493 | - **SMTP(587)**:クライアントからメールサーバーへのメール送信に使用され、STARTTLS暗号化をサポートします。 494 | - **POP3(110)**:メールクライアントがサーバーからメールをダウンロードするために使用され、暗号化されていません。 495 | - **POP3S(995)**:暗号化されたPOP3用で、安全にメールをダウンロードします(SSL/TLS方式)。 496 | - **IMAP(143)**:メールクライアントがオンラインでメールを管理するために使用されます(メールの閲覧、同期)、暗号化されていません。 497 | - **IMAPS(993)**:暗号化されたIMAP用で、安全にメールを管理します(SSL/TLS方式)。 498 | 499 | 具体的に現在のホストマシンがメールサーバーとして使用されていない、または電子メールを受信しない場合、この項目の指標は気にする必要はありません。 500 | 501 | --- 502 | -------------------------------------------------------------------------------- /back/backtrace/backtrace.go: -------------------------------------------------------------------------------- 1 | package backtrace 2 | 3 | import ( 4 | "github.com/oneclickvirt/backtrace/bk" 5 | ) 6 | 7 | func BackTrace(enableIpv6 bool) { 8 | backtrace.BackTrace(enableIpv6) 9 | } 10 | -------------------------------------------------------------------------------- /back/backtrace/backtrace_test.go: -------------------------------------------------------------------------------- 1 | package backtrace 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | //func TestGeneratePrefixMap(t *testing.T) { 8 | // prefix := "223.119.8.0/21" 9 | // prefixList := GeneratePrefixList(prefix) 10 | // if prefixList != nil { 11 | // // 打印生成的IP地址前缀列表 12 | // for _, ip := range prefixList { 13 | // fmt.Println(ip) 14 | // } 15 | // } 16 | //} 17 | 18 | // 本包仅测试,无实际使用 19 | func TestBackTrace(t *testing.T) { 20 | BackTrace(false) 21 | } 22 | -------------------------------------------------------------------------------- /back/basic/basic_test.go: -------------------------------------------------------------------------------- 1 | package basic1 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func Test_basic(t *testing.T) { 8 | Basic("zh") 9 | } 10 | -------------------------------------------------------------------------------- /back/basic/basiccheck.go: -------------------------------------------------------------------------------- 1 | package basic1 2 | 3 | import ( 4 | "fmt" 5 | "github.com/oneclickvirt/basics/network" 6 | "github.com/oneclickvirt/basics/system" 7 | "strings" 8 | ) 9 | 10 | // 本包不在main中使用,仅做测试使用,真正调用的在 utils 中的 BasicsAndSecurityCheck 11 | func Basic(language string) { 12 | ipInfo, _, _ := network.NetworkCheck("both", false, language) 13 | systemInfo := system.CheckSystemInfo(language) 14 | basicInfo := strings.ReplaceAll(systemInfo+ipInfo, "\n\n", "\n") 15 | fmt.Printf(basicInfo) 16 | } 17 | -------------------------------------------------------------------------------- /back/commediatest/media.go: -------------------------------------------------------------------------------- 1 | package commediatest 2 | 3 | import ( 4 | "fmt" 5 | "github.com/oneclickvirt/CommonMediaTests/commediatests" 6 | ) 7 | 8 | func ComMediaTest(language string) { 9 | res := commediatests.MediaTests(language) 10 | fmt.Printf(res) 11 | } 12 | -------------------------------------------------------------------------------- /back/commediatest/media_test.go: -------------------------------------------------------------------------------- 1 | package commediatest 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | // 本包仅测试无实际使用 8 | func TestMedia(t *testing.T) { 9 | ComMediaTest("zh") 10 | } 11 | -------------------------------------------------------------------------------- /back/network/network.go: -------------------------------------------------------------------------------- 1 | package network1 2 | 3 | import "github.com/oneclickvirt/security/network" 4 | 5 | // 本包在main中不使用 6 | func NetworkCheck(checkType string, enableSecurityCheck bool, language string) (string, string, error) { 7 | return network.NetworkCheck(checkType, enableSecurityCheck, language) 8 | } 9 | -------------------------------------------------------------------------------- /back/network/network_test.go: -------------------------------------------------------------------------------- 1 | package network1 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | ) 7 | 8 | func TestIpv4SecurityCheck(t *testing.T) { 9 | // 单项测试 10 | //result1, _ := Ipv4SecurityCheck("8.8.8.8", nil, "zh") 11 | //fmt.Println(result1) 12 | //result2, _ := Ipv6SecurityCheck("2001:4860:4860::8844", nil, "zh") 13 | //fmt.Println(result2) 14 | 15 | // 全项测试 16 | ipInfo, securityInfo, _ := NetworkCheck("both", true, "zh") 17 | fmt.Println("--------------------------------------------------") 18 | fmt.Printf(ipInfo) 19 | fmt.Println("--------------------------------------------------") 20 | fmt.Printf(securityInfo) 21 | fmt.Println("--------------------------------------------------") 22 | } 23 | -------------------------------------------------------------------------------- /back/ntrace/ntrace.go: -------------------------------------------------------------------------------- 1 | package ntrace 2 | 3 | import ( 4 | "github.com/oneclickvirt/nt3/nt" 5 | ) 6 | 7 | func TraceRoute3(language, location, checkType string) { 8 | nt.TraceRoute(language, location, checkType) 9 | } 10 | -------------------------------------------------------------------------------- /back/ntrace/ntrace_test.go: -------------------------------------------------------------------------------- 1 | package ntrace 2 | 3 | import "testing" 4 | 5 | // https://github.com/nxtrace/NTrace-core/blob/main/fast_trace/fast_trace.go 6 | // 本包仅测试无实际使用 7 | func TestTraceRoute(t *testing.T) { 8 | TraceRoute3("en", "GZ", "ipv4") 9 | } 10 | -------------------------------------------------------------------------------- /back/port/port.go: -------------------------------------------------------------------------------- 1 | package port 2 | 3 | import ( 4 | "fmt" 5 | "github.com/oneclickvirt/portchecker/email" 6 | ) 7 | 8 | // 常用端口阻断检测 TCP/UDP/ICMP 协议 9 | // 本包不在main中使用 10 | func EmailCheck() { 11 | res := email.EmailCheck() 12 | fmt.Println(res) 13 | } 14 | -------------------------------------------------------------------------------- /back/port/port_test.go: -------------------------------------------------------------------------------- 1 | package port 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func Test(t *testing.T) { 8 | EmailCheck() 9 | } 10 | -------------------------------------------------------------------------------- /cputest/cputest.go: -------------------------------------------------------------------------------- 1 | package cputest 2 | 3 | import ( 4 | "fmt" 5 | "github.com/oneclickvirt/cputest/cpu" 6 | "runtime" 7 | "strings" 8 | ) 9 | 10 | func CpuTest(language, testMethod, testThread string) { 11 | var res string 12 | if runtime.GOOS == "windows" { 13 | if testMethod != "winsat" && testMethod != "" { 14 | res = "Detected host is Windows, using Winsat for testing.\n" 15 | } 16 | res += cpu.WinsatTest(language, testThread) 17 | } else { 18 | switch testMethod { 19 | case "sysbench": 20 | res = cpu.SysBenchTest(language, testThread) 21 | if res == "" { 22 | res = "Sysbench test failed, switching to Geekbench for testing.\n" 23 | res += cpu.GeekBenchTest(language, testThread) 24 | } 25 | case "geekbench": 26 | res = cpu.GeekBenchTest(language, testThread) 27 | if res == "" { 28 | res = "Geekbench test failed, switching to Sysbench for testing.\n" 29 | res += cpu.SysBenchTest(language, testThread) 30 | } 31 | default: 32 | res = "Invalid test method specified.\n" 33 | } 34 | } 35 | if !strings.Contains(res, "\n") && res != "" { 36 | res += "\n" 37 | } 38 | fmt.Print(res) 39 | } 40 | -------------------------------------------------------------------------------- /cputest/cputest_test.go: -------------------------------------------------------------------------------- 1 | package cputest 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func Test(t *testing.T) { 8 | CpuTest("zh", "sysbench", "1") 9 | } 10 | -------------------------------------------------------------------------------- /disktest/disktest.go: -------------------------------------------------------------------------------- 1 | package disktest 2 | 3 | import ( 4 | "fmt" 5 | "github.com/oneclickvirt/disktest/disk" 6 | "runtime" 7 | "strings" 8 | ) 9 | 10 | func DiskTest(language, testMethod, testPath string, isMultiCheck bool, autoChange bool) { 11 | var res string 12 | if runtime.GOOS == "windows" { 13 | if testMethod != "winsat" && testMethod != "" { 14 | res = "Detected host is Windows, using Winsat for testing.\n" 15 | } 16 | res = disk.WinsatTest(language, isMultiCheck, testPath) 17 | } else { 18 | switch testMethod { 19 | case "fio": 20 | res = disk.FioTest(language, isMultiCheck, testPath) 21 | if res == "" && autoChange { 22 | res = "Fio test failed, switching to DD for testing.\n" 23 | res += disk.DDTest(language, isMultiCheck, testPath) 24 | } 25 | case "dd": 26 | res = disk.DDTest(language, isMultiCheck, testPath) 27 | if res == "" && autoChange { 28 | res = "DD test failed, switching to Fio for testing.\n" 29 | res += disk.FioTest(language, isMultiCheck, testPath) 30 | } 31 | default: 32 | res = "Unsupported test method specified.\n" 33 | } 34 | } 35 | //fmt.Println("--------------------------------------------------") 36 | if !strings.Contains(res, "\n") && res != "" { 37 | res += "\n" 38 | } 39 | fmt.Printf(res) 40 | //fmt.Println("--------------------------------------------------") 41 | } 42 | -------------------------------------------------------------------------------- /disktest/disktest_test.go: -------------------------------------------------------------------------------- 1 | package disktest 2 | 3 | import "testing" 4 | 5 | func TestDiskIoTest(t *testing.T) { 6 | DiskTest("zh", "sysbench", "", false) 7 | } 8 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/oneclickvirt/ecs 2 | 3 | go 1.24.1 4 | 5 | toolchain go1.24.2 6 | 7 | require ( 8 | github.com/imroc/req/v3 v3.50.0 9 | github.com/oneclickvirt/CommonMediaTests v0.0.4-20250329123841 10 | github.com/oneclickvirt/UnlockTests v0.0.26-20250329125926 11 | github.com/oneclickvirt/backtrace v0.0.5-20250517095024 12 | github.com/oneclickvirt/basics v0.0.12-20250521031609 13 | github.com/oneclickvirt/cputest v0.0.10-20250404151448 14 | github.com/oneclickvirt/defaultset v0.0.2-20240624082446 15 | github.com/oneclickvirt/disktest v0.0.8-20250425015826 16 | github.com/oneclickvirt/gostun v0.0.3-20250329105202 17 | github.com/oneclickvirt/memorytest v0.0.5-20250406063420 18 | github.com/oneclickvirt/nt3 v0.0.5-20250416131047 19 | github.com/oneclickvirt/pingtest v0.0.7-20250413051539 20 | github.com/oneclickvirt/portchecker v0.0.3-20250329125750 21 | github.com/oneclickvirt/security v0.0.4-20250522031128 22 | github.com/oneclickvirt/speedtest v0.0.9-20250521034111 23 | ) 24 | 25 | require ( 26 | github.com/PuerkitoBio/goquery v1.9.2 // indirect 27 | github.com/StackExchange/wmi v1.2.1 // indirect 28 | github.com/andybalholm/brotli v1.1.1 // indirect 29 | github.com/andybalholm/cascadia v1.3.2 // indirect 30 | github.com/cloudflare/circl v1.5.0 // indirect 31 | github.com/fatih/color v1.18.0 // indirect 32 | github.com/fsnotify/fsnotify v1.9.0 // indirect 33 | github.com/ghodss/yaml v1.0.0 // indirect 34 | github.com/go-ole/go-ole v1.2.6 // indirect 35 | github.com/go-task/slim-sprig/v3 v3.0.0 // indirect 36 | github.com/go-viper/mapstructure/v2 v2.2.1 // indirect 37 | github.com/gofrs/uuid/v5 v5.2.0 // indirect 38 | github.com/google/gopacket v1.1.19 // indirect 39 | github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad // indirect 40 | github.com/google/uuid v1.6.0 // indirect 41 | github.com/gorilla/websocket v1.5.3 // indirect 42 | github.com/hashicorp/errwrap v1.1.0 // indirect 43 | github.com/hashicorp/go-multierror v1.1.1 // indirect 44 | github.com/huin/goupnp v1.2.0 // indirect 45 | github.com/jackpal/go-nat-pmp v1.0.2 // indirect 46 | github.com/jaypipes/ghw v0.12.0 // indirect 47 | github.com/jaypipes/pcidb v1.0.0 // indirect 48 | github.com/json-iterator/go v1.1.12 // indirect 49 | github.com/klauspost/compress v1.17.11 // indirect 50 | github.com/koron/go-ssdp v0.0.4 // indirect 51 | github.com/libp2p/go-nat v0.2.0 // indirect 52 | github.com/libp2p/go-netroute v0.2.1 // indirect 53 | github.com/lionsoul2014/ip2region v2.11.2+incompatible // indirect 54 | github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect 55 | github.com/mattn/go-colorable v0.1.14 // indirect 56 | github.com/mattn/go-isatty v0.0.20 // indirect 57 | github.com/mattn/go-runewidth v0.0.16 // indirect 58 | github.com/miekg/dns v1.1.61 // indirect 59 | github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect 60 | github.com/mitchellh/go-homedir v1.1.0 // indirect 61 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect 62 | github.com/modern-go/reflect2 v1.0.2 // indirect 63 | github.com/nxtrace/NTrace-core v1.4.0 // indirect 64 | github.com/oneclickvirt/dd v0.0.1-20250406062523 // indirect 65 | github.com/oneclickvirt/fio v0.0.1-20250406060851 // indirect 66 | github.com/onsi/ginkgo/v2 v2.22.1 // indirect 67 | github.com/oschwald/maxminddb-golang v1.13.1 // indirect 68 | github.com/pelletier/go-toml/v2 v2.2.4 // indirect 69 | github.com/pion/dtls/v2 v2.2.7 // indirect 70 | github.com/pion/logging v0.2.2 // indirect 71 | github.com/pion/stun/v2 v2.0.0 // indirect 72 | github.com/pion/transport/v2 v2.2.1 // indirect 73 | github.com/pion/transport/v3 v3.0.1 // indirect 74 | github.com/pkg/errors v0.9.1 // indirect 75 | github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect 76 | github.com/prometheus-community/pro-bing v0.4.1 // indirect 77 | github.com/quic-go/qpack v0.5.1 // indirect 78 | github.com/quic-go/quic-go v0.48.2 // indirect 79 | github.com/refraction-networking/utls v1.6.7 // indirect 80 | github.com/rivo/uniseg v0.4.7 // indirect 81 | github.com/rodaine/table v1.3.0 // indirect 82 | github.com/sagikazarmark/locafero v0.9.0 // indirect 83 | github.com/schollz/progressbar/v3 v3.14.4 // indirect 84 | github.com/shirou/gopsutil v3.21.11+incompatible // indirect 85 | github.com/shirou/gopsutil/v4 v4.24.5 // indirect 86 | github.com/shoenig/go-m1cpu v0.1.6 // indirect 87 | github.com/showwin/speedtest-go v1.7.7 // indirect 88 | github.com/sourcegraph/conc v0.3.0 // indirect 89 | github.com/spf13/afero v1.14.0 // indirect 90 | github.com/spf13/cast v1.7.1 // indirect 91 | github.com/spf13/pflag v1.0.6 // indirect 92 | github.com/spf13/viper v1.20.1 // indirect 93 | github.com/subosito/gotenv v1.6.0 // indirect 94 | github.com/tidwall/gjson v1.18.0 // indirect 95 | github.com/tidwall/match v1.1.1 // indirect 96 | github.com/tidwall/pretty v1.2.1 // indirect 97 | github.com/tklauser/go-sysconf v0.3.14 // indirect 98 | github.com/tklauser/numcpus v0.8.0 // indirect 99 | github.com/tsosunchia/powclient v0.1.5 // indirect 100 | github.com/yusufpapurcu/wmi v1.2.4 // indirect 101 | go.uber.org/mock v0.5.0 // indirect 102 | go.uber.org/multierr v1.11.0 // indirect 103 | go.uber.org/zap v1.27.0 // indirect 104 | golang.org/x/crypto v0.37.0 // indirect 105 | golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 // indirect 106 | golang.org/x/mod v0.22.0 // indirect 107 | golang.org/x/net v0.39.0 // indirect 108 | golang.org/x/sync v0.13.0 // indirect 109 | golang.org/x/sys v0.32.0 // indirect 110 | golang.org/x/term v0.31.0 // indirect 111 | golang.org/x/text v0.24.0 // indirect 112 | golang.org/x/tools v0.29.0 // indirect 113 | gopkg.in/yaml.v2 v2.4.0 // indirect 114 | gopkg.in/yaml.v3 v3.0.1 // indirect 115 | howett.net/plist v1.0.0 // indirect 116 | ) 117 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/PuerkitoBio/goquery v1.9.2 h1:4/wZksC3KgkQw7SQgkKotmKljk0M6V8TUvA8Wb4yPeE= 2 | github.com/PuerkitoBio/goquery v1.9.2/go.mod h1:GHPCaP0ODyyxqcNoFGYlAprUFH81NuRPd0GX3Zu2Mvk= 3 | github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= 4 | github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= 5 | github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA= 6 | github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA= 7 | github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss= 8 | github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU= 9 | github.com/cloudflare/circl v1.5.0 h1:hxIWksrX6XN5a1L2TI/h53AGPhNHoUBo+TD1ms9+pys= 10 | github.com/cloudflare/circl v1.5.0/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs= 11 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 12 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 13 | github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= 14 | github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 15 | github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= 16 | github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= 17 | github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= 18 | github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= 19 | github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= 20 | github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= 21 | github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= 22 | github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= 23 | github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= 24 | github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= 25 | github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= 26 | github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= 27 | github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= 28 | github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= 29 | github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= 30 | github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss= 31 | github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= 32 | github.com/gofrs/uuid/v5 v5.2.0 h1:qw1GMx6/y8vhVsx626ImfKMuS5CvJmhIKKtuyvfajMM= 33 | github.com/gofrs/uuid/v5 v5.2.0/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8= 34 | github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 35 | github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= 36 | github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= 37 | github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= 38 | github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8= 39 | github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo= 40 | github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad h1:a6HEuzUHeKH6hwfN/ZoQgRgVIWFJljSWa/zetS2WTvg= 41 | github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= 42 | github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= 43 | github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 44 | github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= 45 | github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= 46 | github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= 47 | github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= 48 | github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= 49 | github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= 50 | github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= 51 | github.com/huin/goupnp v1.2.0 h1:uOKW26NG1hsSSbXIZ1IR7XP9Gjd1U8pnLaCMgntmkmY= 52 | github.com/huin/goupnp v1.2.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= 53 | github.com/imroc/req/v3 v3.50.0 h1:n3BVnZiTRpvkN5T1IB79LC/THhFU9iXksNRMH4ZNVaY= 54 | github.com/imroc/req/v3 v3.50.0/go.mod h1:tsOk8K7zI6cU4xu/VWCZVtq9Djw9IWm4MslKzme5woU= 55 | github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= 56 | github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= 57 | github.com/jaypipes/ghw v0.12.0 h1:xU2/MDJfWmBhJnujHY9qwXQLs3DBsf0/Xa9vECY0Tho= 58 | github.com/jaypipes/ghw v0.12.0/go.mod h1:jeJGbkRB2lL3/gxYzNYzEDETV1ZJ56OKr+CSeSEym+g= 59 | github.com/jaypipes/pcidb v1.0.0 h1:vtZIfkiCUE42oYbJS0TAq9XSfSmcsgo9IdxSm9qzYU8= 60 | github.com/jaypipes/pcidb v1.0.0/go.mod h1:TnYUvqhPBzCKnH34KrIX22kAeEbDCSRJ9cqLRCuNDfk= 61 | github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= 62 | github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= 63 | github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= 64 | github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213/go.mod h1:vNUNkEQ1e29fT/6vq2aBdFsgNPmy8qMdSay1npru+Sw= 65 | github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc= 66 | github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= 67 | github.com/koron/go-ssdp v0.0.4 h1:1IDwrghSKYM7yLf7XCzbByg2sJ/JcNOZRXS2jczTwz0= 68 | github.com/koron/go-ssdp v0.0.4/go.mod h1:oDXq+E5IL5q0U8uSBcoAXzTzInwy5lEgC91HoKtbmZk= 69 | github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= 70 | github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= 71 | github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= 72 | github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= 73 | github.com/libp2p/go-nat v0.2.0 h1:Tyz+bUFAYqGyJ/ppPPymMGbIgNRH+WqC5QrT5fKrrGk= 74 | github.com/libp2p/go-nat v0.2.0/go.mod h1:3MJr+GRpRkyT65EpVPBstXLvOlAPzUVlG6Pwg9ohLJk= 75 | github.com/libp2p/go-netroute v0.2.1 h1:V8kVrpD8GK0Riv15/7VN6RbUQ3URNZVosw7H2v9tksU= 76 | github.com/libp2p/go-netroute v0.2.1/go.mod h1:hraioZr0fhBjG0ZRXJJ6Zj2IVEVNx6tDTFQfSmcq7mQ= 77 | github.com/lionsoul2014/ip2region v2.11.2+incompatible h1:+VRsGcrHz8ewXI/2UzTptJlACsxD/p4xCxuql4u2nKU= 78 | github.com/lionsoul2014/ip2region v2.11.2+incompatible/go.mod h1:+ZBN7PBoh5gG6/y0ZQ85vJDBe21WnfbRrQQwTfliJJI= 79 | github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= 80 | github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= 81 | github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= 82 | github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= 83 | github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= 84 | github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= 85 | github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= 86 | github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= 87 | github.com/miekg/dns v1.1.61 h1:nLxbwF3XxhwVSm8g9Dghm9MHPaUZuqhPiGL+675ZmEs= 88 | github.com/miekg/dns v1.1.61/go.mod h1:mnAarhS3nWaW+NVP2wTkYVIZyHNJ098SJZUki3eykwQ= 89 | github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ= 90 | github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw= 91 | github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= 92 | github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= 93 | github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 94 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= 95 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 96 | github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= 97 | github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= 98 | github.com/nxtrace/NTrace-core v1.4.0 h1:pDN2BqxIYjedDKCDDOFBcDNOBnavGcx+4wbiG65Xqiw= 99 | github.com/nxtrace/NTrace-core v1.4.0/go.mod h1:0AWqbqiIJbpbFG6W48vtJ6pWM8PPF+lQ1fi2371y+zA= 100 | github.com/oneclickvirt/CommonMediaTests v0.0.4-20250329123841 h1:Zef93z9UiZQwRAKnnZYALmpBKvvuVaq34MEsuWwk6nc= 101 | github.com/oneclickvirt/CommonMediaTests v0.0.4-20250329123841/go.mod h1:DAmFPRjFV5p9fEzUUSml5jJGn2f1NZJQCzTxITHDjc4= 102 | github.com/oneclickvirt/UnlockTests v0.0.26-20250329125926 h1:H5//xwVjDR02bQ1hLa3G7LnwccsudPMjBVt7WCx2y/U= 103 | github.com/oneclickvirt/UnlockTests v0.0.26-20250329125926/go.mod h1:yXWIZB6iLS88pEd9m4QJi1GENn+7I91zA72y5ONz2Oc= 104 | github.com/oneclickvirt/backtrace v0.0.5-20250517095024 h1:j912aga/17znOqMB2VAxWOQYa4GL6YMFBhv+6c7jkvA= 105 | github.com/oneclickvirt/backtrace v0.0.5-20250517095024/go.mod h1:5AH00bo41hH3d2/JVuCTlBkZUs3AXX4nlKVXb6piZcI= 106 | github.com/oneclickvirt/basics v0.0.12-20250521031609 h1:3WxHe+jKrZHF81oa8Xk3IgHCRqTC5GDjv8alR0geamU= 107 | github.com/oneclickvirt/basics v0.0.12-20250521031609/go.mod h1:yN1IEOXN6v/GJqJSA70Pooo6nXBI/6rq72vTY72wJMQ= 108 | github.com/oneclickvirt/cputest v0.0.10-20250404151448 h1:ovGtCwFXG0qmpyNDRqcNDIiAmhrtemCjIUXTJ1fPH0o= 109 | github.com/oneclickvirt/cputest v0.0.10-20250404151448/go.mod h1:MmaHN9+XMntI3rLycwj8Ne31fG18IfNoa8N2utDK1CY= 110 | github.com/oneclickvirt/dd v0.0.1-20250406062523 h1:jegTww4fuoFEqwFozvGJEqUNI/5ew3QJ0XcKZZ/zuTs= 111 | github.com/oneclickvirt/dd v0.0.1-20250406062523/go.mod h1:tImu9sPTkLWo2tf1dEN1xQzrylWKauj9hbU8PHfyAeU= 112 | github.com/oneclickvirt/defaultset v0.0.2-20240624082446 h1:5Pg3mK/u/vQvSz7anu0nxzrNdELi/AcDAU1mMsmPzyc= 113 | github.com/oneclickvirt/defaultset v0.0.2-20240624082446/go.mod h1:e9Jt4tf2sbemCtc84/XgKcHy9EZ2jkc5x2sW1NiJS+E= 114 | github.com/oneclickvirt/disktest v0.0.8-20250425015826 h1:bwVg0zysB3uCwQV+KIIQpuq2IJXWdIcdjD2+FiKPo5w= 115 | github.com/oneclickvirt/disktest v0.0.8-20250425015826/go.mod h1:sqVu6HwbnLmbnRj4389Xn08c301IhLnWCcbaEk2WzEc= 116 | github.com/oneclickvirt/fio v0.0.1-20250406060851 h1:b7xHKpPmU4q0NmvigRCEr3tQuAV/83ZIAGtHycLegw8= 117 | github.com/oneclickvirt/fio v0.0.1-20250406060851/go.mod h1:NIq+XYTey68KNERGIy/oRDlzpwLzBVoHOCiqX8didsE= 118 | github.com/oneclickvirt/gostun v0.0.3-20250329105202 h1:aJ6E91Lp94lq8iWRcCaxpXTjqOOaWvufr5oras6cFtM= 119 | github.com/oneclickvirt/gostun v0.0.3-20250329105202/go.mod h1:f7DPEXAxbmwXSW33dbxtb0/KzqvOBWhTs2Or5xBerQA= 120 | github.com/oneclickvirt/memorytest v0.0.5-20250406063420 h1:eHqpqFIx8Ss062uyNf7Ruv7FC4AdZbElR7u9vX2Oj3g= 121 | github.com/oneclickvirt/memorytest v0.0.5-20250406063420/go.mod h1:HTd0sSxRjT4BcV8kcCh4fF2Nia0xgZNaVjhefsnypic= 122 | github.com/oneclickvirt/nt3 v0.0.5-20250416131047 h1:KL0xowq19cW+FMBGMJxdqpRNoeyR+eEmb+jYSubmlTk= 123 | github.com/oneclickvirt/nt3 v0.0.5-20250416131047/go.mod h1:CVsDJEaIdyyZHn3WKbhU8Wn6GOfmBNvJlC/dDLRqcSQ= 124 | github.com/oneclickvirt/pingtest v0.0.7-20250413051539 h1:mYOsEmMtwKr40hwM2NimVLpnbR2cjwuOh1c/9fQr2Dw= 125 | github.com/oneclickvirt/pingtest v0.0.7-20250413051539/go.mod h1:d3Ntx5m9lMll3a/k3+2B+5emj//vgDh4/NHTxs2qQE8= 126 | github.com/oneclickvirt/portchecker v0.0.3-20250329125750 h1:TTNL0pnQlRsn046kW59I/9UWRpihttFHWnU7Ixycggk= 127 | github.com/oneclickvirt/portchecker v0.0.3-20250329125750/go.mod h1:HQxSTrqM8/QFqHMTBZ7S8H9eEO5FkUXU1eb7ZX5Mk+k= 128 | github.com/oneclickvirt/security v0.0.4-20250522031128 h1:k/zpiES/W0lW6Rumlmo4i7zp2ncimfeOUKadrylde8M= 129 | github.com/oneclickvirt/security v0.0.4-20250522031128/go.mod h1:hdCr9UFkJ0tQfFP4mIycZehF5v7VfzSQwNn2qkY0bGo= 130 | github.com/oneclickvirt/speedtest v0.0.9-20250521034111 h1:yygDk+s5qFhPMDRzdMfyopm1xU512peNqY6WYyvYcfY= 131 | github.com/oneclickvirt/speedtest v0.0.9-20250521034111/go.mod h1:zd5ZgIGslmtQLQehEfRjyumlvgDHTpCSMchKfKXoASI= 132 | github.com/onsi/ginkgo/v2 v2.22.1 h1:QW7tbJAUDyVDVOM5dFa7qaybo+CRfR7bemlQUN6Z8aM= 133 | github.com/onsi/ginkgo/v2 v2.22.1/go.mod h1:S6aTpoRsSq2cZOd+pssHAlKW/Q/jZt6cPrPlnj4a1xM= 134 | github.com/onsi/gomega v1.36.1 h1:bJDPBO7ibjxcbHMgSCoo4Yj18UWbKDlLwX1x9sybDcw= 135 | github.com/onsi/gomega v1.36.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog= 136 | github.com/oschwald/maxminddb-golang v1.13.1 h1:G3wwjdN9JmIK2o/ermkHM+98oX5fS+k5MbwsmL4MRQE= 137 | github.com/oschwald/maxminddb-golang v1.13.1/go.mod h1:K4pgV9N/GcK694KSTmVSDTODk4IsCNThNdTmnaBZ/F8= 138 | github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= 139 | github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= 140 | github.com/pion/dtls/v2 v2.2.7 h1:cSUBsETxepsCSFSxC3mc/aDo14qQLMSL+O6IjG28yV8= 141 | github.com/pion/dtls/v2 v2.2.7/go.mod h1:8WiMkebSHFD0T+dIU+UeBaoV7kDhOW5oDCzZ7WZ/F9s= 142 | github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY= 143 | github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms= 144 | github.com/pion/stun/v2 v2.0.0 h1:A5+wXKLAypxQri59+tmQKVs7+l6mMM+3d+eER9ifRU0= 145 | github.com/pion/stun/v2 v2.0.0/go.mod h1:22qRSh08fSEttYUmJZGlriq9+03jtVmXNODgLccj8GQ= 146 | github.com/pion/transport/v2 v2.2.1 h1:7qYnCBlpgSJNYMbLCKuSY9KbQdBFoETvPNETv0y4N7c= 147 | github.com/pion/transport/v2 v2.2.1/go.mod h1:cXXWavvCnFF6McHTft3DWS9iic2Mftcz1Aq29pGcU5g= 148 | github.com/pion/transport/v3 v3.0.1 h1:gDTlPJwROfSfz6QfSi0ZmeCSkFcnWWiiR9ES0ouANiM= 149 | github.com/pion/transport/v3 v3.0.1/go.mod h1:UY7kiITrlMv7/IKgd5eTUcaahZx5oUN3l9SzK5f5xE0= 150 | github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= 151 | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 152 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 153 | github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= 154 | github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 155 | github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw= 156 | github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= 157 | github.com/prometheus-community/pro-bing v0.4.1 h1:aMaJwyifHZO0y+h8+icUz0xbToHbia0wdmzdVZ+Kl3w= 158 | github.com/prometheus-community/pro-bing v0.4.1/go.mod h1:aLsw+zqCaDoa2RLVVSX3+UiCkBBXTMtZC3c7EkfWnAE= 159 | github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI= 160 | github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg= 161 | github.com/quic-go/quic-go v0.48.2 h1:wsKXZPeGWpMpCGSWqOcqpW2wZYic/8T3aqiOID0/KWE= 162 | github.com/quic-go/quic-go v0.48.2/go.mod h1:yBgs3rWBOADpga7F+jJsb6Ybg1LSYiQvwWlLX+/6HMs= 163 | github.com/refraction-networking/utls v1.6.7 h1:zVJ7sP1dJx/WtVuITug3qYUq034cDq9B2MR1K67ULZM= 164 | github.com/refraction-networking/utls v1.6.7/go.mod h1:BC3O4vQzye5hqpmDTWUqi4P5DDhzJfkV1tdqtawQIH0= 165 | github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= 166 | github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= 167 | github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= 168 | github.com/rodaine/table v1.3.0 h1:4/3S3SVkHnVZX91EHFvAMV7K42AnJ0XuymRR2C5HlGE= 169 | github.com/rodaine/table v1.3.0/go.mod h1:47zRsHar4zw0jgxGxL9YtFfs7EGN6B/TaS+/Dmk4WxU= 170 | github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= 171 | github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= 172 | github.com/sagikazarmark/locafero v0.9.0 h1:GbgQGNtTrEmddYDSAH9QLRyfAHY12md+8YFTqyMTC9k= 173 | github.com/sagikazarmark/locafero v0.9.0/go.mod h1:UBUyz37V+EdMS3hDF3QWIiVr/2dPrx49OMO0Bn0hJqk= 174 | github.com/schollz/progressbar/v3 v3.14.4 h1:W9ZrDSJk7eqmQhd3uxFNNcTr0QL+xuGNI9dEMrw0r74= 175 | github.com/schollz/progressbar/v3 v3.14.4/go.mod h1:aT3UQ7yGm+2ZjeXPqsjTenwL3ddUiuZ0kfQ/2tHlyNI= 176 | github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= 177 | github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= 178 | github.com/shirou/gopsutil/v4 v4.24.5 h1:gGsArG5K6vmsh5hcFOHaPm87UD003CaDMkAOweSQjhM= 179 | github.com/shirou/gopsutil/v4 v4.24.5/go.mod h1:aoebb2vxetJ/yIDZISmduFvVNPHqXQ9SEJwRXxkf0RA= 180 | github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= 181 | github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= 182 | github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= 183 | github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k= 184 | github.com/showwin/speedtest-go v1.7.7 h1:VmK75SZOTKiuWjIVrs+mo7ZoKEw0utiGCvpnurS0olU= 185 | github.com/showwin/speedtest-go v1.7.7/go.mod h1:uLgdWCNarXxlYsL2E5TOZpCIwpgSWnEANZp7gfHXHu0= 186 | github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= 187 | github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= 188 | github.com/spf13/afero v1.14.0 h1:9tH6MapGnn/j0eb0yIXiLjERO8RB6xIVZRDCX7PtqWA= 189 | github.com/spf13/afero v1.14.0/go.mod h1:acJQ8t0ohCGuMN3O+Pv0V0hgMxNYDlvdk+VTfyZmbYo= 190 | github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y= 191 | github.com/spf13/cast v1.7.1/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= 192 | github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o= 193 | github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= 194 | github.com/spf13/viper v1.20.1 h1:ZMi+z/lvLyPSCoNtFCpqjy0S4kPbirhpTMwl8BkW9X4= 195 | github.com/spf13/viper v1.20.1/go.mod h1:P9Mdzt1zoHIG8m2eZQinpiBjo6kCmZSKBClNNqjJvu4= 196 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 197 | github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= 198 | github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= 199 | github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= 200 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 201 | github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 202 | github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= 203 | github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= 204 | github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= 205 | github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= 206 | github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= 207 | github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= 208 | github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= 209 | github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= 210 | github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= 211 | github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= 212 | github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= 213 | github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= 214 | github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= 215 | github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= 216 | github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= 217 | github.com/tklauser/go-sysconf v0.3.14 h1:g5vzr9iPFFz24v2KZXs/pvpvh8/V9Fw6vQK5ZZb78yU= 218 | github.com/tklauser/go-sysconf v0.3.14/go.mod h1:1ym4lWMLUOhuBOPGtRcJm7tEGX4SCYNEEEtghGG/8uY= 219 | github.com/tklauser/numcpus v0.8.0 h1:Mx4Wwe/FjZLeQsK/6kt2EOepwwSl7SmJrK5bV/dXYgY= 220 | github.com/tklauser/numcpus v0.8.0/go.mod h1:ZJZlAY+dmR4eut8epnzf0u/VwodKmryxR8txiloSqBE= 221 | github.com/tsosunchia/powclient v0.1.5 h1:hpixFWoPbWSEC0zc9osSltyjtr1+SnhCueZVLkEpyyU= 222 | github.com/tsosunchia/powclient v0.1.5/go.mod h1:yNlzyq+w9llYZV+0q7nrX83ULy4ghq2mCjpTLJFJ2pg= 223 | github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU= 224 | github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E= 225 | github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= 226 | github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= 227 | github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= 228 | go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= 229 | go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= 230 | go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU= 231 | go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM= 232 | go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= 233 | go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= 234 | go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= 235 | go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= 236 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 237 | golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 238 | golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= 239 | golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE= 240 | golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= 241 | golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE= 242 | golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc= 243 | golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 h1:yqrTHse8TCMW1M1ZCP+VAR/l0kKxwaAIqN/il7x4voA= 244 | golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8/go.mod h1:tujkw807nyEEAamNbDrEGzRav+ilXA7PCRAd6xsmwiU= 245 | golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= 246 | golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= 247 | golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= 248 | golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= 249 | golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4= 250 | golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= 251 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 252 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 253 | golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= 254 | golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= 255 | golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= 256 | golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= 257 | golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= 258 | golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= 259 | golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY= 260 | golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E= 261 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 262 | golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 263 | golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 264 | golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 265 | golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610= 266 | golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= 267 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 268 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 269 | golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 270 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 271 | golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 272 | golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 273 | golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 274 | golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 275 | golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 276 | golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 277 | golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 278 | golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 279 | golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 280 | golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 281 | golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= 282 | golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= 283 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 284 | golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= 285 | golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= 286 | golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= 287 | golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= 288 | golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= 289 | golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= 290 | golang.org/x/term v0.31.0 h1:erwDkOK1Msy6offm1mOgvspSkslFnIGsFnxOKoufg3o= 291 | golang.org/x/term v0.31.0/go.mod h1:R4BeIy7D95HzImkxGkTW1UQTtP54tio2RyHz7PwK0aw= 292 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 293 | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 294 | golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= 295 | golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= 296 | golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= 297 | golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= 298 | golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0= 299 | golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU= 300 | golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= 301 | golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= 302 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 303 | golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 304 | golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 305 | golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= 306 | golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= 307 | golang.org/x/tools v0.29.0 h1:Xx0h3TtM9rzQpQuR4dKLrdglAmCEN5Oi+P74JdhdzXE= 308 | golang.org/x/tools v0.29.0/go.mod h1:KMQVMRsVxU6nHCFXrBPhDB8XncLNLM0lIy/F14RP588= 309 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 310 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 311 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 312 | google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= 313 | google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= 314 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 315 | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= 316 | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= 317 | gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg= 318 | gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= 319 | gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= 320 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 321 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= 322 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 323 | howett.net/plist v1.0.0 h1:7CrbWYbPPO/PyNy38b2EB/+gYbjCe2DXBxgtOOZbSQM= 324 | howett.net/plist v1.0.0/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g= 325 | -------------------------------------------------------------------------------- /goecs.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bufio" 5 | "context" 6 | "flag" 7 | "fmt" 8 | "github.com/oneclickvirt/CommonMediaTests/commediatests" 9 | unlocktestmodel "github.com/oneclickvirt/UnlockTests/model" 10 | "github.com/oneclickvirt/backtrace/bk" 11 | backtracemodel "github.com/oneclickvirt/backtrace/model" 12 | basicmodel "github.com/oneclickvirt/basics/model" 13 | cputestmodel "github.com/oneclickvirt/cputest/model" 14 | disktestmodel "github.com/oneclickvirt/disktest/disk" 15 | "github.com/oneclickvirt/ecs/cputest" 16 | "github.com/oneclickvirt/ecs/disktest" 17 | "github.com/oneclickvirt/ecs/memorytest" 18 | "github.com/oneclickvirt/ecs/speedtest" 19 | "github.com/oneclickvirt/ecs/unlocktest" 20 | "github.com/oneclickvirt/ecs/utils" 21 | gostunmodel "github.com/oneclickvirt/gostun/model" 22 | memorytestmodel "github.com/oneclickvirt/memorytest/memory" 23 | nt3model "github.com/oneclickvirt/nt3/model" 24 | "github.com/oneclickvirt/nt3/nt" 25 | ptmodel "github.com/oneclickvirt/pingtest/model" 26 | "github.com/oneclickvirt/pingtest/pt" 27 | "github.com/oneclickvirt/portchecker/email" 28 | speedtestmodel "github.com/oneclickvirt/speedtest/model" 29 | "net/http" 30 | "os" 31 | "os/signal" 32 | "regexp" 33 | "runtime" 34 | "strings" 35 | "sync" 36 | "syscall" 37 | "time" 38 | ) 39 | 40 | var ( 41 | ecsVersion = "v0.1.33" 42 | menuMode bool 43 | onlyChinaTest bool 44 | input, choice string 45 | showVersion bool 46 | enableLogger bool 47 | language string 48 | cpuTestMethod, cpuTestThreadMode string 49 | memoryTestMethod string 50 | diskTestMethod, diskTestPath string 51 | diskMultiCheck bool 52 | nt3CheckType, nt3Location string 53 | spNum int 54 | width = 82 55 | basicStatus, cpuTestStatus, memoryTestStatus, diskTestStatus bool 56 | commTestStatus, utTestStatus, securityTestStatus, emailTestStatus bool 57 | backtraceStatus, nt3Status, speedTestStatus, pingTestStatus bool 58 | autoChangeDiskTestMethod = true 59 | filePath = "goecs.txt" 60 | enabelUpload = true 61 | help bool 62 | goecsFlag = flag.NewFlagSet("goecs", flag.ContinueOnError) 63 | finish bool 64 | ) 65 | 66 | func getMenuChoice(language string) string { 67 | ctx, cancel := context.WithCancel(context.Background()) 68 | defer cancel() 69 | sigChan := make(chan os.Signal, 1) 70 | signal.Notify(sigChan, os.Interrupt, syscall.SIGINT, syscall.SIGTERM) 71 | defer signal.Stop(sigChan) 72 | inputChan := make(chan string, 1) 73 | go func() { 74 | select { 75 | case <-sigChan: 76 | fmt.Println("\n程序在选择过程中被用户中断") 77 | os.Exit(0) 78 | case <-ctx.Done(): 79 | return 80 | } 81 | }() 82 | 83 | for { 84 | go func() { 85 | var input string 86 | fmt.Print("请输入选项 / Please enter your choice: ") 87 | fmt.Scanln(&input) 88 | input = strings.TrimSpace(input) 89 | input = strings.TrimRight(input, "\n") 90 | select { 91 | case inputChan <- input: 92 | case <-ctx.Done(): 93 | return 94 | } 95 | }() 96 | select { 97 | case input := <-inputChan: 98 | re := regexp.MustCompile(`^\d+$`) // 正则表达式匹配纯数字 99 | if re.MatchString(input) { 100 | inChoice := input 101 | switch inChoice { 102 | case "1", "2", "3", "4", "5", "6", "7", "8", "9", "10": 103 | return inChoice 104 | default: 105 | if language == "zh" { 106 | fmt.Println("无效的选项") 107 | } else { 108 | fmt.Println("Invalid choice") 109 | } 110 | } 111 | } else { 112 | if language == "zh" { 113 | fmt.Println("输入错误,请输入一个纯数字") 114 | } else { 115 | fmt.Println("Invalid input, please enter a number") 116 | } 117 | } 118 | case <-ctx.Done(): 119 | return "" 120 | } 121 | } 122 | } 123 | 124 | func main() { 125 | goecsFlag.BoolVar(&help, "h", false, "Show help information") 126 | goecsFlag.BoolVar(&showVersion, "v", false, "Display version information") 127 | goecsFlag.BoolVar(&menuMode, "menu", true, "Enable/Disable menu mode, disable example: -menu=false") // true 默认启用菜单栏模式 128 | goecsFlag.StringVar(&language, "l", "zh", "Set language (supported: en, zh)") 129 | goecsFlag.BoolVar(&basicStatus, "basic", true, "Enable/Disable basic test") 130 | goecsFlag.BoolVar(&cpuTestStatus, "cpu", true, "Enable/Disable CPU test") 131 | goecsFlag.BoolVar(&memoryTestStatus, "memory", true, "Enable/Disable memory test") 132 | goecsFlag.BoolVar(&diskTestStatus, "disk", true, "Enable/Disable disk test") 133 | goecsFlag.BoolVar(&commTestStatus, "comm", true, "Enable/Disable common media test") 134 | goecsFlag.BoolVar(&utTestStatus, "ut", true, "Enable/Disable unlock media test") 135 | goecsFlag.BoolVar(&securityTestStatus, "security", true, "Enable/Disable security test") 136 | goecsFlag.BoolVar(&emailTestStatus, "email", true, "Enable/Disable email port test") 137 | goecsFlag.BoolVar(&backtraceStatus, "backtrace", true, "Enable/Disable backtrace test (in 'en' language or on windows it always false)") 138 | goecsFlag.BoolVar(&nt3Status, "nt3", true, "Enable/Disable NT3 test (in 'en' language or on windows it always false)") 139 | goecsFlag.BoolVar(&speedTestStatus, "speed", true, "Enable/Disable speed test") 140 | goecsFlag.StringVar(&cpuTestMethod, "cpum", "sysbench", "Set CPU test method (supported: sysbench, geekbench, winsat)") 141 | goecsFlag.StringVar(&cpuTestThreadMode, "cput", "multi", "Set CPU test thread mode (supported: single, multi)") 142 | goecsFlag.StringVar(&memoryTestMethod, "memorym", "sysbench", "Set memory test method (supported: sysbench, dd, winsat)") 143 | goecsFlag.StringVar(&diskTestMethod, "diskm", "fio", "Set disk test method (supported: fio, dd, winsat)") 144 | goecsFlag.StringVar(&diskTestPath, "diskp", "", "Set disk test path, e.g., -diskp /root") 145 | goecsFlag.BoolVar(&diskMultiCheck, "diskmc", false, "Enable/Disable multiple disk checks, e.g., -diskmc=false") 146 | goecsFlag.StringVar(&nt3Location, "nt3loc", "GZ", "Specify NT3 test location (supported: GZ, SH, BJ, CD for Guangzhou, Shanghai, Beijing, Chengdu)") 147 | goecsFlag.StringVar(&nt3CheckType, "nt3t", "ipv4", "Set NT3 test type (supported: both, ipv4, ipv6)") 148 | goecsFlag.IntVar(&spNum, "spnum", 2, "Set the number of servers per operator for speed test") 149 | goecsFlag.BoolVar(&enableLogger, "log", false, "Enable/Disable logging in the current path") 150 | goecsFlag.BoolVar(&enabelUpload, "upload", true, "Enable/Disable upload the result") 151 | goecsFlag.Parse(os.Args[1:]) 152 | if help { 153 | fmt.Printf("Usage: %s [options]\n", os.Args[0]) 154 | goecsFlag.PrintDefaults() 155 | return 156 | } 157 | if showVersion { 158 | fmt.Println(ecsVersion) 159 | return 160 | } 161 | if enableLogger { 162 | gostunmodel.EnableLoger = true 163 | basicmodel.EnableLoger = true 164 | cputestmodel.EnableLoger = true 165 | memorytestmodel.EnableLoger = true 166 | disktestmodel.EnableLoger = true 167 | commediatests.EnableLoger = true 168 | unlocktestmodel.EnableLoger = true 169 | ptmodel.EnableLoger = true 170 | backtracemodel.EnableLoger = true 171 | nt3model.EnableLoger = true 172 | speedtestmodel.EnableLoger = true 173 | } 174 | go func() { 175 | http.Get("https://hits.spiritlhl.net/goecs.svg?action=hit&title=Hits&title_bg=%23555555&count_bg=%230eecf8&edge_flat=false") 176 | }() 177 | if menuMode { 178 | basicStatus, cpuTestStatus, memoryTestStatus, diskTestStatus = false, false, false, false 179 | commTestStatus, utTestStatus, securityTestStatus, emailTestStatus = false, false, false, false 180 | backtraceStatus, nt3Status, speedTestStatus = false, false, false 181 | autoChangeDiskTestMethod = true 182 | switch language { 183 | case "zh": 184 | fmt.Println("VPS融合怪版本: ", ecsVersion) 185 | fmt.Println("1. 融合怪完全体") 186 | fmt.Println("2. 极简版(系统信息+CPU+内存+磁盘+测速节点5个)") 187 | fmt.Println("3. 精简版(系统信息+CPU+内存+磁盘+常用流媒体+路由+测速节点5个)") 188 | fmt.Println("4. 精简网络版(系统信息+CPU+内存+磁盘+回程+路由+测速节点5个)") 189 | fmt.Println("5. 精简解锁版(系统信息+CPU+内存+磁盘IO+御三家+常用流媒体+测速节点5个)") 190 | fmt.Println("6. 网络单项(IP质量检测+三网回程+三网路由与延迟+测速节点11个)") 191 | fmt.Println("7. 解锁单项(御三家解锁+常用流媒体解锁)") 192 | fmt.Println("8. 硬件单项(系统信息+CPU+内存+dd磁盘测试+fio磁盘测试)") 193 | fmt.Println("9. IP质量检测(15个数据库的IP检测+邮件端口检测)") 194 | fmt.Println("10. 三网回程线路+广州三网路由+全国三网延迟") 195 | case "en": 196 | fmt.Println("VPS Fusion Monster Test Version: ", ecsVersion) 197 | fmt.Println("1. VPS Fusion Monster Test Comprehensive Test Suite") 198 | fmt.Println("2. Minimal Test Suite (System Info + CPU + Memory + Disk + 5 Speed Test Nodes)") 199 | fmt.Println("3. Standard Test Suite (System Info + CPU + Memory + Disk + Basic Unlock Tests + 5 Speed Test Nodes)") 200 | fmt.Println("4. Network-Focused Test Suite (System Info + CPU + Memory + Disk + 5 Speed Test Nodes)") 201 | fmt.Println("5. Unlock-Focused Test Suite (System Info + CPU + Memory + Disk IO + Basic Unlock Tests + Common Streaming Services + 5 Speed Test Nodes)") 202 | fmt.Println("6. Network-Only Test (IP Quality Test + 5 Speed Test Nodes)") 203 | fmt.Println("7. Unlock-Only Test (Basic Unlock Tests + Common Streaming Services Unlock)") 204 | fmt.Println("8. Hardware-Only Test (System Info + CPU + Memory + dd Disk Test + fio Disk Test)") 205 | fmt.Println("9. IP Quality Test (IP Test with 15 Databases + Email Port Test)") 206 | } 207 | Loop: 208 | for { 209 | choice = getMenuChoice(language) 210 | switch choice { 211 | case "1": 212 | basicStatus = true 213 | cpuTestStatus = true 214 | memoryTestStatus = true 215 | diskTestStatus = true 216 | commTestStatus = true 217 | utTestStatus = true 218 | securityTestStatus = true 219 | emailTestStatus = true 220 | backtraceStatus = true 221 | nt3Status = true 222 | speedTestStatus = true 223 | onlyChinaTest = utils.CheckChina(enableLogger) 224 | break Loop 225 | case "2": 226 | basicStatus = true 227 | cpuTestStatus = true 228 | memoryTestStatus = true 229 | diskTestStatus = true 230 | speedTestStatus = true 231 | break Loop 232 | case "3": 233 | basicStatus = true 234 | cpuTestStatus = true 235 | memoryTestStatus = true 236 | diskTestStatus = true 237 | utTestStatus = true 238 | nt3Status = true 239 | speedTestStatus = true 240 | break Loop 241 | case "4": 242 | basicStatus = true 243 | cpuTestStatus = true 244 | memoryTestStatus = true 245 | diskTestStatus = true 246 | backtraceStatus = true 247 | nt3Status = true 248 | speedTestStatus = true 249 | break Loop 250 | case "5": 251 | basicStatus = true 252 | cpuTestStatus = true 253 | memoryTestStatus = true 254 | diskTestStatus = true 255 | commTestStatus = true 256 | utTestStatus = true 257 | speedTestStatus = true 258 | break Loop 259 | case "6": 260 | securityTestStatus = true 261 | speedTestStatus = true 262 | backtraceStatus = true 263 | nt3Status = true 264 | break Loop 265 | case "7": 266 | commTestStatus = true 267 | utTestStatus = true 268 | enabelUpload = false 269 | break Loop 270 | case "8": 271 | basicStatus = true 272 | cpuTestStatus = true 273 | memoryTestStatus = true 274 | diskTestStatus = true 275 | securityTestStatus = false 276 | autoChangeDiskTestMethod = false 277 | break Loop 278 | case "9": 279 | securityTestStatus = true 280 | emailTestStatus = true 281 | break Loop 282 | case "10": 283 | backtraceStatus = true 284 | nt3Status = true 285 | pingTestStatus = true 286 | enabelUpload = false 287 | break Loop 288 | default: 289 | if language == "zh" { 290 | fmt.Println("无效的选项") 291 | } else { 292 | fmt.Println("Invalid choice") 293 | } 294 | } 295 | } 296 | } 297 | if language == "en" { 298 | backtraceStatus = false 299 | nt3Status = false 300 | } 301 | if !enabelUpload { 302 | securityTestStatus = false 303 | } 304 | var ( 305 | startTime time.Time 306 | wg1, wg2, wg3 sync.WaitGroup 307 | basicInfo, securityInfo, emailInfo, mediaInfo, ptInfo string 308 | output, tempOutput string 309 | ) 310 | // 信号处理部分 311 | uploadDone := make(chan bool, 1) 312 | sig := make(chan os.Signal, 1) 313 | signal.Notify(sig, os.Interrupt, syscall.SIGINT, syscall.SIGTERM) 314 | // 启动一个goroutine来等待信号 315 | go func() { 316 | startTime = time.Now() 317 | select { 318 | case <-sig: 319 | if !finish { 320 | endTime := time.Now() 321 | duration := endTime.Sub(startTime) 322 | minutes := int(duration.Minutes()) 323 | seconds := int(duration.Seconds()) % 60 324 | currentTime := time.Now().Format("Mon Jan 2 15:04:05 MST 2006") 325 | var mu sync.Mutex 326 | mu.Lock() 327 | output = utils.PrintAndCapture(func() { 328 | utils.PrintCenteredTitle("", width) 329 | fmt.Printf("Cost Time : %d min %d sec\n", minutes, seconds) 330 | fmt.Printf("Current Time : %s\n", currentTime) 331 | utils.PrintCenteredTitle("", width) 332 | }, tempOutput, output) 333 | mu.Unlock() 334 | // 创建一个通道来传递上传结果 335 | resultChan := make(chan struct { 336 | httpURL string 337 | httpsURL string 338 | }, 1) // 使用带缓冲的通道,避免可能的阻塞 339 | // 启动上传 340 | go func() { 341 | httpURL, httpsURL := utils.ProcessAndUpload(output, filePath, enabelUpload) 342 | resultChan <- struct { 343 | httpURL string 344 | httpsURL string 345 | }{httpURL, httpsURL} 346 | uploadDone <- true 347 | }() 348 | // 等待上传完成或超时 349 | select { 350 | case result := <-resultChan: 351 | if result.httpURL != "" || result.httpsURL != "" { 352 | if language == "en" { 353 | fmt.Printf("Upload successfully!\nHttp URL: %s\nHttps URL: %s\n", result.httpURL, result.httpsURL) 354 | } else { 355 | fmt.Printf("上传成功!\nHttp URL: %s\nHttps URL: %s\n", result.httpURL, result.httpsURL) 356 | } 357 | } 358 | // 给打印操作一些时间完成 359 | time.Sleep(100 * time.Millisecond) 360 | if runtime.GOOS == "windows" || runtime.GOOS == "darwin" { 361 | fmt.Println("Press Enter to exit...") 362 | fmt.Scanln() 363 | } 364 | os.Exit(0) 365 | case <-time.After(30 * time.Second): 366 | fmt.Println("上传超时,程序退出") 367 | if runtime.GOOS == "windows" || runtime.GOOS == "darwin" { 368 | fmt.Println("Press Enter to exit...") 369 | fmt.Scanln() 370 | } 371 | os.Exit(1) 372 | } 373 | } 374 | os.Exit(0) 375 | } 376 | }() 377 | switch language { 378 | case "zh": 379 | output = utils.PrintAndCapture(func() { 380 | utils.PrintHead(language, width, ecsVersion) 381 | if basicStatus || securityTestStatus { 382 | if basicStatus { 383 | utils.PrintCenteredTitle("系统基础信息", width) 384 | } 385 | basicInfo, securityInfo, nt3CheckType = utils.BasicsAndSecurityCheck(language, nt3CheckType, securityTestStatus) 386 | if basicStatus { 387 | fmt.Printf(basicInfo) 388 | } else if (input == "6" || input == "9") && securityTestStatus { 389 | scanner := bufio.NewScanner(strings.NewReader(basicInfo)) 390 | for scanner.Scan() { 391 | line := scanner.Text() 392 | if strings.Contains(line, "IPV") { 393 | fmt.Println(line) 394 | } 395 | } 396 | } 397 | } 398 | }, tempOutput, output) 399 | output = utils.PrintAndCapture(func() { 400 | if cpuTestStatus { 401 | utils.PrintCenteredTitle(fmt.Sprintf("CPU测试-通过%s测试", cpuTestMethod), width) 402 | cputest.CpuTest(language, cpuTestMethod, cpuTestThreadMode) 403 | } 404 | }, tempOutput, output) 405 | output = utils.PrintAndCapture(func() { 406 | if memoryTestStatus { 407 | utils.PrintCenteredTitle(fmt.Sprintf("内存测试-通过%s测试", memoryTestMethod), width) 408 | memorytest.MemoryTest(language, memoryTestMethod) 409 | } 410 | }, tempOutput, output) 411 | output = utils.PrintAndCapture(func() { 412 | if diskTestStatus && autoChangeDiskTestMethod { 413 | utils.PrintCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", diskTestMethod), width) 414 | disktest.DiskTest(language, diskTestMethod, diskTestPath, diskMultiCheck, autoChangeDiskTestMethod) 415 | } else if diskTestStatus && !autoChangeDiskTestMethod { 416 | utils.PrintCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", "dd"), width) 417 | disktest.DiskTest(language, "dd", diskTestPath, diskMultiCheck, autoChangeDiskTestMethod) 418 | utils.PrintCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", "fio"), width) 419 | disktest.DiskTest(language, "fio", diskTestPath, diskMultiCheck, autoChangeDiskTestMethod) 420 | } 421 | }, tempOutput, output) 422 | if onlyChinaTest || pingTestStatus { 423 | wg3.Add(1) 424 | go func() { 425 | defer wg3.Done() 426 | ptInfo = pt.PingTest() 427 | }() 428 | } 429 | if emailTestStatus { 430 | wg2.Add(1) 431 | go func() { 432 | defer wg2.Done() 433 | emailInfo = email.EmailCheck() 434 | }() 435 | } 436 | if utTestStatus && !onlyChinaTest { 437 | wg1.Add(1) 438 | go func() { 439 | defer wg1.Done() 440 | mediaInfo = unlocktest.MediaTest(language) 441 | }() 442 | } 443 | output = utils.PrintAndCapture(func() { 444 | if commTestStatus && !onlyChinaTest { 445 | utils.PrintCenteredTitle("御三家流媒体解锁", width) 446 | fmt.Printf(commediatests.MediaTests(language)) 447 | } 448 | }, tempOutput, output) 449 | output = utils.PrintAndCapture(func() { 450 | if utTestStatus && !onlyChinaTest { 451 | utils.PrintCenteredTitle("跨国流媒体解锁", width) 452 | wg1.Wait() 453 | fmt.Printf(mediaInfo) 454 | } 455 | }, tempOutput, output) 456 | output = utils.PrintAndCapture(func() { 457 | if securityTestStatus { 458 | utils.PrintCenteredTitle("IP质量检测", width) 459 | fmt.Printf(securityInfo) 460 | } 461 | }, tempOutput, output) 462 | output = utils.PrintAndCapture(func() { 463 | if emailTestStatus { 464 | utils.PrintCenteredTitle("邮件端口检测", width) 465 | wg2.Wait() 466 | fmt.Println(emailInfo) 467 | } 468 | }, tempOutput, output) 469 | if runtime.GOOS != "windows" { 470 | output = utils.PrintAndCapture(func() { 471 | if backtraceStatus && !onlyChinaTest { 472 | utils.PrintCenteredTitle("三网回程线路检测", width) 473 | if strings.Contains(output, "IPV6") { 474 | backtrace.BackTrace(true) 475 | } else { 476 | backtrace.BackTrace(false) 477 | } 478 | } 479 | }, tempOutput, output) 480 | // nexttrace 在win上不支持检测,报错 bind: An invalid argument was supplied. 481 | output = utils.PrintAndCapture(func() { 482 | if nt3Status && !onlyChinaTest { 483 | utils.PrintCenteredTitle("三网回程路由检测", width) 484 | nt.TraceRoute(language, nt3Location, nt3CheckType) 485 | } 486 | }, tempOutput, output) 487 | output = utils.PrintAndCapture(func() { 488 | if onlyChinaTest || pingTestStatus { 489 | utils.PrintCenteredTitle("三网ICMP的PING值检测", width) 490 | wg3.Wait() 491 | fmt.Println(ptInfo) 492 | } 493 | }, tempOutput, output) 494 | } 495 | output = utils.PrintAndCapture(func() { 496 | if speedTestStatus { 497 | utils.PrintCenteredTitle("就近节点测速", width) 498 | speedtest.ShowHead(language) 499 | if choice == "1" || !menuMode { 500 | speedtest.NearbySP() 501 | speedtest.CustomSP("net", "global", 2, language) 502 | speedtest.CustomSP("net", "cu", spNum, language) 503 | speedtest.CustomSP("net", "ct", spNum, language) 504 | speedtest.CustomSP("net", "cmcc", spNum, language) 505 | } else if choice == "2" || choice == "3" || choice == "4" || choice == "5" { 506 | speedtest.CustomSP("net", "global", 4, language) 507 | } else if choice == "6" { 508 | speedtest.CustomSP("net", "global", 11, language) 509 | } 510 | } 511 | }, tempOutput, output) 512 | endTime := time.Now() 513 | duration := endTime.Sub(startTime) 514 | minutes := int(duration.Minutes()) 515 | seconds := int(duration.Seconds()) % 60 516 | currentTime := time.Now().Format("Mon Jan 2 15:04:05 MST 2006") 517 | output = utils.PrintAndCapture(func() { 518 | utils.PrintCenteredTitle("", width) 519 | fmt.Printf("花费 : %d 分 %d 秒\n", minutes, seconds) 520 | fmt.Printf("时间 : %s\n", currentTime) 521 | utils.PrintCenteredTitle("", width) 522 | }, tempOutput, output) 523 | case "en": 524 | output = utils.PrintAndCapture(func() { 525 | utils.PrintHead(language, width, ecsVersion) 526 | if basicStatus || securityTestStatus { 527 | if basicStatus { 528 | utils.PrintCenteredTitle("System-Basic-Information", width) 529 | } 530 | basicInfo, securityInfo, nt3CheckType = utils.BasicsAndSecurityCheck(language, nt3CheckType, securityTestStatus) 531 | if basicStatus { 532 | fmt.Printf(basicInfo) 533 | } else if (input == "6" || input == "9") && securityTestStatus { 534 | scanner := bufio.NewScanner(strings.NewReader(basicInfo)) 535 | for scanner.Scan() { 536 | line := scanner.Text() 537 | if strings.Contains(line, "IPV") { 538 | fmt.Println(line) 539 | } 540 | } 541 | } 542 | } 543 | }, tempOutput, output) 544 | output = utils.PrintAndCapture(func() { 545 | if cpuTestStatus { 546 | utils.PrintCenteredTitle(fmt.Sprintf("CPU-Test--%s-Method", cpuTestMethod), width) 547 | cputest.CpuTest(language, cpuTestMethod, cpuTestThreadMode) 548 | } 549 | }, tempOutput, output) 550 | output = utils.PrintAndCapture(func() { 551 | if memoryTestStatus { 552 | utils.PrintCenteredTitle(fmt.Sprintf("Memory-Test--%s-Method", memoryTestMethod), width) 553 | memorytest.MemoryTest(language, memoryTestMethod) 554 | } 555 | }, tempOutput, output) 556 | output = utils.PrintAndCapture(func() { 557 | if diskTestStatus && autoChangeDiskTestMethod { 558 | utils.PrintCenteredTitle(fmt.Sprintf("Disk-Test--%s-Method", diskTestMethod), width) 559 | disktest.DiskTest(language, diskTestMethod, diskTestPath, diskMultiCheck, autoChangeDiskTestMethod) 560 | } else if diskTestStatus && !autoChangeDiskTestMethod { 561 | utils.PrintCenteredTitle(fmt.Sprintf("Disk-Test--%s-Method", "dd"), width) 562 | disktest.DiskTest(language, "dd", diskTestPath, diskMultiCheck, autoChangeDiskTestMethod) 563 | utils.PrintCenteredTitle(fmt.Sprintf("Disk-Test--%s-Method", "fio"), width) 564 | disktest.DiskTest(language, "fio", diskTestPath, diskMultiCheck, autoChangeDiskTestMethod) 565 | } 566 | }, tempOutput, output) 567 | if utTestStatus { 568 | wg1.Add(1) 569 | go func() { 570 | defer wg1.Done() 571 | mediaInfo = unlocktest.MediaTest(language) 572 | }() 573 | } 574 | if emailTestStatus { 575 | wg2.Add(1) 576 | go func() { 577 | defer wg2.Done() 578 | emailInfo = email.EmailCheck() 579 | }() 580 | } 581 | output = utils.PrintAndCapture(func() { 582 | if utTestStatus { 583 | utils.PrintCenteredTitle("Cross-Border-Streaming-Media-Unlock", width) 584 | wg1.Wait() 585 | fmt.Printf(mediaInfo) 586 | } 587 | }, tempOutput, output) 588 | output = utils.PrintAndCapture(func() { 589 | if securityTestStatus { 590 | utils.PrintCenteredTitle("IP-Quality-Check", width) 591 | fmt.Printf(securityInfo) 592 | } 593 | }, tempOutput, output) 594 | output = utils.PrintAndCapture(func() { 595 | if emailTestStatus { 596 | utils.PrintCenteredTitle("Email-Port-Check", width) 597 | wg2.Wait() 598 | fmt.Println(emailInfo) 599 | } 600 | }, tempOutput, output) 601 | output = utils.PrintAndCapture(func() { 602 | if speedTestStatus { 603 | utils.PrintCenteredTitle("Speed-Test", width) 604 | speedtest.ShowHead(language) 605 | speedtest.NearbySP() 606 | speedtest.CustomSP("net", "global", -1, language) 607 | } 608 | }, tempOutput, output) 609 | endTime := time.Now() 610 | duration := endTime.Sub(startTime) 611 | minutes := int(duration.Minutes()) 612 | seconds := int(duration.Seconds()) % 60 613 | currentTime := time.Now().Format("Mon Jan 2 15:04:05 MST 2006") 614 | output = utils.PrintAndCapture(func() { 615 | utils.PrintCenteredTitle("", width) 616 | fmt.Printf("Cost Time : %d min %d sec\n", minutes, seconds) 617 | fmt.Printf("Current Time : %s\n", currentTime) 618 | utils.PrintCenteredTitle("", width) 619 | }, tempOutput, output) 620 | default: 621 | fmt.Println("Unsupported language") 622 | } 623 | httpURL, httpsURL := utils.ProcessAndUpload(output, filePath, enabelUpload) 624 | if httpURL != "" || httpsURL != "" { 625 | if language == "en" { 626 | fmt.Printf("Upload successfully!\nHttp URL: %s\nHttps URL: %s\n", httpURL, httpsURL) 627 | } else { 628 | fmt.Printf("上传成功!\nHttp URL: %s\nHttps URL: %s\n", httpURL, httpsURL) 629 | } 630 | } 631 | finish = true 632 | if runtime.GOOS == "windows" || runtime.GOOS == "darwin" { 633 | fmt.Println("Press Enter to exit...") 634 | fmt.Scanln() 635 | } 636 | } 637 | -------------------------------------------------------------------------------- /goecs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # From https://github.com/oneclickvirt/ecs 3 | # 2025.04.07 4 | 5 | # curl -L https://raw.githubusercontent.com/oneclickvirt/ecs/master/goecs.sh -o goecs.sh && chmod +x goecs.sh 6 | # 或 7 | # curl -L https://cnb.cool/oneclickvirt/ecs/-/git/raw/main/goecs.sh -o goecs.sh && chmod +x goecs.sh 8 | 9 | cat <<"EOF" 10 | ,ad8888ba, ,ad8888ba, 88888888888 ,ad8888ba, ad88888ba 11 | d8"' `"8b d8"' `"8b 88 d8"' `"8b d8" "8b 12 | d8' d8' `8b 88 d8' Y8a 13 | 88 88 88 88aaaaa 88 `"Y8aaaaa, 14 | 88 88888 88 88 88""""" 88 `"""""8b, 15 | Y8, 88 Y8, ,8P 88 Y8, `8b 16 | Y8a. .a88 Y8a. .a8P 88 Y8a. .a8P Y8a a8P 17 | `"Y88888P" `"Y8888Y"' 88888888888 `"Y8888Y"' "Y88888P" 18 | EOF 19 | cd /root >/dev/null 2>&1 20 | if [ ! -d "/usr/bin/" ]; then 21 | mkdir -p "/usr/bin/" 22 | fi 23 | _red() { echo -e "\033[31m\033[01m$@\033[0m"; } 24 | _green() { echo -e "\033[32m\033[01m$@\033[0m"; } 25 | _yellow() { echo -e "\033[33m\033[01m$@\033[0m"; } 26 | _blue() { echo -e "\033[36m\033[01m$@\033[0m"; } 27 | reading() { read -rp "$(_green "$1")" "$2"; } 28 | 29 | check_cdn() { 30 | local o_url=$1 31 | for cdn_url in "${cdn_urls[@]}"; do 32 | if curl -sL -k "$cdn_url$o_url" --max-time 6 | grep -q "success" >/dev/null 2>&1; then 33 | export cdn_success_url="$cdn_url" 34 | return 35 | fi 36 | sleep 0.5 37 | done 38 | export cdn_success_url="" 39 | } 40 | 41 | check_cdn_file() { 42 | check_cdn "https://raw.githubusercontent.com/spiritLHLS/ecs/main/back/test" 43 | if [ -n "$cdn_success_url" ]; then 44 | _green "CDN available, using CDN" 45 | else 46 | _yellow "No CDN available, no use CDN" 47 | fi 48 | } 49 | 50 | download_file() { 51 | local url="$1" 52 | local output="$2" 53 | if ! wget -O "$output" "$url"; then 54 | _yellow "wget failed, trying curl..." 55 | if ! curl -L -o "$output" "$url"; then 56 | _red "Both wget and curl failed. Unable to download the file." 57 | return 1 58 | fi 59 | fi 60 | return 0 61 | } 62 | 63 | check_china() { 64 | _yellow "正在检测IP所在区域......" 65 | if [[ -z "${CN}" ]]; then 66 | # 首先尝试通过 ipapi.co 检测 67 | if curl -m 6 -s https://ipapi.co/json | grep -q 'China'; then 68 | _yellow "根据ipapi.co提供的信息,当前IP可能在中国" 69 | if [ "$noninteractive" != "true" ]; then 70 | reading "是否使用中国镜像完成安装? ([y]/n) " input 71 | case $input in 72 | [yY][eE][sS] | [yY] | "") 73 | _green "已选择使用中国镜像" 74 | CN=true 75 | ;; 76 | [nN][oO] | [nN]) 77 | _yellow "已选择不使用中国镜像" 78 | CN=false 79 | ;; 80 | *) 81 | _green "已选择使用中国镜像" 82 | CN=true 83 | ;; 84 | esac 85 | else 86 | # 在非交互模式下默认不使用中国镜像 87 | CN=false 88 | fi 89 | else 90 | CN=false 91 | fi 92 | fi 93 | } 94 | 95 | get_memory_size() { 96 | if [ -f /proc/meminfo ]; then 97 | local mem_kb=$(grep MemTotal /proc/meminfo | awk '{print $2}') 98 | echo $((mem_kb / 1024)) # Convert to MB 99 | return 100 | fi 101 | if command -v free >/dev/null 2>&1; then 102 | local mem_kb=$(free -m | awk '/^Mem:/ {print $2}') 103 | echo "$mem_kb" # Already in MB 104 | return 105 | fi 106 | if command -v sysctl >/dev/null 2>&1; then 107 | local mem_bytes=$(sysctl -n hw.memsize 2>/dev/null || sysctl -n hw.physmem 2>/dev/null) 108 | if [ -n "$mem_bytes" ]; then 109 | echo $((mem_bytes / 1024 / 1024)) # Convert to MB 110 | return 111 | fi 112 | fi 113 | } 114 | 115 | cleanup_epel() { 116 | _yellow "Cleaning up EPEL repositories..." 117 | rm -f /etc/yum.repos.d/*epel* 118 | yum clean all 119 | } 120 | 121 | goecs_check() { 122 | # Get system and architecture info with error handling 123 | os=$(uname -s 2>/dev/null || echo "Unknown") 124 | arch=$(uname -m 2>/dev/null || echo "Unknown") 125 | # First check for China IP 126 | check_china 127 | # Get latest version number with multiple backup sources 128 | ECS_VERSION="" 129 | for api in \ 130 | "https://api.github.com/repos/oneclickvirt/ecs/releases/latest" \ 131 | "https://githubapi.spiritlhl.workers.dev/repos/oneclickvirt/ecs/releases/latest" \ 132 | "https://githubapi.spiritlhl.top/repos/oneclickvirt/ecs/releases/latest"; do 133 | ECS_VERSION=$(curl -m 6 -sSL "$api" | awk -F \" '/tag_name/{gsub(/^v/,"",$4); print $4}') 134 | if [ -n "$ECS_VERSION" ]; then 135 | break 136 | fi 137 | sleep 1 138 | done 139 | if [ -z "$ECS_VERSION" ]; then 140 | _yellow "Unable to get version info, using default version 0.1.33" 141 | ECS_VERSION="0.1.33" 142 | fi 143 | # Check if original goecs command exists 144 | version_output="" 145 | for cmd_path in "goecs" "./goecs" "/usr/bin/goecs" "/usr/local/bin/goecs"; do 146 | if [ -x "$(command -v $cmd_path 2>/dev/null)" ]; then 147 | version_output=$($cmd_path -v command 2>/dev/null) 148 | break 149 | fi 150 | done 151 | if [ -n "$version_output" ]; then 152 | extracted_version=${version_output//v/} 153 | if [ -n "$extracted_version" ]; then 154 | ecs_version=$ECS_VERSION 155 | if [[ "$(echo -e "$extracted_version\n$ecs_version" | sort -V | tail -n 1)" == "$extracted_version" ]]; then 156 | _green "goecs version ($extracted_version) is up to date, no upgrade needed" 157 | return 158 | else 159 | _yellow "goecs version ($extracted_version) < $ecs_version, upgrade needed, starting in 5 seconds" 160 | rm -rf /usr/bin/goecs /usr/local/bin/goecs ./goecs 161 | fi 162 | fi 163 | else 164 | _green "goecs not found, installation needed, starting in 5 seconds" 165 | fi 166 | sleep 5 167 | # Download corresponding version with error handling 168 | if [[ "$CN" == true ]]; then 169 | _yellow "Using China mirror for download..." 170 | base_url="https://cnb.cool/oneclickvirt/ecs/-/git/raw/main" 171 | else 172 | cdn_urls=("https://cdn0.spiritlhl.top/" "http://cdn3.spiritlhl.net/" "http://cdn1.spiritlhl.net/" "http://cdn2.spiritlhl.net/") 173 | check_cdn_file 174 | if [ -n "$cdn_success_url" ]; then 175 | base_url="${cdn_success_url}https://github.com/oneclickvirt/ecs/releases/download/v${ECS_VERSION}" 176 | else 177 | base_url="https://github.com/oneclickvirt/ecs/releases/download/v${ECS_VERSION}" 178 | fi 179 | fi 180 | # Build download URL with architecture support 181 | local zip_file="" 182 | case $os in 183 | Linux|linux|LINUX) 184 | case $arch in 185 | x86_64|amd64|x64) zip_file="goecs_linux_amd64.zip" ;; 186 | i386|i686) zip_file="goecs_linux_386.zip" ;; 187 | aarch64|arm64|armv8|armv8l) zip_file="goecs_linux_arm64.zip" ;; 188 | arm|armv7l) zip_file="goecs_linux_arm.zip" ;; 189 | mips) zip_file="goecs_linux_mips.zip" ;; 190 | mipsle) zip_file="goecs_linux_mipsle.zip" ;; 191 | s390x) zip_file="goecs_linux_s390x.zip" ;; 192 | riscv64) zip_file="goecs_linux_riscv64.zip" ;; 193 | *) zip_file="goecs_linux_amd64.zip" ;; 194 | esac 195 | ;; 196 | FreeBSD|freebsd) 197 | case $arch in 198 | x86_64|amd64) zip_file="goecs_freebsd_amd64.zip" ;; 199 | i386|i686) zip_file="goecs_freebsd_386.zip" ;; 200 | arm64|aarch64) zip_file="goecs_freebsd_arm64.zip" ;; 201 | *) zip_file="goecs_freebsd_amd64.zip" ;; 202 | esac 203 | ;; 204 | Darwin|darwin) 205 | case $arch in 206 | x86_64|amd64) zip_file="goecs_darwin_amd64.zip" ;; 207 | arm64|aarch64) zip_file="goecs_darwin_arm64.zip" ;; 208 | *) zip_file="goecs_darwin_amd64.zip" ;; 209 | esac 210 | ;; 211 | *) 212 | _yellow "Unknown system $os, trying amd64 version" 213 | zip_file="goecs_linux_amd64.zip" 214 | ;; 215 | esac 216 | download_url="${base_url}/${zip_file}" 217 | _green "Downloading $download_url" 218 | # Download file with retry mechanism 219 | local max_retries=3 220 | local retry_count=0 221 | while [ $retry_count -lt $max_retries ]; do 222 | if download_file "$download_url" "goecs.zip"; then 223 | break 224 | fi 225 | _yellow "Download failed, retrying (${retry_count}/${max_retries})..." 226 | retry_count=$((retry_count + 1)) 227 | sleep 2 228 | done 229 | if [ $retry_count -eq $max_retries ]; then 230 | _red "Download failed, please check your network connection or download manually" 231 | return 1 232 | fi 233 | if ! command -v unzip >/dev/null 2>&1; then 234 | _green "Installing $cmd" 235 | if command -v apt-get >/dev/null 2>&1; then 236 | INSTALL_CMD="apt-get -y install" 237 | elif command -v yum >/dev/null 2>&1; then 238 | INSTALL_CMD="yum -y install" 239 | elif command -v dnf >/dev/null 2>&1; then 240 | INSTALL_CMD="dnf -y install" 241 | elif command -v pacman >/dev/null 2>&1; then 242 | INSTALL_CMD="pacman -S --noconfirm" 243 | elif command -v apk >/dev/null 2>&1; then 244 | INSTALL_CMD="apk add" 245 | elif command -v zypper >/dev/null 2>&1; then 246 | INSTALL_CMD="zypper install -y" 247 | fi 248 | ${INSTALL_CMD} "$cmd" 249 | fi 250 | if ! unzip -o goecs.zip >/dev/null 2>&1; then 251 | _red "Extraction failed" 252 | return 1 253 | fi 254 | rm -f goecs.zip README.md LICENSE README_EN.md 255 | # Set execution permissions and install 256 | chmod 777 goecs 257 | for install_path in "/usr/bin" "/usr/local/bin"; do 258 | if [ -d "$install_path" ]; then 259 | cp -f goecs "$install_path/" 260 | break 261 | fi 262 | done 263 | # Set system parameters 264 | if [ "$os" != "Darwin" ]; then 265 | PARAM="net.ipv4.ping_group_range" 266 | NEW_VALUE="0 2147483647" 267 | if [ -f /etc/sysctl.conf ]; then 268 | if grep -q "^$PARAM" /etc/sysctl.conf; then 269 | sed -i "s/^$PARAM.*/$PARAM = $NEW_VALUE/" /etc/sysctl.conf 270 | else 271 | echo "$PARAM = $NEW_VALUE" >> /etc/sysctl.conf 272 | fi 273 | sysctl -p >/dev/null 2>&1 274 | fi 275 | fi 276 | # Set special permissions 277 | setcap cap_net_raw=+ep goecs 2>/dev/null 278 | setcap cap_net_raw=+ep /usr/bin/goecs 2>/dev/null 279 | setcap cap_net_raw=+ep /usr/local/bin/goecs 2>/dev/null 280 | _green "goecs installation complete, current version:" 281 | goecs -v || ./goecs -v 282 | } 283 | 284 | InstallSysbench() { 285 | if [ -f "/etc/opencloudos-release" ]; then # OpenCloudOS 286 | Var_OSRelease="opencloudos" 287 | elif [ -f "/etc/centos-release" ]; then # CentOS 288 | Var_OSRelease="centos" 289 | elif [ -f "/etc/fedora-release" ]; then # Fedora 290 | Var_OSRelease="fedora" 291 | elif [ -f "/etc/redhat-release" ]; then # RedHat 292 | Var_OSRelease="rhel" 293 | elif [ -f "/etc/astra_version" ]; then # Astra 294 | Var_OSRelease="astra" 295 | elif [ -f "/etc/lsb-release" ]; then # Ubuntu 296 | Var_OSRelease="ubuntu" 297 | elif [ -f "/etc/debian_version" ]; then # Debian 298 | Var_OSRelease="debian" 299 | elif [ -f "/etc/alpine-release" ]; then # Alpine Linux 300 | Var_OSRelease="alpinelinux" 301 | elif [ -f "/etc/almalinux-release" ]; then # almalinux 302 | Var_OSRelease="almalinux" 303 | elif [ -f "/etc/arch-release" ]; then # archlinux 304 | Var_OSRelease="arch" 305 | elif [ -f "/etc/freebsd-update.conf" ]; then # freebsd 306 | Var_OSRelease="freebsd" 307 | else 308 | Var_OSRelease="unknown" # 未知系统分支 309 | fi 310 | local mem_size=$(get_memory_size) 311 | if [ -z "$mem_size" ] || [ "$mem_size" -eq 0 ]; then 312 | echo "Error: Unable to determine memory size or memory size is zero." 313 | elif [ $mem_size -lt 1024 ]; then 314 | _red "Warning: Your system has less than 1GB RAM (${mem_size}MB)" 315 | if [ "$noninteractive" != "true" ]; then 316 | reading "Do you want to continue with EPEL installation? (y/N): " confirm 317 | if [[ ! $confirm =~ ^[Yy]$ ]]; then 318 | _yellow "Skipping EPEL installation" 319 | return 1 320 | fi 321 | fi 322 | case "$Var_OSRelease" in 323 | ubuntu | debian | astra) 324 | ! apt-get install -y sysbench && apt-get --fix-broken install -y && apt-get install --no-install-recommends -y sysbench ;; 325 | centos | rhel | almalinux | redhat | opencloudos) 326 | (yum -y install epel-release && yum -y install sysbench) || (dnf install epel-release -y && dnf install sysbench -y) ;; 327 | fedora) 328 | dnf -y install sysbench ;; 329 | arch) 330 | pacman -S --needed --noconfirm sysbench && pacman -S --needed --noconfirm libaio && ldconfig ;; 331 | freebsd) 332 | pkg install -y sysbench ;; 333 | alpinelinux) 334 | if [ "$noninteractive" != "true" ]; then 335 | reading "Do you want to continue with sysbench installation? (y/N): " confirm 336 | if [[ ! $confirm =~ ^[Yy]$ ]]; then 337 | _yellow "Skipping sysbench installation" 338 | return 1 339 | fi 340 | fi 341 | ALPINE_VERSION=$(grep -o '^[0-9]\+\.[0-9]\+' /etc/alpine-release) 342 | COMMUNITY_REPO="http://dl-cdn.alpinelinux.org/alpine/v${ALPINE_VERSION}/community" 343 | if grep -q "^${COMMUNITY_REPO}" /etc/apk/repositories; then 344 | echo "Community repository is already enabled." 345 | else 346 | echo "Enabling community repository..." 347 | echo "${COMMUNITY_REPO}" >> /etc/apk/repositories 348 | echo "Community repository has been added." 349 | echo "Updating apk package index..." 350 | apk update && echo "Package index updated successfully." 351 | fi 352 | if apk info sysbench >/dev/null 2>&1; then 353 | echo -e "${Msg_Info}Sysbench already installed." 354 | else 355 | apk add --no-cache sysbench 356 | if [ $? -ne 0 ]; then 357 | echo -e "${Msg_Warning}Sysbench Module not found, installing ..." && echo -e "${Msg_Warning}SysBench Current not support Alpine Linux, Skipping..." && Var_Skip_SysBench="1" 358 | else 359 | echo -e "${Msg_Success}Sysbench installed successfully." 360 | fi 361 | fi ;; 362 | *) 363 | _red "Sysbench Install Error: Unknown OS release: $Var_OSRelease" ;; 364 | esac 365 | if [[ $SYSTEM =~ ^(CentOS|RHEL|AlmaLinux)$ ]]; then 366 | _yellow "Installing EPEL repository..." 367 | if ! yum -y install epel-release; then 368 | _red "EPEL installation failed!" 369 | cleanup_epel 370 | _yellow "Attempting to continue without EPEL..." 371 | fi 372 | fi 373 | fi 374 | } 375 | 376 | Check_SysBench() { 377 | if [ ! -f "/usr/bin/sysbench" ] && [ ! -f "/usr/local/bin/sysbench" ]; then 378 | InstallSysbench 379 | fi 380 | # 尝试编译安装 381 | if [ ! -f "/usr/bin/sysbench" ] && [ ! -f "/usr/local/bin/sysbench" ]; then 382 | echo -e "${Msg_Warning}Sysbench Module install Failure, trying compile modules ..." 383 | Check_Sysbench_InstantBuild 384 | fi 385 | source ~/.bashrc 386 | # 最终检测 387 | if [ "$(command -v sysbench)" ] || [ -f "/usr/bin/sysbench" ] || [ -f "/usr/local/bin/sysbench" ]; then 388 | _yellow "Install sysbench successfully!" 389 | else 390 | _red "SysBench Moudle install Failure! Try Restart Bench or Manually install it! (/usr/bin/sysbench)" 391 | _blue "Will try to test with geekbench5 instead later." 392 | fi 393 | sleep 3 394 | } 395 | 396 | Check_Sysbench_InstantBuild() { 397 | if [ "${Var_OSRelease}" = "centos" ] || [ "${Var_OSRelease}" = "rhel" ] || [ "${Var_OSRelease}" = "almalinux" ] || [ "${Var_OSRelease}" = "ubuntu" ] || [ "${Var_OSRelease}" = "debian" ] || [ "${Var_OSRelease}" = "fedora" ] || [ "${Var_OSRelease}" = "arch" ] || [ "${Var_OSRelease}" = "astra" ]; then 398 | local os_sysbench=${Var_OSRelease} 399 | if [ "$os_sysbench" = "astra" ]; then 400 | os_sysbench="debian" 401 | fi 402 | if [ "$os_sysbench" = "opencloudos" ]; then 403 | os_sysbench="centos" 404 | fi 405 | echo -e "${Msg_Info}Release Detected: ${os_sysbench}" 406 | echo -e "${Msg_Info}Preparing compile enviorment ..." 407 | prepare_compile_env "${os_sysbench}" 408 | echo -e "${Msg_Info}Downloading Source code (Version 1.0.20)..." 409 | mkdir -p /tmp/sysbench_install/src/ 410 | mv /tmp/sysbench-1.0.20 /tmp/sysbench_install/src/ 411 | echo -e "${Msg_Info}Compiling Sysbench Module ..." 412 | cd /tmp/sysbench_install/src/sysbench-1.0.20 413 | ./autogen.sh && ./configure --without-mysql && make -j8 && make install 414 | echo -e "${Msg_Info}Cleaning up ..." 415 | cd /tmp && rm -rf /tmp/sysbench_install/src/sysbench* 416 | else 417 | echo -e "${Msg_Warning}Unsupported operating system: ${Var_OSRelease}" 418 | fi 419 | } 420 | 421 | prepare_compile_env() { 422 | local system="$1" 423 | if [ "${system}" = "centos" ] || [ "${system}" = "rhel" ] || [ "${system}" = "almalinux" ]; then 424 | yum install -y epel-release 425 | yum install -y wget curl make gcc gcc-c++ make automake libtool pkgconfig libaio-devel 426 | elif [ "${system}" = "ubuntu" ] || [ "${system}" = "debian" ]; then 427 | ! apt-get update && apt-get --fix-broken install -y && apt-get update 428 | ! apt-get -y install --no-install-recommends curl wget make automake libtool pkg-config libaio-dev unzip && apt-get --fix-broken install -y && apt-get -y install --no-install-recommends curl wget make automake libtool pkg-config libaio-dev unzip 429 | elif [ "${system}" = "fedora" ]; then 430 | dnf install -y wget curl gcc gcc-c++ make automake libtool pkgconfig libaio-devel 431 | elif [ "${system}" = "arch" ]; then 432 | pacman -S --needed --noconfirm wget curl gcc gcc make automake libtool pkgconfig libaio lib32-libaio 433 | else 434 | echo -e "${Msg_Warning}Unsupported operating system: ${system}" 435 | fi 436 | } 437 | 438 | env_check() { 439 | REGEX=("debian|astra" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'" "fedora" "arch" "freebsd" "alpine" "openbsd" "opencloudos") 440 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS" "Fedora" "Arch" "FreeBSD" "Alpine" "OpenBSD" "OpenCloudOS") 441 | 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 -qu" "yum -y update") 442 | 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") 443 | 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") 444 | 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") 445 | # Check system information 446 | if [ -f /etc/opencloudos-release ]; then 447 | SYS="opencloudos" 448 | elif [ -s /etc/os-release ]; then 449 | SYS="$(grep -i pretty_name /etc/os-release | cut -d \" -f2)" 450 | elif [ -x "$(type -p hostnamectl)" ]; then 451 | SYS="$(hostnamectl | grep -i system | cut -d : -f2 | xargs)" 452 | elif [ -x "$(type -p lsb_release)" ]; then 453 | SYS="$(lsb_release -sd)" 454 | elif [ -s /etc/lsb-release ]; then 455 | SYS="$(grep -i description /etc/lsb-release | cut -d \" -f2)" 456 | elif [ -s /etc/redhat-release ]; then 457 | SYS="$(grep . /etc/redhat-release)" 458 | elif [ -s /etc/issue ]; then 459 | SYS="$(grep . /etc/issue | cut -d '\' -f1 | sed '/^[ ]*$/d')" 460 | else 461 | SYS="$(uname -s)" 462 | fi 463 | # Match operating system 464 | SYSTEM="" 465 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 466 | if [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]]; then 467 | SYSTEM="${RELEASE[int]}" 468 | UPDATE_CMD=${PACKAGE_UPDATE[int]} 469 | INSTALL_CMD=${PACKAGE_INSTALL[int]} 470 | REMOVE_CMD=${PACKAGE_REMOVE[int]} 471 | UNINSTALL_CMD=${PACKAGE_UNINSTALL[int]} 472 | break 473 | fi 474 | done 475 | # If system is unrecognized, try common package managers 476 | if [ -z "$SYSTEM" ]; then 477 | _yellow "Unable to recognize system, trying common package managers..." 478 | if command -v apt-get >/dev/null 2>&1; then 479 | SYSTEM="Unknown-Debian" 480 | UPDATE_CMD="apt-get update" 481 | INSTALL_CMD="apt-get -y install" 482 | REMOVE_CMD="apt-get -y remove" 483 | UNINSTALL_CMD="apt-get -y autoremove" 484 | elif command -v yum >/dev/null 2>&1; then 485 | SYSTEM="Unknown-RHEL" 486 | UPDATE_CMD="yum -y update" 487 | INSTALL_CMD="yum -y install" 488 | REMOVE_CMD="yum -y remove" 489 | UNINSTALL_CMD="yum -y autoremove" 490 | elif command -v dnf >/dev/null 2>&1; then 491 | SYSTEM="Unknown-Fedora" 492 | UPDATE_CMD="dnf -y update" 493 | INSTALL_CMD="dnf -y install" 494 | REMOVE_CMD="dnf -y remove" 495 | UNINSTALL_CMD="dnf -y autoremove" 496 | elif command -v pacman >/dev/null 2>&1; then 497 | SYSTEM="Unknown-Arch" 498 | UPDATE_CMD="pacman -Sy" 499 | INSTALL_CMD="pacman -S --noconfirm" 500 | REMOVE_CMD="pacman -R --noconfirm" 501 | UNINSTALL_CMD="pacman -Rns --noconfirm" 502 | elif command -v apk >/dev/null 2>&1; then 503 | SYSTEM="Unknown-Alpine" 504 | UPDATE_CMD="apk update" 505 | INSTALL_CMD="apk add" 506 | REMOVE_CMD="apk del" 507 | UNINSTALL_CMD="apk del" 508 | elif command -v zypper >/dev/null 2>&1; then 509 | SYSTEM="Unknown-SLES" 510 | UPDATE_CMD="zypper refresh" 511 | INSTALL_CMD="zypper install -y" 512 | REMOVE_CMD="zypper remove -y" 513 | UNINSTALL_CMD="zypper remove -y" 514 | else 515 | _red "Unable to recognize package manager, exiting installation" 516 | exit 1 517 | fi 518 | fi 519 | _green "System information: $SYSTEM" 520 | _green "Update command: $UPDATE_CMD" 521 | _green "Install command: $INSTALL_CMD" 522 | cdn_urls=("https://cdn0.spiritlhl.top/" "http://cdn3.spiritlhl.net/" "http://cdn1.spiritlhl.net/" "http://cdn2.spiritlhl.net/") 523 | check_cdn_file 524 | _yellow "Warning: System update will be performed" 525 | _yellow "This operation may:" 526 | _yellow "1. Take considerable time" 527 | _yellow "2. Cause temporary network interruptions" 528 | _yellow "3. Impact system stability" 529 | _yellow "4. Affect subsequent system startups" 530 | if [ "$noninteractive" != "true" ]; then 531 | reading "Continue with system update? (y/N): " update_confirm 532 | if [[ ! $update_confirm =~ ^[Yy]$ ]]; then 533 | _yellow "Skipping system update" 534 | _yellow "Note: Some packages may fail to install" 535 | else 536 | _green "Updating system package manager..." 537 | if ! ${UPDATE_CMD} 2>/dev/null; then 538 | _red "System update failed!" 539 | fi 540 | fi 541 | fi 542 | # Install necessary commands 543 | for cmd in sudo wget tar unzip iproute2 systemd-detect-virt dd fio; do 544 | if ! command -v "$cmd" >/dev/null 2>&1; then 545 | _green "Installing $cmd" 546 | ${INSTALL_CMD} "$cmd" 547 | fi 548 | done 549 | # sysbench installation 550 | if ! command -v sysbench >/dev/null 2>&1; then 551 | _green "Installing sysbench" 552 | ${INSTALL_CMD} sysbench 553 | if [ $? -ne 0 ]; then 554 | echo "Unable to download sysbench through package manager, attempting compilation..." 555 | 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" 556 | if [ ! -f /tmp/sysbench.zip ]; then 557 | wget -q -O /tmp/sysbench.zip "https://hub.fgit.cf/akopytov/sysbench/archive/1.0.20.zip" 558 | fi 559 | chmod +x /tmp/sysbench.zip 560 | unzip /tmp/sysbench.zip -d /tmp 561 | Check_SysBench 562 | fi 563 | fi 564 | # geekbench and speedtest installation 565 | if ! command -v geekbench >/dev/null 2>&1; then 566 | _green "Installing geekbench" 567 | curl -L "${cdn_success_url}https://raw.githubusercontent.com/oneclickvirt/cputest/main/dgb.sh" -o dgb.sh && chmod +x dgb.sh 568 | bash dgb.sh -v gb5 569 | rm -rf dgb.sh 570 | fi 571 | if ! command -v speedtest >/dev/null 2>&1; then 572 | _green "Installing speedtest" 573 | curl -L "${cdn_success_url}https://raw.githubusercontent.com/oneclickvirt/speedtest/main/dspt.sh" -o dspt.sh && chmod +x dspt.sh 574 | bash dspt.sh 575 | rm -rf dspt.sh 576 | rm -rf speedtest.tar.gz 577 | fi 578 | if ! command -v ping >/dev/null 2>&1; then 579 | _green "Installing ping" 580 | ${INSTALL_CMD} iputils-ping >/dev/null 2>&1 581 | ${INSTALL_CMD} ping >/dev/null 2>&1 582 | fi 583 | # MacOS support 584 | if [ "$(uname -s)" = "Darwin" ]; then 585 | echo "Detected MacOS, installing sysbench iproute2mac..." 586 | brew install --force sysbench iproute2mac 587 | else 588 | if ! grep -q "^net.ipv4.ping_group_range = 0 2147483647$" /etc/sysctl.conf; then 589 | echo "net.ipv4.ping_group_range = 0 2147483647" >> /etc/sysctl.conf 590 | sysctl -p 591 | fi 592 | fi 593 | _green "Environment preparation complete." 594 | _green "Next command is: ./goecs.sh install" 595 | } 596 | 597 | uninstall_goecs() { 598 | rm -rf /root/goecs 599 | rm -rf /usr/bin/goecs 600 | _green "The command (goecs) has been uninstalled." 601 | } 602 | 603 | show_help() { 604 | cat <<"EOF" 605 | 可用命令: 606 | 607 | ./goecs.sh env 检查并安装依赖包 608 | 警告: 此命令会执行系统更新(可选择),可能: 609 | 1. 耗时较长 610 | 2. 导致网络短暂中断 611 | 3. 影响系统稳定性 612 | 4. 影响后续系统启动 613 | 对于内存小于1GB的系统,还可能导致: 614 | 1. 系统卡死 615 | 2. SSH连接中断 616 | 3. 关键服务失败 617 | 推荐: 618 | 环境依赖安装过程中挂起执行 619 | 620 | 可选组件: 621 | sysbench/geekbench (CPU性能测试) 622 | sudo, tar, unzip, dd, fio 623 | speedtest (网络测试) 624 | ping (网络连通性测试) 625 | systemd-detect-virt/dmidecode (系统信息检测) 626 | 627 | ./goecs.sh install 安装 goecs 命令 628 | ./goecs.sh upgrade 升级 goecs 命令 629 | ./goecs.sh uninstall 卸载 goecs 命令 630 | ./goecs.sh help 显示此消息 631 | 632 | Available commands: 633 | 634 | ./goecs.sh env Check and Install dependencies 635 | Warning: This command performs system update(optional), which may: 636 | 1. Take considerable time 637 | 2. Cause temporary network interruptions 638 | 3. Impact system stability 639 | 4. Affect subsequent system startups 640 | For systems with less than 1GB RAM, additional risks: 641 | 1. System freeze 642 | 2. SSH connection loss 643 | 3. Critical service failures 644 | Recommended: 645 | Hanging execution during environment dependency installation 646 | 647 | Optional components: 648 | sysbench/geekbench (CPU testing) 649 | sudo, tar, unzip, dd, fio 650 | speedtest (Network testing) 651 | ping (Network connectivity) 652 | systemd-detect-virt/dmidecode (System info detection) 653 | 654 | ./goecs.sh install Install goecs command 655 | ./goecs.sh upgrade Upgrade goecs command 656 | ./goecs.sh uninstall Uninstall goecs command 657 | ./goecs.sh help Show this message 658 | EOF 659 | } 660 | 661 | case "$1" in 662 | "help") 663 | show_help 664 | ;; 665 | "env") 666 | env_check 667 | ;; 668 | "install" | "upgrade") 669 | goecs_check 670 | ;; 671 | "uninstall") 672 | uninstall_goecs 673 | ;; 674 | *) 675 | echo "No command found." 676 | echo 677 | show_help 678 | ;; 679 | esac 680 | 681 | -------------------------------------------------------------------------------- /goecs_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func Test(t *testing.T) { 8 | main() 9 | } 10 | -------------------------------------------------------------------------------- /memorytest/memorytest.go: -------------------------------------------------------------------------------- 1 | package memorytest 2 | 3 | import ( 4 | "fmt" 5 | "github.com/oneclickvirt/memorytest/memory" 6 | "runtime" 7 | "strings" 8 | ) 9 | 10 | func MemoryTest(language, testMethod string) { 11 | var res string 12 | if runtime.GOOS == "windows" { 13 | if testMethod != "winsat" && testMethod != "" { 14 | res = "Detected host is Windows, using Winsat for testing.\n" 15 | } 16 | res += memory.WinsatTest(language) 17 | } else { 18 | switch testMethod { 19 | case "sysbench": 20 | res = memory.SysBenchTest(language) 21 | if res == "" { 22 | res = "sysbench test failed, switch to use dd test.\n" 23 | res += memory.DDTest(language) 24 | } 25 | case "dd": 26 | res = memory.DDTest(language) 27 | default: 28 | res = "Unsupported test method" 29 | } 30 | } 31 | if !strings.Contains(res, "\n") && res != "" { 32 | res += "\n" 33 | } 34 | fmt.Printf(res) 35 | } 36 | -------------------------------------------------------------------------------- /memorytest/memorytest_test.go: -------------------------------------------------------------------------------- 1 | package memorytest 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func Test(t *testing.T) { 8 | MemoryTest("zh", "sysbench") 9 | } 10 | -------------------------------------------------------------------------------- /speedtest/sp.go: -------------------------------------------------------------------------------- 1 | package speedtest 2 | 3 | import ( 4 | "github.com/oneclickvirt/speedtest/model" 5 | "github.com/oneclickvirt/speedtest/sp" 6 | "runtime" 7 | "strings" 8 | ) 9 | 10 | func ShowHead(language string) { 11 | sp.ShowHead(language) 12 | } 13 | 14 | func NearbySP() { 15 | if runtime.GOOS == "windows" || sp.OfficialAvailableTest() != nil { 16 | sp.NearbySpeedTest() 17 | } else { 18 | sp.OfficialNearbySpeedTest() 19 | } 20 | } 21 | 22 | func CustomSP(platform, operator string, num int, language string) { 23 | var url, parseType string 24 | if strings.ToLower(platform) == "cn" { 25 | if strings.ToLower(operator) == "cmcc" { 26 | url = model.CnCMCC 27 | } else if strings.ToLower(operator) == "cu" { 28 | url = model.CnCU 29 | } else if strings.ToLower(operator) == "ct" { 30 | url = model.CnCT 31 | } else if strings.ToLower(operator) == "hk" { 32 | url = model.CnHK 33 | } else if strings.ToLower(operator) == "tw" { 34 | url = model.CnTW 35 | } else if strings.ToLower(operator) == "jp" { 36 | url = model.CnJP 37 | } else if strings.ToLower(operator) == "sg" { 38 | url = model.CnSG 39 | } 40 | parseType = "url" 41 | } else if strings.ToLower(platform) == "net" { 42 | if strings.ToLower(operator) == "cmcc" { 43 | url = model.NetCMCC 44 | } else if strings.ToLower(operator) == "cu" { 45 | url = model.NetCU 46 | } else if strings.ToLower(operator) == "ct" { 47 | url = model.NetCT 48 | } else if strings.ToLower(operator) == "hk" { 49 | url = model.NetHK 50 | } else if strings.ToLower(operator) == "tw" { 51 | url = model.NetTW 52 | } else if strings.ToLower(operator) == "jp" { 53 | url = model.NetJP 54 | } else if strings.ToLower(operator) == "sg" { 55 | url = model.NetSG 56 | } else if strings.ToLower(operator) == "global" { 57 | url = model.NetGlobal 58 | } 59 | parseType = "id" 60 | } 61 | if runtime.GOOS == "windows" || sp.OfficialAvailableTest() != nil { 62 | sp.CustomSpeedTest(url, parseType, num, language) 63 | } else { 64 | sp.OfficialCustomSpeedTest(url, parseType, num, language) 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /speedtest/sp_test.go: -------------------------------------------------------------------------------- 1 | package speedtest 2 | 3 | import "testing" 4 | 5 | func Test(t *testing.T) { 6 | ShowHead("en") 7 | NearbySP() 8 | } 9 | -------------------------------------------------------------------------------- /unlocktest/media.go: -------------------------------------------------------------------------------- 1 | package unlocktest 2 | 3 | import ( 4 | "github.com/oneclickvirt/UnlockTests/utils" 5 | "github.com/oneclickvirt/UnlockTests/uts" 6 | "github.com/oneclickvirt/defaultset" 7 | ) 8 | 9 | func MediaTest(language string) string { 10 | var res string 11 | readStatus := uts.ReadSelect(language, "0") 12 | if !readStatus { 13 | return "" 14 | } 15 | if uts.IPV4 { 16 | res += defaultset.Blue("IPV4:") + "\n" 17 | res += uts.RunTests(utils.Ipv4HttpClient, "ipv4", language, false) 18 | return res 19 | } 20 | if uts.IPV6 { 21 | res += defaultset.Blue("IPV6:") + "\n" 22 | res += uts.RunTests(utils.Ipv6HttpClient, "ipv6", language, false) 23 | return res 24 | } 25 | return "" 26 | } 27 | -------------------------------------------------------------------------------- /unlocktest/media_test.go: -------------------------------------------------------------------------------- 1 | package unlocktest 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | ) 7 | 8 | func Test(t *testing.T) { 9 | fmt.Printf(MediaTest("zh")) 10 | } 11 | -------------------------------------------------------------------------------- /utils/utils.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "bufio" 5 | "bytes" 6 | "fmt" 7 | "github.com/imroc/req/v3" 8 | "github.com/oneclickvirt/UnlockTests/uts" 9 | "github.com/oneclickvirt/basics/system" 10 | . "github.com/oneclickvirt/defaultset" 11 | "github.com/oneclickvirt/security/network" 12 | "io" 13 | "os" 14 | "path/filepath" 15 | "regexp" 16 | "strings" 17 | "sync" 18 | "time" 19 | "unicode/utf8" 20 | ) 21 | 22 | // PrintCenteredTitle 根据指定的宽度打印居中标题 23 | func PrintCenteredTitle(title string, width int) { 24 | // 计算字符串的字符数 25 | titleLength := utf8.RuneCountInString(title) 26 | totalPadding := width - titleLength 27 | padding := totalPadding / 2 28 | paddingStr := strings.Repeat("-", padding) 29 | fmt.Println(paddingStr + title + paddingStr + strings.Repeat("-", totalPadding%2)) 30 | } 31 | 32 | // PrintHead 根据语言打印头部信息 33 | func PrintHead(language string, width int, ecsVersion string) { 34 | if language == "zh" { 35 | PrintCenteredTitle("VPS融合怪测试", width) 36 | fmt.Printf("版本:%s\n", ecsVersion) 37 | fmt.Println("测评频道: https://t.me/vps_reviews\n" + 38 | "Go项目地址:https://github.com/oneclickvirt/ecs\n" + 39 | "Shell项目地址:https://github.com/spiritLHLS/ecs") 40 | } else { 41 | PrintCenteredTitle("VPS Fusion Monster Test", width) 42 | fmt.Printf("Version: %s\n", ecsVersion) 43 | fmt.Println("Review Channel: https://t.me/vps_reviews\n" + 44 | "Go Project: https://github.com/oneclickvirt/ecs\n" + 45 | "Shell Project: https://github.com/spiritLHLS/ecs") 46 | } 47 | } 48 | 49 | func CheckChina(enableLogger bool) bool { 50 | if enableLogger { 51 | InitLogger() 52 | defer Logger.Sync() 53 | } 54 | var selectChina bool 55 | client := req.C() 56 | client.SetTimeout(6 * time.Second) 57 | client.R(). 58 | SetRetryCount(2). 59 | SetRetryBackoffInterval(1*time.Second, 3*time.Second). 60 | SetRetryFixedInterval(2 * time.Second) 61 | ipapiURL := "https://ipapi.co/json" 62 | ipapiResp, err := client.R().Get(ipapiURL) 63 | if err != nil { 64 | if enableLogger { 65 | Logger.Info("无法获取IP信息:" + err.Error()) 66 | } 67 | return false 68 | } 69 | defer ipapiResp.Body.Close() 70 | ipapiBody, err := ipapiResp.ToString() 71 | if err != nil { 72 | if enableLogger { 73 | Logger.Info("无法读取IP信息响应:" + err.Error()) 74 | } 75 | return false 76 | } 77 | isInChina := strings.Contains(ipapiBody, "China") 78 | if isInChina { 79 | fmt.Println("根据 ipapi.co 提供的信息,当前IP可能在中国") 80 | var input string 81 | fmt.Print("是否选用中国专项测试(无流媒体测试,有三网Ping值测试)? ([y]/n) ") 82 | fmt.Scanln(&input) 83 | switch strings.ToLower(input) { 84 | case "yes", "y": 85 | fmt.Println("使用中国专项测试") 86 | selectChina = true 87 | case "no", "n": 88 | fmt.Println("不使用中国专项测试") 89 | default: 90 | fmt.Println("使用中国专项测试") 91 | selectChina = true 92 | } 93 | } 94 | return selectChina 95 | } 96 | 97 | // BasicsAndSecurityCheck 执行安全检查 98 | func BasicsAndSecurityCheck(language, nt3CheckType string, securtyCheckStatus bool) (string, string, string) { 99 | var wgt sync.WaitGroup 100 | var ipInfo, securityInfo, systemInfo string 101 | var err error 102 | wgt.Add(1) 103 | go func() { 104 | defer wgt.Done() 105 | ipInfo, securityInfo, err = network.NetworkCheck("both", securtyCheckStatus, language) 106 | if err != nil { 107 | fmt.Println(err.Error()) 108 | } 109 | }() 110 | wgt.Add(1) 111 | go func() { 112 | defer wgt.Done() 113 | systemInfo = system.CheckSystemInfo(language) 114 | }() 115 | wgt.Wait() 116 | basicInfo := systemInfo + ipInfo 117 | if strings.Contains(ipInfo, "IPV4") && strings.Contains(ipInfo, "IPV6") { 118 | uts.IPV4 = true 119 | uts.IPV6 = true 120 | if nt3CheckType == "" { 121 | nt3CheckType = "ipv4" 122 | } 123 | } else if strings.Contains(ipInfo, "IPV4") { 124 | uts.IPV4 = true 125 | uts.IPV6 = false 126 | if nt3CheckType == "" { 127 | nt3CheckType = "ipv4" 128 | } 129 | } else if strings.Contains(ipInfo, "IPV6") { 130 | uts.IPV6 = true 131 | uts.IPV4 = false 132 | if nt3CheckType == "" { 133 | nt3CheckType = "ipv6" 134 | } 135 | } 136 | if nt3CheckType == "ipv4" && !strings.Contains(ipInfo, "IPV4") && strings.Contains(ipInfo, "IPV6") { 137 | nt3CheckType = "ipv6" 138 | } else if nt3CheckType == "ipv6" && !strings.Contains(ipInfo, "IPV6") && strings.Contains(ipInfo, "IPV4") { 139 | nt3CheckType = "ipv4" 140 | } 141 | basicInfo = strings.ReplaceAll(basicInfo, "\n\n", "\n") 142 | return basicInfo, securityInfo, nt3CheckType 143 | } 144 | 145 | // CaptureOutput 捕获函数输出和错误输出,实时输出,并返回字符串 146 | func CaptureOutput(f func()) string { 147 | // 保存旧的 stdout 和 stderr 148 | oldStdout := os.Stdout 149 | oldStderr := os.Stderr 150 | // 创建管道 151 | stdoutPipeR, stdoutPipeW, err := os.Pipe() 152 | if err != nil { 153 | return "Error creating stdout pipe" 154 | } 155 | stderrPipeR, stderrPipeW, err := os.Pipe() 156 | if err != nil { 157 | stdoutPipeW.Close() 158 | stdoutPipeR.Close() 159 | return "Error creating stderr pipe" 160 | } 161 | // 替换标准输出和标准错误输出为管道写入端 162 | os.Stdout = stdoutPipeW 163 | os.Stderr = stderrPipeW 164 | // 恢复标准输出和标准错误输出 165 | defer func() { 166 | os.Stdout = oldStdout 167 | os.Stderr = oldStderr 168 | stdoutPipeW.Close() 169 | stderrPipeW.Close() 170 | stdoutPipeR.Close() 171 | stderrPipeR.Close() 172 | }() 173 | // 缓冲区 174 | var stdoutBuf, stderrBuf bytes.Buffer 175 | // 并发读取 stdout 和 stderr 176 | done := make(chan struct{}) 177 | go func() { 178 | multiWriter := io.MultiWriter(&stdoutBuf, oldStdout) 179 | io.Copy(multiWriter, stdoutPipeR) 180 | done <- struct{}{} 181 | }() 182 | go func() { 183 | multiWriter := io.MultiWriter(&stderrBuf, oldStderr) 184 | io.Copy(multiWriter, stderrPipeR) 185 | done <- struct{}{} 186 | }() 187 | // 执行函数 188 | f() 189 | // 关闭管道写入端,让管道读取端可以读取所有数据 190 | stdoutPipeW.Close() 191 | stderrPipeW.Close() 192 | // 等待两个 goroutine 完成 193 | <-done 194 | <-done 195 | // 返回捕获的输出字符串 196 | // stderrBuf.String() 197 | return stdoutBuf.String() 198 | } 199 | 200 | // PrintAndCapture 捕获函数输出的同时打印内容 201 | func PrintAndCapture(f func(), tempOutput, output string) string { 202 | tempOutput = CaptureOutput(f) 203 | output += tempOutput 204 | return output 205 | } 206 | 207 | // UploadText 上传文本内容到指定URL 208 | func UploadText(absPath string) (string, string, error) { 209 | primaryURL := "http://hpaste.spiritlhl.net/api/UL/upload" 210 | backupURL := "https://paste.spiritlhl.net/api/UL/upload" 211 | token := network.SecurityUploadToken 212 | client := req.C().SetTimeout(6 * time.Second) 213 | client.R(). 214 | SetRetryCount(2). 215 | SetRetryBackoffInterval(1*time.Second, 5*time.Second). 216 | SetRetryFixedInterval(2 * time.Second) 217 | // 打开文件 218 | file, err := os.Open(absPath) 219 | if err != nil { 220 | return "", "", fmt.Errorf("failed to open file: %w", err) 221 | } 222 | defer file.Close() 223 | // 获取文件信息并检查大小 224 | fileInfo, err := file.Stat() 225 | if err != nil { 226 | return "", "", fmt.Errorf("failed to get file info: %w", err) 227 | } 228 | if fileInfo.Size() > 25*1024 { // 25KB 229 | return "", "", fmt.Errorf("file size exceeds 25KB limit") 230 | } 231 | // 上传逻辑 232 | upload := func(url string) (string, string, error) { 233 | file, err := os.Open(absPath) 234 | if err != nil { 235 | return "", "", fmt.Errorf("failed to re-open file for %s: %w", url, err) 236 | } 237 | defer file.Close() 238 | content, err := io.ReadAll(file) 239 | if err != nil { 240 | return "", "", fmt.Errorf("failed to read file content for %s: %w", url, err) 241 | } 242 | resp, err := client.R(). 243 | SetHeader("Authorization", token). 244 | SetFileBytes("file", filepath.Base(absPath), content). 245 | Post(url) 246 | if err != nil { 247 | return "", "", fmt.Errorf("failed to make request to %s: %w", url, err) 248 | } 249 | if resp.StatusCode >= 200 && resp.StatusCode <= 299 && resp.String() != "" { 250 | fileID := strings.TrimSpace(resp.String()) 251 | if strings.Contains(fileID, "show") { 252 | fileID = fileID[strings.LastIndex(fileID, "/")+1:] 253 | } 254 | httpURL := fmt.Sprintf("http://hpaste.spiritlhl.net/#/show/%s", fileID) 255 | httpsURL := fmt.Sprintf("https://paste.spiritlhl.net/#/show/%s", fileID) 256 | return httpURL, httpsURL, nil 257 | } 258 | return "", "", fmt.Errorf("upload failed for %s with status code: %d", url, resp.StatusCode) 259 | } 260 | // 尝试上传到主URL 261 | httpURL, httpsURL, err := upload(primaryURL) 262 | if err == nil { 263 | return httpURL, httpsURL, nil 264 | } 265 | // 尝试上传到备份URL 266 | httpURL, httpsURL, err = upload(backupURL) 267 | if err != nil { 268 | return "", "", fmt.Errorf("failed to upload to both primary and backup URLs: %w", err) 269 | } 270 | return httpURL, httpsURL, nil 271 | } 272 | 273 | // ProcessAndUpload 创建结果文件并上传文件 274 | func ProcessAndUpload(output string, filePath string, enableUplaod bool) (string, string) { 275 | // 使用 defer 来处理 panic 276 | defer func() { 277 | if r := recover(); r != nil { 278 | fmt.Printf("处理上传时发生错误: %v\n", r) 279 | } 280 | }() 281 | // 检查文件是否存在 282 | if _, err := os.Stat(filePath); err == nil { 283 | // 文件存在,删除文件 284 | err = os.Remove(filePath) 285 | if err != nil { 286 | fmt.Println("无法删除文件:", err) 287 | return "", "" 288 | } 289 | } 290 | // 创建文件 291 | file, err := os.Create(filePath) 292 | if err != nil { 293 | fmt.Println("无法创建文件:", err) 294 | return "", "" 295 | } 296 | defer file.Close() 297 | // 匹配 ANSI 转义序列 298 | ansiRegex := regexp.MustCompile("\x1B\\[[0-9;]+[a-zA-Z]") 299 | // 移除 ANSI 转义序列 300 | cleanedOutput := ansiRegex.ReplaceAllString(output, "") 301 | // 使用 bufio.Writer 提高写入效率 302 | writer := bufio.NewWriter(file) 303 | _, err = writer.WriteString(cleanedOutput) 304 | if err != nil { 305 | fmt.Println("无法写入文件:", err) 306 | return "", "" 307 | } 308 | // 确保写入缓冲区的数据都刷新到文件中 309 | err = writer.Flush() 310 | if err != nil { 311 | fmt.Println("无法刷新文件缓冲:", err) 312 | return "", "" 313 | } 314 | fmt.Printf("测试结果已写入 %s\n", filePath) 315 | if enableUplaod { 316 | // 获取文件的绝对路径 317 | absPath, err := filepath.Abs(filePath) 318 | if err != nil { 319 | fmt.Println("无法获取文件绝对路径:", err) 320 | return "", "" 321 | } 322 | // 上传文件并生成短链接 323 | http_url, https_url, err := UploadText(absPath) 324 | if err != nil { 325 | fmt.Println("上传失败,无法生成链接") 326 | fmt.Println(err.Error()) 327 | return "", "" 328 | } 329 | return http_url, https_url 330 | } 331 | return "", "" 332 | } 333 | --------------------------------------------------------------------------------