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)
|
returnValue(None)
|
||||||
raise TransferError("unexpected close")
|
raise TransferError("unexpected close")
|
||||||
#print("GOT", them_d)
|
#print("GOT", them_d)
|
||||||
|
recognized = False
|
||||||
if u"transit" in them_d:
|
if u"transit" in them_d:
|
||||||
|
recognized = True
|
||||||
yield self._parse_transit(them_d[u"transit"], w)
|
yield self._parse_transit(them_d[u"transit"], w)
|
||||||
continue
|
|
||||||
if u"offer" in them_d:
|
if u"offer" in them_d:
|
||||||
|
recognized = True
|
||||||
if not want_offer:
|
if not want_offer:
|
||||||
raise TransferError("duplicate offer")
|
raise TransferError("duplicate offer")
|
||||||
try:
|
try:
|
||||||
|
@ -94,8 +96,8 @@ class TwistedReceiver:
|
||||||
self._send_data({"error": r.response}, w)
|
self._send_data({"error": r.response}, w)
|
||||||
raise TransferError(r.response)
|
raise TransferError(r.response)
|
||||||
returnValue(None)
|
returnValue(None)
|
||||||
|
if not recognized:
|
||||||
log.msg("unrecognized message %r" % (them_d,))
|
log.msg("unrecognized message %r" % (them_d,))
|
||||||
raise TransferError("expected offer, got none")
|
|
||||||
|
|
||||||
def _send_data(self, data, w):
|
def _send_data(self, data, w):
|
||||||
data_bytes = json.dumps(data).encode("utf-8")
|
data_bytes = json.dumps(data).encode("utf-8")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user