3
0
mirror of https://github.com/jlu5/PyLink.git synced 2025-01-11 20:52:42 +01:00

nefarious: forward CMODE and KICK through the server if the sender isn't opped

This prevents mode bounces, kick failures, and the HACK server notices from showing up.

(cherry picked from commit fca23c7d55)
This commit is contained in:
James Lu 2016-07-26 18:30:35 -07:00
parent fd8ba5edfc
commit 9233a94379

View File

@ -352,6 +352,13 @@ class P10Protocol(IRCS2SProtocol):
if not reason: if not reason:
reason = 'No reason given' reason = 'No reason given'
cobj = self.irc.channels[channel]
# HACK: prevent kick bounces by sending our kick through the server if
# the sender isn't op.
if numeric not in self.irc.servers and (not cobj.isOp(numeric)) and (not cobj.isHalfop(numeric)):
reason = '(%s) %s' % (self.irc.getFriendlyName(numeric), reason)
numeric = self.irc.getServer(numeric)
self._send(numeric, 'K %s %s :%s' % (channel, target, reason)) self._send(numeric, 'K %s %s :%s' % (channel, target, reason))
# We can pretend the target left by its own will; all we really care about # We can pretend the target left by its own will; all we really care about
@ -389,7 +396,6 @@ class P10Protocol(IRCS2SProtocol):
(not self.irc.isInternalServer(numeric)): (not self.irc.isInternalServer(numeric)):
raise LookupError('No such PyLink client/server exists.') raise LookupError('No such PyLink client/server exists.')
self.irc.applyModes(target, modes)
modes = list(modes) modes = list(modes)
# According to the P10 specification: # According to the P10 specification:
@ -401,12 +407,20 @@ class P10Protocol(IRCS2SProtocol):
cobj = self.irc.channels[self.irc.toLower(target)] cobj = self.irc.channels[self.irc.toLower(target)]
ts = ts or cobj.ts ts = ts or cobj.ts
send_ts = True send_ts = True
# HACK: prevent mode bounces by sending our mode through the server if
# the sender isn't op.
if numeric not in self.irc.servers and (not cobj.isOp(numeric)) and (not cobj.isHalfop(numeric)):
numeric = self.irc.getServer(numeric)
else: else:
assert target in self.irc.users, "Unknown mode target %s" % target assert target in self.irc.users, "Unknown mode target %s" % target
# P10 uses nicks in user MODE targets, NOT UIDs. ~GL # P10 uses nicks in user MODE targets, NOT UIDs. ~GL
target = self.irc.users[target].nick target = self.irc.users[target].nick
send_ts = False send_ts = False
self.irc.applyModes(target, modes)
while modes[:12]: while modes[:12]:
joinedmodes = self.irc.joinModes([m for m in modes[:12]]) joinedmodes = self.irc.joinModes([m for m in modes[:12]])
modes = modes[12:] modes = modes[12:]