cmd_receive: tolerate unrecognized messages
at the expense of not failing quickly when the sender doesn't send an offer
This commit is contained in:
parent
1b5f3e125e
commit
8e7c6f16cb
|
@ -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)
|
||||
if not recognized:
|
||||
log.msg("unrecognized message %r" % (them_d,))
|
||||
raise TransferError("expected offer, got none")
|
||||
|
||||
def _send_data(self, data, w):
|
||||
data_bytes = json.dumps(data).encode("utf-8")
|
||||
|
|
Loading…
Reference in New Issue
Block a user