Skip to content

Commit 86d4871

Browse files
committed
fix:更新版本
1 parent 308cbf9 commit 86d4871

File tree

15 files changed

+1215
-83
lines changed

15 files changed

+1215
-83
lines changed

go.mod

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,20 @@ go 1.25.3
44

55
require (
66
fyne.io/fyne/v2 v2.7.0
7-
github.com/oneclickvirt/CommonMediaTests v0.0.4-20250629044730
7+
github.com/imroc/req/v3 v3.54.0
8+
github.com/oneclickvirt/CommonMediaTests v0.0.4-20250329123841
9+
github.com/oneclickvirt/UnlockTests v0.0.30-20251030112700
10+
github.com/oneclickvirt/backtrace v0.0.8-20251102140847
811
github.com/oneclickvirt/basics v0.0.16-20251030093657
9-
github.com/oneclickvirt/ecs v0.1.93
10-
github.com/oneclickvirt/pingtest v0.0.8-20250728015259
12+
github.com/oneclickvirt/cputest v0.0.12-20250720122317
13+
github.com/oneclickvirt/defaultset v0.0.2-20240624082446
14+
github.com/oneclickvirt/disktest v0.0.10-20250924030424
15+
github.com/oneclickvirt/memorytest v0.0.10-20250924154648
16+
github.com/oneclickvirt/nt3 v0.0.10-20251103023436
17+
github.com/oneclickvirt/pingtest v0.0.9-20251102150730
1118
github.com/oneclickvirt/portchecker v0.0.3-20250728015900
19+
github.com/oneclickvirt/security v0.0.7-20251030094114
20+
github.com/oneclickvirt/speedtest v0.0.11-20251102151740
1221
)
1322

