From 1789448d6c995ec9cd747fb3b8295c40370a42cd Mon Sep 17 00:00:00 2001 From: sjlleo Date: Fri, 10 Jun 2022 21:20:43 +0800 Subject: [PATCH] =?UTF-8?q?add:=20=E6=96=B0=E5=A2=9E=E8=B5=B7=E5=A7=8BTTL?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fast_trace/fast_trace.go | 1 + main.go | 2 ++ trace/icmp_ipv4.go | 2 +- trace/icmp_ipv6.go | 2 +- trace/tcp_ipv4.go | 2 +- trace/trace.go | 1 + 6 files changed, 7 insertions(+), 3 deletions(-) diff --git a/fast_trace/fast_trace.go b/fast_trace/fast_trace.go index e82f0b1..a04f03f 100644 --- a/fast_trace/fast_trace.go +++ b/fast_trace/fast_trace.go @@ -20,6 +20,7 @@ func (f *FastTracer) tracert(location string, ispCollection ISPCollection) { fmt.Printf("traceroute to %s, 30 hops max, 32 byte packets\n", ispCollection.IP) ip := net.ParseIP(ispCollection.IP) var conf = trace.Config{ + BeginHop: 1, DestIP: ip, DestPort: 80, MaxHops: 30, diff --git a/main.go b/main.go index 45a989e..7cc0547 100644 --- a/main.go +++ b/main.go @@ -29,6 +29,7 @@ var dataOrigin = fSet.String("d", "LeoMoeAPI", "Choose IP Geograph Data Provider var noRdns = fSet.Bool("n", false, "Disable IP Reverse DNS lookup") var routePath = fSet.Bool("report", false, "Route Path") var tablePrint = fSet.Bool("table", false, "Output trace results as table") +var beginHop = fSet.Int("b", 1, "Set The Begin TTL") var ver = fSet.Bool("V", false, "Print Version") func printArgHelp() { @@ -105,6 +106,7 @@ func main() { } var conf = trace.Config{ + BeginHop: *beginHop, DestIP: ip, DestPort: *port, MaxHops: *maxHops, diff --git a/trace/icmp_ipv4.go b/trace/icmp_ipv4.go index 8ba96fd..4eaca37 100644 --- a/trace/icmp_ipv4.go +++ b/trace/icmp_ipv4.go @@ -45,7 +45,7 @@ func (t *ICMPTracer) Execute() (*Result, error) { go t.listenICMP() - for ttl := 1; ttl <= t.MaxHops; ttl++ { + for ttl := t.BeginHop; ttl <= t.MaxHops; ttl++ { if t.final != -1 && ttl > t.final { break } diff --git a/trace/icmp_ipv6.go b/trace/icmp_ipv6.go index d6849d4..ca3a65c 100644 --- a/trace/icmp_ipv6.go +++ b/trace/icmp_ipv6.go @@ -44,7 +44,7 @@ func (t *ICMPTracerv6) Execute() (*Result, error) { go t.listenICMP() - for ttl := 1; ttl <= t.MaxHops; ttl++ { + for ttl := t.BeginHop; ttl <= t.MaxHops; ttl++ { if t.final != -1 && ttl > t.final { break } diff --git a/trace/tcp_ipv4.go b/trace/tcp_ipv4.go index 53f98b6..b0b7130 100644 --- a/trace/tcp_ipv4.go +++ b/trace/tcp_ipv4.go @@ -63,7 +63,7 @@ func (t *TCPTracer) Execute() (*Result, error) { t.sem = semaphore.NewWeighted(int64(t.ParallelRequests)) - for ttl := 1; ttl <= t.MaxHops; ttl++ { + for ttl := t.BeginHop; ttl <= t.MaxHops; ttl++ { // 如果到达最终跳,则退出 if t.final != -1 && ttl > t.final { break diff --git a/trace/trace.go b/trace/trace.go index b54e394..4fcab44 100644 --- a/trace/trace.go +++ b/trace/trace.go @@ -16,6 +16,7 @@ var ( ) type Config struct { + BeginHop int MaxHops int NumMeasurements int ParallelRequests int