Skip to content

Commit

Permalink
feat: 添加 report 模式
Browse files Browse the repository at this point in the history
  • Loading branch information
sjlleo committed Jan 23, 2023
1 parent c682f90 commit 7619e74
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ func Excute() {
dataOrigin := parser.Selector("d", "data-provider", []string{"IP.SB", "IPInfo", "IPInsight", "IPAPI.com"}, &argparse.Options{Default: "LeoMoeAPI",
Help: "Choose IP Geograph Data Provider [LeoMoeAPI,IP.SB, IPInfo, IPInsight, IPAPI.com]"})
noRdns := parser.Flag("n", "no-rdns", &argparse.Options{Help: " Do not resolve IP addresses to their domain names"})
routePath := parser.Flag("r", "route-path", &argparse.Options{Help: "Print traceroute hop path by ASN and location"})
routePath := parser.Flag("P", "route-path", &argparse.Options{Help: "Print traceroute hop path by ASN and location"})
report := parser.Flag("r", "report", &argparse.Options{Help: "output using report mode"})
output := parser.Flag("o", "output", &argparse.Options{Help: "Write trace result to file (RealTimePrinter ONLY)"})
tablePrint := parser.Flag("t", "table", &argparse.Options{Help: "Output trace results as table"})
classicPrint := parser.Flag("c", "classic", &argparse.Options{Help: "Classic Output trace results like BestTrace"})
Expand Down Expand Up @@ -168,7 +169,9 @@ func Excute() {
}
}
} else {
conf.AsyncPrinter = printer.TracerouteTablePrinter
if !*report {
conf.AsyncPrinter = printer.TracerouteTablePrinter
}
}

res, err := trace.Traceroute(m, conf)
Expand Down
4 changes: 4 additions & 0 deletions printer/realtime_printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ func RealtimePrinter(res *trace.Result, ttl int) {
fallthrough
case res.Hops[ttl][i].Geo.Asnumber == "9929":
fallthrough
case res.Hops[ttl][i].Geo.Asnumber == "23764":
fallthrough
case strings.HasPrefix(res.Hops[ttl][i].Address.String(), "59.43."):
fmt.Fprintf(color.Output, " %s", color.New(color.FgHiYellow, color.Bold).Sprintf("AS%-6s", res.Hops[ttl][i].Geo.Asnumber))
default:
Expand Down Expand Up @@ -102,6 +104,8 @@ func RealtimePrinter(res *trace.Result, ttl int) {
fallthrough
case res.Hops[ttl][i].Geo.Asnumber == "9929":
fallthrough
case res.Hops[ttl][i].Geo.Asnumber == "23764":
fallthrough
case whoisFormat[0] == "[CNC-BACKBONE]":
fallthrough
case whoisFormat[0] == "[CUG-BACKBONE]":
Expand Down

0 comments on commit 7619e74

Please sign in to comment.