Compare commits

...

5 Commits

Author SHA1 Message Date
github-actions
d58a45dc56 Update README.md with new tag v0.0.5-20250411152044
Some checks failed
创建IPv6检测的前缀 / fetch-ipv6-prefixes (push) Has been cancelled
2025-04-11 15:20:45 +00:00
spiritlhl
3995e1a1bd
fix: 修复说明的tag自动修改 2025-04-11 23:19:39 +08:00
spiritlhl
a2a95e0444 fix: 修改说明,目前已支持IPV6路由检测 2025-04-11 15:14:53 +00:00
spiritlhl
fa1da298d7 fix: 减少日志输出,避免挤占日志 2025-04-11 15:05:03 +00:00
spiritlhl
9c58bb35cd fix: 减少日志输出,避免挤占日志 2025-04-11 15:03:40 +00:00
4 changed files with 46 additions and 25 deletions

View File

@ -7,25 +7,45 @@ jobs:
test:
strategy:
matrix:
go: [ '1.22.x' ]
os: [ ubuntu-latest ]
go: ['1.22.x']
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Test
run: go test ./... -coverprofile=coverage.txt
- name: Create Tag
if: success() # 仅在测试成功时运行
if: success()
run: |
git config --global user.name 'github-actions'
git config --global user.email 'github-actions@github.com'
TAG="v0.0.5-$(date +'%Y%m%d%H%M%S')"
git tag $TAG
git push origin $TAG
echo "TAG=$TAG" >> $GITHUB_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,18 +10,16 @@
## 功能
- [x] 检测回程显示IPV4地址时的线路(使用1500字节的包)不显示IP地址时显示ASN检测不到
- [x] 检测回程显示IPV4/IPV6地址时的线路(使用1500字节的包)不显示IP地址时显示ASN检测不到
- [x] 支持对```9929```、```4837```和```163```线路的判断
- [x] 支持对```CTGNET```、```CN2GIA```和```CN2GT```线路的判断
- [x] 支持对```CMIN2```和```CMI```线路的判断
- [x] 支持对整个回程路由进行线路分析一个目标IP可能会分析出多种线路
- [x] 增加对全平台的编译支持,原版[backtrace](https://github.com/zhanghanyun/backtrace)仅支持linux平台的amd64和arm64架构
- [x] 兼容额外的ICMP地址获取若当前目标IP无法查询路由尝试额外的IP地址
## TODO
- [ ] 增加IPV6路由能力检测
- [ ] 兼容额外的ICMP地址获取若当前目标IP无法查询路由尝试额外的IP地址
- [ ] 重复检测同一段路由,避免结果不可复现
- [ ] 自动检测汇聚层,裁剪结果不输出汇聚层后的线路(区分境内外段)
- [ ] 添加对主流ISP的POP点检测区分国际互联能力
@ -57,10 +55,13 @@ backtrace
```
Usage: backtrace [options]
-log Enable logging
-h Show help information
-s Disabe show ip info (default true)
-v Show version
-h Show help information
-ipv6
Enable ipv6 testing
-log
Enable logging
-s Disabe show ip info (default true)
-v Show version
```
## 卸载
@ -73,7 +74,7 @@ rm -rf /usr/bin/backtrace
## 在Golang中使用
```
go get github.com/oneclickvirt/backtrace@latest
go get github.com/oneclickvirt/backtrace@v0.0.5-20250411152044
```
## 概览图

View File

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

View File

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