diff --git a/go.mod b/go.mod index b7c604b..e1f2f41 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,7 @@ module github.com/thoj/go-ircevent go 1.12 -require golang.org/x/text v0.3.2 +require ( + golang.org/x/net v0.0.0-20210614182718-04defd469f4e + golang.org/x/text v0.3.6 +) diff --git a/go.sum b/go.sum index 63c9200..2dc5506 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,10 @@ +golang.org/x/net v0.0.0-20210614182718-04defd469f4e h1:XpT3nA5TvE525Ne3hInMh6+GETgn27Zfm9dxsThnX2Q= +golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/irc.go b/irc.go index 03eb318..a02b2b7 100644 --- a/irc.go +++ b/irc.go @@ -31,6 +31,7 @@ import ( "strings" "time" + "golang.org/x/net/proxy" "golang.org/x/text/encoding" ) @@ -461,15 +462,14 @@ func (irc *Connection) Connect(server string) error { return errors.New("empty 'user'") } - if irc.UseTLS { - 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) - } + dialer := proxy.FromEnvironmentUsing(&net.Dialer{Timeout: irc.Timeout}) + irc.socket, err = dialer.Dial("tcp", irc.Server) if err != nil { return err } + if irc.UseTLS { + irc.socket = tls.Client(irc.socket, irc.TLSConfig) + } if irc.Encoding == nil { irc.Encoding = encoding.Nop