From 30608bd31c756a47254427d6c4c19ce05aec889f Mon Sep 17 00:00:00 2001 From: Wesley Dawson Date: Wed, 13 Aug 2014 18:35:37 -0700 Subject: [PATCH] Use tls.DialWithDialer instead of tls.Client and remove irc.netsock --- irc.go | 9 ++------- irc_struct.go | 7 +++---- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/irc.go b/irc.go index 306b061..59c5372 100644 --- a/irc.go +++ b/irc.go @@ -299,10 +299,6 @@ func (irc *Connection) Disconnect() { irc.Wait() irc.socket.Close() irc.socket = nil - if irc.netsock != nil { - irc.netsock.Close() - irc.netsock = nil - } irc.ErrorChan() <- ErrDisconnected } @@ -352,9 +348,8 @@ func (irc *Connection) Connect(server string) error { } if irc.UseTLS { - if irc.netsock, err = net.DialTimeout("tcp", irc.server, irc.Timeout); err == nil { - irc.socket = tls.Client(irc.netsock, irc.TLSConfig) - } + dialer := &net.Dialer{Timeout: irc.Timeout} + irc.socket, err = tls.DialWithDialer(dialer, "tcp", irc.server, irc.TLSConfig) } else { irc.socket, err = net.DialTimeout("tcp", irc.server, irc.Timeout) } diff --git a/irc_struct.go b/irc_struct.go index 1e582aa..161c6a2 100644 --- a/irc_struct.go +++ b/irc_struct.go @@ -24,10 +24,9 @@ type Connection struct { PingFreq time.Duration KeepAlive time.Duration - socket net.Conn - netsock net.Conn - pwrite chan string - end chan struct{} + socket net.Conn + pwrite chan string + end chan struct{} nick string //The nickname we want. nickcurrent string //The nickname we currently have.