From 8b56892a76c88d48f33ff36d40eb26f4c7f569f6 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Wed, 25 May 2016 16:29:56 -0700 Subject: [PATCH] drop peer messages if we're closing This should remove a few Unhandled Errors when the code was wrong. --- src/wormhole/wormhole.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wormhole/wormhole.py b/src/wormhole/wormhole.py index b402e32..d239ed0 100644 --- a/src/wormhole/wormhole.py +++ b/src/wormhole/wormhole.py @@ -652,6 +652,8 @@ class _Wormhole: def _API_derive_key(self, purpose, length): if self._error: raise self._error + if self._key is None: + raise UsageError # call derive_key after get_verifier() or get() if not isinstance(purpose, type(u"")): raise TypeError(type(purpose)) return self._derive_key(to_bytes(purpose), length) @@ -674,6 +676,9 @@ class _Wormhole: # any message in the mailbox means we no longer need the nameplate self._event_mailbox_used() + if self._closing: + log.msg("received peer message while closing '%s'" % phase) + if phase == u"pake": return self._event_received_pake(body) if phase == u"confirm":