diff --git a/cmd/cmd.go b/cmd/cmd.go index 6496ed2b..b32c7322 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -34,7 +34,7 @@ func Excute() { "method (incremented by each probe, default is 33434), or initial seq for \"icmp\" (incremented as well, default from 1), or some constant" + "destination port for other methods (with default of 80 for \"tcp\", 53 for \"udp\", etc.)"}) numMeasurements := parser.Int("q", "queries", &argparse.Options{Default: 3, Help: "Set the number of probes per each hop"}) - parallelRequests := parser.Int("", "parallel-requests", &argparse.Options{Default: 18, Help: "Set ParallelRequests number. It should be 1 when there is a multi-routing."}) + parallelRequests := parser.Int("", "parallel-requests", &argparse.Options{Default: 18, Help: "Set ParallelRequests number. It should be 1 when there is a multi-routing"}) maxHops := parser.Int("m", "max-hops", &argparse.Options{Default: 30, Help: "Set the max number of hops (max TTL to be reached)"}) 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]"}) @@ -49,6 +49,8 @@ func Excute() { src_addr := parser.String("s", "source", &argparse.Options{Help: "Use source src_addr for outgoing packets"}) src_dev := parser.String("D", "dev", &argparse.Options{Help: "Use the following Network Devices as the source address in outgoing packets"}) router := parser.Flag("R", "route", &argparse.Options{Help: "Show Routing Table [Provided By BGP.Tools]"}) + packet_interval := parser.Int("z", "send-time", &argparse.Options{Default: 0, Help: "Set the time interval for sending every packet. Useful when some routers use rate-limit for ICMP messages."}) + ttl_interval := parser.Int("i", "ttl-time", &argparse.Options{Default: 500, Help: "Set the time interval for sending packets groups by TTL. Useful when some routers use rate-limit for ICMP messages."}) str := parser.StringPositional(&argparse.Options{Help: "IP Address or domain name"}) err := parser.Parse(os.Args) @@ -58,7 +60,7 @@ func Excute() { fmt.Print(parser.Usage(err)) return } - + printer.Version() if *ver { printer.CopyRight() os.Exit(0) @@ -66,6 +68,10 @@ func Excute() { domain := *str + if *port == 0 { + *port = 80 + } + if *fast_trace { fastTrace.FastTest(*tcp, *output) if *output { @@ -139,6 +145,8 @@ func Excute() { DestIP: ip, DestPort: *port, MaxHops: *maxHops, + PacketInterval: *packet_interval, + TTLInterval: *ttl_interval, NumMeasurements: *numMeasurements, ParallelRequests: *parallelRequests, RDns: !*noRdns, diff --git a/printer/realtime_printer.go b/printer/realtime_printer.go index 64497837..f0a1f98e 100644 --- a/printer/realtime_printer.go +++ b/printer/realtime_printer.go @@ -79,8 +79,7 @@ func RealtimePrinter(res *trace.Result, ttl int) { } fmt.Fprintf(color.Output, " %s", color.New(color.FgHiGreen, color.Bold).Sprintf("%-16s", whoisFormat[0])) } - - if res.Hops[ttl][i].Geo.Country == "" { + if len(res.Hops[ttl][i].Geo.Country) <= 1 { res.Hops[ttl][i].Geo.Country = "LAN Address" } diff --git a/trace/icmp_ipv4.go b/trace/icmp_ipv4.go index 8b683493..efccd06d 100644 --- a/trace/icmp_ipv4.go +++ b/trace/icmp_ipv4.go @@ -47,7 +47,7 @@ func (t *ICMPTracer) PrintFunc() { } } } - <-time.After(100 * time.Millisecond) + <-time.After(200 * time.Millisecond) } } @@ -84,8 +84,9 @@ func (t *ICMPTracer) Execute() (*Result, error) { for i := 0; i < t.NumMeasurements; i++ { t.wg.Add(1) go t.send(ttl) + <-time.After(time.Millisecond * time.Duration(t.Config.PacketInterval)) } - <-time.After(time.Millisecond * 100) + <-time.After(time.Millisecond * time.Duration(t.Config.TTLInterval)) } t.wg.Wait() diff --git a/trace/icmp_ipv6.go b/trace/icmp_ipv6.go index 3e0ee2ea..ebe1e2f0 100644 --- a/trace/icmp_ipv6.go +++ b/trace/icmp_ipv6.go @@ -48,7 +48,7 @@ func (t *ICMPTracerv6) PrintFunc() { } } - <-time.After(100 * time.Millisecond) + <-time.After(200 * time.Millisecond) } } @@ -85,8 +85,9 @@ func (t *ICMPTracerv6) Execute() (*Result, error) { for i := 0; i < t.NumMeasurements; i++ { t.wg.Add(1) go t.send(ttl) + <-time.After(time.Millisecond * time.Duration(t.Config.PacketInterval)) } - <-time.After(time.Millisecond * 100) + <-time.After(time.Millisecond * time.Duration(t.Config.TTLInterval)) } // for ttl := t.BeginHop; ttl <= t.MaxHops; ttl++ { // if t.final != -1 && ttl > t.final { diff --git a/trace/tcp_ipv4.go b/trace/tcp_ipv4.go index 709649a7..fdf1af88 100644 --- a/trace/tcp_ipv4.go +++ b/trace/tcp_ipv4.go @@ -90,7 +90,7 @@ func (t *TCPTracer) Execute() (*Result, error) { if t.AsyncPrinter != nil { for { t.AsyncPrinter(&t.res) - time.Sleep(50 * time.Millisecond) + time.Sleep(200 * time.Millisecond) } } diff --git a/trace/trace.go b/trace/trace.go index fa557dc7..05caf508 100644 --- a/trace/trace.go +++ b/trace/trace.go @@ -27,6 +27,8 @@ type Config struct { Quic bool IPGeoSource ipgeo.Source RDns bool + PacketInterval int + TTLInterval int RealtimePrinter func(res *Result, ttl int) AsyncPrinter func(res *Result) } diff --git a/trace/udp.go b/trace/udp.go index bd9454bc..7e1d5caf 100644 --- a/trace/udp.go +++ b/trace/udp.go @@ -73,7 +73,7 @@ func (t *UDPTracer) Execute() (*Result, error) { if t.AsyncPrinter != nil { for { t.AsyncPrinter(&t.res) - time.Sleep(50 * time.Millisecond) + time.Sleep(200 * time.Millisecond) } } }()