From 79ffb76f6e87fde36bee3e4bd43d7d5145ba3c67 Mon Sep 17 00:00:00 2001 From: Wim Date: Thu, 21 Jul 2016 23:47:44 +0200 Subject: Add (PLAIN) SASL support --- vendor/github.com/thoj/go-ircevent/irc.go | 20 ++++++++++++++++++++ vendor/github.com/thoj/go-ircevent/irc_struct.go | 24 ++++++++++++++---------- vendor/manifest | 4 ++-- 3 files changed, 36 insertions(+), 12 deletions(-) (limited to 'vendor') diff --git a/vendor/github.com/thoj/go-ircevent/irc.go b/vendor/github.com/thoj/go-ircevent/irc.go index 9043e888..0ba1d650 100644 --- a/vendor/github.com/thoj/go-ircevent/irc.go +++ b/vendor/github.com/thoj/go-ircevent/irc.go @@ -439,6 +439,25 @@ func (irc *Connection) Connect(server string) error { if len(irc.Password) > 0 { irc.pwrite <- fmt.Sprintf("PASS %s\r\n", irc.Password) } + + resChan := make(chan *SASLResult) + if irc.UseSASL { + irc.setupSASLCallbacks(resChan) + irc.pwrite <- fmt.Sprintf("CAP LS\r\n") + // request SASL + irc.pwrite <- fmt.Sprintf("CAP REQ :sasl\r\n") + // if sasl request doesn't complete in 15 seconds, close chan and timeout + select { + case res := <-resChan: + if res.Failed { + close(resChan) + return res.Err + } + case <-time.After(time.Second * 15): + close(resChan) + return errors.New("SASL setup timed out. This shouldn't happen.") + } + } irc.pwrite <- fmt.Sprintf("NICK %s\r\n", irc.nick) irc.pwrite <- fmt.Sprintf("USER %s 0.0.0.0 0.0.0.0 :%s\r\n", irc.user, irc.user) return nil @@ -466,6 +485,7 @@ func IRC(nick, user string) *Connection { KeepAlive: 4 * time.Minute, Timeout: 1 * time.Minute, PingFreq: 15 * time.Minute, + SASLMech: "PLAIN", QuitMessage: "", } irc.setupCallbacks() diff --git a/vendor/github.com/thoj/go-ircevent/irc_struct.go b/vendor/github.com/thoj/go-ircevent/irc_struct.go index 3e4a438f..33db846e 100644 --- a/vendor/github.com/thoj/go-ircevent/irc_struct.go +++ b/vendor/github.com/thoj/go-ircevent/irc_struct.go @@ -14,16 +14,20 @@ import ( type Connection struct { sync.WaitGroup - Debug bool - Error chan error - Password string - UseTLS bool - TLSConfig *tls.Config - Version string - Timeout time.Duration - PingFreq time.Duration - KeepAlive time.Duration - Server string + Debug bool + Error chan error + Password string + UseTLS bool + UseSASL bool + SASLLogin string + SASLPassword string + SASLMech string + TLSConfig *tls.Config + Version string + Timeout time.Duration + PingFreq time.Duration + KeepAlive time.Duration + Server string socket net.Conn pwrite chan string diff --git a/vendor/manifest b/vendor/manifest index 1961eb2a..11862129 100644 --- a/vendor/manifest +++ b/vendor/manifest @@ -113,8 +113,8 @@ { "importpath": "github.com/thoj/go-ircevent", "repository": "https://github.com/thoj/go-ircevent", - "vcs": "", - "revision": "da78ed515c0f0833e7a92c7cc52898176198e2c1", + "vcs": "git", + "revision": "98c1902dd2097f38142384167e60206ba26f1585", "branch": "master", "notests": true }, -- cgit v1.2.3