mirror of
https://github.com/jlu5/PyLink.git
synced 2025-05-06 14:47:25 +02:00
relay: get rid of kill/save protection
This commit is contained in:
parent
75ec95b8d3
commit
9fe3373906
@ -9,8 +9,6 @@ import threading
|
|||||||
import string
|
import string
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
from expiringdict import ExpiringDict
|
|
||||||
|
|
||||||
import utils
|
import utils
|
||||||
from log import log
|
from log import log
|
||||||
import world
|
import world
|
||||||
@ -20,8 +18,7 @@ relayusers = defaultdict(dict)
|
|||||||
relayservers = defaultdict(dict)
|
relayservers = defaultdict(dict)
|
||||||
spawnlocks = defaultdict(threading.RLock)
|
spawnlocks = defaultdict(threading.RLock)
|
||||||
spawnlocks_servers = defaultdict(threading.RLock)
|
spawnlocks_servers = defaultdict(threading.RLock)
|
||||||
savecache = ExpiringDict(max_len=5, max_age_seconds=10)
|
|
||||||
killcache = ExpiringDict(max_len=5, max_age_seconds=10)
|
|
||||||
exportdb_timer = None
|
exportdb_timer = None
|
||||||
|
|
||||||
dbname = utils.getDatabaseName('pylinkrelay')
|
dbname = utils.getDatabaseName('pylinkrelay')
|
||||||
@ -1088,7 +1085,6 @@ def handle_kill(irc, numeric, command, args):
|
|||||||
# We don't allow killing over the relay, so we must respawn the affected
|
# We don't allow killing over the relay, so we must respawn the affected
|
||||||
# client and rejoin it to its channels.
|
# client and rejoin it to its channels.
|
||||||
del relayusers[realuser][irc.name]
|
del relayusers[realuser][irc.name]
|
||||||
if killcache.setdefault(irc.name, 0) <= 5:
|
|
||||||
remoteirc = world.networkobjects[realuser[0]]
|
remoteirc = world.networkobjects[realuser[0]]
|
||||||
for remotechan in remoteirc.users[realuser[1]].channels:
|
for remotechan in remoteirc.users[realuser[1]].channels:
|
||||||
localchan = getRemoteChan(remoteirc, irc, remotechan)
|
localchan = getRemoteChan(remoteirc, irc, remotechan)
|
||||||
@ -1110,11 +1106,6 @@ def handle_kill(irc, numeric, command, args):
|
|||||||
log.info('(%s) relay.handle_kill: Blocked KILL (reason %r) from server %s to relay client %s/%s.',
|
log.info('(%s) relay.handle_kill: Blocked KILL (reason %r) from server %s to relay client %s/%s.',
|
||||||
irc.name, args['text'], irc.servers[numeric].name,
|
irc.name, args['text'], irc.servers[numeric].name,
|
||||||
remoteirc.users[realuser[1]].nick, realuser[0])
|
remoteirc.users[realuser[1]].nick, realuser[0])
|
||||||
else:
|
|
||||||
log.error('(%s) relay.handle_kill: Too many kills received for target %s, aborting!',
|
|
||||||
irc.name, userdata.nick)
|
|
||||||
irc.disconnect()
|
|
||||||
killcache[irc.name] += 1
|
|
||||||
|
|
||||||
# Target user was local.
|
# Target user was local.
|
||||||
else:
|
else:
|
||||||
@ -1215,18 +1206,11 @@ def handle_save(irc, numeric, command, args):
|
|||||||
remotenet, remoteuser = realuser
|
remotenet, remoteuser = realuser
|
||||||
remoteirc = world.networkobjects[remotenet]
|
remoteirc = world.networkobjects[remotenet]
|
||||||
nick = remoteirc.users[remoteuser].nick
|
nick = remoteirc.users[remoteuser].nick
|
||||||
# Limit how many times we can attempt to fix our nick, to prevent
|
|
||||||
# floods and such.
|
|
||||||
if savecache.setdefault(irc.name, 0) <= 5:
|
|
||||||
newnick = normalizeNick(irc, remotenet, nick)
|
newnick = normalizeNick(irc, remotenet, nick)
|
||||||
log.info('(%s) relay.handle_save: SAVE received for relay client %r (%s), fixing nick to %s',
|
log.info('(%s) relay.handle_save: SAVE received for relay client %r (%s), fixing nick to %s',
|
||||||
irc.name, target, nick, newnick)
|
irc.name, target, nick, newnick)
|
||||||
irc.proto.nick(target, newnick)
|
irc.proto.nick(target, newnick)
|
||||||
else:
|
|
||||||
log.warning('(%s) relay.handle_save: SAVE received for relay client %r (%s), not '
|
|
||||||
'fixing nick again due to 5 failed attempts in '
|
|
||||||
'the last 10 seconds!', irc.name, target, nick)
|
|
||||||
savecache[irc.name] += 1
|
|
||||||
else:
|
else:
|
||||||
# Somebody else on the network (not a PyLink client) had a nick collision;
|
# Somebody else on the network (not a PyLink client) had a nick collision;
|
||||||
# relay this as a nick change appropriately.
|
# relay this as a nick change appropriately.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user