diff options
-rw-r--r-- | htping.go | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/htping.go b/htping.go index 9e13baa..b480237 100644 --- a/htping.go +++ b/htping.go @@ -87,6 +87,7 @@ var ntotal int32 var flag4 bool var flag6 bool +var network = "tcp" var quiet bool var myHeaders headers var method string @@ -150,16 +151,7 @@ func newTransport() *transport { ForceAttemptHTTP2: !http11, DialContext: func(ctx context.Context, _, addr string) (net.Conn, error) { - var network string - switch { - case flag4: - network = "tcp4" - case flag6: - network = "tcp6" - default: - network = "tcp" - } - return dialer.DialContext(ctx, network, addr) + return dialer.DialContext(ctx, network, addr) // force our network preference }, } @@ -334,6 +326,13 @@ func main() { os.Exit(2) } + switch { + case flag4: + network = "tcp4" + case flag6: + network = "tcp6" + } + ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt) defer stop() |