mirror of
https://github.com/jlu5/PyLink.git
synced 2025-01-27 04:34:13 +01:00
relay: fixes to support IDs as channel name
- Don't enforce local channel validity rules on the remote channel name - Normalize channels to str before looking them up in the DB
This commit is contained in:
parent
55360dd0b2
commit
9d459fab92
@ -524,7 +524,7 @@ def get_relay(irc, channel):
|
|||||||
"""Finds the matching relay entry name for the given network, channel
|
"""Finds the matching relay entry name for the given network, channel
|
||||||
pair, if one exists."""
|
pair, if one exists."""
|
||||||
|
|
||||||
chanpair = (irc.name, irc.to_lower(channel))
|
chanpair = (irc.name, irc.to_lower(str(channel)))
|
||||||
|
|
||||||
if chanpair in db: # This chanpair is a shared channel; others link to it
|
if chanpair in db: # This chanpair is a shared channel; others link to it
|
||||||
return chanpair
|
return chanpair
|
||||||
@ -2241,14 +2241,14 @@ def create(irc, source, args):
|
|||||||
creator = irc.get_hostmask(source)
|
creator = irc.get_hostmask(source)
|
||||||
# Create the relay database entry with the (network name, channel name)
|
# Create the relay database entry with the (network name, channel name)
|
||||||
# pair - this is just a dict with various keys.
|
# pair - this is just a dict with various keys.
|
||||||
db[(irc.name, channel)] = {'links': set(),
|
db[(irc.name, str(channel))] = {'links': set(),
|
||||||
'blocked_nets': set(),
|
'blocked_nets': set(),
|
||||||
'creator': creator,
|
'creator': creator,
|
||||||
'ts': time.time(),
|
'ts': time.time(),
|
||||||
'use_whitelist': irc.get_service_option('relay', 'linkacl_use_whitelist', False),
|
'use_whitelist': irc.get_service_option('relay', 'linkacl_use_whitelist', False),
|
||||||
'allowed_nets': set(),
|
'allowed_nets': set(),
|
||||||
'claim': [irc.name] if irc.get_service_option('relay', 'enable_default_claim', True)
|
'claim': [irc.name] if irc.get_service_option('relay', 'enable_default_claim', True)
|
||||||
else []}
|
else []}
|
||||||
log.info('(%s) relay: Channel %s created by %s.', irc.name, channel, creator)
|
log.info('(%s) relay: Channel %s created by %s.', irc.name, channel, creator)
|
||||||
initialize_channel(irc, channel)
|
initialize_channel(irc, channel)
|
||||||
irc.reply('Done.')
|
irc.reply('Done.')
|
||||||
@ -2350,14 +2350,13 @@ def link(irc, source, args):
|
|||||||
args = link_parser.parse_args(args)
|
args = link_parser.parse_args(args)
|
||||||
|
|
||||||
# Normalize channel case
|
# Normalize channel case
|
||||||
channel = irc.to_lower(args.channel)
|
channel = irc.to_lower(str(args.channel))
|
||||||
localchan = irc.to_lower(args.localchannel or args.channel)
|
localchan = irc.to_lower(str(args.localchannel or args.channel))
|
||||||
remotenet = args.remotenet
|
remotenet = args.remotenet
|
||||||
|
|
||||||
for c in (channel, localchan):
|
if not irc.is_channel(localchan):
|
||||||
if not irc.is_channel(c):
|
irc.error('Invalid channel %r.' % c)
|
||||||
irc.error('Invalid channel %r.' % c)
|
return
|
||||||
return
|
|
||||||
|
|
||||||
if remotenet == irc.name:
|
if remotenet == irc.name:
|
||||||
irc.error('Cannot link two channels on the same network.')
|
irc.error('Cannot link two channels on the same network.')
|
||||||
|
Loading…
Reference in New Issue
Block a user