backtrace/README.md
spiritlhl 16e551b631
Some checks failed
CI / test (push) Waiting to run
Sync ASN metadata / sync (push) Has been cancelled
feat(dns): prepare backtrace v0.0.21
2026-08-26 15:37:44 +08:00

101 lines
3.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# backtrace
[![Hits](https://hits.spiritlhl.net/backtrace.svg?action=hit&title=Hits&title_bg=%23555555&count_bg=%230eecf8&edge_flat=false)](https://hits.spiritlhl.net) [![Downloads](https://ghdownload.spiritlhl.net/oneclickvirt/backtrace?color=01c674)](https://github.com/oneclickvirt/backtrace/releases)
[![Build and Release](https://github.com/oneclickvirt/backtrace/actions/workflows/main.yaml/badge.svg)](https://github.com/oneclickvirt/backtrace/actions/workflows/main.yaml)
三网回程路由线路测试
路由的线路判断最终还是得人工判断的才准确,本项目测试结果仅供参考
## 功能
- [x] 检测回程显示IPV4/IPV6地址时的线路(使用1500字节的包)不显示IP地址时显示ASN检测不到
- [x] 支持对```9929```、```4837```和```163```线路的判断
- [x] 支持对```CTGNET```、```CN2GIA```和```CN2GT```线路的判断
- [x] 支持对```CMIN2```和```CMI```线路的判断
- [x] 支持对整个回程路由进行线路分析一个目标IP可能会分析出多种线路
- [x] 支持对主流接入点的线路检测,方便分析国际互联能力
- [x] 多次并发路由检测以分析平均多次路由,避免单次路由因网络波动未能准确检测
- [x] 增加对全平台的编译支持,原版[backtrace](https://github.com/zhanghanyun/backtrace)仅支持linux平台的amd64和arm64架构
- [x] 兼容额外的ICMP地址获取若当前目标IP无法查询路由尝试额外的IP地址
- [x] 在线但本地 DNS 确认缺失时,在当前进程内使用经过固定地址 TLS 查询校验的最快 DoH/DoT 上游瞬时超时、SERVFAIL 或丢包不会切换系统解析
相关输出和查询结果的说明:[跳转](https://github.com/oneclickvirt/ecs/blob/master/README_NEW_USER.md#%E4%B8%8A%E6%B8%B8%E5%8F%8A%E5%9B%9E%E7%A8%8B%E7%BA%BF%E8%B7%AF%E6%A3%80%E6%B5%8B)
## 使用
下载、安装、更新
```shell
curl https://raw.githubusercontent.com/oneclickvirt/backtrace/main/backtrace_install.sh -sSf | bash
```
```
curl https://cdn.spiritlhl.net/https://raw.githubusercontent.com/oneclickvirt/backtrace/main/backtrace_install.sh -sSf | bash
```
使用
```
backtrace
```
```
./backtrace
```
进行测试
无环境依赖,理论上适配所有系统和主流架构,更多架构请查看 https://github.com/oneclickvirt/backtrace/releases
```
Usage: backtrace [options]
-h Show help information
-ip string
Specify IP address for bgptools
-ipv6
Enable ipv6 testing
-dns-mode string
DNS mode (auto, system, doh, or dot) (default "auto")
-log
Enable logging
-s Disabe show ip info (default true)
-v Show version
```
## 卸载
```
rm -rf /root/backtrace
rm -rf /usr/bin/backtrace
```
## 在Golang中使用
```
go get github.com/oneclickvirt/backtrace@v0.0.21
```
## DNS 解析回退
`-dns-mode=auto` 是默认值。它会先保留系统 DNS只有独立探测都确认本地解析器不可用时才在本次进程内启用内置加密 DNS并选择实测延迟最低的 DoH 或 DoT 上游。正常响应、NXDOMAIN、短暂超时、SERVFAIL 和丢包都不会被误判为 DNS 缺失。`system` 禁用回退,`doh` 和 `dot` 可显式强制相应协议;不会修改 `/etc/resolv.conf`、`/etc/hosts` 或其他系统配置。
## 概览图
![图片](https://github.com/oneclickvirt/backtrace/assets/103393591/4688f99f-0f02-486f-8ffc-78d30f2c2f95)
![图片](https://github.com/oneclickvirt/backtrace/assets/103393591/2812a47d-4e6b-4091-9bb9-596af6c3c8bc)
![图片](https://github.com/oneclickvirt/backtrace/assets/103393591/2e5cc625-e0da-41ff-85ff-9d21c01114a3)
## Thanks
部分代码基于 https://github.com/zhanghanyun/backtrace 的重构和优化,与原版存在很大不同
IPV4/IPV6可ICMP进行ping测试的 https://github.com/spiritLHLS/icmp_targets 收集仓库