mirror of
https://github.com/oneclickvirt/ecs.git
synced 2025-09-26 19:31:18 +08:00
fix: 提取三网详细路由的测试逻辑至于单独的包,添加单项测试
This commit is contained in:
36
goecs.go
36
goecs.go
@@ -24,6 +24,7 @@ import (
|
||||
"github.com/oneclickvirt/ecs/cputest"
|
||||
"github.com/oneclickvirt/ecs/disktest"
|
||||
"github.com/oneclickvirt/ecs/memorytest"
|
||||
"github.com/oneclickvirt/ecs/nexttrace"
|
||||
"github.com/oneclickvirt/ecs/speedtest"
|
||||
"github.com/oneclickvirt/ecs/unlocktest"
|
||||
"github.com/oneclickvirt/ecs/upstreams"
|
||||
@@ -31,7 +32,6 @@ import (
|
||||
gostunmodel "github.com/oneclickvirt/gostun/model"
|
||||
memorytestmodel "github.com/oneclickvirt/memorytest/memory"
|
||||
nt3model "github.com/oneclickvirt/nt3/model"
|
||||
"github.com/oneclickvirt/nt3/nt"
|
||||
ptmodel "github.com/oneclickvirt/pingtest/model"
|
||||
"github.com/oneclickvirt/pingtest/pt"
|
||||
"github.com/oneclickvirt/portchecker/email"
|
||||
@@ -783,39 +783,7 @@ func runNetworkTests(wg3 *sync.WaitGroup, ptInfo *string, output, tempOutput str
|
||||
output = utils.PrintAndCapture(func() {
|
||||
if nt3Status && !onlyChinaTest {
|
||||
utils.PrintCenteredTitle("三网回程路由检测", width)
|
||||
resultChan := make(chan nt.TraceResult, 100)
|
||||
go nt.TraceRoute(language, nt3Location, nt3CheckType, resultChan)
|
||||
for result := range resultChan {
|
||||
if result.Index == -1 {
|
||||
for index, res := range result.Output {
|
||||
res = strings.TrimSpace(res)
|
||||
if res != "" && index == 0 {
|
||||
fmt.Println(res)
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
if result.ISPName == "Error" {
|
||||
for _, res := range result.Output {
|
||||
res = strings.TrimSpace(res)
|
||||
if res != "" {
|
||||
fmt.Println(res)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
for _, res := range result.Output {
|
||||
res = strings.TrimSpace(res)
|
||||
if res == "" {
|
||||
continue
|
||||
}
|
||||
if strings.Contains(res, "ICMP") {
|
||||
fmt.Print(res)
|
||||
} else {
|
||||
fmt.Println(res)
|
||||
}
|
||||
}
|
||||
}
|
||||
nexttrace.NextTrace3Check(language, nt3Location, nt3CheckType)
|
||||
}
|
||||
}, tempOutput, output)
|
||||
return utils.PrintAndCapture(func() {
|
||||
|
44
nexttrace/nexttrace.go
Normal file
44
nexttrace/nexttrace.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package nexttrace
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/oneclickvirt/nt3/nt"
|
||||
)
|
||||
|
||||
func NextTrace3Check(language, nt3Location, nt3CheckType string) {
|
||||
resultChan := make(chan nt.TraceResult, 100)
|
||||
go nt.TraceRoute(language, nt3Location, nt3CheckType, resultChan)
|
||||
for result := range resultChan {
|
||||
if result.Index == -1 {
|
||||
for index, res := range result.Output {
|
||||
res = strings.TrimSpace(res)
|
||||
if res != "" && index == 0 {
|
||||
fmt.Println(res)
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
if result.ISPName == "Error" {
|
||||
for _, res := range result.Output {
|
||||
res = strings.TrimSpace(res)
|
||||
if res != "" {
|
||||
fmt.Println(res)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
for _, res := range result.Output {
|
||||
res = strings.TrimSpace(res)
|
||||
if res == "" {
|
||||
continue
|
||||
}
|
||||
if strings.Contains(res, "ICMP") {
|
||||
fmt.Print(res)
|
||||
} else {
|
||||
fmt.Println(res)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
13
nexttrace/nexttrace_test.go
Normal file
13
nexttrace/nexttrace_test.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package nexttrace
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestNextTrace3Check(t *testing.T) {
|
||||
start := time.Now()
|
||||
NextTrace3Check("zh", "ALL", "ipv4")
|
||||
duration := time.Since(start)
|
||||
t.Logf("执行耗时: %s", duration)
|
||||
}
|
Reference in New Issue
Block a user