-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8c08bc0
commit 03f2b43
Showing
7 changed files
with
321 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ jobs: | |
run: | | ||
git config --global user.name 'github-actions' | ||
git config --global user.email '[email protected]' | ||
TAG="v0.0.1-$(date +'%Y%m%d%H%M%S')" | ||
TAG="v0.0.2-$(date +'%Y%m%d%H%M%S')" | ||
git tag $TAG | ||
git push origin $TAG | ||
env: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,58 @@ | ||
# speedtest | ||
# speedtest | ||
|
||
[![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Foneclickvirt%2Fspeedtest&count_bg=%232EFFF8&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false)](https://hits.seeyoufarm.com) | ||
|
||
就近节点测速模块 | ||
|
||
## 说明 | ||
|
||
- [x] 基于[speedtest.net-爬虫](https://github.com/spiritLHLS/speedtest.net-CN-ID)、[speedtest.cn-爬虫](https://github.com/spiritLHLS/speedtest.cn-CN-ID)的数据 | ||
- [x] 基于[speedtest-go](https://github.com/showwin/speedtest-go)二次开发 | ||
- [x] 主体逻辑借鉴了[ecsspeed](https://github.com/spiritLHLS/ecsspeed) | ||
|
||
## 使用 | ||
|
||
下载及安装 | ||
|
||
``` | ||
curl https://raw.githubusercontent.com/oneclickvirt/speedtest/main/spt_install.sh -sSf | bash | ||
``` | ||
|
||
或 | ||
|
||
``` | ||
curl https://cdn.spiritlhl.net/https://raw.githubusercontent.com/oneclickvirt/speedtest/main/spt_install.sh -sSf | bash | ||
``` | ||
|
||
使用 | ||
|
||
``` | ||
spt | ||
``` | ||
|
||
或 | ||
|
||
``` | ||
./spt | ||
``` | ||
|
||
进行测试 | ||
|
||
无环境依赖,理论上适配所有系统和主流架构,更多架构请查看 https://github.com/oneclickvirt/speedtest/releases/tag/output | ||
|
||
``` | ||
``` | ||
|
||
## 卸载 | ||
|
||
``` | ||
rm -rf /root/spt | ||
rm -rf /usr/bin/spt | ||
``` | ||
|
||
## 在Golang中使用 | ||
|
||
``` | ||
go get github.com/oneclickvirt/speedtest@latest | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,71 @@ | ||
package main | ||
|
||
import "github.com/oneclickvirt/speedtest/sp" | ||
import ( | ||
"flag" | ||
"fmt" | ||
"net/http" | ||
"strings" | ||
|
||
"github.com/oneclickvirt/speedtest/model" | ||
"github.com/oneclickvirt/speedtest/sp" | ||
) | ||
|
||
func main() { | ||
sp.NearbySpeedTest("en") | ||
sp.CustomSpeedTest("https://raw.githubusercontent.com/spiritLHLS/speedtest.net-CN-ID/main/CN_Telecom.csv", 2) | ||
go func() { | ||
http.Get("https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Foneclickvirt%2Fspeedtest&count_bg=%2323E01C&title_bg=%23555555&icon=sonarcloud.svg&icon_color=%23E7E7E7&title=hits&edge_flat=false") | ||
}() | ||
fmt.Println("项目地址:", "https://github.com/oneclickvirt/speedtest") | ||
var showVersion, nearByServer bool | ||
var language, operator, platform string | ||
var num int | ||
flag.BoolVar(&showVersion, "v", false, "Show version information") | ||
flag.BoolVar(&nearByServer, "nearby", false, "Test only nearby servers") | ||
flag.StringVar(&language, "l", "zh", "Language parameter (options: en, zh)") | ||
flag.StringVar(&platform, "pf", "net", "Platform parameter (options: net, cn)") | ||
flag.StringVar(&operator, "opt", "", "Operator parameter (options: cmcc, cu, ct, sg, tw, jp, hk, global)") | ||
flag.IntVar(&num, "num", -1, "Number of test servers") | ||
flag.Parse() | ||
if showVersion { | ||
fmt.Println(model.SpeedTestVersion) | ||
return | ||
} | ||
if nearByServer { | ||
sp.NearbySpeedTest(language) | ||
return | ||
} | ||
var url string | ||
if strings.ToLower(platform) == "net" { | ||
if strings.ToLower(operator) == "cmcc" { | ||
url = model.CnCMCC | ||
} else if strings.ToLower(operator) == "cu" { | ||
url = model.CnCU | ||
} else if strings.ToLower(operator) == "ct" { | ||
url = model.CnCT | ||
} else if strings.ToLower(operator) == "hk" { | ||
url = model.CnHK | ||
} else if strings.ToLower(operator) == "tw" { | ||
url = model.CnTW | ||
} else if strings.ToLower(operator) == "jp" { | ||
url = model.CnJP | ||
} else if strings.ToLower(operator) == "sg" { | ||
url = model.CnSG | ||
} | ||
} else if strings.ToLower(platform) == "cn" { | ||
if strings.ToLower(operator) == "cmcc" { | ||
url = model.NetCMCC | ||
} else if strings.ToLower(operator) == "cu" { | ||
url = model.NetCU | ||
} else if strings.ToLower(operator) == "ct" { | ||
url = model.NetCT | ||
} else if strings.ToLower(operator) == "hk" { | ||
url = model.NetHK | ||
} else if strings.ToLower(operator) == "tw" { | ||
url = model.NetTW | ||
} else if strings.ToLower(operator) == "jp" { | ||
url = model.NetJP | ||
} else if strings.ToLower(operator) == "sg" { | ||
url = model.NetSG | ||
} | ||
} | ||
sp.CustomSpeedTest(url, "id", num) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.