From 4b4db64705ab7848fe4f95989bb55272bd2f5d21 Mon Sep 17 00:00:00 2001 From: James Lu Date: Mon, 18 Apr 2016 10:46:26 -0700 Subject: [PATCH] nefarious: experimental host changing support via FAKE This seems to work fine for changing remote users' hosts, but changing the host of internal PyLink clients doesn't seem to work at all... --- protocols/nefarious.py | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/protocols/nefarious.py b/protocols/nefarious.py index 041a891..cf68c5d 100644 --- a/protocols/nefarious.py +++ b/protocols/nefarious.py @@ -175,7 +175,8 @@ class P10Protocol(Protocol): 'XR': 'XREPLY', 'SN': 'SVSNICK', 'SJ': 'SVSJOIN', - 'SH': 'SETHOST' + 'SH': 'SETHOST', + 'FA': 'FAKE' } # If the token isn't in the list, return it raw. return tokens.get(token, token) @@ -562,7 +563,23 @@ class P10Protocol(Protocol): self.irc.channels[target].topicset = True def updateClient(self, target, field, text): - raise NotImplementedError + """Updates the ident or host of any connected client.""" + # This uses the FAKE command, which isn't documented anywhere + # but uses the target UID and host as two arguments. + + if field == 'HOST': + self._send(self.irc.sid, 'FA %s %s' % (target, text)) + # Save the host change as a user mode (this is what P10 does), + # so further host checks work. + utils.applyModes(self.irc, target, [('+f', text)]) + + # P10 cloaks aren't as simple as just replacing the displayed host with the one we're + # sending. Check for cloak changes properly. + self.checkCloakChange(target) + + # We don't need to send any hooks here, checkCloakChange does that for us. + else: + raise NotImplementedError ### HANDLERS @@ -1225,5 +1242,16 @@ class P10Protocol(Protocol): # Check for any cloak changes now. self.checkCloakChange(target) + def handle_fake(self, numeric, command, args): + """Handles incoming FAKE hostmask changes.""" + target = args[0] + text = args[1] + + # Assume a usermode +f change, and then update the cloak checking. + utils.applyModes(self.irc, target, [('+f', text)]) + + self.checkCloakChange(target) + # We don't need to send any hooks here, checkCloakChange does that for us. + Class = P10Protocol