Merge pull request #669 from nyuszika7h/patch/sasl-wait-auth

src/irclib.py: Delay sending SASL authstring until given green light
This commit is contained in:
Valentin Lorentz 2014-05-24 16:19:49 +02:00
commit 77298106a7

View File

@ -930,7 +930,7 @@ class Irc(IrcCommandDispatcher):
else: else:
if self.sasl_password: if self.sasl_password:
if not self.sasl_username: if not self.sasl_username:
log.error('SASL username is not set, unable to identify.') log.warning('SASL username is not set, unable to identify.')
else: else:
auth_string = base64.b64encode('\x00'.join([ auth_string = base64.b64encode('\x00'.join([
self.sasl_username, self.sasl_username,
@ -941,8 +941,6 @@ class Irc(IrcCommandDispatcher):
self.queueMsg(ircmsgs.IrcMsg(command="CAP", args=('REQ', 'sasl'))) self.queueMsg(ircmsgs.IrcMsg(command="CAP", args=('REQ', 'sasl')))
log.debug('Using SASL mechanism PLAIN.') log.debug('Using SASL mechanism PLAIN.')
self.queueMsg(ircmsgs.IrcMsg(command="AUTHENTICATE", args=('PLAIN',))) self.queueMsg(ircmsgs.IrcMsg(command="AUTHENTICATE", args=('PLAIN',)))
log.info('Authenticating using SASL.')
self.queueMsg(ircmsgs.IrcMsg(command="AUTHENTICATE", args=(auth_string,)))
if self.password: if self.password:
log.info('Sending PASS command, not logging the password.') log.info('Sending PASS command, not logging the password.')
self.queueMsg(ircmsgs.password(self.password)) self.queueMsg(ircmsgs.password(self.password))
@ -952,6 +950,12 @@ class Irc(IrcCommandDispatcher):
self.ident, self.user) self.ident, self.user)
self.queueMsg(ircmsgs.user(self.ident, self.user)) self.queueMsg(ircmsgs.user(self.ident, self.user))
def doAuthenticate(self, msg):
if msg.args[0] == '+':
log.info('Authenticating using SASL.')
self.queueMsg(ircmsgs.IrcMsg(command="AUTHENTICATE", args=(auth_string,)))
def do903(self, msg): def do903(self, msg):
log.info('%s: SASL authentication successful' % self.network) log.info('%s: SASL authentication successful' % self.network)
self.queueMsg(ircmsgs.IrcMsg(command='CAP', args=('END',))) self.queueMsg(ircmsgs.IrcMsg(command='CAP', args=('END',)))