RelayNext: make flood detection command-specific too

This commit is contained in:
James Lu 2015-09-22 18:02:45 -07:00
parent 14b6b9c82e
commit 1c5dd5f0a4
2 changed files with 5 additions and 6 deletions

View File

@ -58,7 +58,7 @@ Most of these plugins also have their own READMEs in their folders; you can usua
- A small random name generator. - A small random name generator.
##### [OperUp](OperUp/README.md) ##### [OperUp](OperUp/README.md)
- Allows Supybot to oper up automatically (on connect) and on demand. - Allows Supybot to oper up on configured networks, automatically (on connect) and on demand.
##### PassGen ##### PassGen
- Generates random passwords on the fly! - Generates random passwords on the fly!
@ -71,7 +71,6 @@ Most of these plugins also have their own READMEs in their folders; you can usua
- Looks up commonly used UDP and TCP port numbers from Wikipedia: https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers - Looks up commonly used UDP and TCP port numbers from Wikipedia: https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers
- **Requires:** [Beautiful Soup 4](http://www.crummy.com/software/BeautifulSoup/bs4/doc/) - **Requires:** [Beautiful Soup 4](http://www.crummy.com/software/BeautifulSoup/bs4/doc/)
##### [RelayNext](RelayNext/README.md) ##### [RelayNext](RelayNext/README.md)
- Next generation relayer plugin, designed with two-way relays in mind. - Next generation relayer plugin, designed with two-way relays in mind.

View File

@ -92,7 +92,7 @@ class RelayNext(callbacks.Plugin):
# This part facilitates flood protection # This part facilitates flood protection
self.msgcounters = {} self.msgcounters = {}
self.floodTriggered = False self.floodTriggered = {}
self.db = {} self.db = {}
self.loadDB() self.loadDB()
@ -236,17 +236,17 @@ class RelayNext(callbacks.Plugin):
if len(self.msgcounters[(source, msg.command)]) > maximum: if len(self.msgcounters[(source, msg.command)]) > maximum:
self.log.debug("RelayNext (%s): message from %s blocked by " self.log.debug("RelayNext (%s): message from %s blocked by "
"flood protection.", irc.network, channel) "flood protection.", irc.network, channel)
if self.floodTriggered: if self.floodTriggered.get((source, msg.command)):
return return
c = msg.command.lower() c = msg.command.lower()
e = format("Flood detected on %s (%s %ss/%s seconds), " e = format("Flood detected on %s (%s %ss/%s seconds), "
"not relaying %ss for %s seconds!", channel, "not relaying %ss for %s seconds!", channel,
maximum, c, seconds, c, timeout) maximum, c, seconds, c, timeout)
out_s = self._format(irc, msg, channel, announcement=e) out_s = self._format(irc, msg, channel, announcement=e)
self.floodTriggered = True self.floodTriggered[(source, msg.command)] = True
self.log.info("RelayNext (%s): %s", irc.network, e) self.log.info("RelayNext (%s): %s", irc.network, e)
else: else:
self.floodTriggered = False self.floodTriggered[(source, msg.command)] = False
for cn in targets: for cn in targets:
target, net = cn.split("@") target, net = cn.split("@")
otherIrc = world.getIrc(net) otherIrc = world.getIrc(net)