From: W. Trevor King Date: Fri, 30 May 2014 00:11:41 +0000 (-0700) Subject: irkerd: Record errors (for example bad-password messages) X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=556a95c85964cb9ba05d2d9357800e34ca320f27;p=irker.git irkerd: Record errors (for example bad-password messages) We can use these to distinguish between lost connections because of flaky connections (where trying again is useful) and lost connections because of bad passwords (where we should just give up). --- diff --git a/irkerd b/irkerd index 9cbb347..070e0e9 100755 --- a/irkerd +++ b/irkerd @@ -546,6 +546,7 @@ class IRCProtocol(StateStringOwner, Lock, LineProtocol): handshake_ttl=None, transmit_ttl=None, receive_ttl=None, anti_flood_delay=None, **kwargs): super(IRCProtocol, self).__init__(state='unseen', **kwargs) + self.errors = [] self._password = password self._nick_template = nick_template if nick_needs_number is None: @@ -674,6 +675,8 @@ class IRCProtocol(StateStringOwner, Lock, LineProtocol): self._handle_part(channel=target) elif command == 'featurelist': self._handle_features(arguments=arguments) + elif command == 'error': + self._handle_error(message=target) elif command == 'disconnect': self._handle_disconnect() elif command == 'kick': @@ -766,6 +769,11 @@ class IRCProtocol(StateStringOwner, Lock, LineProtocol): LOG.error('{}: ill-formed CHANLIMIT property'.format( self)) + def _handle_error(self, message): + "Server sent us an error message." + LOG.info('{}: server error: {}'.format(self, message)) + self.errors.append(message) + def _handle_disconnect(self): "Server disconnected us for flooding or some other reason." LOG.info('{}: server disconnected'.format(self))