mirror of
https://github.com/jlu5/PyLink.git
synced 2024-12-26 12:43:09 +01:00
make relay and ts6 a bit less, well, buggy
This commit is contained in:
parent
6ba42759cf
commit
9b8ef0a45d
@ -208,8 +208,11 @@ def initializeChannel(irc, channel):
|
|||||||
# Don't spawn our pseudoclients again.
|
# Don't spawn our pseudoclients again.
|
||||||
if not utils.isInternalClient(remoteirc, user):
|
if not utils.isInternalClient(remoteirc, user):
|
||||||
log.debug('(%s) initializeChannel: should be joining %s/%s to %s', irc.name, user, remotenet, channel)
|
log.debug('(%s) initializeChannel: should be joining %s/%s to %s', irc.name, user, remotenet, channel)
|
||||||
remoteuser = getRemoteUser(remoteirc, irc, user)
|
localuser = getRemoteUser(remoteirc, irc, user)
|
||||||
userpair = (getPrefixModes(remoteirc, irc, remotechan, user), remoteuser)
|
if localuser is None:
|
||||||
|
log.warning('(%s) got None for local user for %s/%s', irc.name, user, remotenet)
|
||||||
|
continue
|
||||||
|
userpair = (getPrefixModes(remoteirc, irc, remotechan, user), localuser)
|
||||||
log.debug('(%s) initializeChannel: adding %s to queued_users for %s', irc.name, userpair, channel)
|
log.debug('(%s) initializeChannel: adding %s to queued_users for %s', irc.name, userpair, channel)
|
||||||
queued_users.append(userpair)
|
queued_users.append(userpair)
|
||||||
if queued_users:
|
if queued_users:
|
||||||
@ -581,16 +584,14 @@ def relayJoins(irc, channel, users, ts, modes):
|
|||||||
# Is the .remote attribute set? If so, don't relay already
|
# Is the .remote attribute set? If so, don't relay already
|
||||||
# relayed clients; that'll trigger an endless loop!
|
# relayed clients; that'll trigger an endless loop!
|
||||||
continue
|
continue
|
||||||
except AttributeError: # Nope, it isn't.
|
except (AttributeError, KeyError): # Nope, it isn't.
|
||||||
pass
|
pass
|
||||||
if user == irc.pseudoclient.uid:
|
if utils.isInternalClient(irc, user):
|
||||||
# We don't need to clone the PyLink pseudoclient... That's
|
# We don't need to clone PyLink pseudoclients... That's
|
||||||
# meaningless.
|
# meaningless.
|
||||||
continue
|
continue
|
||||||
log.debug('Okay, spawning %s/%s everywhere', user, irc.name)
|
log.debug('Okay, spawning %s/%s everywhere', user, irc.name)
|
||||||
u = getRemoteUser(irc, remoteirc, user)
|
u = getRemoteUser(irc, remoteirc, user)
|
||||||
if u is None:
|
|
||||||
continue
|
|
||||||
ts = irc.channels[channel].ts
|
ts = irc.channels[channel].ts
|
||||||
# TODO: join users in batches with SJOIN, not one by one.
|
# TODO: join users in batches with SJOIN, not one by one.
|
||||||
prefixes = getPrefixModes(irc, remoteirc, channel, user)
|
prefixes = getPrefixModes(irc, remoteirc, channel, user)
|
||||||
|
@ -66,6 +66,7 @@ def sjoinServer(irc, server, channel, users, ts=None):
|
|||||||
channel = channel.lower()
|
channel = channel.lower()
|
||||||
server = server or irc.sid
|
server = server or irc.sid
|
||||||
assert users, "sjoinServer: No users sent?"
|
assert users, "sjoinServer: No users sent?"
|
||||||
|
log.debug('(%s) sjoinServer: got %r for users', irc.name, users)
|
||||||
if not server:
|
if not server:
|
||||||
raise LookupError('No such PyLink PseudoClient exists.')
|
raise LookupError('No such PyLink PseudoClient exists.')
|
||||||
if ts is None:
|
if ts is None:
|
||||||
|
@ -17,7 +17,7 @@ from inspircd import handle_privmsg, handle_kill, handle_kick, handle_error, \
|
|||||||
handle_quit, handle_nick, handle_save, handle_squit, handle_mode, handle_topic, \
|
handle_quit, handle_nick, handle_save, handle_squit, handle_mode, handle_topic, \
|
||||||
handle_notice
|
handle_notice
|
||||||
|
|
||||||
hook_map = {'SJOIN': 'JOIN', 'TB': 'TOPIC'}
|
hook_map = {'SJOIN': 'JOIN', 'TB': 'TOPIC', 'TMODE': 'MODE'}
|
||||||
|
|
||||||
def _send(irc, sid, msg):
|
def _send(irc, sid, msg):
|
||||||
irc.send(':%s %s' % (sid, msg))
|
irc.send(':%s %s' % (sid, msg))
|
||||||
@ -72,6 +72,7 @@ def sjoinServer(irc, server, channel, users, ts=None):
|
|||||||
channel = channel.lower()
|
channel = channel.lower()
|
||||||
server = server or irc.sid
|
server = server or irc.sid
|
||||||
assert users, "sjoinServer: No users sent?"
|
assert users, "sjoinServer: No users sent?"
|
||||||
|
log.debug('(%s) sjoinServer: got %r for users', irc.name, users)
|
||||||
if not server:
|
if not server:
|
||||||
raise LookupError('No such PyLink PseudoClient exists.')
|
raise LookupError('No such PyLink PseudoClient exists.')
|
||||||
if ts is None:
|
if ts is None:
|
||||||
@ -304,32 +305,30 @@ def handle_sjoin(irc, servernumeric, command, args):
|
|||||||
parsedmodes = utils.parseModes(irc, channel, modestring)
|
parsedmodes = utils.parseModes(irc, channel, modestring)
|
||||||
utils.applyModes(irc, channel, parsedmodes)
|
utils.applyModes(irc, channel, parsedmodes)
|
||||||
namelist = []
|
namelist = []
|
||||||
for user in userlist:
|
log.debug('(%s) handle_sjoin: got userlist %r for %r', irc.name, userlist, channel)
|
||||||
|
for userpair in userlist:
|
||||||
# charybdis sends this in the form "@+UID1, +UID2, UID3, @UID4"
|
# charybdis sends this in the form "@+UID1, +UID2, UID3, @UID4"
|
||||||
modeprefix = ''
|
r = re.search(r'([%s]*)(.*)' % ''.join(irc.prefixmodes.values()), userpair)
|
||||||
r = re.search(r'([%s]*)(.*)' % ''.join(irc.prefixmodes.values()), user)
|
|
||||||
user = r.group(2)
|
user = r.group(2)
|
||||||
for m in r.group(1):
|
modeprefix = r.group(1) or ''
|
||||||
|
finalprefix = ''
|
||||||
|
assert user, 'Failed to get the UID from %r; our regex needs updating?' % userpair
|
||||||
|
log.debug('(%s) handle_sjoin: got modeprefix %r for user %r', irc.name, modeprefix, user)
|
||||||
|
for m in modeprefix:
|
||||||
# Iterate over the mapping of prefix chars to prefixes, and
|
# Iterate over the mapping of prefix chars to prefixes, and
|
||||||
# find the characters that match.
|
# find the characters that match.
|
||||||
for char, prefix in irc.prefixmodes.items():
|
for char, prefix in irc.prefixmodes.items():
|
||||||
if m == prefix:
|
if m == prefix:
|
||||||
modeprefix += char
|
finalprefix += char
|
||||||
namelist.append(user)
|
namelist.append(user)
|
||||||
irc.users[user].channels.add(channel)
|
irc.users[user].channels.add(channel)
|
||||||
utils.applyModes(irc, channel, [('+%s' % mode, user) for mode in modeprefix])
|
utils.applyModes(irc, channel, [('+%s' % mode, user) for mode in finalprefix])
|
||||||
irc.channels[channel].users.add(user)
|
irc.channels[channel].users.add(user)
|
||||||
return {'channel': channel, 'users': namelist, 'modes': parsedmodes, 'ts': their_ts}
|
return {'channel': channel, 'users': namelist, 'modes': parsedmodes, 'ts': their_ts}
|
||||||
|
|
||||||
def handle_join(irc, numeric, command, args):
|
def handle_join(irc, numeric, command, args):
|
||||||
# parameters: channelTS, channel, '+' (a plus sign)
|
# parameters: channelTS, channel, '+' (a plus sign)
|
||||||
ts = int(args[0])
|
ts = int(args[0])
|
||||||
our_ts = irc.channels[channel].ts
|
|
||||||
if ts < our_ts:
|
|
||||||
# Channel timestamp was reset on burst
|
|
||||||
log.debug('(%s) Setting channel TS of %s to %s from %s',
|
|
||||||
irc.name, channel, ts, our_ts)
|
|
||||||
irc.channels[channel].ts = ts
|
|
||||||
if args[0] == '0':
|
if args[0] == '0':
|
||||||
# /join 0; part the user from all channels
|
# /join 0; part the user from all channels
|
||||||
oldchans = list(irc.users[numeric].channels)
|
oldchans = list(irc.users[numeric].channels)
|
||||||
@ -339,6 +338,12 @@ def handle_join(irc, numeric, command, args):
|
|||||||
return {'channels': oldchans, 'text': 'Left all channels.', 'parse_as': 'PART'}
|
return {'channels': oldchans, 'text': 'Left all channels.', 'parse_as': 'PART'}
|
||||||
else:
|
else:
|
||||||
channel = args[1].lower()
|
channel = args[1].lower()
|
||||||
|
our_ts = irc.channels[channel].ts
|
||||||
|
if ts < our_ts:
|
||||||
|
# Channel timestamp was reset on burst
|
||||||
|
log.debug('(%s) Setting channel TS of %s to %s from %s',
|
||||||
|
irc.name, channel, ts, our_ts)
|
||||||
|
irc.channels[channel].ts = ts
|
||||||
irc.channels[channel].users.add(numeric)
|
irc.channels[channel].users.add(numeric)
|
||||||
irc.users[numeric].channels.add(numeric)
|
irc.users[numeric].channels.add(numeric)
|
||||||
# We send users and modes here because SJOIN and JOIN both use one hook,
|
# We send users and modes here because SJOIN and JOIN both use one hook,
|
||||||
@ -347,10 +352,16 @@ def handle_join(irc, numeric, command, args):
|
|||||||
irc.channels[channel].modes, 'ts': ts}
|
irc.channels[channel].modes, 'ts': ts}
|
||||||
|
|
||||||
def handle_euid(irc, numeric, command, args):
|
def handle_euid(irc, numeric, command, args):
|
||||||
# <- :42X EUID GL 1 1437448431 +ailoswz ~gl 0::1 0::1 42XAAAAAB real hostname, account name :realname
|
# <- :42X EUID GL 1 1437505322 +ailoswz ~gl 127.0.0.1 127.0.0.1 42XAAAAAB * * :realname
|
||||||
nick = args[0]
|
nick = args[0]
|
||||||
ts, modes, ident, host, ip, uid, realhost = args[2:9]
|
ts, modes, ident, host, ip, uid, realhost = args[2:9]
|
||||||
realname = [-1]
|
if realhost == '*':
|
||||||
|
realhost = None
|
||||||
|
realname = args[-1]
|
||||||
|
log.debug('(%s) handle_euid got args: nick=%s ts=%s uid=%s ident=%s '
|
||||||
|
'host=%s realname=%s realhost=%s ip=%s', irc.name, nick, ts, uid,
|
||||||
|
ident, host, realname, realhost, ip)
|
||||||
|
|
||||||
irc.users[uid] = IrcUser(nick, ts, uid, ident, host, realname, realhost, ip)
|
irc.users[uid] = IrcUser(nick, ts, uid, ident, host, realname, realhost, ip)
|
||||||
parsedmodes = utils.parseModes(irc, uid, [modes])
|
parsedmodes = utils.parseModes(irc, uid, [modes])
|
||||||
log.debug('Applying modes %s for %s', parsedmodes, uid)
|
log.debug('Applying modes %s for %s', parsedmodes, uid)
|
||||||
|
Loading…
Reference in New Issue
Block a user