mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-10 12:59:22 +01:00
Merge remote-tracking branch 'supybot/master' into testing
Conflicts: src/callbacks.py src/ircdb.py
This commit is contained in:
commit
990b911c06
16
src/ircdb.py
16
src/ircdb.py
@ -1,7 +1,8 @@
|
|||||||
###
|
###
|
||||||
# Copyright (c) 2002-2009, Jeremiah Fincher
|
# Copyright (c) 2002-2009, Jeremiah Fincher
|
||||||
# Copyright (c) 2009, James McCoy
|
|
||||||
# Copyright (c) 2011, Valentin Lorentz
|
# Copyright (c) 2011, Valentin Lorentz
|
||||||
|
# Copyright (c) 2009,2013, James McCoy
|
||||||
|
>>>>>>> supybot/master
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@ -322,9 +323,20 @@ class IrcUser(object):
|
|||||||
self.nicks[network].remove(nick)
|
self.nicks[network].remove(nick)
|
||||||
|
|
||||||
def addAuth(self, 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:
|
if self.checkHostmask(hostmask, useAuth=False) or not self.secure:
|
||||||
self.auth.append((time.time(), hostmask))
|
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:
|
else:
|
||||||
raise ValueError, 'secure flag set, unmatched hostmask'
|
raise ValueError, 'secure flag set, unmatched hostmask'
|
||||||
|
|
||||||
|
@ -260,6 +260,9 @@ class IrcUserTestCase(IrcdbTestCase):
|
|||||||
u = ircdb.IrcUser()
|
u = ircdb.IrcUser()
|
||||||
u.addAuth('foo!bar@baz')
|
u.addAuth('foo!bar@baz')
|
||||||
self.failUnless(u.checkHostmask('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')
|
u.addAuth('boo!far@fizz')
|
||||||
self.failUnless(u.checkHostmask('boo!far@fizz'))
|
self.failUnless(u.checkHostmask('boo!far@fizz'))
|
||||||
time.sleep(2.1)
|
time.sleep(2.1)
|
||||||
|
Loading…
Reference in New Issue
Block a user