whyrusleeping / hellabot

A hella awesome irc bot framework written in go, Simply plug in your triggers and run!
MIT License
142 stars 41 forks source link

SASL Auth doesn't work #33

Closed Fryyyyy closed 5 years ago

Fryyyyy commented 5 years ago

While trying to connect to Freenode using SSL and SASL, it seems the server times out and closes our link - and then we realise we actually did receive the ACK packet:

DBUG[01-05|17:04:19] Starting bot goroutines                  id=4bf23afc8423912e host=irc.freenode.net:6697 nick=BotNickname
DBUG[01-05|17:04:19] Connecting                               id=4bf23afc8423912e host=irc.freenode.net:6697 nick=BotNickname
INFO[01-05|17:04:20] Connected successfully!                  id=4bf23afc8423912e host=irc.freenode.net:6697 nick=BotNickname
DBUG[01-05|17:04:20] Beginning SASL Authentication            id=4bf23afc8423912e host=irc.freenode.net:6697 nick=BotNickname
DBUG[01-05|17:04:20] Outgoing                                 id=4bf23afc8423912e host=irc.freenode.net:6697 nick=BotNickname data="CAP REQ :sasl"
DBUG[01-05|17:04:20] Incoming                                 id=4bf23afc8423912e host=irc.freenode.net:6697 nick=BotNickname raw=":hitchcock.freenode.net NOTICE * :*** Looking up your hostname..." msg.To=* msg.From=hitchcock.freenode.net msg.Params=[*] msg.Trailing="*** Looking up your hostname..."
DBUG[01-05|17:04:20] Incoming                                 id=4bf23afc8423912e host=irc.freenode.net:6697 nick=BotNickname raw=":hitchcock.freenode.net NOTICE * :*** Checking Ident" msg.To=* msg.From=hitchcock.freenode.net msg.Params=[*] msg.Trailing="*** Checking Ident"
DBUG[01-05|17:04:20] Incoming                                 id=4bf23afc8423912e host=irc.freenode.net:6697 nick=BotNickname raw=":hitchcock.freenode.net NOTICE * :*** Found your hostname" msg.To=* msg.From=hitchcock.freenode.net msg.Params=[*] msg.Trailing="*** Found your hostname"
DBUG[01-05|17:04:20] Outgoing                                 id=4bf23afc8423912e host=irc.freenode.net:6697 nick=BotNickname data="NICK BotNickname"
DBUG[01-05|17:04:20] Outgoing                                 id=4bf23afc8423912e host=irc.freenode.net:6697 nick=BotNickname data="USER BotNickname 8 * :BotNickname"
DBUG[01-05|17:04:29] Incoming                                 id=4bf23afc8423912e host=irc.freenode.net:6697 nick=BotNickname raw=":hitchcock.freenode.net NOTICE * :*** No Ident response" msg.To=* msg.From=hitchcock.freenode.net msg.Params=[*] msg.Trailing="*** No Ident response"
DBUG[01-05|17:04:29] Incoming                                 id=4bf23afc8423912e host=irc.freenode.net:6697 nick=BotNickname raw=":hitchcock.freenode.net CAP * ACK :sasl " msg.To=* msg.From=hitchcock.freenode.net msg.Params="[* ACK]" msg.Trailing="sasl "
DBUG[01-05|17:05:03] Incoming                                 id=4bf23afc8423912e host=irc.freenode.net:6697 nick=BotNickname raw="ERROR :Closing Link: hostnamehere.compute.amazonaws.com (Connection timed out)" msg.To= msg.From= msg.Params=[] msg.Trailing="Closing Link: hostnamehere.compute.amazonaws.com (Connection timed out)"
DBUG[01-05|17:05:03] Recieved SASL ACK                        id=4bf23afc8423912e host=irc.freenode.net:6697 nick=BotNickname
DBUG[01-05|17:05:03] Got auth message!                        id=4bf23afc8423912e host=irc.freenode.net:6697 nick=BotNickname
Bot shutting down.
icholy commented 5 years ago

Can you provide any code than can easily reproduce this?

Fryyyyy commented 5 years ago

Minimal test case:


import (
    "flag"
    "fmt"
    "time"

    hbot "github.com/whyrusleeping/hellabot"
    log "gopkg.in/inconshreveable/log15.v2"
)

