3
0
mirror of https://github.com/jlu5/PyLink.git synced 2025-01-23 18:54:05 +01:00

servprotect: only track kills and saves to PyLink clients

why wasn't this done before...
This commit is contained in:
James Lu 2017-05-20 15:02:04 -07:00
parent ead20f5be9
commit 76ecc60675

View File

@ -17,12 +17,14 @@ def handle_kill(irc, numeric, command, args):
Tracks kills against PyLink clients. If too many are received,
automatically disconnects from the network.
"""
if killcache.setdefault(irc.name, 1) >= length:
log.error('(%s) servprotect: Too many kills received, aborting!', irc.name)
irc.disconnect()
log.debug('(%s) servprotect: Incrementing killcache by 1', irc.name)
killcache[irc.name] += 1
if (args['userdata'] and irc.isInternalServer(args['userdata'].server)) or irc.isInternalClient(args['target']):
if killcache.setdefault(irc.name, 1) >= length:
log.error('(%s) servprotect: Too many kills received, aborting!', irc.name)
irc.disconnect()
log.debug('(%s) servprotect: Incrementing killcache by 1', irc.name)
killcache[irc.name] += 1
utils.add_hook(handle_kill, 'KILL')
@ -31,11 +33,12 @@ def handle_save(irc, numeric, command, args):
Tracks SAVEs (nick collision) against PyLink clients. If too many are received,
automatically disconnects from the network.
"""
if savecache.setdefault(irc.name, 0) >= length:
log.error('(%s) servprotect: Too many nick collisions, aborting!', irc.name)
irc.disconnect()
if irc.isInternalClient(args['target']):
if savecache.setdefault(irc.name, 0) >= length:
log.error('(%s) servprotect: Too many nick collisions, aborting!', irc.name)
irc.disconnect()
log.debug('(%s) servprotect: Incrementing savecache by 1', irc.name)
savecache[irc.name] += 1
log.debug('(%s) servprotect: Incrementing savecache by 1', irc.name)
savecache[irc.name] += 1
utils.add_hook(handle_save, 'SAVE')