mirror of
https://github.com/oneclickvirt/ecs.git
synced 2025-09-27 11:42:23 +08:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
06e76a9c33 | ||
![]() |
6b88a81c02 | ||
![]() |
5482506bab | ||
![]() |
b7130db8ce | ||
![]() |
dc5e3b7852 |
4
go.mod
4
go.mod
@@ -6,11 +6,11 @@ require (
|
||||
github.com/imroc/req/v3 v3.54.0
|
||||
github.com/oneclickvirt/CommonMediaTests v0.0.4-20250329123841
|
||||
github.com/oneclickvirt/UnlockTests v0.0.28-20250727155204
|
||||
github.com/oneclickvirt/backtrace v0.0.5-20250727160732
|
||||
github.com/oneclickvirt/backtrace v0.0.6-20250801151556
|
||||
github.com/oneclickvirt/basics v0.0.15-20250728021329
|
||||
github.com/oneclickvirt/cputest v0.0.12-20250720122317
|
||||
github.com/oneclickvirt/defaultset v0.0.2-20240624082446
|
||||
github.com/oneclickvirt/disktest v0.0.8-20250701092629
|
||||
github.com/oneclickvirt/disktest v0.0.9-20250801101625
|
||||
github.com/oneclickvirt/gostun v0.0.5-20250727155022
|
||||
github.com/oneclickvirt/memorytest v0.0.9-20250720135728
|
||||
github.com/oneclickvirt/nt3 v0.0.6-20250726150925
|
||||
|
8
go.sum
8
go.sum
@@ -98,8 +98,8 @@ github.com/oneclickvirt/CommonMediaTests v0.0.4-20250329123841 h1:Zef93z9UiZQwRA
|
||||
github.com/oneclickvirt/CommonMediaTests v0.0.4-20250329123841/go.mod h1:DAmFPRjFV5p9fEzUUSml5jJGn2f1NZJQCzTxITHDjc4=
|
||||
github.com/oneclickvirt/UnlockTests v0.0.28-20250727155204 h1:apFaEbHGKflYMZzK17nXzEai4GG873mTd+d9hCO/KdY=
|
||||
github.com/oneclickvirt/UnlockTests v0.0.28-20250727155204/go.mod h1:oOa6wj/qECtRMxwBO6D7o0L0F0Q/5sQ747OCnFQqoGE=
|
||||
github.com/oneclickvirt/backtrace v0.0.5-20250727160732 h1:izs46j9hYYOOXcdtBX7y9PSlzLlxWSiC2+4rQ8P0DxA=
|
||||
github.com/oneclickvirt/backtrace v0.0.5-20250727160732/go.mod h1:yxL1ixDmOmEt8NkHnMIetsTXJW8xMslUpEY2L8sYZ4Y=
|
||||
github.com/oneclickvirt/backtrace v0.0.6-20250801151556 h1:qxCHjNkaUH2z4buO5qrqqXE1XPB0bTU3wfkCEp8G51w=
|
||||
github.com/oneclickvirt/backtrace v0.0.6-20250801151556/go.mod h1:/+KUtOWz48TyiTTbhVTsp3D6b5WY+4pCgvFBYtUGtns=
|
||||
github.com/oneclickvirt/basics v0.0.15-20250728021329 h1:bXat5W1twZdOdzJ15BFZUYsjAEcTH9ly9oMDIg5+Rbo=
|
||||
github.com/oneclickvirt/basics v0.0.15-20250728021329/go.mod h1:2PV+1ge01zb0Sqzj2V2I7P0wAdFSLF1XgAiumchJJbg=
|
||||
github.com/oneclickvirt/cputest v0.0.12-20250720122317 h1:toiwAK1hZE5b8klu2mOQ7J4sv5yV9lpPKwgPahfRYBQ=
|
||||
@@ -108,8 +108,8 @@ github.com/oneclickvirt/dd v0.0.2-20250701085922 h1:WiWZwcnCPhRc8hLZdvkjD2kOEpnq
|
||||
github.com/oneclickvirt/dd v0.0.2-20250701085922/go.mod h1:tImu9sPTkLWo2tf1dEN1xQzrylWKauj9hbU8PHfyAeU=
|
||||
github.com/oneclickvirt/defaultset v0.0.2-20240624082446 h1:5Pg3mK/u/vQvSz7anu0nxzrNdELi/AcDAU1mMsmPzyc=
|
||||
github.com/oneclickvirt/defaultset v0.0.2-20240624082446/go.mod h1:e9Jt4tf2sbemCtc84/XgKcHy9EZ2jkc5x2sW1NiJS+E=
|
||||
github.com/oneclickvirt/disktest v0.0.8-20250701092629 h1:B/gA6SOr4qL5pQmVpHl9m5bn3paDcL7wJ1SZ7aY66M8=
|
||||
github.com/oneclickvirt/disktest v0.0.8-20250701092629/go.mod h1:6YCvGr+Z0tvcP4Ue8bezZqm/GqS/dSyEnSUhvS3Q03o=
|
||||
github.com/oneclickvirt/disktest v0.0.9-20250801101625 h1:N8sAZrziexT/4qqVwK1hIvXrIKjAinsGdQ9ceumBxNo=
|
||||
github.com/oneclickvirt/disktest v0.0.9-20250801101625/go.mod h1:6YCvGr+Z0tvcP4Ue8bezZqm/GqS/dSyEnSUhvS3Q03o=
|
||||
github.com/oneclickvirt/fio v0.0.2-20250701085933 h1:4P7QcOTxbqyx5DhHdFvyeRSsdNajSo9l/H2XK0vICIc=
|
||||
github.com/oneclickvirt/fio v0.0.2-20250701085933/go.mod h1:NIq+XYTey68KNERGIy/oRDlzpwLzBVoHOCiqX8didsE=
|
||||
github.com/oneclickvirt/gostun v0.0.5-20250727155022 h1:/e3gSUrOp1tg/1NTRx+P8B51OGcP26Q6//5EoSIjOvk=
|
||||
|
13
goecs.go
13
goecs.go
@@ -17,8 +17,6 @@ import (
|
||||
|
||||
"github.com/oneclickvirt/CommonMediaTests/commediatests"
|
||||
unlocktestmodel "github.com/oneclickvirt/UnlockTests/model"
|
||||
"github.com/oneclickvirt/UnlockTests/uts"
|
||||
backtrace "github.com/oneclickvirt/backtrace/bk"
|
||||
backtracemodel "github.com/oneclickvirt/backtrace/model"
|
||||
basicmodel "github.com/oneclickvirt/basics/model"
|
||||
cputestmodel "github.com/oneclickvirt/cputest/model"
|
||||
@@ -28,6 +26,7 @@ import (
|
||||
"github.com/oneclickvirt/ecs/memorytest"
|
||||
"github.com/oneclickvirt/ecs/speedtest"
|
||||
"github.com/oneclickvirt/ecs/unlocktest"
|
||||
"github.com/oneclickvirt/ecs/upstreams"
|
||||
"github.com/oneclickvirt/ecs/utils"
|
||||
gostunmodel "github.com/oneclickvirt/gostun/model"
|
||||
memorytestmodel "github.com/oneclickvirt/memorytest/memory"
|
||||
@@ -40,7 +39,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
ecsVersion = "v0.1.71"
|
||||
ecsVersion = "v0.1.72"
|
||||
menuMode bool
|
||||
onlyChinaTest bool
|
||||
input, choice string
|
||||
@@ -691,12 +690,8 @@ func runNetworkTests(wg3 *sync.WaitGroup, ptInfo *string, output, tempOutput str
|
||||
defer outputMutex.Unlock()
|
||||
output = utils.PrintAndCapture(func() {
|
||||
if backtraceStatus && !onlyChinaTest {
|
||||
utils.PrintCenteredTitle("三网回程线路检测", width)
|
||||
if uts.IPV6 {
|
||||
backtrace.BackTrace(true)
|
||||
} else {
|
||||
backtrace.BackTrace(false)
|
||||
}
|
||||
utils.PrintCenteredTitle("上游及回程线路检测", width)
|
||||
upstreams.UpstreamsCheck()
|
||||
}
|
||||
}, tempOutput, output)
|
||||
output = utils.PrintAndCapture(func() {
|
||||
|
6
goecs.sh
6
goecs.sh
@@ -143,7 +143,7 @@ goecs_check() {
|
||||
os=$(uname -s 2>/dev/null || echo "Unknown")
|
||||
arch=$(uname -m 2>/dev/null || echo "Unknown")
|
||||
check_china
|
||||
ECS_VERSION="0.1.70"
|
||||
ECS_VERSION="0.1.71"
|
||||
for api in \
|
||||
"https://api.github.com/repos/oneclickvirt/ecs/releases/latest" \
|
||||
"https://githubapi.spiritlhl.workers.dev/repos/oneclickvirt/ecs/releases/latest" \
|
||||
@@ -155,8 +155,8 @@ goecs_check() {
|
||||
sleep 1
|
||||
done
|
||||
if [ -z "$ECS_VERSION" ]; then
|
||||
_yellow "Unable to get version info, using default version 0.1.70"
|
||||
ECS_VERSION="0.1.70"
|
||||
_yellow "Unable to get version info, using default version 0.1.71"
|
||||
ECS_VERSION="0.1.71"
|
||||
fi
|
||||
version_output=""
|
||||
for cmd_path in "goecs" "./goecs" "/usr/bin/goecs" "/usr/local/bin/goecs"; do
|
||||
|
66
upstreams/upstreams.go
Normal file
66
upstreams/upstreams.go
Normal file
@@ -0,0 +1,66 @@
|
||||
package upstreams
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/imroc/req/v3"
|
||||
"github.com/oneclickvirt/UnlockTests/uts"
|
||||
bgptools "github.com/oneclickvirt/backtrace/bgptools"
|
||||
backtrace "github.com/oneclickvirt/backtrace/bk"
|
||||
)
|
||||
|
||||
type IpInfo struct {
|
||||
Ip string `json:"ip"`
|
||||
City string `json:"city,omitempty"`
|
||||
Region string `json:"region,omitempty"`
|
||||
Country string `json:"country,omitempty"`
|
||||
Org string `json:"org,omitempty"`
|
||||
}
|
||||
|
||||
func fetchIP(ctx context.Context, url string, parse func([]byte) (string, error), ch chan<- string) {
|
||||
client := req.C().SetTimeout(3 * time.Second)
|
||||
resp, err := client.R().SetContext(ctx).Get(url)
|
||||
if err != nil || !resp.IsSuccessState() {
|
||||
return
|
||||
}
|
||||
ip, err := parse(resp.Bytes())
|
||||
if err == nil && ip != "" && strings.Contains(ip, ".") {
|
||||
ch <- ip
|
||||
}
|
||||
}
|
||||
|
||||
func UpstreamsCheck() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
defer cancel()
|
||||
ipChan := make(chan string, 3)
|
||||
go fetchIP(ctx, "https://ipinfo.io", func(b []byte) (string, error) {
|
||||
var data IpInfo
|
||||
err := json.Unmarshal(b, &data)
|
||||
return data.Ip, err
|
||||
}, ipChan)
|
||||
go fetchIP(ctx, "https://api.ip.sb/ip", func(b []byte) (string, error) {
|
||||
return strings.TrimSpace(string(b)), nil
|
||||
}, ipChan)
|
||||
go fetchIP(ctx, "http://ip-api.com/json/?fields=query", func(b []byte) (string, error) {
|
||||
var data struct {
|
||||
Query string `json:"query"`
|
||||
}
|
||||
err := json.Unmarshal(b, &data)
|
||||
return data.Query, err
|
||||
}, ipChan)
|
||||
var ip string
|
||||
select {
|
||||
case ip = <-ipChan:
|
||||
case <-ctx.Done():
|
||||
}
|
||||
if ip != "" {
|
||||
if result, err := bgptools.GetPoPInfo(ip); err == nil {
|
||||
fmt.Print(result.Result)
|
||||
}
|
||||
}
|
||||
backtrace.BackTrace(uts.IPV6)
|
||||
}
|
7
upstreams/uptreams_test.go
Normal file
7
upstreams/uptreams_test.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package upstreams
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestUpstreamsCheck(t *testing.T) {
|
||||
UpstreamsCheck()
|
||||
}
|
Reference in New Issue
Block a user