mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-30 23:09:23 +01:00
Merge branch 'wip/relay/better-normalizehost' into devel
Conflicts: plugins/relay.py
This commit is contained in:
commit
1765d61973
@ -176,21 +176,19 @@ def normalize_host(irc, host):
|
|||||||
"""Creates a normalized hostname for the given host suitable for
|
"""Creates a normalized hostname for the given host suitable for
|
||||||
introduction to a remote network (as a relay client)."""
|
introduction to a remote network (as a relay client)."""
|
||||||
log.debug('(%s) relay.normalize_host: IRCd=%s, host=%s', irc.name, irc.protoname, host)
|
log.debug('(%s) relay.normalize_host: IRCd=%s, host=%s', irc.name, irc.protoname, host)
|
||||||
if irc.protoname not in ('inspircd', 'ts6', 'clientbot', 'nefarious'):
|
|
||||||
# UnrealIRCd and IRCd-Hybrid don't allow slashes in hostnames
|
|
||||||
host = host.replace('/', '.')
|
|
||||||
if irc.protoname in ('ts6', 'ratbox'):
|
|
||||||
# TS6 doesn't allow _ in hosts.
|
|
||||||
host = host.replace('_', '.')
|
|
||||||
|
|
||||||
host = host.replace('\x03', '') # Strip colours
|
allowed_chars = string.ascii_letters + string.digits + '-.:'
|
||||||
host = host.replace('\x02', '') # Strip bold
|
if irc.protoname in ('inspircd', 'ts6', 'clientbot', 'nefarious'):
|
||||||
host = host.replace('\x1f', '') # Strip underline
|
# UnrealIRCd and IRCd-Hybrid don't allow slashes in hostnames
|
||||||
host = host.replace('\x1d', '') # Strip italic
|
allowed_chars += '/'
|
||||||
host = host.replace('\x0f', '') # Strip color reset
|
|
||||||
host = host.replace('\x16', '') # Strip reverse color
|
if irc.protoname in ('inspircd', 'clientbot', 'nefarious', 'unreal'):
|
||||||
# And no, I'm not supporting colours in hosts. Screw your IRCd-breaking patches if you think
|
# The above IRCds allow _ in hostnames, while TS6-like IRCds do not.
|
||||||
# this is cool. -GL
|
allowed_chars += '_'
|
||||||
|
|
||||||
|
for char in host:
|
||||||
|
if char not in allowed_chars:
|
||||||
|
host = host.replace(char, '-')
|
||||||
|
|
||||||
return host[:63] # Limit hosts to 63 chars for best compatibility
|
return host[:63] # Limit hosts to 63 chars for best compatibility
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user