Skip to content
This repository was archived by the owner on Nov 26, 2018. It is now read-only.

Commit f80ea09

Browse files
committed
More robust SASL detection
Thx @jwheare and @grawity
1 parent 461b034 commit f80ea09

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

network/irc/irc.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,6 @@ func (bot *ircBot) sendPassword() {
546546

547547
func (bot *ircBot) sendSaslStart() {
548548
bot.SendRaw("AUTHENTICATE PLAIN")
549-
550549
}
551550

552551
func (bot *ircBot) sendSaslPass() {
@@ -614,19 +613,19 @@ func (bot *ircBot) act(theLine *line.Line) {
614613
return
615614
}
616615

617-
isAskingForSasl := theLine.User == "" && strings.HasSuffix(theLine.Raw, " CAP * ACK :sasl")
616+
isAskingForSasl := strings.ToUpper(theLine.Command) == "CAP" && len(theLine.Args) == 2 && strings.ToUpper(theLine.Args[1]) == "ACK" && theLine.Content == "sasl"
618617
if isAskingForSasl {
619618
bot.sendSaslStart()
620619
return
621620
}
622621

623-
isAskingForSaslPass := theLine.User == "" && theLine.Raw == "AUTHENTICATE +"
622+
isAskingForSaslPass := theLine.User == "" && strings.ToUpper(theLine.Command) == "AUTHENTICATE" && theLine.Args[0] == "+"
624623
if isAskingForSaslPass {
625624
bot.sendSaslPass()
626625
return
627626
}
628627

629-
isSaslConfirm := theLine.User == "" && theLine.Content == "SASL authentication successful"
628+
isSaslConfirm := theLine.User == "" && theLine.Command == "903"
630629
// After SASL is accepted, join all the channels
631630
if isSaslConfirm {
632631
bot.sendSaslEnd()

0 commit comments

Comments
 (0)