make cmd_send/cmd_receive basically work again
This commit is contained in:
parent
e9f3107127
commit
8ee342ad82
|
@ -76,18 +76,23 @@ class TwistedReceiver:
|
||||||
# as coming from the "yield self._go" line, which wasn't very useful
|
# as coming from the "yield self._go" line, which wasn't very useful
|
||||||
# for tracking it down.
|
# for tracking it down.
|
||||||
d = self._go(w)
|
d = self._go(w)
|
||||||
d.addBoth(w.close)
|
@inlineCallbacks
|
||||||
|
def _close(res):
|
||||||
|
yield w.close()
|
||||||
|
returnValue(res)
|
||||||
|
d.addBoth(_close)
|
||||||
yield d
|
yield d
|
||||||
|
|
||||||
@inlineCallbacks
|
@inlineCallbacks
|
||||||
def _go(self, w):
|
def _go(self, w):
|
||||||
yield self._handle_code(w)
|
yield self._handle_code(w)
|
||||||
|
verifier = yield w.when_verifier()
|
||||||
def on_slow_connection():
|
def on_slow_connection():
|
||||||
print(u"Key established, waiting for confirmation...",
|
print(u"Key established, waiting for confirmation...",
|
||||||
file=self.args.stderr)
|
file=self.args.stderr)
|
||||||
notify = self._reactor.callLater(VERIFY_TIMER, on_slow_connection)
|
notify = self._reactor.callLater(VERIFY_TIMER, on_slow_connection)
|
||||||
try:
|
try:
|
||||||
verifier = yield w.when_verifier()
|
yield w.when_version()
|
||||||
finally:
|
finally:
|
||||||
if not notify.called:
|
if not notify.called:
|
||||||
notify.cancel()
|
notify.cancel()
|
||||||
|
@ -143,8 +148,10 @@ class TwistedReceiver:
|
||||||
if code:
|
if code:
|
||||||
w.set_code(code)
|
w.set_code(code)
|
||||||
else:
|
else:
|
||||||
|
raise NotImplemented
|
||||||
yield w.input_code("Enter receive wormhole code: ", # TODO
|
yield w.input_code("Enter receive wormhole code: ", # TODO
|
||||||
self.args.code_length)
|
self.args.code_length)
|
||||||
|
yield w.when_code()
|
||||||
|
|
||||||
def _show_verifier(self, verifier):
|
def _show_verifier(self, verifier):
|
||||||
verifier_hex = bytes_to_hexstr(verifier)
|
verifier_hex = bytes_to_hexstr(verifier)
|
||||||
|
|
|
@ -57,7 +57,11 @@ class Sender:
|
||||||
tor_manager=self._tor_manager,
|
tor_manager=self._tor_manager,
|
||||||
timing=self._timing)
|
timing=self._timing)
|
||||||
d = self._go(w)
|
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
|
yield d
|
||||||
|
|
||||||
def _send_data(self, data, w):
|
def _send_data(self, data, w):
|
||||||
|
@ -94,15 +98,20 @@ class Sender:
|
||||||
args.stderr.flush()
|
args.stderr.flush()
|
||||||
print(u"", file=args.stderr)
|
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():
|
def on_slow_connection():
|
||||||
print(u"Key established, waiting for confirmation...",
|
print(u"Key established, waiting for confirmation...",
|
||||||
file=args.stderr)
|
file=args.stderr)
|
||||||
notify = self._reactor.callLater(VERIFY_TIMER, on_slow_connection)
|
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:
|
try:
|
||||||
|
yield w.when_version()
|
||||||
# this may raise WrongPasswordError
|
# this may raise WrongPasswordError
|
||||||
verifier_bytes = yield w.when_verifier()
|
|
||||||
finally:
|
finally:
|
||||||
if not notify.called:
|
if not notify.called:
|
||||||
notify.cancel()
|
notify.cancel()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user