Compare commits

..

No commits in common. "d58a45dc566f489d7095a23949566b4f63837d6a" and "b3be692d7e3c898cec46b2575ada8c2fb7f7fb18" have entirely different histories.

4 changed files with 25 additions and 46 deletions

View File

@ -7,45 +7,25 @@ jobs:
test: test:
strategy: strategy:
matrix: matrix:
go: ['1.22.x'] go: [ '1.22.x' ]
os: [ubuntu-latest] os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup Go - name: Setup Go
uses: actions/setup-go@v2 uses: actions/setup-go@v2
with: with:
go-version: ${{ matrix.go }} go-version: ${{ matrix.go }}
- name: Test - name: Test
run: go test ./... -coverprofile=coverage.txt run: go test ./... -coverprofile=coverage.txt
- name: Create Tag - name: Create Tag
if: success() if: success() # 仅在测试成功时运行
run: | run: |
git config --global user.name 'github-actions' git config --global user.name 'github-actions'
git config --global user.email 'github-actions@github.com' git config --global user.email 'github-actions@github.com'
TAG="v0.0.5-$(date +'%Y%m%d%H%M%S')" TAG="v0.0.5-$(date +'%Y%m%d%H%M%S')"
git tag $TAG git tag $TAG
git push origin $TAG git push origin $TAG
echo "TAG=$TAG" >> $GITHUB_ENV
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update README.md
if: success()
run: |
sed -i "s|go get github.com/oneclickvirt/backtrace@.*|go get github.com/oneclickvirt/backtrace@${TAG}|" README.md
env:
TAG: ${{ env.TAG }}
- name: Commit and Push README.md
if: success()
run: |
git add README.md
git commit -m "Update README.md with new tag ${TAG}"
git push origin main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -10,16 +10,18 @@
## 功能 ## 功能
- [x] 检测回程显示IPV4/IPV6地址时的线路(使用1500字节的包)不显示IP地址时显示ASN检测不到 - [x] 检测回程显示IPV4地址时的线路(使用1500字节的包)不显示IP地址时显示ASN检测不到
- [x] 支持对```9929```、```4837```和```163```线路的判断 - [x] 支持对```9929```、```4837```和```163```线路的判断
- [x] 支持对```CTGNET```、```CN2GIA```和```CN2GT```线路的判断 - [x] 支持对```CTGNET```、```CN2GIA```和```CN2GT```线路的判断
- [x] 支持对```CMIN2```和```CMI```线路的判断 - [x] 支持对```CMIN2```和```CMI```线路的判断
- [x] 支持对整个回程路由进行线路分析一个目标IP可能会分析出多种线路 - [x] 支持对整个回程路由进行线路分析一个目标IP可能会分析出多种线路
- [x] 增加对全平台的编译支持,原版[backtrace](https://github.com/zhanghanyun/backtrace)仅支持linux平台的amd64和arm64架构 - [x] 增加对全平台的编译支持,原版[backtrace](https://github.com/zhanghanyun/backtrace)仅支持linux平台的amd64和arm64架构
- [x] 兼容额外的ICMP地址获取若当前目标IP无法查询路由尝试额外的IP地址
## TODO ## TODO
- [ ] 增加IPV6路由能力检测
- [ ] 兼容额外的ICMP地址获取若当前目标IP无法查询路由尝试额外的IP地址
- [ ] 重复检测同一段路由,避免结果不可复现
- [ ] 自动检测汇聚层,裁剪结果不输出汇聚层后的线路(区分境内外段) - [ ] 自动检测汇聚层,裁剪结果不输出汇聚层后的线路(区分境内外段)
- [ ] 添加对主流ISP的POP点检测区分国际互联能力 - [ ] 添加对主流ISP的POP点检测区分国际互联能力
@ -55,13 +57,10 @@ backtrace
``` ```
Usage: backtrace [options] Usage: backtrace [options]
-h Show help information -log Enable logging
-ipv6 -h Show help information
Enable ipv6 testing -s Disabe show ip info (default true)
-log -v Show version
Enable logging
-s Disabe show ip info (default true)
-v Show version
``` ```
## 卸载 ## 卸载
@ -74,7 +73,7 @@ rm -rf /usr/bin/backtrace
## 在Golang中使用 ## 在Golang中使用
``` ```
go get github.com/oneclickvirt/backtrace@v0.0.5-20250411152044 go get github.com/oneclickvirt/backtrace@latest
``` ```
## 概览图 ## 概览图

View File

@ -330,9 +330,9 @@ func (t *Tracer) serveReply(dst net.IP, res *packet) error {
Logger.Warn(fmt.Sprintf("找不到目标IP=%v的会话", dst)) Logger.Warn(fmt.Sprintf("找不到目标IP=%v的会话", dst))
} }
for _, s := range a { for _, s := range a {
// if model.EnableLoger { if model.EnableLoger {
// Logger.Info(fmt.Sprintf("处理会话响应: 会话目标=%v", s.ip)) Logger.Info(fmt.Sprintf("处理会话响应: 会话目标=%v", s.ip))
// } }
s.handle(res) s.handle(res)
} }
return nil return nil
@ -419,9 +419,9 @@ func (s *Session) handle(res *packet) {
} }
// 对于IPv6 松散匹配 // 对于IPv6 松散匹配
if r.ID == res.ID || res.IP.To4() == nil { if r.ID == res.ID || res.IP.To4() == nil {
// if model.EnableLoger { if model.EnableLoger {
// Logger.Info(fmt.Sprintf("找到匹配的探测包: ID=%d, TTL=%d", r.ID, r.TTL)) Logger.Info(fmt.Sprintf("找到匹配的探测包: ID=%d, TTL=%d", r.ID, r.TTL))
// } }
req = r req = r
continue continue
} }
@ -431,9 +431,9 @@ func (s *Session) handle(res *packet) {
s.probes = s.probes[:n] s.probes = s.probes[:n]
s.mu.Unlock() s.mu.Unlock()
if req == nil { if req == nil {
// if model.EnableLoger { if model.EnableLoger {
// Logger.Warn(fmt.Sprintf("未找到匹配的探测包: 响应ID=%d", res.ID)) Logger.Warn(fmt.Sprintf("未找到匹配的探测包: 响应ID=%d", res.ID))
// } }
return return
} }
hops := req.TTL - res.TTL + 1 hops := req.TTL - res.TTL + 1
@ -450,6 +450,9 @@ func (s *Session) handle(res *packet) {
RTT: res.Time.Sub(req.Time), RTT: res.Time.Sub(req.Time),
Hops: hops, Hops: hops,
}: }:
if model.EnableLoger {
Logger.Info("响应已发送到通道")
}
default: default:
if model.EnableLoger { if model.EnableLoger {
Logger.Warn("发送响应到通道失败,通道已满") Logger.Warn("发送响应到通道失败,通道已满")

View File

@ -92,9 +92,6 @@ func tryAlternativeIPs(targetName string, ipVersion string) []string {
if model.ParsedIcmpTargets == nil || (model.ParsedIcmpTargets != nil && len(model.ParsedIcmpTargets) == 0) { if model.ParsedIcmpTargets == nil || (model.ParsedIcmpTargets != nil && len(model.ParsedIcmpTargets) == 0) {
return nil return nil
} }
if model.EnableLoger {
Logger.Info(fmt.Sprintf("使用备选地址: %s %s", targetName, ipVersion))
}
// 从目标名称中提取省份和ISP信息 // 从目标名称中提取省份和ISP信息
var targetProvince, targetISP string var targetProvince, targetISP string
if strings.Contains(targetName, "北京") { if strings.Contains(targetName, "北京") {