Fixes https://github.com/anacrolix/torrent/issues/314. Comments were added to the the conntrack package master, but have no functional change required here.
"dial torrent client",
0,
)
+ // Try to avoid committing to a dial if the context is complete as it's
+ // difficult to determine which dial errors allow us to forget the connection
+ // tracking entry handle.
if ctx.Err() != nil {
- cte.Forget()
+ if cte != nil {
+ cte.Forget()
+ }
resCh <- dialResult{}
return
}