3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-27 13:09:23 +01:00

protocols: raise NotImplementedError with proper reasons

This commit is contained in:
James Lu 2017-03-26 14:32:41 -07:00
parent 938a1fb9d7
commit d6243d9f89
2 changed files with 13 additions and 7 deletions

View File

@ -715,10 +715,13 @@ class P10Protocol(IRCS2SProtocol):
"""Updates the ident or host of any connected client."""
uobj = self.irc.users[target]
ircd = self.irc.serverdata.get('p10_ircd', 'nefarious').lower()
if self.irc.isInternalClient(target):
# Host changing via SETHOST is only supported on nefarious and snircd.
if self.irc.serverdata.get('p10_ircd', 'nefarious').lower() not in ('nefarious', 'snircd'):
raise NotImplementedError
if ircd not in ('nefarious', 'snircd'):
raise NotImplementedError("Host changing for internal clients (via SETHOST) is only "
"available on nefarious and snircd, and we're using p10_ircd=%r" % ircd)
# Use SETHOST (umode +h) for internal clients.
if field == 'HOST':
@ -731,11 +734,13 @@ class P10Protocol(IRCS2SProtocol):
self.mode(target, target, [('-h', None)])
self.mode(target, target, [('+x', None), ('+h', '%s@%s' % (text, uobj.host))])
else:
raise NotImplementedError
raise NotImplementedError("Changing field %r of a client is "
"unsupported by this protocol." % field)
elif field == 'HOST':
# Host changing via FAKE is only supported on nefarious.
if self.irc.serverdata.get('p10_ircd', 'nefarious').lower() != 'nefarious':
raise NotImplementedError
if ircd != 'nefarious':
raise NotImplementedError("vHost changing for non-PyLink clients (via FAKE) is "
"only available on nefarious, and we're using p10_ircd=%r" % ircd)
# Use FAKE (FA) for external clients.
self._send(self.irc.sid, 'FA %s %s' % (target, text))
@ -745,7 +750,8 @@ class P10Protocol(IRCS2SProtocol):
self.irc.applyModes(target, [('+f', text)])
self.mode(self.irc.sid, target, [('+x', None)])
else:
raise NotImplementedError
raise NotImplementedError("Changing field %r of a client is "
"unsupported by this protocol." % field)
# P10 cloaks aren't as simple as just replacing the displayed host with the one we're
# sending. Check for cloak changes properly.

View File

@ -82,7 +82,7 @@ class RatboxProtocol(TS6Protocol):
def updateClient(self, target, field, text):
"""updateClient() stub for ratbox."""
raise NotImplementedError
raise NotImplementedError("User data changing is not supported on ircd-ratbox.")
def handle_realhost(self, uid, command, args):
"""Handles real host propagation."""