mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 01:09:22 +01:00
relay: normalize hostnames too (e.g. unreal doesn't allow / in vHosts)
This commit is contained in:
parent
e86d21e67d
commit
a3e0159054
@ -124,6 +124,14 @@ def normalizeNick(irc, netname, nick, separator=None, uid=''):
|
|||||||
|
|
||||||
return nick
|
return nick
|
||||||
|
|
||||||
|
def normalizeHost(irc, host):
|
||||||
|
"""Creates a normalized hostname for the given host suitable for
|
||||||
|
introduction to a remote network (as a relay client)."""
|
||||||
|
if irc.protoname == 'unreal':
|
||||||
|
# UnrealIRCd doesn't allow slashes in hostnames
|
||||||
|
host = host.replace('/', '.')
|
||||||
|
return host[:64] # Limited to 64 chars
|
||||||
|
|
||||||
def loadDB():
|
def loadDB():
|
||||||
"""Loads the relay database, creating a new one if this fails."""
|
"""Loads the relay database, creating a new one if this fails."""
|
||||||
global db
|
global db
|
||||||
@ -219,8 +227,8 @@ def getRemoteUser(irc, remoteirc, user, spawnIfMissing=True):
|
|||||||
nick = normalizeNick(remoteirc, irc.name, userobj.nick)
|
nick = normalizeNick(remoteirc, irc.name, userobj.nick)
|
||||||
# Truncate idents at 10 characters, because TS6 won't like them otherwise!
|
# Truncate idents at 10 characters, because TS6 won't like them otherwise!
|
||||||
ident = userobj.ident[:10]
|
ident = userobj.ident[:10]
|
||||||
# Ditto hostname at 64 chars.
|
# Normalize hostnames
|
||||||
host = userobj.host[:64]
|
host = normalizeHost(remoteirc, userobj.host)
|
||||||
realname = userobj.realname
|
realname = userobj.realname
|
||||||
modes = getSupportedUmodes(irc, remoteirc, userobj.modes)
|
modes = getSupportedUmodes(irc, remoteirc, userobj.modes)
|
||||||
opertype = ''
|
opertype = ''
|
||||||
@ -849,6 +857,8 @@ def handle_chgclient(irc, source, command, args):
|
|||||||
for netname, user in relayusers[(irc.name, target)].items():
|
for netname, user in relayusers[(irc.name, target)].items():
|
||||||
remoteirc = world.networkobjects[netname]
|
remoteirc = world.networkobjects[netname]
|
||||||
try:
|
try:
|
||||||
|
if field == 'HOST':
|
||||||
|
text = normalizeHost(remoteirc, text)
|
||||||
remoteirc.proto.updateClient(user, field, text)
|
remoteirc.proto.updateClient(user, field, text)
|
||||||
except NotImplementedError: # IRCd doesn't support changing the field we want
|
except NotImplementedError: # IRCd doesn't support changing the field we want
|
||||||
log.debug('(%s) Ignoring changing field %r of %s on %s (for %s/%s);'
|
log.debug('(%s) Ignoring changing field %r of %s on %s (for %s/%s);'
|
||||||
|
Loading…
Reference in New Issue
Block a user