Merge pull request #201 from nxtrace/main

chore: sync
This commit is contained in:
tsosunchia
2023-12-02 13:23:47 +08:00
committed by GitHub
13 changed files with 110 additions and 82 deletions

View File

@@ -62,7 +62,7 @@ Please note, there are exceptions to this synchronization. If a version of NTrac
* One-click installation script
```shell
bash -c "$(curl http://nexttrace-io-leomoe-api-a0.shop/nt_install_v1.sh)"
curl nxtrace.org/nt |bash
```
* Arch Linux AUR installation command
* Directly download bin package (only supports amd64)
@@ -160,7 +160,7 @@ nexttrace 2606:4700:4700::1111
# Disable Path Visualization With the -M parameter
nexttrace koreacentral.blob.core.windows.net
# MapTrace URL: https://api.leo.moe/tracemap/html/c14e439e-3250-5310-8965-42a1e3545266.html
# MapTrace URL: https://api.nxtrace.org/tracemap/html/c14e439e-3250-5310-8965-42a1e3545266.html
# Disable MPLS display using the --disable-mpls / -e parameter or the NEXTTRACE_DISABLEMPLS environment variable
nexttrace --disable-mpls example.com
@@ -250,6 +250,11 @@ nexttrace --psize 1024 example.com
# ╭╯
# ╰AS37963 Aliyun「ALIDNS.COM『ALIDNS.COM』」
nexttrace --route-path www.time.com.my
# Disable color output
nexttrace --nocolor 1.1.1.1
# or use ENV
export NO_COLOR=1
```
`NextTrace` supports users to select their own IP API (currently supports: `LeoMoeAPI`, `IP.SB`, `IPInfo`, `IPInsight`, `IPAPI.com`, `Ip2region`, `IPInfoLocal`, `CHUNZHEN`)
@@ -308,7 +313,7 @@ Usage: nexttrace [-h|--help] [-4|--ipv4] [-6|--ipv6] [-T|--tcp] [-U|--udp]
<integer>] [--parallel-requests <integer>] [-m|--max-hops
<integer>] [-d|--data-provider
(Ip2region|ip2region|IP.SB|ip.sb|IPInfo|ipinfo|IPInsight|ipinsight|IPAPI.com|ip-api.com|IPInfoLocal|ipinfolocal|chunzhen|LeoMoeAPI|leomoeapi|disable-geoip)]
[--pow-provider (api.leo.moe|sakura)] [-n|--no-rdns]
[--pow-provider (api.nxtrace.org|sakura)] [-n|--no-rdns]
[-a|--always-rdns] [-P|--route-path] [-r|--report] [--dn42]
[-o|--output] [-t|--table] [--raw] [-j|--json] [-c|--classic]
[-f|--first <integer>] [-M|--map] [-e|--disable-mpls]
@@ -317,7 +322,7 @@ Usage: nexttrace [-h|--help] [-4|--ipv4] [-6|--ipv6] [-T|--tcp] [-U|--udp]
[--timeout <integer>] [--psize <integer>]
[_positionalArg_nexttrace_32 "<value>"] [--dot-server
(dnssb|aliyun|dnspod|google|cloudflare)] [-g|--language
(en|cn)] [--file "<value>"]
(en|cn)] [--file "<value>"] [-C|--nocolor]
Arguments:
@@ -348,9 +353,9 @@ Arguments:
IPInfo, IPInsight, IP-API.com, Ip2region,
IPInfoLocal, CHUNZHEN, disable-geoip].
Default: LeoMoeAPI
--pow-provider Choose PoW Provider [api.leo.moe, sakura]
--pow-provider Choose PoW Provider [api.nxtrace.org, sakura]
For China mainland users, please use
sakura. Default: api.leo.moe
sakura. Default: api.nxtrace.org
-n --no-rdns Do not resolve IP addresses to their
domain names
-a --always-rdns Always resolve IP addresses to their
@@ -393,6 +398,7 @@ Arguments:
-g --language Choose the language for displaying [en,
cn]. Default: cn
--file Read IP Address or domain name from file
-C --nocolor Disable Colorful Output
```
## Project screenshot
@@ -440,15 +446,15 @@ We hope you can give us as much feedback as possible on IP geolocation errors (s
## Credits
[sjlleo](https://github.com/sjlleo) The perpetual leader, founder, and core contributors of the NextTrace Project
[BGP.TOOLS](https://bgp.tools) provided some data support for this project. And we would like to express our sincere gratitude.
[Vincent Young](https://github.com/missuo) (i@yyt.moe)
[sjlleo](https://github.com/sjlleo) The perpetual leader, founder, and core contributors
[Sam Sam](https://github.com/samleong123) (samsam123@samsam123.name.my)
[tsosunchia](https://github.com/tsosunchia) The project chair, infra maintainer, and core contributors
[tsosunchia](https://github.com/tsosunchia)
[Vincent Young](https://github.com/missuo)
[Sam Sam](https://github.com/samleong123)
[waiting4new](https://github.com/waiting4new)

View File

@@ -71,7 +71,7 @@ Document Language: [English](README.md) | 简体中文
* 一键安装脚本
```shell
bash -c "$(curl http://nexttrace-io-leomoe-api-a0.shop/nt_install_v1.sh)"
curl nxtrace.org/nt | bash
```
* Arch Linux AUR 安装命令
@@ -173,7 +173,7 @@ nexttrace 2606:4700:4700::1111
# 禁用路径可视化 使用 --map / -M 参数
nexttrace koreacentral.blob.core.windows.net
# MapTrace URL: https://api.leo.moe/tracemap/html/c14e439e-3250-5310-8965-42a1e3545266.html
# MapTrace URL: https://api.nxtrace.org/tracemap/html/c14e439e-3250-5310-8965-42a1e3545266.html
# 禁用MPLS显示 使用 --disable-mpls / -e 参数 或 NEXTTRACE_DISABLEMPLS 环境变量
nexttrace --disable-mpls example.com
@@ -266,6 +266,10 @@ nexttrace --psize 1024 example.com
# ╭╯
# ╰AS37963 阿里云「ALIDNS.COM『ALIDNS.COM』」
nexttrace --route-path www.time.com.my
# 禁止色彩输出
nexttrace --nocolor 1.1.1.1
# 或者使用环境变量
export NO_COLOR=1
```
`NextTrace`支持用户自主选择 IP 数据库(目前支持:`LeoMoeAPI`, `IP.SB`, `IPInfo`, `IPInsight`, `IPAPI.com`, `Ip2region`, `IPInfoLocal`, `CHUNZHEN`)
@@ -308,7 +312,7 @@ Usage: nexttrace [-h|--help] [-4|--ipv4] [-6|--ipv6] [-T|--tcp] [-U|--udp]
<integer>] [--parallel-requests <integer>] [-m|--max-hops
<integer>] [-d|--data-provider
(Ip2region|ip2region|IP.SB|ip.sb|IPInfo|ipinfo|IPInsight|ipinsight|IPAPI.com|ip-api.com|IPInfoLocal|ipinfolocal|chunzhen|LeoMoeAPI|leomoeapi|disable-geoip)]
[--pow-provider (api.leo.moe|sakura)] [-n|--no-rdns]
[--pow-provider (api.nxtrace.org|sakura)] [-n|--no-rdns]
[-a|--always-rdns] [-P|--route-path] [-r|--report] [--dn42]
[-o|--output] [-t|--table] [--raw] [-j|--json] [-c|--classic]
[-f|--first <integer>] [-M|--map] [-e|--disable-mpls]
@@ -317,7 +321,7 @@ Usage: nexttrace [-h|--help] [-4|--ipv4] [-6|--ipv6] [-T|--tcp] [-U|--udp]
[--timeout <integer>] [--psize <integer>]
[_positionalArg_nexttrace_32 "<value>"] [--dot-server
(dnssb|aliyun|dnspod|google|cloudflare)] [-g|--language
(en|cn)] [--file "<value>"]
(en|cn)] [--file "<value>"] [-C|--nocolor]
Arguments:
@@ -348,9 +352,9 @@ Arguments:
IPInfo, IPInsight, IP-API.com, Ip2region,
IPInfoLocal, CHUNZHEN, disable-geoip].
Default: LeoMoeAPI
--pow-provider Choose PoW Provider [api.leo.moe, sakura]
--pow-provider Choose PoW Provider [api.nxtrace.org, sakura]
For China mainland users, please use
sakura. Default: api.leo.moe
sakura. Default: api.nxtrace.org
-n --no-rdns Do not resolve IP addresses to their
domain names
-a --always-rdns Always resolve IP addresses to their
@@ -393,6 +397,7 @@ Arguments:
-g --language Choose the language for displaying [en,
cn]. Default: cn
--file Read IP Address or domain name from file
-C --nocolor Disable Colorful Output
```
## 项目截图
@@ -440,15 +445,15 @@ nexttrace --pow-provider sakura
## Credits
[sjlleo](https://github.com/sjlleo) NextTrace 项目永远的领导者、创始人及核心贡献者
[BGP.TOOLS](https://bgp.tools) 提供了本项目的一些数据支持,在此表示由衷地感谢。
[Vincent Young](https://github.com/missuo) (i@yyt.moe)
[sjlleo](https://github.com/sjlleo) 项目永远的领导者、创始人及核心贡献者
[Sam Sam](https://github.com/samleong123) (samsam123@samsam123.name.my)
[tsosunchia](https://github.com/tsosunchia) 项目现任管理、基础设施运维及核心贡献者
[tsosunchia](https://github.com/tsosunchia)
[Vincent Young](https://github.com/missuo)
[Sam Sam](https://github.com/samleong123)
[waiting4new](https://github.com/waiting4new)

View File

@@ -3,6 +3,7 @@ package cmd
import (
"encoding/json"
"fmt"
"github.com/fatih/color"
"log"
"net"
"os"
@@ -41,8 +42,8 @@ func Excute() {
maxHops := parser.Int("m", "max-hops", &argparse.Options{Default: 30, Help: "Set the max number of hops (max TTL to be reached)"})
dataOrigin := parser.Selector("d", "data-provider", []string{"Ip2region", "ip2region", "IP.SB", "ip.sb", "IPInfo", "ipinfo", "IPInsight", "ipinsight", "IPAPI.com", "ip-api.com", "IPInfoLocal", "ipinfolocal", "chunzhen", "LeoMoeAPI", "leomoeapi", "disable-geoip"}, &argparse.Options{Default: "LeoMoeAPI",
Help: "Choose IP Geograph Data Provider [IP.SB, IPInfo, IPInsight, IP-API.com, Ip2region, IPInfoLocal, CHUNZHEN, disable-geoip]"})
powProvider := parser.Selector("", "pow-provider", []string{"api.leo.moe", "sakura"}, &argparse.Options{Default: "api.leo.moe",
Help: "Choose PoW Provider [api.leo.moe, sakura] For China mainland users, please use sakura"})
powProvider := parser.Selector("", "pow-provider", []string{"api.nxtrace.org", "sakura"}, &argparse.Options{Default: "api.nxtrace.org",
Help: "Choose PoW Provider [api.nxtrace.org, sakura] For China mainland users, please use sakura"})
noRdns := parser.Flag("n", "no-rdns", &argparse.Options{Help: "Do not resolve IP addresses to their domain names"})
alwaysRdns := parser.Flag("a", "always-rdns", &argparse.Options{Help: "Always resolve IP addresses to their domain names"})
routePath := parser.Flag("P", "route-path", &argparse.Options{Help: "Print traceroute hop path by ASN and location"})
@@ -70,6 +71,7 @@ func Excute() {
lang := parser.Selector("g", "language", []string{"en", "cn"}, &argparse.Options{Default: "cn",
Help: "Choose the language for displaying [en, cn]"})
file := parser.String("", "file", &argparse.Options{Help: "Read IP Address or domain name from file"})
nocolor := parser.Flag("C", "nocolor", &argparse.Options{Help: "Disable Colorful Output"})
err := parser.Parse(os.Args)
if err != nil {
@@ -86,6 +88,12 @@ func Excute() {
os.Exit(0)
}
if *nocolor {
color.NoColor = true
} else {
color.NoColor = false
}
domain := *str
if *port == 0 {
@@ -165,7 +173,7 @@ func Excute() {
// defer wg.Done()
if strings.ToUpper(*dataOrigin) == "LEOMOEAPI" {
val, ok := os.LookupEnv("NEXTTRACE_DATAPROVIDER")
if strings.ToUpper(*powProvider) != "API.LEO.MOE" {
if strings.ToUpper(*powProvider) != "API.NXTRACE.ORG" {
util.PowProviderParam = *powProvider
}
if ok {

View File

@@ -49,36 +49,36 @@ var Beijing = BackBoneCollection{
Location: "北京",
CT163: ISPCollection{
ISPName: CT163,
IP: "ipv4.pek-4134.nexttrace-io-fasttrace-endpoint.win.",
IPv6: "ipv6.pek-4134.nexttrace-io-fasttrace-endpoint.win.",
IP: "ipv4.pek-4134.endpoint.nxtrace.org.",
IPv6: "ipv6.pek-4134.endpoint.nxtrace.org.",
},
CU169: ISPCollection{
ISPName: CU169,
IP: "ipv4.pek-4837.nexttrace-io-fasttrace-endpoint.win.",
IPv6: "ipv6.pek-4837.nexttrace-io-fasttrace-endpoint.win.",
IP: "ipv4.pek-4837.endpoint.nxtrace.org.",
IPv6: "ipv6.pek-4837.endpoint.nxtrace.org.",
},
CU9929: ISPCollection{
ISPName: CU9929,
IP: "ipv4.pek-9929.nexttrace-io-fasttrace-endpoint.win.",
IP: "ipv4.pek-9929.endpoint.nxtrace.org.",
},
CM: ISPCollection{
ISPName: CM,
IP: "ipv4.pek-9808.nexttrace-io-fasttrace-endpoint.win.",
IPv6: "ipv6.pek-9808.nexttrace-io-fasttrace-endpoint.win.",
IP: "ipv4.pek-9808.endpoint.nxtrace.org.",
IPv6: "ipv6.pek-9808.endpoint.nxtrace.org.",
},
CMIN2: ISPCollection{
ISPName: CMIN2,
IP: "ipv4.pek-58807.nexttrace-io-fasttrace-endpoint.win.",
IP: "ipv4.pek-58807.endpoint.nxtrace.org.",
},
EDU: ISPCollection{
ISPName: EDU,
IP: "ipv4.pek-4538.nexttrace-io-fasttrace-endpoint.win.",
IPv6: "ipv6.pek-4538.nexttrace-io-fasttrace-endpoint.win.",
IP: "ipv4.pek-4538.endpoint.nxtrace.org.",
IPv6: "ipv6.pek-4538.endpoint.nxtrace.org.",
},
}
@@ -86,42 +86,42 @@ var Shanghai = BackBoneCollection{
Location: "上海",
CT163: ISPCollection{
ISPName: CT163,
IP: "ipv4.sha-4134.nexttrace-io-fasttrace-endpoint.win.",
IPv6: "ipv6.sha-4134.nexttrace-io-fasttrace-endpoint.win.",
IP: "ipv4.sha-4134.endpoint.nxtrace.org.",
IPv6: "ipv6.sha-4134.endpoint.nxtrace.org.",
},
CTCN2: ISPCollection{
ISPName: CTCN2,
IP: "ipv4.sha-4809.nexttrace-io-fasttrace-endpoint.win.",
IP: "ipv4.sha-4809.endpoint.nxtrace.org.",
},
CU169: ISPCollection{
ISPName: CU169,
IP: "ipv4.sha-4837.nexttrace-io-fasttrace-endpoint.win.",
IPv6: "ipv6.sha-4837.nexttrace-io-fasttrace-endpoint.win.",
IP: "ipv4.sha-4837.endpoint.nxtrace.org.",
IPv6: "ipv6.sha-4837.endpoint.nxtrace.org.",
},
CU9929: ISPCollection{
ISPName: CU9929,
IP: "ipv4.sha-9929.nexttrace-io-fasttrace-endpoint.win.",
IPv6: "ipv6.sha-9929.nexttrace-io-fasttrace-endpoint.win.",
IP: "ipv4.sha-9929.endpoint.nxtrace.org.",
IPv6: "ipv6.sha-9929.endpoint.nxtrace.org.",
},
CM: ISPCollection{
ISPName: CM,
IP: "ipv4.sha-9808.nexttrace-io-fasttrace-endpoint.win.",
IPv6: "ipv6.sha-9808.nexttrace-io-fasttrace-endpoint.win.",
IP: "ipv4.sha-9808.endpoint.nxtrace.org.",
IPv6: "ipv6.sha-9808.endpoint.nxtrace.org.",
},
CMIN2: ISPCollection{
ISPName: CMIN2,
IP: "ipv4.sha-58807.nexttrace-io-fasttrace-endpoint.win.",
IP: "ipv4.sha-58807.endpoint.nxtrace.org.",
},
EDU: ISPCollection{
ISPName: EDU,
IP: "ipv4.sha-4538.nexttrace-io-fasttrace-endpoint.win.",
IPv6: "ipv6.sha-4538.nexttrace-io-fasttrace-endpoint.win.",
IP: "ipv4.sha-4538.endpoint.nxtrace.org.",
IPv6: "ipv6.sha-4538.endpoint.nxtrace.org.",
},
}
@@ -129,20 +129,20 @@ var Guangzhou = BackBoneCollection{
Location: "广州",
CT163: ISPCollection{
ISPName: CT163,
IP: "ipv4.can-4134.nexttrace-io-fasttrace-endpoint.win.",
IPv6: "ipv6.can-4134.nexttrace-io-fasttrace-endpoint.win.",
IP: "ipv4.can-4134.endpoint.nxtrace.org.",
IPv6: "ipv6.can-4134.endpoint.nxtrace.org.",
},
CU169: ISPCollection{
ISPName: CU169,
IP: "ipv4.can-4837.nexttrace-io-fasttrace-endpoint.win.",
IPv6: "ipv6.can-4837.nexttrace-io-fasttrace-endpoint.win.",
IP: "ipv4.can-4837.endpoint.nxtrace.org.",
IPv6: "ipv6.can-4837.endpoint.nxtrace.org.",
},
CM: ISPCollection{
ISPName: CM,
IP: "ipv4.can-9808.nexttrace-io-fasttrace-endpoint.win.",
IPv6: "ipv6.can-9808.nexttrace-io-fasttrace-endpoint.win.",
IP: "ipv4.can-9808.endpoint.nxtrace.org.",
IPv6: "ipv6.can-9808.endpoint.nxtrace.org.",
},
}
@@ -150,23 +150,23 @@ var Hangzhou = BackBoneCollection{
Location: "杭州",
CT163: ISPCollection{
ISPName: CT163,
IP: "ipv4.hgh-4134.nexttrace-io-fasttrace-endpoint.win.",
IPv6: "ipv6.hgh-4134.nexttrace-io-fasttrace-endpoint.win.",
IP: "ipv4.hgh-4134.endpoint.nxtrace.org.",
IPv6: "ipv6.hgh-4134.endpoint.nxtrace.org.",
},
CU169: ISPCollection{
ISPName: CU169,
IP: "ipv4.hgh-4837.nexttrace-io-fasttrace-endpoint.win.",
IP: "ipv4.hgh-4837.endpoint.nxtrace.org.",
},
CM: ISPCollection{
ISPName: CM,
IP: "ipv4.hgh-9808.nexttrace-io-fasttrace-endpoint.win.",
IPv6: "ipv6.hgh-9808.nexttrace-io-fasttrace-endpoint.win.",
IP: "ipv4.hgh-9808.endpoint.nxtrace.org.",
IPv6: "ipv6.hgh-9808.endpoint.nxtrace.org.",
},
// 浙江大学 教育网
EDU: ISPCollection{
ISPName: EDU,
IP: "ipv4.hgh-4538.nexttrace-io-fasttrace-endpoint.win.",
IPv6: "ipv6.hgh-4538.nexttrace-io-fasttrace-endpoint.win.",
IP: "ipv4.hgh-4538.endpoint.nxtrace.org.",
IPv6: "ipv6.hgh-4538.endpoint.nxtrace.org.",
},
}
@@ -175,12 +175,12 @@ var Hefei = BackBoneCollection{
// 中国科学技术大学 教育网
EDU: ISPCollection{
ISPName: EDU,
IP: "ipv4.hfe-4538.nexttrace-io-fasttrace-endpoint.win.",
IPv6: "ipv6.hfe-4538.nexttrace-io-fasttrace-endpoint.win.",
IP: "ipv4.hfe-4538.endpoint.nxtrace.org.",
IPv6: "ipv6.hfe-4538.endpoint.nxtrace.org.",
},
// 中国科学技术大学 科技网
CST: ISPCollection{
ISPName: "中国科学技术大学 科技网 AS7497",
IP: "ipv4.hfe-7497.nexttrace-io-fasttrace-endpoint.win.",
IP: "ipv4.hfe-7497.endpoint.nxtrace.org.",
},
}

View File

@@ -10,7 +10,7 @@ import (
func TestGetToken(t *testing.T) {
// 计时开始
start := time.Now()
token, err := GetToken("api.leo.moe", "api.leo.moe", "443")
token, err := GetToken("origin-fallback.nxtrace.org", "origin-fallback.nxtrace.org", "443")
// 计时结束
end := time.Now()
fmt.Println("耗时:", end.Sub(start))

View File

@@ -25,7 +25,7 @@ func Version() {
func CopyRight() {
sponsor()
fmt.Fprintf(color.Output, "\n%s\n%s %s\n%s %s\n%s %s, %s, %s, %s\n%s %s\n%s %s\n",
fmt.Fprintf(color.Output, "\n%s\n%s %s\n%s %s\n%s %s, %s, %s, %s\n%s %s\n",
color.New(color.FgCyan, color.Bold).Sprintf("%s", "NextTrace CopyRight"),
//color.New(color.FgGreen, color.Bold).Sprintf("%s", "Contact Us"),
//color.New(color.FgWhite, color.Bold).Sprintf("%s", "Feedback Email:"),
@@ -48,8 +48,8 @@ func CopyRight() {
//color.New(color.FgHiBlack, color.Bold).Sprintf("%s", "tsosunchia@gmail.com"),
color.New(color.FgWhite, color.Bold).Sprintf("%s", "Infra Maintainer:"),
color.New(color.FgHiBlue, color.Bold).Sprintf("%s", "Tso"),
color.New(color.FgWhite, color.Bold).Sprintf("%s", "NOC Manager:"),
color.New(color.FgHiBlue, color.Bold).Sprintf("%s", "YekongTAT"),
//color.New(color.FgWhite, color.Bold).Sprintf("%s", "NOC Manager:"),
//color.New(color.FgHiBlue, color.Bold).Sprintf("%s", "YekongTAT"),
//color.New(color.FgHiBlack, color.Bold).Sprintf("%s", "tsosunchia@gmail.com"),
)
//PluginCopyRight()

View File

@@ -114,11 +114,13 @@ func (r *reporter) InitialBaseData() Reporter {
r.targetTTL = uint16(len(r.routeResult.Hops))
for i := uint16(0); i < r.targetTTL; i++ {
traceHop := r.routeResult.Hops[i][0]
if traceHop.Success {
currentIP := traceHop.Address.String()
r.wg.Add(1)
go r.generateRouteReportNode(currentIP, *traceHop.Geo, i)
if i < uint16(len(r.routeResult.Hops)) && len(r.routeResult.Hops[i]) > 0 {
traceHop := r.routeResult.Hops[i][0]
if traceHop.Success {
currentIP := traceHop.Address.String()
r.wg.Add(1)
go r.generateRouteReportNode(currentIP, *traceHop.Geo, i)
}
}
}

View File

@@ -16,14 +16,14 @@ import (
func GetMapUrl(r string) (string, error) {
host, port := util.GetHostAndPort()
fastIp := "api.leo.moe"
fastIp := "origin-fallback.nxtrace.org"
// 如果 host 是一个 IP 使用默认域名
if valid := net.ParseIP(host); valid != nil {
fastIp = host
if len(strings.Split(fastIp, ":")) > 1 {
fastIp = "[" + fastIp + "]"
}
host = "api.leo.moe"
host = "origin-fallback.nxtrace.org"
} else {
// 默认配置完成,开始寻找最优 IP
fastIp = util.GetFastIP(host, port, false)

View File

@@ -13,8 +13,8 @@ func TestDNS(t *testing.T) {
}
func TestDomainLookUp(t *testing.T) {
ips, _ := DomainLookUp("pek-4134.nexttrace-io-fasttrace-endpoint.win.", "all", "", false)
ips, _ := DomainLookUp("pek-4134.endpoint.nxtrace.org.", "all", "", false)
fmt.Println(ips)
ips, _ = DomainLookUp("pek-4134.nexttrace-io-fasttrace-endpoint.win.", "4", "", false)
ips, _ = DomainLookUp("pek-4134.endpoint.nxtrace.org.", "4", "", false)
fmt.Println(ips)
}

View File

@@ -28,13 +28,20 @@ var FastIpCache = ""
func GetFastIP(domain string, port string, enableOutput bool) string {
proxyUrl := GetProxy()
if proxyUrl != nil {
return "api.leo.moe"
return "origin-fallback.nxtrace.org"
}
if FastIpCache != "" {
return FastIpCache
}
ips, err := net.LookupIP(domain)
var ips []net.IP
var err error
if domain == "origin-fallback.nxtrace.org" {
ips, err = net.LookupIP("api.nxtrace.org")
} else {
ips, err = net.LookupIP(domain)
}
if err != nil {
log.Fatal("DNS resolution failed, please check your system DNS Settings")
}

View File

@@ -2,5 +2,5 @@ package util
//github action test 不支持v6 这里会报错
//func TestGetFastIP(t *testing.T) {
// GetFastIP("api.leo.moe", "443", true)
// GetFastIP("origin-fallback.nxtrace.org", "443", true)
//}

View File

@@ -168,7 +168,7 @@ func GetenvDefault(key, defVal string) string {
}
func GetHostAndPort() (host string, port string) {
var hostP = GetenvDefault("NEXTTRACE_HOSTPORT", "api.leo.moe")
var hostP = GetenvDefault("NEXTTRACE_HOSTPORT", "origin-fallback.nxtrace.org")
// 解析域名
hostArr := strings.Split(hostP, ":")
// 判断是否有指定端口
@@ -210,7 +210,7 @@ func GetProxy() *url.URL {
func GetPowProvider() string {
var powProvider = ""
if PowProviderParam == "" {
powProvider = GetenvDefault("NEXTTRACE_POWPROVIDER", "api.leo.moe")
powProvider = GetenvDefault("NEXTTRACE_POWPROVIDER", "api.nxtrace.org")
} else {
powProvider = PowProviderParam
}

View File

@@ -192,7 +192,7 @@ func createWsConn() *WsConn {
if len(strings.Split(fastIp, ":")) > 1 {
fastIp = "[" + fastIp + "]"
}
host = "api.leo.moe"
host = "origin-fallback.nxtrace.org"
} else {
// 默认配置完成,开始寻找最优 IP
fastIp = util.GetFastIP(host, port, true)