From 8e7c6f16cbcf92c7a157664f3222a320467b71ce Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Tue, 24 May 2016 19:30:21 -0700 Subject: [PATCH] cmd_receive: tolerate unrecognized messages at the expense of not failing quickly when the sender doesn't send an offer --- src/wormhole/cli/cmd_receive.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/wormhole/cli/cmd_receive.py b/src/wormhole/cli/cmd_receive.py index 7f8983a..e860958 100644 --- a/src/wormhole/cli/cmd_receive.py +++ b/src/wormhole/cli/cmd_receive.py @@ -82,10 +82,12 @@ class TwistedReceiver: returnValue(None) raise TransferError("unexpected close") #print("GOT", them_d) + recognized = False if u"transit" in them_d: + recognized = True yield self._parse_transit(them_d[u"transit"], w) - continue if u"offer" in them_d: + recognized = True if not want_offer: raise TransferError("duplicate offer") try: @@ -94,8 +96,8 @@ class TwistedReceiver: self._send_data({"error": r.response}, w) raise TransferError(r.response) returnValue(None) - log.msg("unrecognized message %r" % (them_d,)) - raise TransferError("expected offer, got none") + if not recognized: + log.msg("unrecognized message %r" % (them_d,)) def _send_data(self, data, w): data_bytes = json.dumps(data).encode("utf-8")