1423
require (
@@ -45,7 +54,6 @@ require (
4554
github.com/hashicorp/go-multierror v1.1.1 // indirect
4655
github.com/huin/goupnp v1.2.0 // indirect
4756
github.com/icholy/digest v1.1.0 // indirect
48-
github.com/imroc/req/v3 v3.54.0 // indirect
4957
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
5058
github.com/jaypipes/ghw v0.17.0 // indirect
5159
github.com/jaypipes/pcidb v1.0.1 // indirect
@@ -69,19 +77,10 @@ require (
6977
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
7078
github.com/nicksnyder/go-i18n/v2 v2.5.1 // indirect
7179
github.com/nxtrace/NTrace-core v1.4.3-rc.1 // indirect
72-
github.com/oneclickvirt/UnlockTests v0.0.30-20251030112700 // indirect
73-
github.com/oneclickvirt/backtrace v0.0.7-20250811023541 // indirect
74-
github.com/oneclickvirt/cputest v0.0.12-20250720122317 // indirect
7580
github.com/oneclickvirt/dd v0.0.2-20250808062818 // indirect
76-
github.com/oneclickvirt/defaultset v0.0.2-20240624082446 // indirect
77-
github.com/oneclickvirt/disktest v0.0.10-20250924030424 // indirect
7881
github.com/oneclickvirt/fio v0.0.2-20250808045755 // indirect
7982
github.com/oneclickvirt/gostun v0.0.5-20250727155022 // indirect
8083
github.com/oneclickvirt/mbw v0.0.1-20250808061222 // indirect
81-
github.com/oneclickvirt/memorytest v0.0.10-20250924154648 // indirect
82-
github.com/oneclickvirt/nt3 v0.0.9-20251031045617 // indirect
83-
github.com/oneclickvirt/security v0.0.7-20251030094114 // indirect
84-
github.com/oneclickvirt/speedtest v0.0.10-20250728015734 // indirect
8584
github.com/oneclickvirt/stream v0.0.2-20250924154001 // indirect
8685
github.com/oschwald/maxminddb-golang v1.13.1 // indirect
8786
github.com/pelletier/go-toml/v2 v2.2.4 // indirect

go.sum

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ github.com/nicksnyder/go-i18n/v2 v2.5.1 h1:IxtPxYsR9Gp60cGXjfuR/llTqV8aYMsC472zD
138138
github.com/nicksnyder/go-i18n/v2 v2.5.1/go.mod h1:DrhgsSDZxoAfvVrBVLXoxZn/pN5TXqaDbq7ju94viiQ=
139139
github.com/nxtrace/NTrace-core v1.4.3-rc.1 h1:V19tkw3kKAMQOOh7Ibb/jZFBk4kMUfQYmpxxtsOfYWo=
140140
github.com/nxtrace/NTrace-core v1.4.3-rc.1/go.mod h1:lGhfZ916pEUJh+VzWZTYu7bKBo06pAn+/gXb0A/7gGg=
141-
github.com/oneclickvirt/CommonMediaTests v0.0.4-20250629044730 h1:F1HMLJDXXOQfpeLa/LShm3GIE8r4bWOZWVMCcrqjtBc=
142-
github.com/oneclickvirt/CommonMediaTests v0.0.4-20250629044730/go.mod h1:DAmFPRjFV5p9fEzUUSml5jJGn2f1NZJQCzTxITHDjc4=
141+
github.com/oneclickvirt/CommonMediaTests v0.0.4-20250329123841 h1:Zef93z9UiZQwRAKnnZYALmpBKvvuVaq34MEsuWwk6nc=
142+
github.com/oneclickvirt/CommonMediaTests v0.0.4-20250329123841/go.mod h1:DAmFPRjFV5p9fEzUUSml5jJGn2f1NZJQCzTxITHDjc4=
143143
github.com/oneclickvirt/UnlockTests v0.0.30-20251030112700 h1:dtHHyWZdshox8StzrjgImj3Rvqwup5OZJ8FAZZQjPIA=
144144
github.com/oneclickvirt/UnlockTests v0.0.30-20251030112700/go.mod h1:oOa6wj/qECtRMxwBO6D7o0L0F0Q/5sQ747OCnFQqoGE=
145-
github.com/oneclickvirt/backtrace v0.0.7-20250811023541 h1:GzkzvUC6U9b6Dkz/Bl4JRPeQ7XBGoW7Qw1aWqzhF+MQ=
146-
github.com/oneclickvirt/backtrace v0.0.7-20250811023541/go.mod h1:/+KUtOWz48TyiTTbhVTsp3D6b5WY+4pCgvFBYtUGtns=
145+
github.com/oneclickvirt/backtrace v0.0.8-20251102140847 h1:OiwD06+Mql3pYP8jJFFdP3OUlCrx/qJT7y2YCd/OMiI=
146+
github.com/oneclickvirt/backtrace v0.0.8-20251102140847/go.mod h1:mj9TSow7FNszBb3bQj2Hhm41LwBo7HQP6sgaPtovKdM=
147147
github.com/oneclickvirt/basics v0.0.16-20251030093657 h1:6SWWILNjJfMTXbspqYRpktUEOe/QIVhGonKO8ODC7n4=
148148
github.com/oneclickvirt/basics v0.0.16-20251030093657/go.mod h1:2PV+1ge01zb0Sqzj2V2I7P0wAdFSLF1XgAiumchJJbg=
149149
github.com/oneclickvirt/cputest v0.0.12-20250720122317 h1:toiwAK1hZE5b8klu2mOQ7J4sv5yV9lpPKwgPahfRYBQ=
@@ -154,8 +154,6 @@ github.com/oneclickvirt/defaultset v0.0.2-20240624082446 h1:5Pg3mK/u/vQvSz7anu0n
154154
github.com/oneclickvirt/defaultset v0.0.2-20240624082446/go.mod h1:e9Jt4tf2sbemCtc84/XgKcHy9EZ2jkc5x2sW1NiJS+E=
155155
github.com/oneclickvirt/disktest v0.0.10-20250924030424 h1:56Aq2xygO/vA/co5vJ7/MQTNijIDl8eYbVk8uCWN4mI=
156156
github.com/oneclickvirt/disktest v0.0.10-20250924030424/go.mod h1:Vp3iMVBD4ccReDJz5n5SlzUdq0kDuVhpRklQk21KT+8=
157-
github.com/oneclickvirt/ecs v0.1.93 h1:64yYNQGBRCjgZujGacu1GTgIKRA48mXpYyK1/d4F+ns=
158-
github.com/oneclickvirt/ecs v0.1.93/go.mod h1:qwjqNyxEjJwep5aiYI15WOyJEqOOM1oS7jeTR+knlf0=
159157
github.com/oneclickvirt/fio v0.0.2-20250808045755 h1:eWihCRWcalJjPIdrF8dMe68ZiPnMkSfHC8ENvElp/xE=
160158
github.com/oneclickvirt/fio v0.0.2-20250808045755/go.mod h1:NIq+XYTey68KNERGIy/oRDlzpwLzBVoHOCiqX8didsE=
161159
github.com/oneclickvirt/gostun v0.0.5-20250727155022 h1:/e3gSUrOp1tg/1NTRx+P8B51OGcP26Q6//5EoSIjOvk=
@@ -164,16 +162,16 @@ github.com/oneclickvirt/mbw v0.0.1-20250808061222 h1:WGXOe6QvHiDRhPVMI0VcctjzW08
164162
github.com/oneclickvirt/mbw v0.0.1-20250808061222/go.mod h1:0Vq6NRpyLmGUdfHfL3uDcFsuZhi7KlG+OCs5ky2757Y=
165163
github.com/oneclickvirt/memorytest v0.0.10-20250924154648 h1:trk6oZ7xs1eVtr+6oIv5IX8LDVtEMG+E6GVzQ810BtU=
166164
github.com/oneclickvirt/memorytest v0.0.10-20250924154648/go.mod h1:4kiHsEWkW9r3/1ZcV5xIweU0smiKP0IRfQj74AUIiVI=
167-
github.com/oneclickvirt/nt3 v0.0.9-20251031045617 h1:g42R4kwOL4s6sDsG+axEXJsI82pldv42HLMYCDFypNg=
168-
github.com/oneclickvirt/nt3 v0.0.9-20251031045617/go.mod h1:yo1ufkduFt9QjqG7nqSUf1D3YlQOmFpdlTYniJfclQI=
169-
github.com/oneclickvirt/pingtest v0.0.8-20250728015259 h1:egoxZRZBOWN3JqBwqEsULDyRo2/dpGMeWcmV3U87zig=
170-
github.com/oneclickvirt/pingtest v0.0.8-20250728015259/go.mod h1:gxwsxxwitNQiGq2OI0ZogYoOLwc8DtuOdSRe6/EvRqs=
165+
github.com/oneclickvirt/nt3 v0.0.10-20251103023436 h1:vXqiU/HE0EXGf17LHyIQx8xYJz3+MOCHtlbfKyvt3cQ=
166+
github.com/oneclickvirt/nt3 v0.0.10-20251103023436/go.mod h1:yo1ufkduFt9QjqG7nqSUf1D3YlQOmFpdlTYniJfclQI=
167+
github.com/oneclickvirt/pingtest v0.0.9-20251102150730 h1:pipqyJUaUI0K5waFvDNNfqbIikMp+9Kg8Dw/kLEUYF8=
168+
github.com/oneclickvirt/pingtest v0.0.9-20251102150730/go.mod h1:gxwsxxwitNQiGq2OI0ZogYoOLwc8DtuOdSRe6/EvRqs=
171169
github.com/oneclickvirt/portchecker v0.0.3-20250728015900 h1:AomzdppSOFB70AJESQhlp0IPbsHTTJGimAWDk2TzCWM=
172170
github.com/oneclickvirt/portchecker v0.0.3-20250728015900/go.mod h1:9sjMDPCd4Z40wkYB0S9gQPGH8YPtnNE1ZJthVIuHUzA=
173171
github.com/oneclickvirt/security v0.0.7-20251030094114 h1:Ax8J1TYqprXyiWNAIJJ3xhoyGhvBlKw4m9j6va5Q2nM=
174172
github.com/oneclickvirt/security v0.0.7-20251030094114/go.mod h1:YfDilPFW22szjdUNgv4VOuSwHnZzsFsdPOfRYiMoc3I=
175-
github.com/oneclickvirt/speedtest v0.0.10-20250728015734 h1:HKO7/JQ74ueXA8Wo8NIvcK9DphbEG/YTfAAVz/akSiY=
176-
github.com/oneclickvirt/speedtest v0.0.10-20250728015734/go.mod h1:0W8vnMbA3iucXLXFdGfe9Ia6RPS0izRO7jvu/SnH1P8=
173+
github.com/oneclickvirt/speedtest v0.0.11-20251102151740 h1:1NUrNt5ay6/xVNC5x62UrQjPqK8jgbKtyjBml/3boZg=
174+
github.com/oneclickvirt/speedtest v0.0.11-20251102151740/go.mod h1:fy0II2Wo7kDWVBKTwcHdodZwyfmJo0g8N9V02EwQDZE=
177175
github.com/oneclickvirt/stream v0.0.2-20250924154001 h1:GuJWdiPkoK84+y/+oHKr2Ghl3c/MzS9Z5m1nM+lMmy4=
178176
github.com/oneclickvirt/stream v0.0.2-20250924154001/go.mod h1:oWaizaHTC2VQciBC9RfaLbAOf8qeR6n20/gY7QxriDE=
179177
github.com/oschwald/maxminddb-golang v1.13.1 h1:G3wwjdN9JmIK2o/ermkHM+98oX5fS+k5MbwsmL4MRQE=

internal/tests/cpu.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package tests
2+
3+
import (
4+
"runtime"
5+
"strings"
6+
7+
"github.com/oneclickvirt/cputest/cpu"
8+
)
9+
10+
func CpuTest(language, testMethod, testThread string) (realTestMethod, res string) {
11+
if runtime.GOOS == "windows" {
12+
if testMethod != "winsat" && testMethod != "" {
13+
// res = "Detected host is Windows, using Winsat for testing.\n"
14+
realTestMethod = "winsat"
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+
realTestMethod = "geekbench"
24+
res += cpu.GeekBenchTest(language, testThread)
25+
} else {
26+
realTestMethod = "sysbench"
27+
}
28+
case "geekbench":
29+
res = cpu.GeekBenchTest(language, testThread)
30+
if res == "" {
31+
// res = "Geekbench test failed, switching to Sysbench for testing.\n"
32+
realTestMethod = "sysbench"
33+
res += cpu.SysBenchTest(language, testThread)
34+
} else {
35+
realTestMethod = "geekbench"
36+
}
37+
default:
38+
res = "Invalid test method specified.\n"
39+
realTestMethod = "null"
40+
}
41+
}
42+
if !strings.Contains(res, "\n") && res != "" {
43+
res += "\n"
44+
}
45+
return
46+
}

internal/tests/disk.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package tests
2+
3+
import (
4+
"runtime"
5+
"strings"
6+
7+
"github.com/oneclickvirt/disktest/disk"
8+
)
9+
10+
func DiskTest(language, testMethod, testPath string, isMultiCheck bool, autoChange bool) (realTestMethod, res string) {
11+
switch testMethod {
12+
case "fio":
13+
res = disk.FioTest(language, isMultiCheck, testPath)
14+
if res == "" && autoChange {
15+
res += disk.DDTest(language, isMultiCheck, testPath)
16+
realTestMethod = "dd"
17+
} else {
18+
realTestMethod = "fio"
19+
}
20+
case "dd":
21+
res = disk.DDTest(language, isMultiCheck, testPath)
22+
if res == "" && autoChange {
23+
res += disk.FioTest(language, isMultiCheck, testPath)
24+
realTestMethod = "fio"
25+
} else {
26+
realTestMethod = "dd"
27+
}
28+
default:
29+
if runtime.GOOS == "windows" {
30+
realTestMethod = "winsat"
31+
res = disk.WinsatTest(language, isMultiCheck, testPath)
32+
} else {
33+
res = disk.DDTest(language, isMultiCheck, testPath)
34+
realTestMethod = "dd"
35+
}
36+
}
37+
if !strings.Contains(res, "\n") && res != "" {
38+
res += "\n"
39+
}
40+
return
41+
}

internal/tests/memory.go

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
package tests
2+
3+
import (
4+
"runtime"
5+
"strings"
6+
7+
"github.com/oneclickvirt/memorytest/memory"
8+
)
9+
10+
func MemoryTest(language, testMethod string) (realTestMethod, res string) {
11+
testMethod = strings.ToLower(testMethod)
12+
if testMethod == "" {
13+
testMethod = "auto"
14+
}
15+
if runtime.GOOS == "windows" {
16+
switch testMethod {
17+
case "stream":
18+
res = memory.WinsatTest(language)
19+
realTestMethod = "winsat"
20+
case "dd":
21+
res = memory.WindowsDDTest(language)
22+
if res == "" || strings.TrimSpace(res) == "" {
23+
res += memory.WinsatTest(language)
24+
realTestMethod = "winsat"
25+
} else {
26+
realTestMethod = "dd"
27+
}
28+
case "sysbench":
29+
res = memory.WinsatTest(language)
30+
realTestMethod = "winsat"
31+
case "auto", "winsat":
32+
res = memory.WinsatTest(language)
33+
realTestMethod = "winsat"
34+
default:
35+
res = memory.WinsatTest(language)
36+
realTestMethod = "winsat"
37+
}
38+
} else {
39+
switch testMethod {
40+
case "stream":
41+
res = memory.StreamTest(language)
42+
if res == "" || strings.TrimSpace(res) == "" {
43+
res += memory.DDTest(language)
44+
realTestMethod = "dd"
45+
} else {
46+
realTestMethod = "stream"
47+
}
48+
case "dd":
49+
res = memory.DDTest(language)
50+
realTestMethod = "dd"
51+
case "sysbench":
52+
res = memory.SysBenchTest(language)
53+
if res == "" || strings.TrimSpace(res) == "" {
54+
res += memory.DDTest(language)
55+
realTestMethod = "dd"
56+
} else {
57+
realTestMethod = "sysbench"
58+
}
59+
case "auto":
60+
res = memory.StreamTest(language)
61+
if res == "" || strings.TrimSpace(res) == "" {
62+
res = memory.DDTest(language)
63+
if res == "" || strings.TrimSpace(res) == "" {
64+
res = memory.SysBenchTest(language)
65+
if res == "" || strings.TrimSpace(res) == "" {
66+
realTestMethod = ""
67+
} else {
68+
realTestMethod = "sysbench"
69+
}
70+
} else {
71+
realTestMethod = "dd"
72+
}
73+
} else {
74+
realTestMethod = "stream"
75+
}
76+
case "winsat":
77+
// winsat 仅 Windows 支持,非 Windows fallback 到 dd
78+
res = memory.DDTest(language)
79+
realTestMethod = "dd"
80+
default:
81+
res = "Unsupported test method"
82+
realTestMethod = ""
83+
}
84+
}
85+
if !strings.Contains(res, "\n") && res != "" {
86+
res += "\n"
87+
}
88+
return
89+
}

internal/tests/nexttrace.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package tests
2+
3+
import (
4+
"fmt"
5+
"strings"
6+
7+
"github.com/oneclickvirt/nt3/nt"
8+
)
9+
10+
func NextTrace3Check(language, nt3Location, nt3CheckType string) {
11+
resultChan := make(chan nt.TraceResult, 100)
12+
go nt.TraceRoute(language, nt3Location, nt3CheckType, resultChan)
13+
for result := range resultChan {
14+
if result.Index == -1 {
15+
for index, res := range result.Output {
16+
res = strings.TrimSpace(res)
17+
if res != "" && index == 0 {
18+
fmt.Println(res)
19+
}
20+
}
21+
continue
22+
}
23+
if result.ISPName == "Error" {
24+
for _, res := range result.Output {
25+
res = strings.TrimSpace(res)
26+
if res != "" {
27+
fmt.Println(res)
28+
}
29+
}
30+
return
31+
}
32+
for _, res := range result.Output {
33+
res = strings.TrimSpace(res)
34+
if res == "" {
35+
continue
36+
}
37+
if strings.Contains(res, "ICMP") {
38+
fmt.Print(res)
39+
} else {
40+
fmt.Println(res)
41+
}
42+
}
43+
}
44+
}

internal/tests/speed.go

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package tests
2+
3+
import (
4+
"runtime"
5+
"strings"
6+
7+
"github.com/oneclickvirt/speedtest/model"
8+
"github.com/oneclickvirt/speedtest/sp"
9+
)
10+
11+
func ShowHead(language string) {
12+
sp.ShowHead(language)
13+
}
14+
15+
func NearbySP() {
16+
if runtime.GOOS == "windows" || sp.OfficialAvailableTest() != nil {
17+
sp.NearbySpeedTest()
18+
} else {
19+
sp.OfficialNearbySpeedTest()
20+
}
21+
}
22+
23+
func CustomSP(platform, operator string, num int, language string) {
24+
var url, parseType string
25+
if strings.ToLower(platform) == "cn" {
26+
if strings.ToLower(operator) == "cmcc" {
27+
url = model.CnCMCC
28+
} else if strings.ToLower(operator) == "cu" {
29+
url = model.CnCU
30+
} else if strings.ToLower(operator) == "ct" {
31+
url = model.CnCT
32+
} else if strings.ToLower(operator) == "hk" {
33+
url = model.CnHK
34+
} else if strings.ToLower(operator) == "tw" {
35+
url = model.CnTW
36+
} else if strings.ToLower(operator) == "jp" {
37+
url = model.CnJP
38+
} else if strings.ToLower(operator) == "sg" {
39+
url = model.CnSG
40+
}
41+
parseType = "url"
42+
} else if strings.ToLower(platform) == "net" {
43+
if strings.ToLower(operator) == "cmcc" {
44+
url = model.NetCMCC
45+
} else if strings.ToLower(operator) == "cu" {
46+
url = model.NetCU
47+
} else if strings.ToLower(operator) == "ct" {
48+
url = model.NetCT
49+
} else if strings.ToLower(operator) == "hk" {
50+
url = model.NetHK
51+
} else if strings.ToLower(operator) == "tw" {
52+
url = model.NetTW
53+
} else if strings.ToLower(operator) == "jp" {
54+
url = model.NetJP
55+
} else if strings.ToLower(operator) == "sg" {
56+
url = model.NetSG
57+
} else if strings.ToLower(operator) == "global" {
58+
url = model.NetGlobal
59+
}
60+
parseType = "id"
61+
}
62+
if runtime.GOOS == "windows" || sp.OfficialAvailableTest() != nil {
63+
sp.CustomSpeedTest(url, parseType, num, language)
64+
} else {
65+
sp.OfficialCustomSpeedTest(url, parseType, num, language)
66+
}
67+
}

0 commit comments

Comments
 (0)