diff options
author | Wim <wim@42.be> | 2016-07-21 23:47:44 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2016-07-21 23:47:44 +0200 |
commit | 79ffb76f6e87fde36bee3e4bd43d7d5145ba3c67 (patch) | |
tree | bc5f5c332b82fbea4fa5c7f6f5ca1e3658054ebb | |
parent | 5fe4b749cfb56ca5f499abaaba76e0292e1d04fa (diff) | |
download | matterbridge-msglm-79ffb76f6e87fde36bee3e4bd43d7d5145ba3c67.tar.gz matterbridge-msglm-79ffb76f6e87fde36bee3e4bd43d7d5145ba3c67.tar.bz2 matterbridge-msglm-79ffb76f6e87fde36bee3e4bd43d7d5145ba3c67.zip |
Add (PLAIN) SASL support
-rw-r--r-- | bridge/bridge.go | 3 | ||||
-rw-r--r-- | bridge/config.go | 1 | ||||
-rw-r--r-- | matterbridge.conf.sample | 6 | ||||
-rw-r--r-- | matterbridge.go | 2 | ||||
-rw-r--r-- | vendor/github.com/thoj/go-ircevent/irc.go | 20 | ||||
-rw-r--r-- | vendor/github.com/thoj/go-ircevent/irc_struct.go | 24 | ||||
-rw-r--r-- | vendor/manifest | 4 |
7 files changed, 47 insertions, 13 deletions
diff --git a/bridge/bridge.go b/bridge/bridge.go index 406e4687..034aed6f 100644 --- a/bridge/bridge.go +++ b/bridge/bridge.go @@ -108,6 +108,9 @@ func NewBridge(name string, config *Config, kind string) *Bridge { func (b *Bridge) createIRC(name string) *irc.Connection { i := irc.IRC(b.Config.IRC.Nick, b.Config.IRC.Nick) i.UseTLS = b.Config.IRC.UseTLS + i.UseSASL = b.Config.IRC.UseSASL + i.SASLLogin = b.Config.IRC.NickServNick + i.SASLPassword = b.Config.IRC.NickServPassword i.TLSConfig = &tls.Config{InsecureSkipVerify: b.Config.IRC.SkipTLSVerify} if b.Config.IRC.Password != "" { i.Password = b.Config.IRC.Password diff --git a/bridge/config.go b/bridge/config.go index 1daa04d8..3750a1a0 100644 --- a/bridge/config.go +++ b/bridge/config.go @@ -9,6 +9,7 @@ import ( type Config struct { IRC struct { UseTLS bool + UseSASL bool SkipTLSVerify bool Server string Nick string diff --git a/matterbridge.conf.sample b/matterbridge.conf.sample index 8af6fc97..55746539 100644 --- a/matterbridge.conf.sample +++ b/matterbridge.conf.sample @@ -11,6 +11,11 @@ Server="irc.freenode.net:6667" #OPTIONAL (default false) UseTLS=false +#Enable SASL (PLAIN) authentication. (freenode requires this from eg AWS hosts) +#It uses NickServNick and NickServPassword as login and password +#OPTIONAL (deefault false) +UseSASL=false + #Enable to not verify the certificate on your irc server. i #e.g. when using selfsigned certificates #OPTIONAL (default false) @@ -21,6 +26,7 @@ SkipTLSVerify=true Nick="matterbot" #If you registered your bot with a service like Nickserv on freenode. +#Also being used when UseSASL=true #OPTIONAL NickServNick="nickserv" NickServPassword="secret" diff --git a/matterbridge.go b/matterbridge.go index 29f28b00..4d2c4c06 100644 --- a/matterbridge.go +++ b/matterbridge.go @@ -7,7 +7,7 @@ import ( log "github.com/Sirupsen/logrus" ) -var version = "0.5.0-beta1" +var version = "0.5.0-beta2" func init() { log.SetFormatter(&log.TextFormatter{FullTimestamp: true}) 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 }, |