From d92a791b6864901f9263f7d73d97cfd30ac53b09 Mon Sep 17 00:00:00 2001 From: David Fifield Date: Fri, 24 Dec 2021 07:37:24 -0700 Subject: [PATCH] Don't leave TLSPacketConn unclosed when there's a first Dial error. --- dnstt-client/tls.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dnstt-client/tls.go b/dnstt-client/tls.go index 8e85ef6..67434fe 100644 --- a/dnstt-client/tls.go +++ b/dnstt-client/tls.go @@ -37,9 +37,6 @@ type TLSPacketConn struct { // the resolver, reconnecting as necessary. It closes the connection if any // reconnection attempt fails. func NewTLSPacketConn(addr string) (*TLSPacketConn, error) { - c := &TLSPacketConn{ - QueuePacketConn: turbotunnel.NewQueuePacketConn(turbotunnel.DummyAddr{}, 0), - } // We maintain one TLS connection at a time, redialing it whenever it // becomes disconnected. We do the first dial here, outside the // goroutine, so that any immediate and permanent connection errors are @@ -52,6 +49,9 @@ func NewTLSPacketConn(addr string) (*TLSPacketConn, error) { if err != nil { return nil, err } + c := &TLSPacketConn{ + QueuePacketConn: turbotunnel.NewQueuePacketConn(turbotunnel.DummyAddr{}, 0), + } go func() { defer c.Close() for {