func main() {
    noHijackSession := func(bot *hbot.Bot) {
        bot.HijackSession = false
    }
    prodChannels := func(bot *hbot.Bot) {
        bot.Channels = []string{"#frybottest"}
    }
    yesSSLOptions := func(bot *hbot.Bot) {
        bot.SSL = true
    }
    saslOptions := func(bot *hbot.Bot) {
        bot.SASL = true
        bot.Password = "<REDACTED>"
    }
    timeOut := func(bot *hbot.Bot) {
        bot.ThrottleDelay = 300 * time.Millisecond
    }

    sslServ := flag.String("server", "irc.freenode.net:6697", "hostname and port for irc server to connect to")
    nick := flag.String("nick", "Fryatog", "nickname for the bot")
    bot, err := hbot.NewBot(*sslServ, *nick, noHijackSession, prodChannels, yesSSLOptions, saslOptions, timeOut)
    if err != nil {
        panic(err)
    }
    bot.Logger.SetHandler(log.StdoutHandler)
    bot.Run()
    fmt.Println("Bot shutting down.")
}

Gives the following output:

DBUG[01-05|19:09:22] Connecting                               id=08d1618e9c28aa61 host=irc.freenode.net:6697 nick=Fryatog
INFO[01-05|19:09:23] Connected successfully!                  id=08d1618e9c28aa61 host=irc.freenode.net:6697 nick=Fryatog
DBUG[01-05|19:09:23] Beginning SASL Authentication            id=08d1618e9c28aa61 host=irc.freenode.net:6697 nick=Fryatog
DBUG[01-05|19:09:23] Outgoing                                 id=08d1618e9c28aa61 host=irc.freenode.net:6697 nick=Fryatog data="CAP RE                                                                   Q :sasl"
DBUG[01-05|19:09:23] Incoming                                 id=08d1618e9c28aa61 host=irc.freenode.net:6697 nick=Fryatog raw=":watson                                                                   .freenode.net NOTICE * :*** Looking up your hostname..." msg.To=* msg.From=watson.freenode.net msg.Params=[*] msg.Trailing="*** Lookin                                                                   g up your hostname..."
DBUG[01-05|19:09:23] Incoming                                 id=08d1618e9c28aa61 host=irc.freenode.net:6697 nick=Fryatog raw=":watson                                                                   .freenode.net NOTICE * :*** Checking Ident" msg.To=* msg.From=watson.freenode.net msg.Params=[*] msg.Trailing="*** Checking Ident"
DBUG[01-05|19:09:23] Outgoing                                 id=08d1618e9c28aa61 host=irc.freenode.net:6697 nick=Fryatog data="NICK F                                                                   ryatog"
DBUG[01-05|19:09:24] Outgoing                                 id=08d1618e9c28aa61 host=irc.freenode.net:6697 nick=Fryatog data="USER F                                                                   ryatog 8 * :Fryatog"
DBUG[01-05|19:09:24] Incoming                                 id=08d1618e9c28aa61 host=irc.freenode.net:6697 nick=Fryatog raw=":watson                                                                   .freenode.net NOTICE * :*** Found your hostname" msg.To=* msg.From=watson.freenode.net msg.Params=[*] msg.Trailing="*** Found your hos                                                                   tname"
DBUG[01-05|19:09:32] Incoming                                 id=08d1618e9c28aa61 host=irc.freenode.net:6697 nick=Fryatog raw=":watson                                                                   .freenode.net NOTICE * :*** No Ident response" msg.To=* msg.From=watson.freenode.net msg.Params=[*] msg.Trailing="*** No Ident respons                                                                   e"
DBUG[01-05|19:09:32] Incoming                                 id=08d1618e9c28aa61 host=irc.freenode.net:6697 nick=Fryatog raw=":watson                                                                   .freenode.net CAP * ACK :sasl " msg.To=* msg.From=watson.freenode.net msg.Params="[* ACK]" msg.Trailing="sasl "
DBUG[01-05|19:10:00] Incoming                                 id=08d1618e9c28aa61 host=irc.freenode.net:6697 nick=Fryatog raw="ERROR :Closing Link:hostname.com.au (Connection timed out)" msg.To= msg.From= msg.Params=[] msg.Trailing="Closing Link: hostname.com.au (Connection timed out)"
DBUG[01-05|19:10:00] Recieved SASL ACK                        id=08d1618e9c28aa61 host=irc.freenode.net:6697 nick=Fryatog
DBUG[01-05|19:10:00] Got auth message!                        id=08d1618e9c28aa61 host=irc.freenode.net:6697 nick=Fryatog
Bot shutting down.
Fryyyyy commented 5 years ago

Were you able to repro?

icholy commented 5 years ago

@Fryyyyy Haven't had a chance to check this out yet.

Fryyyyy commented 5 years ago

@icholy Ping for the pull request that we've tested works