mirror of
https://github.com/oneclickvirt/ecs.git
synced 2025-10-04 23:12:49 +08:00
update
This commit is contained in:
2
go.mod
2
go.mod
@@ -13,7 +13,7 @@ require (
|
|||||||
github.com/oneclickvirt/memorytest v0.0.1-20240624151629
|
github.com/oneclickvirt/memorytest v0.0.1-20240624151629
|
||||||
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-20240630101628
|
||||||
github.com/oneclickvirt/speedtest v0.0.5-20240630045424
|
github.com/oneclickvirt/speedtest v0.0.5-20240630045424
|
||||||
)
|
)
|
||||||
|
|
||||||
|
2
go.sum
2
go.sum
@@ -115,6 +115,8 @@ github.com/oneclickvirt/portchecker v0.0.1-20240624155429 h1:+wapaOcFrg1iWJDhBKT
|
|||||||
github.com/oneclickvirt/portchecker v0.0.1-20240624155429/go.mod h1:HQxSTrqM8/QFqHMTBZ7S8H9eEO5FkUXU1eb7ZX5Mk+k=
|
github.com/oneclickvirt/portchecker v0.0.1-20240624155429/go.mod h1:HQxSTrqM8/QFqHMTBZ7S8H9eEO5FkUXU1eb7ZX5Mk+k=
|
||||||
github.com/oneclickvirt/security v0.0.1-20240625075931 h1:Vj1Wq/JVcqYpfqUWRtsITbz3zM4HxnLC0iPxxA6akP0=
|
github.com/oneclickvirt/security v0.0.1-20240625075931 h1:Vj1Wq/JVcqYpfqUWRtsITbz3zM4HxnLC0iPxxA6akP0=
|
||||||
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/security v0.0.1-20240630101628 h1:Ain+TvrWo22ex9CGc1Z2seOX32XIXW8ajs2K3sfd+JY=
|
||||||
|
github.com/oneclickvirt/security v0.0.1-20240630101628/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 h1:LXvoAgCAJVGci0Tzm3cDgvNaezncS8R5nOn8s+p+kNA=
|
||||||
|
202
goecs.go
202
goecs.go
@@ -3,8 +3,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/oneclickvirt/UnlockTests/uts"
|
|
||||||
"github.com/oneclickvirt/basics/system"
|
|
||||||
"github.com/oneclickvirt/ecs/backtrace"
|
"github.com/oneclickvirt/ecs/backtrace"
|
||||||
"github.com/oneclickvirt/ecs/commediatest"
|
"github.com/oneclickvirt/ecs/commediatest"
|
||||||
"github.com/oneclickvirt/ecs/cputest"
|
"github.com/oneclickvirt/ecs/cputest"
|
||||||
@@ -13,13 +11,11 @@ import (
|
|||||||
"github.com/oneclickvirt/ecs/ntrace"
|
"github.com/oneclickvirt/ecs/ntrace"
|
||||||
"github.com/oneclickvirt/ecs/speedtest"
|
"github.com/oneclickvirt/ecs/speedtest"
|
||||||
"github.com/oneclickvirt/ecs/unlocktest"
|
"github.com/oneclickvirt/ecs/unlocktest"
|
||||||
|
"github.com/oneclickvirt/ecs/utils"
|
||||||
"github.com/oneclickvirt/portchecker/email"
|
"github.com/oneclickvirt/portchecker/email"
|
||||||
"github.com/oneclickvirt/security/network"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
"unicode/utf8"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -35,76 +31,6 @@ var (
|
|||||||
width = 84
|
width = 84
|
||||||
)
|
)
|
||||||
|
|
||||||
func printCenteredTitle(title string, width int) {
|
|
||||||
titleLength := utf8.RuneCountInString(title) // 计算字符串的字符数
|
|
||||||
totalPadding := width - titleLength
|
|
||||||
padding := totalPadding / 2
|
|
||||||
paddingStr := strings.Repeat("-", padding)
|
|
||||||
fmt.Println(paddingStr + title + paddingStr + strings.Repeat("-", totalPadding%2))
|
|
||||||
}
|
|
||||||
|
|
||||||
func securityCheck() (string, string) {
|
|
||||||
var wgt sync.WaitGroup
|
|
||||||
var ipInfo, securityInfo, systemInfo string
|
|
||||||
var err error
|
|
||||||
wgt.Add(2)
|
|
||||||
go func() {
|
|
||||||
defer wgt.Done()
|
|
||||||
ipInfo, securityInfo, err = network.NetworkCheck("both", true, language)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err.Error())
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
go func() {
|
|
||||||
defer wgt.Done()
|
|
||||||
systemInfo = system.CheckSystemInfo(language)
|
|
||||||
}()
|
|
||||||
wgt.Wait()
|
|
||||||
basicInfo := systemInfo + ipInfo
|
|
||||||
if strings.Contains(ipInfo, "IPV4") && strings.Contains(ipInfo, "IPV6") {
|
|
||||||
uts.IPV4 = true
|
|
||||||
uts.IPV6 = true
|
|
||||||
if nt3CheckType == "" {
|
|
||||||
nt3CheckType = "ipv4"
|
|
||||||
}
|
|
||||||
} else if strings.Contains(ipInfo, "IPV4") {
|
|
||||||
uts.IPV4 = true
|
|
||||||
uts.IPV6 = false
|
|
||||||
if nt3CheckType == "" {
|
|
||||||
nt3CheckType = "ipv4"
|
|
||||||
}
|
|
||||||
} else if strings.Contains(ipInfo, "IPV6") {
|
|
||||||
uts.IPV6 = true
|
|
||||||
uts.IPV4 = false
|
|
||||||
if nt3CheckType == "" {
|
|
||||||
nt3CheckType = "ipv6"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if nt3CheckType == "ipv4" && !strings.Contains(ipInfo, "IPV4") && strings.Contains(ipInfo, "IPV6") {
|
|
||||||
nt3CheckType = "ipv6"
|
|
||||||
} else if nt3CheckType == "ipv6" && !strings.Contains(ipInfo, "IPV6") && strings.Contains(ipInfo, "IPV4") {
|
|
||||||
nt3CheckType = "ipv4"
|
|
||||||
}
|
|
||||||
basicInfo = strings.ReplaceAll(basicInfo, "\n\n", "\n")
|
|
||||||
return basicInfo, securityInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
func printHead() {
|
|
||||||
if language == "zh" {
|
|
||||||
printCenteredTitle("融合怪测试", width)
|
|
||||||
fmt.Printf("版本:%s\n", ecsVersion)
|
|
||||||
fmt.Println("测评频道: https://t.me/vps_reviews\n" +
|
|
||||||
"Go项目地址:https://github.com/oneclickvirt/ecs\n" +
|
|
||||||
"Shell项目地址:https://github.com/spiritLHLS/ecs")
|
|
||||||
} else {
|
|
||||||
printCenteredTitle("Fusion Monster Test", width)
|
|
||||||
fmt.Printf("Version: %s\n", ecsVersion)
|
|
||||||
fmt.Println("Review Channel: https://t.me/vps_reviews\n" +
|
|
||||||
"Go Project URL: https://github.com/oneclickvirt/ecs\n" +
|
|
||||||
"Shell Project URL: https://github.com/spiritLHLS/ecs")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
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)")
|
||||||
@@ -125,17 +51,29 @@ func main() {
|
|||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
var basicInfo, securityInfo, emailInfo, mediaInfo string
|
var basicInfo, securityInfo, emailInfo, mediaInfo string
|
||||||
|
var output, tempOutput string
|
||||||
if language == "zh" {
|
if language == "zh" {
|
||||||
printHead()
|
output = utils.PrintAndCapture(func() {
|
||||||
printCenteredTitle("基础信息", width)
|
utils.PrintHead(language, width, ecsVersion)
|
||||||
basicInfo, securityInfo = securityCheck()
|
utils.PrintCenteredTitle("基础信息", width)
|
||||||
fmt.Printf(basicInfo)
|
}, tempOutput, output)
|
||||||
printCenteredTitle(fmt.Sprintf("CPU测试-通过%s测试", cpuTestMethod), width)
|
output = utils.PrintAndCapture(func() {
|
||||||
cputest.CpuTest(language, cpuTestMethod, cpuTestThreadMode)
|
basicInfo, securityInfo, nt3CheckType = utils.SecurityCheck(language, nt3CheckType)
|
||||||
printCenteredTitle(fmt.Sprintf("内存测试-通过%s测试", cpuTestMethod), width)
|
fmt.Printf(basicInfo)
|
||||||
memorytest.MemoryTest(language, memoryTestMethod)
|
utils.PrintCenteredTitle(fmt.Sprintf("CPU测试-通过%s测试", cpuTestMethod), width)
|
||||||
printCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", diskTestMethod), width)
|
}, tempOutput, output)
|
||||||
disktest.DiskTest(language, diskTestMethod, diskTestPath, diskMultiCheck)
|
output = utils.PrintAndCapture(func() {
|
||||||
|
cputest.CpuTest(language, cpuTestMethod, cpuTestThreadMode)
|
||||||
|
utils.PrintCenteredTitle(fmt.Sprintf("内存测试-通过%s测试", cpuTestMethod), width)
|
||||||
|
}, tempOutput, output)
|
||||||
|
output = utils.PrintAndCapture(func() {
|
||||||
|
memorytest.MemoryTest(language, memoryTestMethod)
|
||||||
|
utils.PrintCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", diskTestMethod), width)
|
||||||
|
}, tempOutput, output)
|
||||||
|
output = utils.PrintAndCapture(func() {
|
||||||
|
disktest.DiskTest(language, diskTestMethod, diskTestPath, diskMultiCheck)
|
||||||
|
utils.PrintCenteredTitle("御三家流媒体解锁", width)
|
||||||
|
}, tempOutput, output)
|
||||||
wg.Add(2)
|
wg.Add(2)
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
@@ -145,69 +83,82 @@ func main() {
|
|||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
mediaInfo = unlocktest.MediaTest(language)
|
mediaInfo = unlocktest.MediaTest(language)
|
||||||
}()
|
}()
|
||||||
printCenteredTitle("御三家流媒体解锁", width)
|
output = utils.PrintAndCapture(func() {
|
||||||
commediatest.ComMediaTest(language)
|
commediatest.ComMediaTest(language)
|
||||||
printCenteredTitle("跨国流媒体解锁", width)
|
utils.PrintCenteredTitle("跨国流媒体解锁", width)
|
||||||
wg.Wait()
|
}, tempOutput, output)
|
||||||
fmt.Printf(mediaInfo)
|
wg.Wait() // 后台任务含流媒体测试和邮件测试
|
||||||
printCenteredTitle("IP质量检测", width)
|
output = utils.PrintAndCapture(func() {
|
||||||
fmt.Printf(securityInfo)
|
fmt.Printf(mediaInfo)
|
||||||
printCenteredTitle("邮件端口检测", width)
|
utils.PrintCenteredTitle("IP质量检测", width)
|
||||||
fmt.Println(emailInfo)
|
fmt.Printf(securityInfo)
|
||||||
printCenteredTitle("三网回程", width)
|
utils.PrintCenteredTitle("邮件端口检测", width)
|
||||||
backtrace.BackTrace()
|
fmt.Println(emailInfo)
|
||||||
|
utils.PrintCenteredTitle("三网回程", width)
|
||||||
|
}, tempOutput, output)
|
||||||
|
output = utils.PrintAndCapture(func() {
|
||||||
|
backtrace.BackTrace()
|
||||||
|
}, tempOutput, output)
|
||||||
if runtime.GOOS != "windows" {
|
if runtime.GOOS != "windows" {
|
||||||
// nexttrace 在win上不支持检测,报错 bind: An invalid argument was supplied.
|
// nexttrace 在win上不支持检测,报错 bind: An invalid argument was supplied.
|
||||||
printCenteredTitle("路由检测", width)
|
output = utils.PrintAndCapture(func() {
|
||||||
ntrace.TraceRoute3(language, nt3Location, nt3CheckType)
|
utils.PrintCenteredTitle("路由检测", width)
|
||||||
|
ntrace.TraceRoute3(language, nt3Location, nt3CheckType)
|
||||||
|
}, tempOutput, output)
|
||||||
}
|
}
|
||||||
printCenteredTitle("就近节点测速", width)
|
output = utils.PrintAndCapture(func() {
|
||||||
speedtest.ShowHead(language)
|
utils.PrintCenteredTitle("就近节点测速", width)
|
||||||
speedtest.NearbySP()
|
speedtest.ShowHead(language)
|
||||||
speedtest.CustomSP("net", "global", 4)
|
}, tempOutput, output)
|
||||||
speedtest.CustomSP("net", "cu", spNum)
|
output = utils.PrintAndCapture(func() {
|
||||||
speedtest.CustomSP("net", "ct", spNum)
|
speedtest.NearbySP()
|
||||||
speedtest.CustomSP("net", "cmcc", spNum)
|
speedtest.CustomSP("net", "global", 4)
|
||||||
printCenteredTitle("", width)
|
speedtest.CustomSP("net", "cu", spNum)
|
||||||
|
speedtest.CustomSP("net", "ct", spNum)
|
||||||
|
speedtest.CustomSP("net", "cmcc", spNum)
|
||||||
|
utils.PrintCenteredTitle("", width)
|
||||||
|
}, tempOutput, output)
|
||||||
endTime := time.Now()
|
endTime := time.Now()
|
||||||
duration := endTime.Sub(startTime)
|
duration := endTime.Sub(startTime)
|
||||||
minutes := int(duration.Minutes())
|
minutes := int(duration.Minutes())
|
||||||
seconds := int(duration.Seconds()) % 60
|
seconds := int(duration.Seconds()) % 60
|
||||||
fmt.Printf("花费 : %d 分 %d 秒\n", minutes, seconds)
|
|
||||||
currentTime := time.Now().Format("Mon Jan 2 15:04:05 MST 2006")
|
currentTime := time.Now().Format("Mon Jan 2 15:04:05 MST 2006")
|
||||||
fmt.Printf("时间 : %s\n", currentTime)
|
output = utils.PrintAndCapture(func() {
|
||||||
printCenteredTitle("", width)
|
fmt.Printf("花费 : %d 分 %d 秒\n", minutes, seconds)
|
||||||
|
fmt.Printf("时间 : %s\n", currentTime)
|
||||||
|
utils.PrintCenteredTitle("", width)
|
||||||
|
}, tempOutput, output)
|
||||||
} else if language == "en" {
|
} else if language == "en" {
|
||||||
printHead()
|
utils.PrintHead(language, width, ecsVersion)
|
||||||
printCenteredTitle("Basic Information", width)
|
utils.PrintCenteredTitle("Basic Information", width)
|
||||||
basicInfo, securityInfo = securityCheck()
|
basicInfo, securityInfo, nt3CheckType = utils.SecurityCheck(language, nt3CheckType)
|
||||||
fmt.Printf(basicInfo)
|
fmt.Printf(basicInfo)
|
||||||
printCenteredTitle(fmt.Sprintf("CPU Test - %s Method", cpuTestMethod), width)
|
utils.PrintCenteredTitle(fmt.Sprintf("CPU Test - %s Method", cpuTestMethod), width)
|
||||||
cputest.CpuTest(language, cpuTestMethod, cpuTestThreadMode)
|
cputest.CpuTest(language, cpuTestMethod, cpuTestThreadMode)
|
||||||
printCenteredTitle(fmt.Sprintf("Memory Test - %s Method", memoryTestMethod), width)
|
utils.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)
|
utils.PrintCenteredTitle(fmt.Sprintf("Disk Test - %s Method", diskTestMethod), width)
|
||||||
disktest.DiskTest(language, diskTestMethod, diskTestPath, diskMultiCheck)
|
disktest.DiskTest(language, diskTestMethod, diskTestPath, diskMultiCheck)
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
emailInfo = email.EmailCheck()
|
emailInfo = email.EmailCheck()
|
||||||
}()
|
}()
|
||||||
printCenteredTitle("The Three Families Streaming Media Unlock", width)
|
utils.PrintCenteredTitle("The Three Families Streaming Media Unlock", width)
|
||||||
commediatest.ComMediaTest(language)
|
commediatest.ComMediaTest(language)
|
||||||
printCenteredTitle("Cross-Border Streaming Media Unlock", width)
|
utils.PrintCenteredTitle("Cross-Border Streaming Media Unlock", width)
|
||||||
unlocktest.MediaTest(language)
|
unlocktest.MediaTest(language)
|
||||||
printCenteredTitle("IP Quality Check", width)
|
utils.PrintCenteredTitle("IP Quality Check", width)
|
||||||
fmt.Printf(securityInfo)
|
fmt.Printf(securityInfo)
|
||||||
printCenteredTitle("Email Port Check", width)
|
utils.PrintCenteredTitle("Email Port Check", width)
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
fmt.Println(emailInfo)
|
fmt.Println(emailInfo)
|
||||||
//printCenteredTitle("Return Path Routing", width)
|
//utils.PrintCenteredTitle("Return Path Routing", width)
|
||||||
printCenteredTitle("Nearby Node Speed Test", width)
|
utils.PrintCenteredTitle("Nearby Node Speed Test", width)
|
||||||
speedtest.ShowHead(language)
|
speedtest.ShowHead(language)
|
||||||
speedtest.NearbySP()
|
speedtest.NearbySP()
|
||||||
speedtest.CustomSP("net", "global", -1)
|
speedtest.CustomSP("net", "global", -1)
|
||||||
printCenteredTitle("", width)
|
utils.PrintCenteredTitle("", width)
|
||||||
endTime := time.Now()
|
endTime := time.Now()
|
||||||
duration := endTime.Sub(startTime)
|
duration := endTime.Sub(startTime)
|
||||||
minutes := int(duration.Minutes())
|
minutes := int(duration.Minutes())
|
||||||
@@ -215,6 +166,11 @@ func main() {
|
|||||||
fmt.Printf("Cost Time : %d 分 %d 秒\n", minutes, seconds)
|
fmt.Printf("Cost Time : %d 分 %d 秒\n", minutes, seconds)
|
||||||
currentTime := time.Now().Format("Mon Jan 2 15:04:05 MST 2006")
|
currentTime := time.Now().Format("Mon Jan 2 15:04:05 MST 2006")
|
||||||
fmt.Printf("Current Time : %s\n", currentTime)
|
fmt.Printf("Current Time : %s\n", currentTime)
|
||||||
printCenteredTitle("", width)
|
utils.PrintCenteredTitle("", width)
|
||||||
}
|
}
|
||||||
|
shorturl, err := utils.UploadText(output)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Upload failed, can not generate short URL.")
|
||||||
|
}
|
||||||
|
fmt.Println("Upload successful, short URL:", shorturl)
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import "testing"
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
func Test(t *testing.T) {
|
func Test(t *testing.T) {
|
||||||
main()
|
main()
|
||||||
|
133
utils/utils.go
Normal file
133
utils/utils.go
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"github.com/imroc/req/v3"
|
||||||
|
"github.com/oneclickvirt/UnlockTests/uts"
|
||||||
|
"github.com/oneclickvirt/basics/system"
|
||||||
|
"github.com/oneclickvirt/security/network"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
"unicode/utf8"
|
||||||
|
)
|
||||||
|
|
||||||
|
// PrintCenteredTitle 根据指定的宽度打印居中标题
|
||||||
|
func PrintCenteredTitle(title string, width int) {
|
||||||
|
// 计算字符串的字符数
|
||||||
|
titleLength := utf8.RuneCountInString(title)
|
||||||
|
totalPadding := width - titleLength
|
||||||
|
padding := totalPadding / 2
|
||||||
|
paddingStr := strings.Repeat("-", padding)
|
||||||
|
fmt.Println(paddingStr + title + paddingStr + strings.Repeat("-", totalPadding%2))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PrintHead 根据语言打印头部信息
|
||||||
|
func PrintHead(language string, width int, ecsVersion string) {
|
||||||
|
if language == "zh" {
|
||||||
|
PrintCenteredTitle("融合怪测试", width)
|
||||||
|
fmt.Printf("版本:%s\n", ecsVersion)
|
||||||
|
fmt.Println("测评频道: https://t.me/vps_reviews\n" +
|
||||||
|
"Go项目地址:https://github.com/oneclickvirt/ecs\n" +
|
||||||
|
"Shell项目地址:https://github.com/spiritLHLS/ecs")
|
||||||
|
} else {
|
||||||
|
PrintCenteredTitle("Fusion Monster Test", width)
|
||||||
|
fmt.Printf("Version: %s\n", ecsVersion)
|
||||||
|
fmt.Println("Review Channel: https://t.me/vps_reviews\n" +
|
||||||
|
"Go Project URL: https://github.com/oneclickvirt/ecs\n" +
|
||||||
|
"Shell Project URL: https://github.com/spiritLHLS/ecs")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SecurityCheck 执行安全检查
|
||||||
|
func SecurityCheck(language, nt3CheckType string) (string, string, string) {
|
||||||
|
var wgt sync.WaitGroup
|
||||||
|
var ipInfo, securityInfo, systemInfo string
|
||||||
|
var err error
|
||||||
|
wgt.Add(2)
|
||||||
|
go func() {
|
||||||
|
defer wgt.Done()
|
||||||
|
ipInfo, securityInfo, err = network.NetworkCheck("both", true, language)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err.Error())
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
go func() {
|
||||||
|
defer wgt.Done()
|
||||||
|
systemInfo = system.CheckSystemInfo(language)
|
||||||
|
}()
|
||||||
|
wgt.Wait()
|
||||||
|
basicInfo := systemInfo + ipInfo
|
||||||
|
if strings.Contains(ipInfo, "IPV4") && strings.Contains(ipInfo, "IPV6") {
|
||||||
|
uts.IPV4 = true
|
||||||
|
uts.IPV6 = true
|
||||||
|
if nt3CheckType == "" {
|
||||||
|
nt3CheckType = "ipv4"
|
||||||
|
}
|
||||||
|
} else if strings.Contains(ipInfo, "IPV4") {
|
||||||
|
uts.IPV4 = true
|
||||||
|
uts.IPV6 = false
|
||||||
|
if nt3CheckType == "" {
|
||||||
|
nt3CheckType = "ipv4"
|
||||||
|
}
|
||||||
|
} else if strings.Contains(ipInfo, "IPV6") {
|
||||||
|
uts.IPV6 = true
|
||||||
|
uts.IPV4 = false
|
||||||
|
if nt3CheckType == "" {
|
||||||
|
nt3CheckType = "ipv6"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if nt3CheckType == "ipv4" && !strings.Contains(ipInfo, "IPV4") && strings.Contains(ipInfo, "IPV6") {
|
||||||
|
nt3CheckType = "ipv6"
|
||||||
|
} else if nt3CheckType == "ipv6" && !strings.Contains(ipInfo, "IPV6") && strings.Contains(ipInfo, "IPV4") {
|
||||||
|
nt3CheckType = "ipv4"
|
||||||
|
}
|
||||||
|
basicInfo = strings.ReplaceAll(basicInfo, "\n\n", "\n")
|
||||||
|
return basicInfo, securityInfo, nt3CheckType
|
||||||
|
}
|
||||||
|
|
||||||
|
// CaptureOutput 捕获函数输出并返回字符串
|
||||||
|
func CaptureOutput(f func()) string {
|
||||||
|
old := os.Stdout
|
||||||
|
r, w, _ := os.Pipe()
|
||||||
|
os.Stdout = w
|
||||||
|
f()
|
||||||
|
w.Close()
|
||||||
|
os.Stdout = old
|
||||||
|
var buf bytes.Buffer
|
||||||
|
buf.ReadFrom(r)
|
||||||
|
return buf.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// PrintAndCapture 捕获函数输出的同时打印内容
|
||||||
|
func PrintAndCapture(f func(), tempOutput, output string) string {
|
||||||
|
tempOutput = CaptureOutput(f)
|
||||||
|
fmt.Printf(tempOutput)
|
||||||
|
output += tempOutput
|
||||||
|
return output
|
||||||
|
}
|
||||||
|
|
||||||
|
// UploadText 上传文本内容到指定URL
|
||||||
|
func UploadText(textContent string) (string, error) {
|
||||||
|
url := "https://paste.spiritlhl.net/api/upload"
|
||||||
|
token := network.SecurityUploadToken
|
||||||
|
client := req.C().SetTimeout(10 * 1000 * 1000) // 10 seconds timeout
|
||||||
|
resp, err := client.R().
|
||||||
|
SetHeader("Authorization", token).
|
||||||
|
SetHeader("Format", "RANDOM").
|
||||||
|
SetHeader("Max-Views", "0").
|
||||||
|
SetHeader("UploadText", "true").
|
||||||
|
SetHeader("Content-Type", "multipart/form-data").
|
||||||
|
SetHeader("No-JSON", "true").
|
||||||
|
SetBodyString(textContent).
|
||||||
|
Post(url)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if resp.StatusCode >= 200 && resp.StatusCode <= 299 {
|
||||||
|
return resp.String(), nil
|
||||||
|
} else {
|
||||||
|
return "", fmt.Errorf("upload failed with status code: %d", resp.StatusCode)
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user