Browse Source

Fix bug in channel selection in prepare_privmsg

Fixes #105.
Prior to this commit the channel chosen to send on in a
call to MessageChannelCollection.prepare_privmsg was not
respect and instead the entry in the active_channels was
used, resulting in a Taker not seeing the presence of Makers
in other channels than the one chosen here. This meant that
in cases of channel disconnection, fallback to other channels
was failing (although not always deterministically). This
commit fixes this by allowing the sending of the privmsg
on a specific channel, as was intended, and so when Makers
send messages on multiple channels, they are marked as seen
on all those channels, allowing dynamic switching in case
of channel connection failures.
In addition there are two minor improvements to debug
messages.
master
AdamISZ 7 years ago
parent
commit
3a2c462c6b
No known key found for this signature in database
GPG Key ID: 141001A1AF77F20B
  1. 10
      jmdaemon/jmdaemon/message_channel.py

10
jmdaemon/jmdaemon/message_channel.py

@ -144,7 +144,7 @@ class MessageChannelCollection(object):
for mc2 in self.available_channels():
if peer in self.nicks_seen[mc2]:
log.debug("Dynamically switching: " + peer + " to: " + \
str(mc2.serverport))
str(mc2.hostid))
self.active_channels[peer] = mc2
break
#Remove all entries for the newly unavailable channel
@ -235,12 +235,16 @@ class MessageChannelCollection(object):
#to the signature; this prevents cross-channel replay but NOT
#same-channel replay (in case of snooper after dropped connection
#on this channel).
if mc is None:
if nick in self.active_channels:
hostid = self.active_channels[nick].hostid
else:
log.info("Failed to send message to: " + str(nick) + \
"; cannot find on any message channel.")
return
else:
hostid = mc.hostid
msg_to_be_signed = message + str(hostid)
self.daemon.request_signed_message(nick, cmd, message, msg_to_be_signed,
@ -402,8 +406,10 @@ class MessageChannelCollection(object):
"""
self.mc_status[mc] = 2
self.flush_nicks()
# construct a readable nicks seen:
readablens = dict([(k.hostid, self.nicks_seen[k]) for k in self.nicks_seen])
log.debug("On disconnect fired, nicks_seen is now: " + str(
self.nicks_seen) + " " + mc.hostid)
readablens) + " " + mc.hostid)
if not any([x == 1 for x in self.mc_status.values()]):
if self.on_disconnect:
self.on_disconnect()

Loading…
Cancel
Save