mirror of
https://github.com/cwinfo/matterbridge.git
synced 2024-11-28 23:01:34 +00:00
Add (PLAIN) SASL support
This commit is contained in:
parent
5fe4b749cf
commit
79ffb76f6e
@ -108,6 +108,9 @@ func NewBridge(name string, config *Config, kind string) *Bridge {
|
|||||||
func (b *Bridge) createIRC(name string) *irc.Connection {
|
func (b *Bridge) createIRC(name string) *irc.Connection {
|
||||||
i := irc.IRC(b.Config.IRC.Nick, b.Config.IRC.Nick)
|
i := irc.IRC(b.Config.IRC.Nick, b.Config.IRC.Nick)
|
||||||
i.UseTLS = b.Config.IRC.UseTLS
|
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}
|
i.TLSConfig = &tls.Config{InsecureSkipVerify: b.Config.IRC.SkipTLSVerify}
|
||||||
if b.Config.IRC.Password != "" {
|
if b.Config.IRC.Password != "" {
|
||||||
i.Password = b.Config.IRC.Password
|
i.Password = b.Config.IRC.Password
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
type Config struct {
|
type Config struct {
|
||||||
IRC struct {
|
IRC struct {
|
||||||
UseTLS bool
|
UseTLS bool
|
||||||
|
UseSASL bool
|
||||||
SkipTLSVerify bool
|
SkipTLSVerify bool
|
||||||
Server string
|
Server string
|
||||||
Nick string
|
Nick string
|
||||||
|
@ -11,6 +11,11 @@ Server="irc.freenode.net:6667"
|
|||||||
#OPTIONAL (default false)
|
#OPTIONAL (default false)
|
||||||
UseTLS=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
|
#Enable to not verify the certificate on your irc server. i
|
||||||
#e.g. when using selfsigned certificates
|
#e.g. when using selfsigned certificates
|
||||||
#OPTIONAL (default false)
|
#OPTIONAL (default false)
|
||||||
@ -21,6 +26,7 @@ SkipTLSVerify=true
|
|||||||
Nick="matterbot"
|
Nick="matterbot"
|
||||||
|
|
||||||
#If you registered your bot with a service like Nickserv on freenode.
|
#If you registered your bot with a service like Nickserv on freenode.
|
||||||
|
#Also being used when UseSASL=true
|
||||||
#OPTIONAL
|
#OPTIONAL
|
||||||
NickServNick="nickserv"
|
NickServNick="nickserv"
|
||||||
NickServPassword="secret"
|
NickServPassword="secret"
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
var version = "0.5.0-beta1"
|
var version = "0.5.0-beta2"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
log.SetFormatter(&log.TextFormatter{FullTimestamp: true})
|
log.SetFormatter(&log.TextFormatter{FullTimestamp: true})
|
||||||
|
20
vendor/github.com/thoj/go-ircevent/irc.go
generated
vendored
20
vendor/github.com/thoj/go-ircevent/irc.go
generated
vendored
@ -439,6 +439,25 @@ func (irc *Connection) Connect(server string) error {
|
|||||||
if len(irc.Password) > 0 {
|
if len(irc.Password) > 0 {
|
||||||
irc.pwrite <- fmt.Sprintf("PASS %s\r\n", irc.Password)
|
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("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)
|
irc.pwrite <- fmt.Sprintf("USER %s 0.0.0.0 0.0.0.0 :%s\r\n", irc.user, irc.user)
|
||||||
return nil
|
return nil
|
||||||
@ -466,6 +485,7 @@ func IRC(nick, user string) *Connection {
|
|||||||
KeepAlive: 4 * time.Minute,
|
KeepAlive: 4 * time.Minute,
|
||||||
Timeout: 1 * time.Minute,
|
Timeout: 1 * time.Minute,
|
||||||
PingFreq: 15 * time.Minute,
|
PingFreq: 15 * time.Minute,
|
||||||
|
SASLMech: "PLAIN",
|
||||||
QuitMessage: "",
|
QuitMessage: "",
|
||||||
}
|
}
|
||||||
irc.setupCallbacks()
|
irc.setupCallbacks()
|
||||||
|
4
vendor/github.com/thoj/go-ircevent/irc_struct.go
generated
vendored
4
vendor/github.com/thoj/go-ircevent/irc_struct.go
generated
vendored
@ -18,6 +18,10 @@ type Connection struct {
|
|||||||
Error chan error
|
Error chan error
|
||||||
Password string
|
Password string
|
||||||
UseTLS bool
|
UseTLS bool
|
||||||
|
UseSASL bool
|
||||||
|
SASLLogin string
|
||||||
|
SASLPassword string
|
||||||
|
SASLMech string
|
||||||
TLSConfig *tls.Config
|
TLSConfig *tls.Config
|
||||||
Version string
|
Version string
|
||||||
Timeout time.Duration
|
Timeout time.Duration
|
||||||
|
4
vendor/manifest
vendored
4
vendor/manifest
vendored
@ -113,8 +113,8 @@
|
|||||||
{
|
{
|
||||||
"importpath": "github.com/thoj/go-ircevent",
|
"importpath": "github.com/thoj/go-ircevent",
|
||||||
"repository": "https://github.com/thoj/go-ircevent",
|
"repository": "https://github.com/thoj/go-ircevent",
|
||||||
"vcs": "",
|
"vcs": "git",
|
||||||
"revision": "da78ed515c0f0833e7a92c7cc52898176198e2c1",
|
"revision": "98c1902dd2097f38142384167e60206ba26f1585",
|
||||||
"branch": "master",
|
"branch": "master",
|
||||||
"notests": true
|
"notests": true
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user