From 01a6ed6540aed0c762afa4fba5dd9974111c0e19 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Tue, 2 Jul 2013 13:18:57 +0200 Subject: [PATCH 1/4] Fix use of rsplit for IPv6 addresses. Signed-off-by: James McCoy --- src/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conf.py b/src/conf.py index b3dba0d8f..458b9c865 100644 --- a/src/conf.py +++ b/src/conf.py @@ -223,7 +223,7 @@ class Servers(registry.SpaceSeparatedListOfStrings): def convert(self, s): s = self.normalize(s) - (server, port) = s.rsplit(':', 2) + (server, port) = s.rsplit(':', 1) port = int(port) return (server, port) From cf975227ba52338609b4362d51d129fd4534e6eb Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Thu, 11 Jul 2013 06:58:46 +0000 Subject: [PATCH 2/4] Factoids: Fix help of @random. Signed-off-by: James McCoy --- plugins/Factoids/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/Factoids/plugin.py b/plugins/Factoids/plugin.py index cafd0dccb..1750b195e 100644 --- a/plugins/Factoids/plugin.py +++ b/plugins/Factoids/plugin.py @@ -304,7 +304,7 @@ class Factoids(callbacks.Plugin, plugins.ChannelDBHandler): def random(self, irc, msg, args, channel): """[] - Returns a random factoid from the database for . + Returns random factoids from the database for . is only necessary if the message isn't sent in the channel itself. """ db = self.getDb(channel) From 4bc549c1ed14c71c3e80a5c7ad54a7714bb2aa2f Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sat, 31 Aug 2013 23:04:38 -0400 Subject: [PATCH 3/4] Prevent exception when replying with a genericNoCapability error Signed-off-by: James McCoy --- src/callbacks.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/callbacks.py b/src/callbacks.py index a0d8ddb8e..01b398408 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -466,7 +466,8 @@ class RichReplyMethods(object): v = self._getConfig(conf.supybot.replies.genericNoCapability) else: v = self._getConfig(conf.supybot.replies.noCapability) - s = self.__makeReply(v % capability, s) + v = v % capability + s = self.__makeReply(v, s) return self._error(s, **kwargs) else: log.warning('Denying %s for some unspecified capability ' From 6361b1e856ebbc8e14d399019e2c53a35f4e0063 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sun, 22 Sep 2013 11:13:52 -0400 Subject: [PATCH 4/4] ircdb: Deduplicate hostmasks in IrcUser.addAuth If addAuth is called with a hostmask that already exists (exactly, not just equivalent patterns) in self.auth, remove the entry for the old authentication. This essentially updates the timeout for the hostmask. Signed-off-by: James McCoy --- src/ircdb.py | 15 +++++++++++++-- test/test_ircdb.py | 5 ++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/ircdb.py b/src/ircdb.py index 5f10cc107..b96cfa7ae 100644 --- a/src/ircdb.py +++ b/src/ircdb.py @@ -1,6 +1,6 @@ ### # Copyright (c) 2002-2009, Jeremiah Fincher -# Copyright (c) 2009, James McCoy +# Copyright (c) 2009,2013, James McCoy # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -291,9 +291,20 @@ class IrcUser(object): self.hostmasks.remove(hostmask) def addAuth(self, hostmask): - """Sets a user's authenticated hostmask. This times out in 1 hour.""" + """Sets a user's authenticated hostmask. This times out according to + conf.supybot.timeoutIdentification. If hostmask exactly matches an + existing, known hostmask, the previous entry is removed.""" if self.checkHostmask(hostmask, useAuth=False) or not self.secure: self.auth.append((time.time(), hostmask)) + knownHostmasks = set() + def uniqueHostmask(auth): + (_, mask) = auth + if mask not in knownHostmasks: + knownHostmasks.add(mask) + return True + return False + uniqued = filter(uniqueHostmask, reversed(self.auth)) + self.auth = list(reversed(uniqued)) else: raise ValueError, 'secure flag set, unmatched hostmask' diff --git a/test/test_ircdb.py b/test/test_ircdb.py index 8eec61771..0a505cd22 100644 --- a/test/test_ircdb.py +++ b/test/test_ircdb.py @@ -252,7 +252,7 @@ class IrcUserTestCase(IrcdbTestCase): self.failIf(u.checkHostmask('foo!bar@baz')) finally: conf.supybot.databases.users.timeoutIdentification.setValue(orig) - + def testMultipleAuth(self): orig = conf.supybot.databases.users.timeoutIdentification() try: @@ -260,6 +260,9 @@ class IrcUserTestCase(IrcdbTestCase): u = ircdb.IrcUser() u.addAuth('foo!bar@baz') self.failUnless(u.checkHostmask('foo!bar@baz')) + u.addAuth('foo!bar@baz') + self.failUnless(u.checkHostmask('foo!bar@baz')) + self.failUnless(len(u.auth) == 1) u.addAuth('boo!far@fizz') self.failUnless(u.checkHostmask('boo!far@fizz')) time.sleep(2.1)