diff --git a/.gitignore b/.gitignore index c00f18c..f35b924 100644 --- a/.gitignore +++ b/.gitignore @@ -163,3 +163,5 @@ Temporary Items # compile target directory dist/ + +NTrace-core diff --git a/cmd/cmd.go b/cmd/cmd.go index f7c9773..b50c570 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -133,6 +133,7 @@ func Excute() { } if strings.Contains(domain, "/") { + domain = "n" + domain parts := strings.Split(domain, "/") if len(parts) < 3 { fmt.Println("Invalid input") @@ -239,10 +240,6 @@ func Excute() { } } - if !*jsonPrint { - printer.PrintTraceRouteNav(ip, domain, *dataOrigin, *maxHops, *packetSize) - } - var m trace.Method switch { @@ -254,6 +251,10 @@ func Excute() { m = trace.ICMPTrace } + if !*jsonPrint { + printer.PrintTraceRouteNav(ip, domain, *dataOrigin, *maxHops, *packetSize, *srcAddr, string(m)) + } + if !*tcp && *port == 80 { *port = 33494 } diff --git a/fast_trace/fast_trace ipv6.go b/fast_trace/fast_trace ipv6.go index b3acebe..97dc60a 100644 --- a/fast_trace/fast_trace ipv6.go +++ b/fast_trace/fast_trace ipv6.go @@ -12,13 +12,14 @@ import ( "log" "os" "os/signal" + "strings" ) //var pFastTracer ParamsFastTrace func (f *FastTracer) tracert_v6(location string, ispCollection ISPCollection) { fmt.Fprintf(color.Output, "%s\n", color.New(color.FgYellow, color.Bold).Sprintf("『%s %s 』", location, ispCollection.ISPName)) - fmt.Printf("traceroute to %s, %d hops max, %d byte packets\n", ispCollection.IPv6, f.ParamsFastTrace.MaxHops, f.ParamsFastTrace.PktSize) + fmt.Printf("traceroute to %s, %d hops max, %d byte packets, %s mode\n", ispCollection.IPv6, f.ParamsFastTrace.MaxHops, f.ParamsFastTrace.PktSize, strings.ToUpper(string(f.TracerouteMethod))) // ip, err := util.DomainLookUp(ispCollection.IPv6, "6", "", true) ip, err := util.DomainLookUp(ispCollection.IPv6, "6", f.ParamsFastTrace.Dot, true) @@ -58,7 +59,7 @@ func (f *FastTracer) tracert_v6(location string, ispCollection ISPCollection) { log.SetOutput(fp) log.SetFlags(0) log.Printf("『%s %s 』\n", location, ispCollection.ISPName) - log.Printf("traceroute to %s, %d hops max, %d byte packets\n", ispCollection.IPv6, f.ParamsFastTrace.MaxHops, f.ParamsFastTrace.PktSize) + log.Printf("traceroute to %s, %d hops max, %d byte packets, %s mode\n", ispCollection.IPv6, f.ParamsFastTrace.MaxHops, f.ParamsFastTrace.PktSize, strings.ToUpper(string(f.TracerouteMethod))) conf.RealtimePrinter = tracelog.RealtimePrinter } else { conf.RealtimePrinter = printer.RealtimePrinter diff --git a/fast_trace/fast_trace.go b/fast_trace/fast_trace.go index eda5d6d..6c90e98 100644 --- a/fast_trace/fast_trace.go +++ b/fast_trace/fast_trace.go @@ -48,7 +48,7 @@ var oe = false func (f *FastTracer) tracert(location string, ispCollection ISPCollection) { fmt.Fprintf(color.Output, "%s\n", color.New(color.FgYellow, color.Bold).Sprintf("『%s %s 』", location, ispCollection.ISPName)) - fmt.Printf("traceroute to %s, %d hops max, %d byte packets\n", ispCollection.IP, f.ParamsFastTrace.MaxHops, f.ParamsFastTrace.PktSize) + fmt.Printf("traceroute to %s, %d hops max, %d byte packets, %s mode\n", ispCollection.IP, f.ParamsFastTrace.MaxHops, f.ParamsFastTrace.PktSize, strings.ToUpper(string(f.TracerouteMethod))) // ip, err := util.DomainLookUp(ispCollection.IP, "4", "", true) ip, err := util.DomainLookUp(ispCollection.IP, "4", f.ParamsFastTrace.Dot, true) @@ -89,7 +89,7 @@ func (f *FastTracer) tracert(location string, ispCollection ISPCollection) { log.SetOutput(fp) log.SetFlags(0) log.Printf("『%s %s 』\n", location, ispCollection.ISPName) - log.Printf("traceroute to %s, %d hops max, %d byte packets\n", ispCollection.IP, f.ParamsFastTrace.MaxHops, f.ParamsFastTrace.PktSize) + log.Printf("traceroute to %s, %d hops max, %d byte packets, %s mode\n", ispCollection.IP, f.ParamsFastTrace.MaxHops, f.ParamsFastTrace.PktSize, strings.ToUpper(string(f.TracerouteMethod))) conf.RealtimePrinter = tracelog.RealtimePrinter } else { conf.RealtimePrinter = printer.RealtimePrinter @@ -283,9 +283,9 @@ func testFile(paramsFastTrace ParamsFastTrace, tm bool) { color.New(color.FgYellow, color.Bold).Sprint("『 "+ip.Desc+"』"), ) if util.EnableHidDstIP == "" { - fmt.Printf("traceroute to %s, %d hops max, %d bytes payload\n", ip.Ip, paramsFastTrace.MaxHops, paramsFastTrace.PktSize) + fmt.Printf("traceroute to %s, %d hops max, %d bytes payload, %s mode\n", ip.Ip, paramsFastTrace.MaxHops, paramsFastTrace.PktSize, strings.ToUpper(string(tracerouteMethod))) } else { - fmt.Printf("traceroute to %s, %d hops max, %d bytes payload\n", util.HideIPPart(ip.Ip), paramsFastTrace.MaxHops, paramsFastTrace.PktSize) + fmt.Printf("traceroute to %s, %d hops max, %d bytes payload, %s mode\n", util.HideIPPart(ip.Ip), paramsFastTrace.MaxHops, paramsFastTrace.PktSize, strings.ToUpper(string(tracerouteMethod))) } var srcAddr string if ip.Version4 { @@ -354,7 +354,7 @@ func testFile(paramsFastTrace ParamsFastTrace, tm bool) { log.SetOutput(fp) log.SetFlags(0) log.Printf("『%s』\n", ip.Desc) - log.Printf("traceroute to %s, %d hops max, %d byte packets\n", ip.Ip, paramsFastTrace.MaxHops, paramsFastTrace.PktSize) + log.Printf("traceroute to %s, %d hops max, %d byte packets, %s mode\n", ip.Ip, paramsFastTrace.MaxHops, paramsFastTrace.PktSize, strings.ToUpper(string(tracerouteMethod))) conf.RealtimePrinter = tracelog.RealtimePrinter err = fp.Close() if err != nil { diff --git a/printer/basic.go b/printer/basic.go index ea0c195..a53da0f 100644 --- a/printer/basic.go +++ b/printer/basic.go @@ -6,6 +6,7 @@ import ( "github.com/nxtrace/NTrace-core/trace" "github.com/nxtrace/NTrace-core/util" "net" + "strings" "github.com/fatih/color" ) @@ -76,16 +77,21 @@ func sponsor() { // ) //} -func PrintTraceRouteNav(ip net.IP, domain string, dataOrigin string, maxHops int, packetSize int) { +func PrintTraceRouteNav(ip net.IP, domain string, dataOrigin string, maxHops int, packetSize int, srcAddr string, mode string) { fmt.Println("IP Geo Data Provider: " + dataOrigin) + if srcAddr == "" { + srcAddr = "traceroute to" + } else { + srcAddr += " ->" + } if util.EnableHidDstIP == "" { if ip.String() == domain { - fmt.Printf("traceroute to %s, %d hops max, %d bytes payload\n", ip.String(), maxHops, packetSize) + fmt.Printf("%s %s, %d hops max, %d bytes payload, %s mode\n", srcAddr, ip.String(), maxHops, packetSize, strings.ToUpper(mode)) } else { - fmt.Printf("traceroute to %s (%s), %d hops max, %d bytes payload\n", ip.String(), domain, maxHops, packetSize) + fmt.Printf("%s %s (%s), %d hops max, %d bytes payload, %s mode\n", srcAddr, ip.String(), domain, maxHops, packetSize, strings.ToUpper(mode)) } } else { - fmt.Printf("traceroute to %s, %d hops max, %d bytes payload\n", util.HideIPPart(ip.String()), maxHops, packetSize) + fmt.Printf("%s %s, %d hops max, %d bytes payload, %s mode\n", srcAddr, util.HideIPPart(ip.String()), maxHops, packetSize, strings.ToUpper(mode)) } }