Compare commits

..

1 Commits
v1 ... v1.2.1.1

Author SHA1 Message Date
tsosunchia
30a0e92d7c Merge pull request #162 from nxtrace/main
推送v1更新至v1分支
2023-09-09 16:23:58 +08:00
44 changed files with 150 additions and 345 deletions

View File

@@ -26,15 +26,15 @@ for pl in ${PLATFORMS}; do
echo "build => ${TARGET}"
if [ "${DEBUG_MODE}" == "debug" ]; then
go build -trimpath -gcflags "all=-N -l" -o ${TARGET} \
-ldflags "-X 'github.com/nxtrace/NTrace-core/config.Version=${BUILD_VERSION}' \
-X 'github.com/nxtrace/NTrace-core/config.BuildDate=${BUILD_DATE}' \
-X 'github.com/nxtrace/NTrace-core/config.CommitID=${COMMIT_SHA1}'\
-ldflags "-X 'github.com/xgadget-lab/nexttrace/config.Version=${BUILD_VERSION}' \
-X 'github.com/xgadget-lab/nexttrace/config.BuildDate=${BUILD_DATE}' \
-X 'github.com/xgadget-lab/nexttrace/config.CommitID=${COMMIT_SHA1}'\
-w -s"
else
go build -trimpath -o ${TARGET} \
-ldflags "-X 'github.com/nxtrace/NTrace-core/config.Version=${BUILD_VERSION}' \
-X 'github.com/nxtrace/NTrace-core/config.BuildDate=${BUILD_DATE}' \
-X 'github.com/nxtrace/NTrace-core/config.CommitID=${COMMIT_SHA1}'\
-ldflags "-X 'github.com/xgadget-lab/nexttrace/config.Version=${BUILD_VERSION}' \
-X 'github.com/xgadget-lab/nexttrace/config.BuildDate=${BUILD_DATE}' \
-X 'github.com/xgadget-lab/nexttrace/config.CommitID=${COMMIT_SHA1}'\
-w -s"
fi
done
@@ -46,15 +46,15 @@ done
echo "build => ${TARGET}"
if [ "${DEBUG_MODE}" == "debug" ]; then
go build -trimpath -gcflags "all=-N -l" -o ${TARGET} \
-ldflags "-X 'github.com/nxtrace/NTrace-core/config.Version=${BUILD_VERSION}' \
-X 'github.com/nxtrace/NTrace-core/config.BuildDate=${BUILD_DATE}' \
-X 'github.com/nxtrace/NTrace-core/config.CommitID=${COMMIT_SHA1}'\
-ldflags "-X 'github.com/xgadget-lab/nexttrace/config.Version=${BUILD_VERSION}' \
-X 'github.com/xgadget-lab/nexttrace/config.BuildDate=${BUILD_DATE}' \
-X 'github.com/xgadget-lab/nexttrace/config.CommitID=${COMMIT_SHA1}'\
-w -s"
else
go build -trimpath -o ${TARGET} \
-ldflags "-X 'github.com/nxtrace/NTrace-core/config.Version=${BUILD_VERSION}' \
-X 'github.com/nxtrace/NTrace-core/config.BuildDate=${BUILD_DATE}' \
-X 'github.com/nxtrace/NTrace-core/config.CommitID=${COMMIT_SHA1}'\
-ldflags "-X 'github.com/xgadget-lab/nexttrace/config.Version=${BUILD_VERSION}' \
-X 'github.com/xgadget-lab/nexttrace/config.BuildDate=${BUILD_DATE}' \
-X 'github.com/xgadget-lab/nexttrace/config.CommitID=${COMMIT_SHA1}'\
-w -s"
fi

View File

