diff options
author | Shohi Wang <oshohi@gmail.com> | 2020-11-07 15:39:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-07 08:39:47 +0100 |
commit | c2542e5acf973cb1a2ab82d74dcb66f7afcb968b (patch) | |
tree | 05dd8257ab8eff3bf69d9c42cb5a51e97c9de5fa /tcpdialer.go | |
parent | Adding Power support(ppc64le) with continuous integration/testing to the proj... (diff) | |
download | fasthttp-c2542e5acf973cb1a2ab82d74dcb66f7afcb968b.tar.gz fasthttp-c2542e5acf973cb1a2ab82d74dcb66f7afcb968b.tar.bz2 fasthttp-c2542e5acf973cb1a2ab82d74dcb66f7afcb968b.zip |
add nil check for LocalAddr (#907)
Diffstat (limited to 'tcpdialer.go')
-rw-r--r-- | tcpdialer.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/tcpdialer.go b/tcpdialer.go index 8d6bbfb..0023cf6 100644 --- a/tcpdialer.go +++ b/tcpdialer.go @@ -327,7 +327,11 @@ func (d *TCPDialer) tryDial(network string, addr *net.TCPAddr, deadline time.Tim defer func() { <-concurrencyCh }() } - dialer := net.Dialer{LocalAddr: d.LocalAddr} + dialer := net.Dialer{} + if d.LocalAddr != nil { + dialer.LocalAddr = d.LocalAddr + } + ctx, cancel_ctx := context.WithDeadline(context.Background(), deadline) defer cancel_ctx() conn, err := dialer.DialContext(ctx, network, addr.String()) |