3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-27 21:19:31 +01:00

nefarious: support SETHOST-based (+h) cloaks

Closes #210.
This commit is contained in:
James Lu 2016-05-28 12:53:23 -07:00
parent 188d2f891c
commit 0e298dcb4d

View File

@ -822,8 +822,9 @@ class P10Protocol(Protocol):
return {'newnick': newnick, 'oldnick': oldnick, 'ts': int(args[1])}
def checkCloakChange(self, uid):
"""Checks for cloak changes on the given UID."""
"""Checks for cloak changes (ident and host) on the given UID."""
uobj = self.irc.users[uid]
ident = uobj.ident
modes = dict(uobj.modes)
log.debug('(%s) checkCloakChange: modes of %s are %s', self.irc.name, uid, modes)
@ -831,7 +832,12 @@ class P10Protocol(Protocol):
if 'x' not in modes: # +x isn't set, so cloaking is disabled.
newhost = uobj.realhost
else:
if 'f' in modes:
if 'h' in modes:
# +h is used by SETHOST/spoofhost blocks, or by /sethost when freeform is enabled.
# It takes the form umode +h ident@some.host, though only the host is
# actually settable in /sethost.
ident, newhost = modes['h'].split('@')
elif 'f' in modes:
# +f represents another way of setting vHosts, via a command called FAKE.
# Atheme uses this for vHosts, afaik.
newhost = modes['f']
@ -871,7 +877,10 @@ class P10Protocol(Protocol):
# Propagate a hostname update to plugins, but only if the changed host is different.
if newhost != uobj.host:
self.irc.callHooks([uid, 'CHGHOST', {'target': uid, 'newhost': newhost}])
if ident != uobj.ident:
self.irc.callHooks([uid, 'CHGIDENT', {'target': uid, 'newident': ident}])
uobj.host = newhost
uobj.ident = ident
return newhost