@@ -15,7 +15,7 @@ copyright: [v2fly](https://github.com/v2fly)
<!--
除非特殊情况,请完整填写所有问题。不按模板发的 issue 将直接被关闭。
如果你遇到的问题不是 nexttrace 的 bug比如你不清楚如何配置请在 https://github.com/nxtrace/NTrace-core/discussions 进行讨论。
如果你遇到的问题不是 nexttrace 的 bug比如你不清楚如何配置请在 https://github.com/xgadget-lab/nexttrace/discussions 进行讨论。
-->
## 你正在使用哪个版本的 nexttrace

View File

@@ -125,15 +125,15 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
go-version: '1.20'
- name: Get project dependencies
run: go mod download
- name: Build
run: |
go build -trimpath -o dist/${ASSET_NAME} \
-ldflags "-X 'github.com/nxtrace/NTrace-core/config.Version=${BUILD_VERSION}' \
-X 'github.com/nxtrace/NTrace-core/config.BuildDate=${BUILD_DATE}' \
-X 'github.com/nxtrace/NTrace-core/config.CommitID=${COMMIT_SHA1}'\
-ldflags "-X 'github.com/xgadget-lab/nexttrace/config.Version=${BUILD_VERSION}' \
-X 'github.com/xgadget-lab/nexttrace/config.BuildDate=${BUILD_DATE}' \
-X 'github.com/xgadget-lab/nexttrace/config.CommitID=${COMMIT_SHA1}'\
-w -s"
- name: Upload files to Artifacts
uses: actions/upload-artifact@v3

View File

@@ -31,7 +31,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
go-version: '1.20'
check-latest: true
- name: Checkout codebase
uses: actions/checkout@v4
@@ -40,4 +40,4 @@ jobs:
run: sudo go test -v -coverprofile='coverage.out' -covermode=count ./...
- name: Test with windows
if: ${{ matrix.os == 'windows-latest' }}
run: go test -v -coverprofile='coverage.out' -covermode=count ./...
run: go test -v -coverprofile='coverage.out' -covermode=count ./...

View File

@@ -20,9 +20,6 @@
<a href="https://github.com/nxtrace/Ntrace-V1/releases">
<img src="https://img.shields.io/github/release/nxtrace/Ntrace-V1/all.svg?style=flat-square">
</a>
<a href="https://telegram.dog/sjprojects">
<img src="https://img.shields.io/endpoint?color=neon&style=flat-square&url=https%3A%2F%2Ftg.sumanjay.workers.dev%2Fnexttrace">
</a>
</p>
## IAAS Sponsor
@@ -47,7 +44,27 @@ We are extremely grateful to [DMIT](https://dmit.io) and [Misaka](https://misaka
Document Language: English | [简体中文](README_zh_CN.md)
⚠️ This is the README for the V1 Enhanced version of NextTrace.
⚠️ This is the README for the V1 version of NextTrace.
Differences between version v1.1.2 and v1.2.0:
* Added and fixed support for some third-party GEOIP APIs
* ipinfo
* ipinfoLocal, which is the offline version of the ipinfo database
* chunzhen
* ipinsight
* (disable-geoip)
* Added some parameters
* For use in secondary development by other projects
* JSON output
* raw output
* Parse only the IPv4/IPv6 addresses of the domain
* packet-size to set the ICMP packet size
* timeout to set the timeout period
* Supports accessing APIs through socks5/http proxy
* Supports more parameters in fasttrace mode
* Added cache handling to speed up resolution
* Fixed some bugs
* Golang v1.21.0
### Automated Install
@@ -144,10 +161,6 @@ 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
# Disable MPLS display using the --disable-mpls / -e parameter or the NEXTTRACE_DISABLEMPLS environment variable
nexttrace --disable-mpls example.com
export NEXTTRACE_DISABLEMPLS=1
```
PS: The routing visualization drawing module was written by [@tsosunchia](https://github.com/tsosunchia), and the specific code can be viewed at [tsosunchia/traceMap](https://github.com/tsosunchia/traceMap).
@@ -268,7 +281,7 @@ NextTrace `LeoMoeAPI` now utilizes the Proof of Work (POW) mechanism to prevent
- [GitHub - tsosunchia/powclient: Proof of Work CLIENT for NextTrace](https://github.com/tsosunchia/powclient)
- [GitHub - tsosunchia/powserver: Proof of Work SERVER for NextTrace](https://github.com/tsosunchia/powserver)
All NextTrace IP geolocation `API DEMO` can refer to [here](https://github.com/nxtrace/NTrace-core/blob/main/ipgeo/)
All NextTrace IP geolocation `API DEMO` can refer to [here](https://github.com/xgadget-lab/nexttrace/blob/main/ipgeo/)
### For full usage list, please refer to the usage menu
@@ -338,7 +351,6 @@ Arguments:
-f --first Start from the first_ttl hop (instead from
1). Default: 1
-M --map Disable Print Trace Map
-e --disable-mpls Disable MPLS
-v --version Print version info and exit
-s --source Use source src_addr for outgoing packets
-D --dev Use the following Network Devices as the
@@ -409,8 +421,6 @@ 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)

View File

@@ -21,9 +21,6 @@
<a href="https://github.com/nxtrace/Ntrace-V1/releases">
<img src="https://img.shields.io/github/release/nxtrace/Ntrace-V1/all.svg?style=flat-square">
</a>
<a href="https://telegram.dog/sjprojects">
<img src="https://img.shields.io/endpoint?color=neon&style=flat-square&url=https%3A%2F%2Ftg.sumanjay.workers.dev%2Fnexttrace">
</a>
</p>
## IAAS Sponsor
@@ -50,13 +47,35 @@
Document Language: [English](README.md) | 简体中文
⚠️ 这是NextTrace V1 增强版的README文件。
⚠️ 这是NextTrace V1 版的README文件。
关于 v1.1.2 与 v1.2.0 版本的区别:
* 增加和修复了部分第三方GEOIP API的支持
* ipinfo
* ipinfoLocal 即ipinfo数据库离线版
* chunzhen
* ipinsight
* (disable-geoip)
* 增加了部分参数
* 供其他项目二次开发调用
* json 输出
* raw 输出
* 仅解析域名的IPv4/IPv6地址
* packet-size 设置ICMP包大小
* timeout 设置超时时间
* 支持使用socks5/http代理访问API
* fasttrace模式下支持更多的参数
* 增加缓存处理以加速解析
* 修复了部分BUG
* Golang v1.21.0
### Before Using
使用 NextTrace 之前,我们建议您先阅读 [#IP 数据以及精准度说明](https://github.com/sjlleo/nexttrace/blob/main/README_zh_CN.md#ip-%E6%95%B0%E6%8D%AE%E4%BB%A5%E5%8F%8A%E7%B2%BE%E5%87%86%E5%BA%A6%E8%AF%B4%E6%98%8E),在了解您自己的对数据精准度需求以后再进行抉择。
[NextTrace 的Telegram频道](https://t.me/nexttrace)由项目成员负责,会传递一部分通知,也会发布一些成员自己分享的小工具。项目成员的意见可作为未来项目发展的可能方向,随着开发进度变化可能会有所改动,不代表未来一定会实装,正式定稿公告会发布于 Issue 中。
NextTrace 的频道由项目成员负责,会传递一部分通知,也会发布一些成员自己分享的小工具。项目成员的意见可作为未来项目发展的可能方向,随着开发进度变化可能会有所改动,不代表未来一定会实装,正式定稿公告会发布于 Issue 中。
目前项目重构中1.0 版本将进入维护期,提供长达 2 年的 LTS 支持,新版本将启用 PoW 验证,届时内部 API 会有大幅的调整,会导致参数的大量变动,请知悉。
### Automated Install
@@ -154,10 +173,6 @@ 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
# 禁用MPLS显示 使用 --disable-mpls / -e 参数 或 NEXTTRACE_DISABLEMPLS 环境变量
nexttrace --disable-mpls example.com
export NEXTTRACE_DISABLEMPLS=1
```
PS: 路由可视化的绘制模块由 [@tsosunchia](https://github.com/tsosunchia) 同学编写,具体代码可在 [tsosunchia/traceMap](https://github.com/tsosunchia/traceMap) 查看
@@ -335,7 +350,6 @@ Arguments:
-f --first Start from the first_ttl hop (instead from
1). Default: 1
-M --map Disable Print Trace Map
-e --disable-mpls Disable MPLS
-v --version Print version info and exit
-s --source Use source src_addr for outgoing packets
-D --dev Use the following Network Devices as the
@@ -406,8 +420,6 @@ 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)

View File

@@ -12,17 +12,17 @@ import (
"time"
"github.com/akamensky/argparse"
"github.com/nxtrace/NTrace-core/config"
fastTrace "github.com/nxtrace/NTrace-core/fast_trace"
"github.com/nxtrace/NTrace-core/ipgeo"
"github.com/nxtrace/NTrace-core/printer"
"github.com/nxtrace/NTrace-core/reporter"
"github.com/nxtrace/NTrace-core/trace"
"github.com/nxtrace/NTrace-core/tracelog"
"github.com/nxtrace/NTrace-core/tracemap"
"github.com/nxtrace/NTrace-core/util"
"github.com/nxtrace/NTrace-core/wshandle"
"github.com/syndtr/gocapability/capability"
"github.com/xgadget-lab/nexttrace/config"
fastTrace "github.com/xgadget-lab/nexttrace/fast_trace"
"github.com/xgadget-lab/nexttrace/ipgeo"
"github.com/xgadget-lab/nexttrace/printer"
"github.com/xgadget-lab/nexttrace/reporter"
"github.com/xgadget-lab/nexttrace/trace"
"github.com/xgadget-lab/nexttrace/tracelog"
"github.com/xgadget-lab/nexttrace/tracemap"
"github.com/xgadget-lab/nexttrace/util"
"github.com/xgadget-lab/nexttrace/wshandle"
)
func Excute() {
@@ -55,7 +55,6 @@ func Excute() {
classicPrint := parser.Flag("c", "classic", &argparse.Options{Help: "Classic Output trace results like BestTrace"})
beginHop := parser.Int("f", "first", &argparse.Options{Default: 1, Help: "Start from the first_ttl hop (instead from 1)"})
disableMaptrace := parser.Flag("M", "map", &argparse.Options{Help: "Disable Print Trace Map"})
disableMPLS := parser.Flag("e", "disable-mpls", &argparse.Options{Help: "Disable MPLS"})
ver := parser.Flag("v", "version", &argparse.Options{Help: "Print version info and exit"})
srcAddr := parser.String("s", "source", &argparse.Options{Help: "Use source src_addr for outgoing packets"})
srcDev := parser.String("D", "dev", &argparse.Options{Help: "Use the following Network Devices as the source address in outgoing packets"})
@@ -287,10 +286,6 @@ func Excute() {
}
}
if *disableMPLS {
util.DisableMPLS = "1"
}
res, err := trace.Traceroute(m, conf)
if err != nil {

View File

@@ -2,12 +2,12 @@ package fastTrace
import (
"fmt"
"github.com/nxtrace/NTrace-core/ipgeo"
"github.com/nxtrace/NTrace-core/printer"
"github.com/nxtrace/NTrace-core/trace"
"github.com/nxtrace/NTrace-core/tracelog"
"github.com/nxtrace/NTrace-core/util"
"github.com/nxtrace/NTrace-core/wshandle"
"github.com/xgadget-lab/nexttrace/ipgeo"
"github.com/xgadget-lab/nexttrace/printer"
"github.com/xgadget-lab/nexttrace/trace"
"github.com/xgadget-lab/nexttrace/tracelog"
"github.com/xgadget-lab/nexttrace/util"
"github.com/xgadget-lab/nexttrace/wshandle"
"log"
"os"
"os/signal"
@@ -103,20 +103,13 @@ func (f *FastTracer) testEDU_v6() {
f.tracert_v6(TestIPsCollection.Hangzhou.Location, TestIPsCollection.Hangzhou.EDU)
}
func (f *FastTracer) testFast_v6() {
f.tracert_v6(TestIPsCollection.Beijing.Location, TestIPsCollection.Beijing.CT163)
f.tracert_v6(TestIPsCollection.Beijing.Location, TestIPsCollection.Beijing.CU169)
f.tracert_v6(TestIPsCollection.Beijing.Location, TestIPsCollection.Beijing.CM)
f.tracert_v6(TestIPsCollection.Beijing.Location, TestIPsCollection.Beijing.EDU)
}
func FastTestv6(tm bool, outEnable bool, paramsFastTrace ParamsFastTrace) {
var c string
oe = outEnable
pFastTracer = paramsFastTrace
fmt.Println("您想测试哪些ISP的路由\n1. 国内四网\n2. 电信\n3. 联通\n4. 移动\n5. 教育网\n6. 全部")
fmt.Println("您想测试哪些ISP的路由\n1. 国内四网\n2. 电信\n3. 联通\n4. 移动\n5. 教育网")
fmt.Print("请选择选项:")
_, err := fmt.Scanln(&c)
if err != nil {
@@ -142,7 +135,7 @@ func FastTestv6(tm bool, outEnable bool, paramsFastTrace ParamsFastTrace) {
switch c {
case "1":
ft.testFast_v6()
ft.testAll_v6()
case "2":
ft.testCT_v6()
case "3":
@@ -151,9 +144,7 @@ func FastTestv6(tm bool, outEnable bool, paramsFastTrace ParamsFastTrace) {
ft.testCM_v6()
case "5":
ft.testEDU_v6()
case "6":
ft.testAll_v6()
default:
ft.testFast_v6()
ft.testAll_v6()
}
}

View File

@@ -2,12 +2,12 @@ package fastTrace
import (
"fmt"
"github.com/nxtrace/NTrace-core/ipgeo"
"github.com/nxtrace/NTrace-core/printer"
"github.com/nxtrace/NTrace-core/trace"
"github.com/nxtrace/NTrace-core/tracelog"
"github.com/nxtrace/NTrace-core/util"
"github.com/nxtrace/NTrace-core/wshandle"
"github.com/xgadget-lab/nexttrace/ipgeo"
"github.com/xgadget-lab/nexttrace/printer"
"github.com/xgadget-lab/nexttrace/trace"
"github.com/xgadget-lab/nexttrace/tracelog"
"github.com/xgadget-lab/nexttrace/util"
"github.com/xgadget-lab/nexttrace/wshandle"
"log"
"net"
"os"
@@ -112,7 +112,7 @@ func FastTest(tm bool, outEnable bool, paramsFastTrace ParamsFastTrace) {
}
}
fmt.Println("您想测试哪些ISP的路由\n1. 国内四网\n2. 电信\n3. 联通\n4. 移动\n5. 教育网\n6. 全部")
fmt.Println("您想测试哪些ISP的路由\n1. 国内四网\n2. 电信\n3. 联通\n4. 移动\n5. 教育网")
fmt.Print("请选择选项:")
_, err = fmt.Scanln(&c)
if err != nil {
@@ -140,7 +140,7 @@ func FastTest(tm bool, outEnable bool, paramsFastTrace ParamsFastTrace) {
switch c {
case "1":
ft.testFast()
ft.testAll()
case "2":
ft.testCT()
case "3":
@@ -149,10 +149,8 @@ func FastTest(tm bool, outEnable bool, paramsFastTrace ParamsFastTrace) {
ft.testCM()
case "5":
ft.testEDU()
case "6":
ft.testAll()
default:
ft.testFast()
ft.testAll()
}
}
@@ -199,10 +197,3 @@ func (f *FastTracer) testEDU() {
// 科技网暂时算在EDU里面等拿到了足够多的数据再分离出去单独用于测试
f.tracert(TestIPsCollection.Hefei.Location, TestIPsCollection.Hefei.CST)
}
func (f *FastTracer) testFast() {
f.tracert(TestIPsCollection.Beijing.Location, TestIPsCollection.Beijing.CT163)
f.tracert(TestIPsCollection.Beijing.Location, TestIPsCollection.Beijing.CU169)
f.tracert(TestIPsCollection.Beijing.Location, TestIPsCollection.Beijing.CM)
f.tracert(TestIPsCollection.Beijing.Location, TestIPsCollection.Beijing.EDU)
}

View File

@@ -6,8 +6,8 @@ import (
"os/signal"
"testing"
"github.com/nxtrace/NTrace-core/trace"
"github.com/nxtrace/NTrace-core/wshandle"
"github.com/xgadget-lab/nexttrace/trace"
"github.com/xgadget-lab/nexttrace/wshandle"
)
func TestTrace(t *testing.T) {

14
go.mod
View File

@@ -1,6 +1,6 @@
module github.com/nxtrace/NTrace-core
module github.com/xgadget-lab/nexttrace
go 1.21
go 1.20
require (
github.com/akamensky/argparse v1.4.0
@@ -10,7 +10,7 @@ require (
github.com/stretchr/testify v1.8.4
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635
github.com/tsosunchia/powclient v0.1.3
golang.org/x/net v0.15.0
golang.org/x/net v0.14.0
golang.org/x/sync v0.3.0
)
@@ -24,12 +24,12 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/afero v1.10.0 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/text v0.12.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
)
@@ -38,9 +38,9 @@ require (
github.com/gorilla/websocket v1.5.0
github.com/lionsoul2014/ip2region v2.11.2+incompatible
github.com/rodaine/table v1.1.0
github.com/tidwall/gjson v1.17.0
github.com/tidwall/gjson v1.16.0
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/sys v0.11.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

22
go.sum
View File

@@ -60,7 +60,6 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY=
github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
@@ -138,11 +137,9 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/lionsoul2014/ip2region v2.11.2+incompatible h1:+VRsGcrHz8ewXI/2UzTptJlACsxD/p4xCxuql4u2nKU=
github.com/lionsoul2014/ip2region v2.11.2+incompatible/go.mod h1:+ZBN7PBoh5gG6/y0ZQ85vJDBe21WnfbRrQQwTfliJJI=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
@@ -169,11 +166,8 @@ github.com/rodaine/table v1.1.0 h1:/fUlCSdjamMY8VifdQRIu3VWZXYLY7QHFkVorS8NTr4=
github.com/rodaine/table v1.1.0/go.mod h1:Qu3q5wi1jTQD6B6HsP6szie/S4w1QUQ8pq22pz9iL8g=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/spf13/afero v1.9.5 h1:stMpOSZFs//0Lv29HduCmli3GUfpFoF3Y1Q/aXj/wVM=
github.com/spf13/afero v1.9.5/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ=
github.com/spf13/afero v1.10.0 h1:EaGW2JJh15aKOejeuJ+wpFSHnbd7GE6Wvp3TsNhb6LY=
github.com/spf13/afero v1.10.0/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ=
github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA=
github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48=
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
@@ -198,8 +192,8 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 h1:kdXcSzyDtseVEc4yCz2qF8ZrQvIDBJLl4S1c3GCXmoI=
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM=
github.com/tidwall/gjson v1.17.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/gjson v1.16.0 h1:SyXa+dsSPpUlcwEDuKuEBJEz5vzTvOea+9rjyYodQFg=
github.com/tidwall/gjson v1.16.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
@@ -289,8 +283,8 @@ golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v
golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -350,8 +344,8 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -361,8 +355,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=

View File

@@ -2,7 +2,7 @@ package ipgeo
import (
"encoding/json"
"github.com/nxtrace/NTrace-core/util"
"github.com/xgadget-lab/nexttrace/util"
"io"
"log"
"net/http"

View File

@@ -4,7 +4,7 @@ import (
"strings"
"time"
"github.com/nxtrace/NTrace-core/dn42"
"github.com/xgadget-lab/nexttrace/dn42"
)
func LtdCodeToCountryOrAreaName(Code string) string {

View File

@@ -23,24 +23,14 @@ func downloadDataBase() error {
if err != nil {
return err
}
defer func(Body io.ReadCloser) {
err := Body.Close()
if err != nil {
panic(err)
}
}(resp.Body)
defer resp.Body.Close()
// Create the file
out, err := os.Create(ipDataBasePath)
if err != nil {
return err
}
defer func(out *os.File) {
err := out.Close()
if err != nil {
panic(err)
}
}(out)
defer out.Close()
// Write the body to file
_, err = io.Copy(out, resp.Body)

View File

@@ -2,7 +2,7 @@ package ipgeo
import (
"errors"
"github.com/nxtrace/NTrace-core/util"
"github.com/xgadget-lab/nexttrace/util"
"io"
"log"
"net/http"

View File

@@ -78,42 +78,6 @@ func Filter(ip string) (*IPGeoData, bool) {
asn = ""
whois = "RFC1112"
isFiltered = true
case cidrRangeContains("fe80::/10", ip):
asn = ""
whois = "RFC4291"
isFiltered = true
case cidrRangeContains("ff00::/8", ip):
asn = ""
whois = "RFC4291"
isFiltered = true
case cidrRangeContains("fec0::/10", ip):
asn = ""
whois = "RFC3879"
isFiltered = true
case cidrRangeContains("fe00::/9", ip):
asn = ""
whois = "RFC4291"
isFiltered = true
case cidrRangeContains("64:ff9b::/96", ip):
asn = ""
whois = "RFC6052"
isFiltered = true
case cidrRangeContains("0::/96", ip):
asn = ""
whois = "RFC4291"
isFiltered = true
case cidrRangeContains("64:ff9b:1::/48", ip):
asn = ""
whois = "RFC6052"
isFiltered = true
case cidrRangeContains("2001:db8::/32", ip):
asn = ""
whois = "RFC3849"
isFiltered = true
case cidrRangeContains("2002::/16", ip):
asn = ""
whois = "RFC3056"
isFiltered = true
case net.ParseIP(ip).IsPrivate():
//rfc4193
if cidrRangeContains("fc00::/7", ip) {
@@ -157,12 +121,6 @@ func Filter(ip string) (*IPGeoData, bool) {
isFiltered = true
default:
}
// 判断是否为v6 且不在2000::/3
if net.ParseIP(ip).To4() == nil && !cidrRangeContains("2000::/3", ip) {
asn = ""
whois = "INVALID"
isFiltered = true
}
if !isFiltered {
return nil, false
} else {

View File

@@ -37,13 +37,6 @@ func TestXxx(t *testing.T) {
log.Println(process_id, ttl_r)
}
func TestFilter(t *testing.T) {
res, err := Filter("::1")
//打印whois信息
fmt.Println(res.Whois)
print(err)
}
func reverseID(id string) (int64, int64, error) {
ttl, _ := strconv.ParseInt(id[9:15], 2, 32)
//process ID

View File

@@ -1,7 +1,7 @@
package ipgeo
import (
"github.com/nxtrace/NTrace-core/util"
"github.com/xgadget-lab/nexttrace/util"
"io"
"net/http"
"strconv"

View File

@@ -7,8 +7,8 @@ import (
"sync"
"time"
"github.com/nxtrace/NTrace-core/wshandle"
"github.com/tidwall/gjson"
"github.com/xgadget-lab/nexttrace/wshandle"
)
/***

View File

@@ -1,6 +1,6 @@
package ipgeo
import "github.com/nxtrace/NTrace-core/util"
import "github.com/xgadget-lab/nexttrace/util"
type tokenData struct {
ipinsight string

View File

@@ -1,7 +1,7 @@
package main
import (
"github.com/nxtrace/NTrace-core/cmd"
"github.com/xgadget-lab/nexttrace/cmd"
)
func main() {

View File

@@ -2,8 +2,8 @@ package pow
import (
"fmt"
"github.com/nxtrace/NTrace-core/util"
"github.com/tsosunchia/powclient"
"github.com/xgadget-lab/nexttrace/util"
"net/url"
"os"
)

View File

@@ -2,8 +2,8 @@ package printer
import (
"fmt"
"github.com/nxtrace/NTrace-core/config"
"github.com/nxtrace/NTrace-core/trace"
"github.com/xgadget-lab/nexttrace/config"
"github.com/xgadget-lab/nexttrace/trace"
"net"
"github.com/fatih/color"
@@ -108,5 +108,4 @@ func applyLangSetting(h *trace.Hop) {
}
}
}
}

View File

@@ -4,7 +4,7 @@ import (
"fmt"
"strings"
"github.com/nxtrace/NTrace-core/trace"
"github.com/xgadget-lab/nexttrace/trace"
)
type HopInfo int

View File

@@ -3,7 +3,7 @@ package printer
import (
"fmt"
"github.com/nxtrace/NTrace-core/trace"
"github.com/xgadget-lab/nexttrace/trace"
)
func EasyPrinter(res *trace.Result, ttl int) {

View File

@@ -4,9 +4,9 @@ import (
"fmt"
"strings"
"github.com/nxtrace/NTrace-core/trace"
"github.com/xgadget-lab/nexttrace/trace"
"github.com/nxtrace/NTrace-core/ipgeo"
"github.com/xgadget-lab/nexttrace/ipgeo"
)
// var dataOrigin string
@@ -47,9 +47,6 @@ func HopPrinter(h trace.Hop, info HopInfo) {
if h.Geo != nil {
txt += " " + formatIpGeoData(h.Address.String(), h.Geo)
}
for _, v := range h.MPLS {
txt += " " + v
}
switch info {
case IXP:
fmt.Print(CYAN_PREFIX)

View File

@@ -7,7 +7,7 @@ import (
"strings"
"github.com/fatih/color"
"github.com/nxtrace/NTrace-core/trace"
"github.com/xgadget-lab/nexttrace/trace"
)
func RealtimePrinter(res *trace.Result, ttl int) {
@@ -166,11 +166,6 @@ func RealtimePrinter(res *trace.Result, ttl int) {
)
}
}
for _, v := range res.Hops[ttl][i].MPLS {
fmt.Fprintf(color.Output, "%s",
color.New(color.FgHiBlack, color.Bold).Sprintf("\n %s", v),
)
}
fmt.Println()
blockDisplay = true
}

View File

@@ -7,7 +7,7 @@ import (
"strings"
"github.com/fatih/color"
"github.com/nxtrace/NTrace-core/trace"
"github.com/xgadget-lab/nexttrace/trace"
)
func RealtimePrinterWithRouter(res *trace.Result, ttl int) {

View File

@@ -4,9 +4,9 @@ import (
"fmt"
"strings"
"github.com/nxtrace/NTrace-core/ipgeo"
"github.com/xgadget-lab/nexttrace/ipgeo"
"github.com/nxtrace/NTrace-core/trace"
"github.com/xgadget-lab/nexttrace/trace"
"github.com/fatih/color"
"github.com/rodaine/table"

View File

@@ -6,8 +6,8 @@ import (
"strings"
"sync"
"github.com/nxtrace/NTrace-core/ipgeo"
"github.com/nxtrace/NTrace-core/trace"
"github.com/xgadget-lab/nexttrace/ipgeo"
"github.com/xgadget-lab/nexttrace/trace"
)
type Reporter interface {

View File

@@ -5,8 +5,8 @@ import (
"testing"
"time"
"github.com/nxtrace/NTrace-core/ipgeo"
"github.com/nxtrace/NTrace-core/trace"
"github.com/xgadget-lab/nexttrace/ipgeo"
"github.com/xgadget-lab/nexttrace/trace"
)
var testResult = &trace.Result{

View File

@@ -30,8 +30,6 @@ type ICMPTracer struct {
fetchLock sync.Mutex
}
var psize = 52
func (t *ICMPTracer) PrintFunc() {
defer t.wg.Done()
var ttl = t.Config.BeginHop - 1
@@ -120,7 +118,6 @@ func (t *ICMPTracer) Execute() (*Result, error) {
func (t *ICMPTracer) listenICMP() {
lc := NewPacketListener(t.icmpListen, t.ctx)
psize = t.Config.PktSize
go lc.Start()
for {
select {
@@ -178,13 +175,10 @@ func (t *ICMPTracer) listenICMP() {
func (t *ICMPTracer) handleICMPMessage(msg ReceivedMessage, icmpType int8, data []byte, ttl int) {
t.inflightRequestRWLock.RLock()
defer t.inflightRequestRWLock.RUnlock()
mpls := extractMPLS(msg, data)
if _, ok := t.inflightRequest[ttl]; ok {
t.inflightRequest[ttl] <- Hop{
Success: true,
Address: msg.Peer,
MPLS: mpls,
}
}
}
@@ -207,7 +201,7 @@ func gernerateID(ttl_int int) int {
id += "0"
}
res, _ := strconv.ParseInt(id, 2, 32)
res, _ := strconv.ParseInt(id, 2, 64)
return int(res)
}
@@ -262,7 +256,7 @@ func (t *ICMPTracer) send(ttl int) error {
Body: &icmp.Echo{
ID: id,
//Data: []byte("HELLO-R-U-THERE"),
Data: append(bytes.Repeat([]byte{1}, t.Config.PktSize-4), 0x00, 0x00, 0x4f, 0xff),
Data: bytes.Repeat([]byte{1}, t.Config.PktSize),
Seq: ttl,
},
}

View File

@@ -137,7 +137,6 @@ func (t *ICMPTracerv6) Execute() (*Result, error) {
func (t *ICMPTracerv6) listenICMP() {
lc := NewPacketListener(t.icmpListen, t.ctx)
psize = t.Config.PktSize
go lc.Start()
for {
select {
@@ -234,13 +233,10 @@ func (t *ICMPTracerv6) listenICMP() {
func (t *ICMPTracerv6) handleICMPMessage(msg ReceivedMessage, icmpType int8, data []byte, ttl int) {
t.inflightRequestRWLock.RLock()
defer t.inflightRequestRWLock.RUnlock()
mpls := extractMPLS(msg, data)
if _, ok := t.inflightRequest[ttl]; ok {
t.inflightRequest[ttl] <- Hop{
Success: true,
Address: msg.Peer,
MPLS: mpls,
}
}
}
@@ -257,7 +253,7 @@ func (t *ICMPTracerv6) send(ttl int) error {
Body: &icmp.Echo{
ID: id,
//Data: []byte("HELLO-R-U-THERE"),
Data: append(bytes.Repeat([]byte{1}, t.Config.PktSize-4), 0x00, 0x00, 0x4f, 0xff),
Data: bytes.Repeat([]byte{1}, t.Config.PktSize),
Seq: ttl,
},
}

View File

@@ -28,7 +28,7 @@ var (
}
)
// ListenICMP 会造成指定出口IP功能不可使用
// 会造成指定出口IP功能不可使用
func ListenICMP(network string, laddr string) (net.PacketConn, error) {
if os.Getuid() == 0 { // root
return net.ListenPacket(network, laddr)

View File

@@ -10,7 +10,7 @@ import (
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
"github.com/nxtrace/NTrace-core/util"
"github.com/xgadget-lab/nexttrace/util"
"golang.org/x/net/context"
"golang.org/x/net/icmp"
"golang.org/x/net/ipv4"

View File

@@ -10,7 +10,7 @@ import (
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
"github.com/nxtrace/NTrace-core/util"
"github.com/xgadget-lab/nexttrace/util"
"golang.org/x/net/context"
"golang.org/x/net/icmp"
"golang.org/x/net/ipv6"

View File

@@ -4,7 +4,7 @@ import (
"fmt"
"strings"
"github.com/nxtrace/NTrace-core/ipgeo"
"github.com/xgadget-lab/nexttrace/ipgeo"
)
func HopPrinter(h Hop) {

View File

@@ -2,15 +2,12 @@ package trace
import (
"errors"
"fmt"
"net"
"strconv"
"strings"
"sync"
"time"
"github.com/nxtrace/NTrace-core/ipgeo"
"github.com/nxtrace/NTrace-core/util"
"github.com/xgadget-lab/nexttrace/ipgeo"
"github.com/xgadget-lab/nexttrace/util"
)
var (
@@ -127,7 +124,6 @@ type Hop struct {
Error error
Geo *ipgeo.IPGeoData
Lang string
MPLS []string
}
func (h *Hop) fetchIPData(c Config) (err error) {
@@ -229,108 +225,3 @@ func (h *Hop) fetchIPData(c Config) (err error) {
return
}
func extractMPLS(msg ReceivedMessage, data []byte) []string {
if util.DisableMPLS != "" {
return nil
}
if psize != 52 {
return nil
}
extensionOffset := 20 + 8 + psize
if len(data) <= extensionOffset {
return nil
}
extensionBody := data[extensionOffset:]
if len(extensionBody) < 8 || len(extensionBody)%8 != 0 {
return nil
}
tmp := fmt.Sprintf("%x", msg.Msg[:*msg.N])
index := strings.Index(tmp, strings.Repeat("01", psize-4)+"00004fff")
if index == -1 {
return nil
}
tmp = tmp[index+psize*2:]
//由于限制长度了
index1 := strings.Index(tmp, "00002000")
l := len(tmp[index1+4:])/8 - 2
//fmt.Printf("l:%d\n", l)
if l < 1 {
return nil
}
//去掉扩展头和MPLS头
tmp = tmp[index1+4+8*2:]
//fmt.Print(tmp)
var retStrList []string
for i := 0; i < l; i++ {
label, err := strconv.ParseInt(tmp[i*8+0:i*8+5], 16, 32)
if err != nil {
return nil
}
strSlice := fmt.Sprintf("%s", []byte(tmp[i*8+5:i*8+6]))
//fmt.Printf("\nstrSlice: %s\n", strSlice)
num, err := strconv.ParseUint(strSlice, 16, 64)
if err != nil {
return nil
}
binaryStr := fmt.Sprintf("%04s", strconv.FormatUint(num, 2))
//fmt.Printf("\nbinaryStr: %s\n", binaryStr)
tc, err := strconv.ParseInt(binaryStr[:3], 2, 32)
if err != nil {
return nil
}
s := binaryStr[3:]
ttlMpls, err := strconv.ParseInt(tmp[i*8+6:i*8+8], 16, 32)
if err != nil {
return nil
}
//if i > 0 {
// retStr += "\n "
//}
retStrList = append(retStrList, fmt.Sprintf("[MPLS: Lbl %d, TC %d, S %s, TTL %d]", label, tc, s, ttlMpls))
}
//label, err := strconv.ParseInt(tmp[len(tmp)-8:len(tmp)-3], 16, 32)
//if err != nil {
// return ""
//}
//
//strSlice := fmt.Sprintf("%s", []byte(tmp[len(tmp)-3:len(tmp)-2]))
////fmt.Printf("\nstrSlice: %s\n", strSlice)
//
//num, err := strconv.ParseUint(strSlice, 16, 64)
//if err != nil {
// return ""
//}
//binaryStr := fmt.Sprintf("%04s", strconv.FormatUint(num, 2))
//
////fmt.Printf("\nbinaryStr: %s\n", binaryStr)
//tc, err := strconv.ParseInt(binaryStr[:3], 2, 32)
//if err != nil {
// return ""
//}
//s := binaryStr[3:]
//
//ttlMpls, err := strconv.ParseInt(tmp[len(tmp)-2:], 16, 32)
//if err != nil {
// return ""
//}
//
//retStr := fmt.Sprintf("Lbl %d, TC %d, S %s, TTL %d", label, tc, s, ttlMpls)
return retStrList
}

View File

@@ -8,7 +8,7 @@ import (
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
"github.com/nxtrace/NTrace-core/util"
"github.com/xgadget-lab/nexttrace/util"
"golang.org/x/net/context"
"golang.org/x/net/icmp"
"golang.org/x/net/ipv4"

View File

@@ -9,7 +9,7 @@ import (
"strconv"
"strings"
"github.com/nxtrace/NTrace-core/trace"
"github.com/xgadget-lab/nexttrace/trace"
)
func RealtimePrinter(res *trace.Result, ttl int) {

View File

@@ -5,7 +5,7 @@ import (
"errors"
"fmt"
"github.com/fatih/color"
"github.com/nxtrace/NTrace-core/util"
"github.com/xgadget-lab/nexttrace/util"
"io"
"net"
"net/http"
@@ -66,7 +66,7 @@ func GetMapUrl(r string) (string, error) {
func PrintMapUrl(r string) {
_, err := fmt.Fprintf(color.Output, "%s %s\n",
color.New(color.FgWhite, color.Bold).Sprintf("%s", "MapTrace URL:"),
color.New(color.FgBlue, color.Bold).Sprintf("%s", r),
color.New(color.FgBlue, color.Bold).Sprintf("%s", string(r)),
)
if err != nil {
return

View File

@@ -3,7 +3,7 @@ package util
import (
"context"
"fmt"
"github.com/nxtrace/NTrace-core/config"
"github.com/xgadget-lab/nexttrace/config"
"log"
"net"
"net/url"
@@ -20,7 +20,6 @@ var EnvToken = GetenvDefault("NEXTTRACE_TOKEN", "")
var UserAgent = fmt.Sprintf("NextTrace %s/%s/%s", config.Version, runtime.GOOS, runtime.GOARCH)
var RdnsCache sync.Map
var PowProviderParam = ""
var DisableMPLS = GetenvDefault("NEXTTRACE_DISABLEMPLS", "")
func LookupAddr(addr string) ([]string, error) {
// 如果在缓存中找到,直接返回

View File

@@ -2,8 +2,8 @@ package wshandle
import (
"crypto/tls"
"github.com/nxtrace/NTrace-core/pow"
"github.com/nxtrace/NTrace-core/util"
"github.com/xgadget-lab/nexttrace/pow"
"github.com/xgadget-lab/nexttrace/util"
"log"
"net"
"net/http"