Merge remote-tracking branch 'supybot/master' into testing

Conflicts:
	src/callbacks.py
	src/ircdb.py
This commit is contained in:
Valentin Lorentz 2013-09-22 20:16:20 +02:00
commit 990b911c06
2 changed files with 18 additions and 3 deletions

View File

@ -1,7 +1,8 @@
###
# Copyright (c) 2002-2009, Jeremiah Fincher
# Copyright (c) 2009, James McCoy
# Copyright (c) 2011, Valentin Lorentz
# Copyright (c) 2009,2013, James McCoy
>>>>>>> supybot/master
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -322,9 +323,20 @@ class IrcUser(object):
self.nicks[network].remove(nick)
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'

View File

@ -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)