Compare commits

..

3 Commits

Author SHA1 Message Date
spiritysdx
9073802585 update 2024-06-30 13:37:49 +08:00
spiritysdx
f7b00cf621 update 2024-06-30 13:19:32 +08:00
spiritysdx
9f956f6e8c update 2024-06-30 13:02:07 +08:00
6 changed files with 74 additions and 58 deletions

View File

@@ -10,11 +10,10 @@ import (
// 使用gopsutil查询可能会特别慢执行命令查询反而更快 // 使用gopsutil查询可能会特别慢执行命令查询反而更快
// TODO // TODO
// 迁移Shell的完整检测逻辑使用执行命令的方式查询最后都失败才使用gopsutil查询 // 迁移Shell的完整检测逻辑使用执行命令的方式查询最后都失败才使用gopsutil查询
// 本包已在main中调用
func Basic(language string) { func Basic(language string) {
ipInfo, _, _ := network.NetworkCheck("both", false, language) ipInfo, _, _ := network.NetworkCheck("both", false, language)
res := system.CheckSystemInfo(language) systemInfo := system.CheckSystemInfo(language)
//fmt.Println("--------------------------------------------------") basicInfo := strings.ReplaceAll(systemInfo+ipInfo, "\n\n", "\n")
fmt.Printf(strings.ReplaceAll(res+ipInfo, "\n\n", "\n")) fmt.Printf(basicInfo)
//fmt.Println("--------------------------------------------------")
} }

4
go.mod
View File

@@ -4,7 +4,7 @@ go 1.22.4
require ( require (
github.com/oneclickvirt/CommonMediaTests v0.0.2-20240630023003 github.com/oneclickvirt/CommonMediaTests v0.0.2-20240630023003
github.com/oneclickvirt/UnlockTests v0.0.9-20240630032239 github.com/oneclickvirt/UnlockTests v0.0.10-20240630044930
github.com/oneclickvirt/backtrace v0.0.4-20240624090335 github.com/oneclickvirt/backtrace v0.0.4-20240624090335
github.com/oneclickvirt/basics v0.0.3-20240625075226 github.com/oneclickvirt/basics v0.0.3-20240625075226
github.com/oneclickvirt/cputest v0.0.5-20240630022206 github.com/oneclickvirt/cputest v0.0.5-20240630022206
@@ -14,7 +14,7 @@ require (
github.com/oneclickvirt/nt3 v0.0.1-20240627070009 github.com/oneclickvirt/nt3 v0.0.1-20240627070009
github.com/oneclickvirt/portchecker v0.0.1-20240624155429 github.com/oneclickvirt/portchecker v0.0.1-20240624155429
github.com/oneclickvirt/security v0.0.1-20240625075931 github.com/oneclickvirt/security v0.0.1-20240625075931
github.com/oneclickvirt/speedtest v0.0.4-20240629100548 github.com/oneclickvirt/speedtest v0.0.5-20240630045424
) )
require ( require (

6
go.sum
View File

@@ -91,6 +91,10 @@ github.com/oneclickvirt/UnlockTests v0.0.7-20240624115527 h1:rMC+aLDkvOe9K+AXjUt
github.com/oneclickvirt/UnlockTests v0.0.7-20240624115527/go.mod h1:HP3CvAS+AJWxxY+BVbxIOlvaQ87YOSge89vAMG52b5o= github.com/oneclickvirt/UnlockTests v0.0.7-20240624115527/go.mod h1:HP3CvAS+AJWxxY+BVbxIOlvaQ87YOSge89vAMG52b5o=
github.com/oneclickvirt/UnlockTests v0.0.9-20240630032239 h1:b2tf2AVZtTmDvOOtm7tmeOCqFJPm7fe2mF/0Kk15Mhk= github.com/oneclickvirt/UnlockTests v0.0.9-20240630032239 h1:b2tf2AVZtTmDvOOtm7tmeOCqFJPm7fe2mF/0Kk15Mhk=
github.com/oneclickvirt/UnlockTests v0.0.9-20240630032239/go.mod h1:HP3CvAS+AJWxxY+BVbxIOlvaQ87YOSge89vAMG52b5o= github.com/oneclickvirt/UnlockTests v0.0.9-20240630032239/go.mod h1:HP3CvAS+AJWxxY+BVbxIOlvaQ87YOSge89vAMG52b5o=
github.com/oneclickvirt/UnlockTests v0.0.10-20240630041851 h1:YC/Phn7I4hxlj+WvNfO7uHfKOSiNvd+3JA1vVkqKv1M=
github.com/oneclickvirt/UnlockTests v0.0.10-20240630041851/go.mod h1:HP3CvAS+AJWxxY+BVbxIOlvaQ87YOSge89vAMG52b5o=
github.com/oneclickvirt/UnlockTests v0.0.10-20240630044930 h1:/Sc4Eas1Pso18ak93wlazkuMKRRElCntITja/0opOpM=
github.com/oneclickvirt/UnlockTests v0.0.10-20240630044930/go.mod h1:HP3CvAS+AJWxxY+BVbxIOlvaQ87YOSge89vAMG52b5o=
github.com/oneclickvirt/backtrace v0.0.4-20240624090335 h1:0LP5KyA6GLlqQAtOF0uyBSAykHJrzOA96Eb87qUhGQw= github.com/oneclickvirt/backtrace v0.0.4-20240624090335 h1:0LP5KyA6GLlqQAtOF0uyBSAykHJrzOA96Eb87qUhGQw=
github.com/oneclickvirt/backtrace v0.0.4-20240624090335/go.mod h1:zvsC7xY/WZqs5KL2JB967OVnuqjNbxu9bW6wXRLo5h8= github.com/oneclickvirt/backtrace v0.0.4-20240624090335/go.mod h1:zvsC7xY/WZqs5KL2JB967OVnuqjNbxu9bW6wXRLo5h8=
github.com/oneclickvirt/basics v0.0.3-20240625075226 h1:K9VriCHIYnXPZXBSn9PRQX+jBS6AIFH8tBVb/i8VGAw= github.com/oneclickvirt/basics v0.0.3-20240625075226 h1:K9VriCHIYnXPZXBSn9PRQX+jBS6AIFH8tBVb/i8VGAw=
@@ -113,6 +117,8 @@ github.com/oneclickvirt/security v0.0.1-20240625075931 h1:Vj1Wq/JVcqYpfqUWRtsITb
github.com/oneclickvirt/security v0.0.1-20240625075931/go.mod h1:6bjZjpYJ8M3aRIcLP61b0mjYRwvtWbYkvoGjS28Bdy4= github.com/oneclickvirt/security v0.0.1-20240625075931/go.mod h1:6bjZjpYJ8M3aRIcLP61b0mjYRwvtWbYkvoGjS28Bdy4=
github.com/oneclickvirt/speedtest v0.0.4-20240629100548 h1:DQA0R/EdtmLJrQBb9JvQBaBpcMgiGDvIHq+0quNZQQM= github.com/oneclickvirt/speedtest v0.0.4-20240629100548 h1:DQA0R/EdtmLJrQBb9JvQBaBpcMgiGDvIHq+0quNZQQM=
github.com/oneclickvirt/speedtest v0.0.4-20240629100548/go.mod h1:JNIxUbEJD12w81b7754RLHD55fsH6wHj+fCV2PqBDhk= github.com/oneclickvirt/speedtest v0.0.4-20240629100548/go.mod h1:JNIxUbEJD12w81b7754RLHD55fsH6wHj+fCV2PqBDhk=
github.com/oneclickvirt/speedtest v0.0.5-20240630045424 h1:LXvoAgCAJVGci0Tzm3cDgvNaezncS8R5nOn8s+p+kNA=
github.com/oneclickvirt/speedtest v0.0.5-20240630045424/go.mod h1:zd5ZgIGslmtQLQehEfRjyumlvgDHTpCSMchKfKXoASI=
github.com/onsi/ginkgo/v2 v2.16.0 h1:7q1w9frJDzninhXxjZd+Y/x54XNjG/UlRLIYPZafsPM= github.com/onsi/ginkgo/v2 v2.16.0 h1:7q1w9frJDzninhXxjZd+Y/x54XNjG/UlRLIYPZafsPM=
github.com/onsi/ginkgo/v2 v2.16.0/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs= github.com/onsi/ginkgo/v2 v2.16.0/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs=
github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8=

View File

@@ -4,8 +4,8 @@ import (
"flag" "flag"
"fmt" "fmt"
"github.com/oneclickvirt/UnlockTests/uts" "github.com/oneclickvirt/UnlockTests/uts"
"github.com/oneclickvirt/basics/system"
"github.com/oneclickvirt/ecs/backtrace" "github.com/oneclickvirt/ecs/backtrace"
"github.com/oneclickvirt/ecs/basic"
"github.com/oneclickvirt/ecs/commediatest" "github.com/oneclickvirt/ecs/commediatest"
"github.com/oneclickvirt/ecs/cputest" "github.com/oneclickvirt/ecs/cputest"
"github.com/oneclickvirt/ecs/disktest" "github.com/oneclickvirt/ecs/disktest"
@@ -23,16 +23,16 @@ import (
) )
var ( var (
ecsVersion = "2024.06.30" ecsVersion = "2024.06.30"
showVersion bool showVersion bool
language string language string
cpuTestMethod, cpuTestThread string cpuTestMethod, cpuTestThreadMode string
memoryTestMethod string memoryTestMethod string
diskTestMethod, diskTestPath string diskTestMethod, diskTestPath string
diskMultiCheck bool diskMultiCheck bool
nt3CheckType, nt3Location string nt3CheckType, nt3Location string
spNum int spNum int
width = 84 width = 84
) )
func printCenteredTitle(title string, width int) { func printCenteredTitle(title string, width int) {
@@ -43,8 +43,21 @@ func printCenteredTitle(title string, width int) {
fmt.Println(paddingStr + title + paddingStr + strings.Repeat("-", totalPadding%2)) fmt.Println(paddingStr + title + paddingStr + strings.Repeat("-", totalPadding%2))
} }
func securityCheck() string { func securityCheck() (string, string) {
ipInfo, securityInfo, _ := network.NetworkCheck("both", true, language) var wgt sync.WaitGroup
var ipInfo, securityInfo, systemInfo string
go func() {
wgt.Add(1)
defer wgt.Done()
ipInfo, securityInfo, _ = network.NetworkCheck("both", true, language)
}()
go func() {
wgt.Add(1)
defer wgt.Done()
systemInfo = system.CheckSystemInfo(language)
}()
wgt.Wait()
basicInfo := systemInfo + ipInfo
if strings.Contains(ipInfo, "IPV4") && strings.Contains(ipInfo, "IPV6") { if strings.Contains(ipInfo, "IPV4") && strings.Contains(ipInfo, "IPV6") {
uts.IPV4 = true uts.IPV4 = true
uts.IPV6 = true uts.IPV6 = true
@@ -69,7 +82,8 @@ func securityCheck() string {
} else if nt3CheckType == "ipv6" && !strings.Contains(ipInfo, "IPV6") && strings.Contains(ipInfo, "IPV4") { } else if nt3CheckType == "ipv6" && !strings.Contains(ipInfo, "IPV6") && strings.Contains(ipInfo, "IPV4") {
nt3CheckType = "ipv4" nt3CheckType = "ipv4"
} }
return securityInfo basicInfo = strings.ReplaceAll(basicInfo, "\n\n", "\n")
return basicInfo, securityInfo
} }
func printHead() { func printHead() {
@@ -92,16 +106,13 @@ func main() {
flag.BoolVar(&showVersion, "v", false, "Show version information") flag.BoolVar(&showVersion, "v", false, "Show version information")
flag.StringVar(&language, "l", "zh", "Specify language (supported: en, zh)") flag.StringVar(&language, "l", "zh", "Specify language (supported: en, zh)")
flag.StringVar(&cpuTestMethod, "cpum", "sysbench", "Specify CPU test method (supported: sysbench, geekbench, winsat)") flag.StringVar(&cpuTestMethod, "cpum", "sysbench", "Specify CPU test method (supported: sysbench, geekbench, winsat)")
flag.StringVar(&cpuTestThread, "cput", "", "Specify CPU test thread count (supported: 1, 2, ...)") flag.StringVar(&cpuTestThreadMode, "cput", "multi", "Specify CPU test thread mode (supported: single multi)")
flag.StringVar(&memoryTestMethod, "memorym", "dd", "Specify Memory test method (supported: sysbench, dd, winsat)") flag.StringVar(&memoryTestMethod, "memorym", "dd", "Specify Memory test method (supported: sysbench, dd, winsat)")
flag.StringVar(&diskTestMethod, "diskm", "fio", "Specify Disk test method (supported: fio, dd, winsat)") flag.StringVar(&diskTestMethod, "diskm", "fio", "Specify Disk test method (supported: fio, dd, winsat)")
flag.StringVar(&diskTestPath, "diskp", "", "Specify Disk test path, example: -diskp /root") flag.StringVar(&diskTestPath, "diskp", "", "Specify Disk test path, example: -diskp /root")
flag.BoolVar(&diskMultiCheck, "diskmc", false, "Enable multiple disk checks, example: -diskmc=false") flag.BoolVar(&diskMultiCheck, "diskmc", false, "Enable multiple disk checks, example: -diskmc=false")
flag.Parse() flag.StringVar(&nt3Location, "nt3loc", "GZ", "指定三网回程路由检测的地址,支持 GZ, SH, BJ, CD 对应 广州,上海,北京,成都")
if language == "zh" { flag.StringVar(&nt3CheckType, "nt3t", "ipv4", "指定三网回程路由检测的类型,支持 both, ipv4, ipv6")
flag.StringVar(&nt3Location, "nt3loc", "GZ", "指定三网回程路由检测的地址,支持 GZ, SH, BJ, CD 对应 广州,上海,北京,成都")
flag.StringVar(&nt3CheckType, "nt3t", "ipv4", "指定三网回程路由检测的类型,支持 both, ipv4, ipv6")
}
flag.IntVar(&spNum, "spnum", 2, "Specify speedtest each operator servers num") flag.IntVar(&spNum, "spnum", 2, "Specify speedtest each operator servers num")
flag.Parse() flag.Parse()
if showVersion { if showVersion {
@@ -110,39 +121,36 @@ func main() {
} }
startTime := time.Now() startTime := time.Now()
var wg sync.WaitGroup var wg sync.WaitGroup
var securityInfo, emailInfo string var basicInfo, securityInfo, emailInfo, mediaInfo string
if language == "zh" { if language == "zh" {
printHead() printHead()
printCenteredTitle("基础信息", width) printCenteredTitle("基础信息", width)
wg.Add(2) basicInfo, securityInfo = securityCheck()
go func() { fmt.Println(basicInfo)
defer wg.Done()
basic.Basic(language)
}()
go func() {
defer wg.Done()
securityInfo = securityCheck()
}()
wg.Wait()
printCenteredTitle(fmt.Sprintf("CPU测试-通过%s测试", cpuTestMethod), width) printCenteredTitle(fmt.Sprintf("CPU测试-通过%s测试", cpuTestMethod), width)
cputest.CpuTest(language, cpuTestMethod, cpuTestThread) cputest.CpuTest(language, cpuTestMethod, cpuTestThreadMode)
printCenteredTitle(fmt.Sprintf("内存测试-通过%s测试", cpuTestMethod), width) printCenteredTitle(fmt.Sprintf("内存测试-通过%s测试", cpuTestMethod), width)
memorytest.MemoryTest(language, memoryTestMethod) memorytest.MemoryTest(language, memoryTestMethod)
printCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", diskTestMethod), width) printCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", diskTestMethod), width)
disktest.DiskTest(language, diskTestMethod, diskTestPath, diskMultiCheck) disktest.DiskTest(language, diskTestMethod, diskTestPath, diskMultiCheck)
wg.Add(1)
go func() { go func() {
wg.Add(1)
defer wg.Done() defer wg.Done()
emailInfo = email.EmailCheck() emailInfo = email.EmailCheck()
}() }()
go func() {
wg.Add(1)
defer wg.Done()
mediaInfo = unlocktest.MediaTest(language)
}()
printCenteredTitle("御三家流媒体解锁", width) printCenteredTitle("御三家流媒体解锁", width)
commediatest.ComMediaTest(language) commediatest.ComMediaTest(language)
printCenteredTitle("跨国流媒体解锁", width) printCenteredTitle("跨国流媒体解锁", width)
unlocktest.MediaTest(language) wg.Wait()
fmt.Printf(mediaInfo)
printCenteredTitle("IP质量检测", width) printCenteredTitle("IP质量检测", width)
fmt.Printf(securityInfo) fmt.Printf(securityInfo)
printCenteredTitle("邮件端口检测", width) printCenteredTitle("邮件端口检测", width)
wg.Wait()
fmt.Println(emailInfo) fmt.Println(emailInfo)
printCenteredTitle("三网回程", width) printCenteredTitle("三网回程", width)
backtrace.BackTrace() backtrace.BackTrace()
@@ -170,18 +178,15 @@ func main() {
} else if language == "en" { } else if language == "en" {
printHead() printHead()
printCenteredTitle("Basic Information", width) printCenteredTitle("Basic Information", width)
wg.Add(2)
go func() { go func() {
wg.Add(1)
defer wg.Done() defer wg.Done()
basic.Basic(language) basicInfo, securityInfo = securityCheck()
}()
go func() {
defer wg.Done()
securityInfo = securityCheck()
}() }()
wg.Wait() wg.Wait()
fmt.Printf(basicInfo)
printCenteredTitle(fmt.Sprintf("CPU Test - %s Method", cpuTestMethod), width) printCenteredTitle(fmt.Sprintf("CPU Test - %s Method", cpuTestMethod), width)
cputest.CpuTest(language, cpuTestMethod, cpuTestThread) cputest.CpuTest(language, cpuTestMethod, cpuTestThreadMode)
printCenteredTitle(fmt.Sprintf("Memory Test - %s Method", memoryTestMethod), width) printCenteredTitle(fmt.Sprintf("Memory Test - %s Method", memoryTestMethod), width)
memorytest.MemoryTest(language, memoryTestMethod) memorytest.MemoryTest(language, memoryTestMethod)
printCenteredTitle(fmt.Sprintf("Disk Test - %s Method", diskTestMethod), width) printCenteredTitle(fmt.Sprintf("Disk Test - %s Method", diskTestMethod), width)

View File

@@ -1,23 +1,26 @@
package unlocktest package unlocktest
import ( import (
"fmt"
"github.com/oneclickvirt/UnlockTests/utils" "github.com/oneclickvirt/UnlockTests/utils"
"github.com/oneclickvirt/UnlockTests/uts" "github.com/oneclickvirt/UnlockTests/uts"
"github.com/oneclickvirt/defaultset" "github.com/oneclickvirt/defaultset"
) )
func MediaTest(language string) { func MediaTest(language string) string {
var res string
readStatus := uts.ReadSelect(language, "0") readStatus := uts.ReadSelect(language, "0")
if !readStatus { if !readStatus {
return return ""
} }
if uts.IPV4 { if uts.IPV4 {
fmt.Println(defaultset.Blue("IPV4:")) res += defaultset.Blue("IPV4:") + "\n"
uts.RunTests(utils.Ipv4HttpClient, "ipv4", language, false) res += uts.RunTests(utils.Ipv4HttpClient, "ipv4", language, false)
return res
} }
if uts.IPV6 { if uts.IPV6 {
fmt.Println(defaultset.Blue("IPV6:")) res += defaultset.Blue("IPV6:") + "\n"
uts.RunTests(utils.Ipv6HttpClient, "ipv6", language, false) res += uts.RunTests(utils.Ipv6HttpClient, "ipv6", language, false)
return res
} }
return ""
} }

View File

@@ -1,7 +1,10 @@
package unlocktest package unlocktest
import "testing" import (
"fmt"
"testing"
)
func Test(t *testing.T) { func Test(t *testing.T) {
MediaTest("zh") fmt.Printf(MediaTest("zh"))
} }