mirror of
https://github.com/oneclickvirt/backtrace.git
synced 2025-06-07 20:14:46 +08:00
Compare commits
5 Commits
b3be692d7e
...
d58a45dc56
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d58a45dc56 | ||
![]() |
3995e1a1bd | ||
![]() |
a2a95e0444 | ||
![]() |
fa1da298d7 | ||
![]() |
9c58bb35cd |
26
.github/workflows/ci.yaml
vendored
26
.github/workflows/ci.yaml
vendored
@ -7,25 +7,45 @@ 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:
|
||||||
|
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:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
13
README.md
13
README.md
@ -10,18 +10,16 @@
|
|||||||
|
|
||||||
## 功能
|
## 功能
|
||||||
|
|
||||||
- [x] 检测回程显示IPV4地址时的线路(使用1500字节的包),不显示IP地址时显示ASN检测不到
|
- [x] 检测回程显示IPV4/IPV6地址时的线路(使用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点检测,区分国际互联能力
|
||||||
|
|
||||||
@ -57,8 +55,11 @@ backtrace
|
|||||||
|
|
||||||
```
|
```
|
||||||
Usage: backtrace [options]
|
Usage: backtrace [options]
|
||||||
-log Enable logging
|
|
||||||
-h Show help information
|
-h Show help information
|
||||||
|
-ipv6
|
||||||
|
Enable ipv6 testing
|
||||||
|
-log
|
||||||
|
Enable logging
|
||||||
-s Disabe show ip info (default true)
|
-s Disabe show ip info (default true)
|
||||||
-v Show version
|
-v Show version
|
||||||
```
|
```
|
||||||
@ -73,7 +74,7 @@ rm -rf /usr/bin/backtrace
|
|||||||
## 在Golang中使用
|
## 在Golang中使用
|
||||||
|
|
||||||
```
|
```
|
||||||
go get github.com/oneclickvirt/backtrace@latest
|
go get github.com/oneclickvirt/backtrace@v0.0.5-20250411152044
|
||||||
```
|
```
|
||||||
|
|
||||||
## 概览图
|
## 概览图
|
||||||
|
@ -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,9 +450,6 @@ 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("发送响应到通道失败,通道已满")
|
||||||
|
@ -92,6 +92,9 @@ 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, "北京") {
|
||||||
|
Loading…
Reference in New Issue
Block a user