diff --git a/src/wormhole/cli/cmd_receive.py b/src/wormhole/cli/cmd_receive.py index 0c2c438..c15b458 100644 --- a/src/wormhole/cli/cmd_receive.py +++ b/src/wormhole/cli/cmd_receive.py @@ -76,18 +76,23 @@ class TwistedReceiver: # as coming from the "yield self._go" line, which wasn't very useful # for tracking it down. d = self._go(w) - d.addBoth(w.close) + @inlineCallbacks + def _close(res): + yield w.close() + returnValue(res) + d.addBoth(_close) yield d @inlineCallbacks def _go(self, w): yield self._handle_code(w) + verifier = yield w.when_verifier() def on_slow_connection(): print(u"Key established, waiting for confirmation...", file=self.args.stderr) notify = self._reactor.callLater(VERIFY_TIMER, on_slow_connection) try: - verifier = yield w.when_verifier() + yield w.when_version() finally: if not notify.called: notify.cancel() @@ -143,8 +148,10 @@ class TwistedReceiver: if code: w.set_code(code) else: + raise NotImplemented yield w.input_code("Enter receive wormhole code: ", # TODO self.args.code_length) + yield w.when_code() def _show_verifier(self, verifier): verifier_hex = bytes_to_hexstr(verifier) diff --git a/src/wormhole/cli/cmd_send.py b/src/wormhole/cli/cmd_send.py index 30436b8..337f314 100644 --- a/src/wormhole/cli/cmd_send.py +++ b/src/wormhole/cli/cmd_send.py @@ -57,7 +57,11 @@ class Sender: tor_manager=self._tor_manager, timing=self._timing) d = self._go(w) - d.addBoth(w.close) # must wait for ack from close() + @inlineCallbacks + def _close(res): + yield w.close() # must wait for ack from close() + returnValue(res) + d.addBoth(_close) yield d def _send_data(self, data, w): @@ -94,15 +98,20 @@ class Sender: args.stderr.flush() print(u"", file=args.stderr) + verifier_bytes = yield w.when_verifier() + # we've seen PAKE, but not yet VERSION, so we don't know if they got + # the right password or not + def on_slow_connection(): print(u"Key established, waiting for confirmation...", file=args.stderr) notify = self._reactor.callLater(VERIFY_TIMER, on_slow_connection) - # TODO: maybe don't stall on verifier unless they want it + # TODO: maybe don't stall for VERSION, if they don't want + # verification, to save a roundtrip? try: + yield w.when_version() # this may raise WrongPasswordError - verifier_bytes = yield w.when_verifier() finally: if not notify.called: notify.cancel()