diff --git a/src/wormhole/cli/cmd_receive.py b/src/wormhole/cli/cmd_receive.py index d9ba896..03357ca 100644 --- a/src/wormhole/cli/cmd_receive.py +++ b/src/wormhole/cli/cmd_receive.py @@ -7,7 +7,7 @@ from twisted.internet.defer import inlineCallbacks, returnValue from twisted.python import log from wormhole import create, input_with_completion, __version__ from ..transit import TransitReceiver -from ..errors import TransferError, WormholeClosedError +from ..errors import TransferError from ..util import (dict_to_bytes, bytes_to_dict, bytes_to_hexstr, estimate_free_space) from .welcome import handle_welcome @@ -152,15 +152,9 @@ class Receiver: self._show_verifier(verifier_bytes) want_offer = True - done = False while True: - try: - them_d = yield self._get_data(w) - except WormholeClosedError: - if done: - returnValue(None) - raise TransferError("unexpected close") + them_d = yield self._get_data(w) #print("GOT", them_d) recognized = False if u"transit" in them_d: diff --git a/src/wormhole/cli/cmd_send.py b/src/wormhole/cli/cmd_send.py index adec1e2..0e5c4e5 100644 --- a/src/wormhole/cli/cmd_send.py +++ b/src/wormhole/cli/cmd_send.py @@ -6,7 +6,7 @@ from twisted.python import log from twisted.protocols import basic from twisted.internet import reactor from twisted.internet.defer import inlineCallbacks, returnValue -from ..errors import (TransferError, WormholeClosedError, UnsendableFileError) +from ..errors import TransferError, UnsendableFileError from wormhole import create, __version__ from ..transit import TransitSender from ..util import dict_to_bytes, bytes_to_dict, bytes_to_hexstr @@ -169,15 +169,9 @@ class Sender: self._send_data({"offer": offer}, w) want_answer = True - done = False while True: - try: - them_d_bytes = yield w.get_message() - except WormholeClosedError: - if done: - returnValue(None) - raise TransferError("unexpected close") + them_d_bytes = yield w.get_message() # TODO: get_message() fired, so get_verifier must have fired, so # now it's safe to use w.derive_key() them_d = bytes_to_dict(them_d_bytes) @@ -193,8 +187,8 @@ class Sender: recognized = True if not want_answer: raise TransferError("duplicate answer") + want_answer = True yield self._handle_answer(them_d[u"answer"]) - done = True returnValue(None) if not recognized: log.msg("unrecognized message %r" % (them_d,)) diff --git a/src/wormhole/errors.py b/src/wormhole/errors.py index 8d191b1..8bd9718 100644 --- a/src/wormhole/errors.py +++ b/src/wormhole/errors.py @@ -61,9 +61,6 @@ class ReflectionAttack(WormholeError): class InternalError(WormholeError): """The programmer did something wrong.""" -class WormholeClosedError(InternalError): - """API calls may not be made after close() is called.""" - class TransferError(WormholeError): """Something bad happened and the transfer failed."""