Commit Graph

83 Commits

Author SHA1 Message Date
Brian Warner
dce01174eb improve debug_set_trace: add Allocate and Input events
Also log events at the beginning and end of Input.choose_nameplate and
Input.choose_words, since those are the two big locally-driven (UI) triggers
that cause multiple messages to be fired and lots of work to happen.
2018-02-14 00:56:14 -08:00
Brian Warner
57352431ab define IDeferredWormhole, add methods to (internal) IWormhole
refs #153
2017-06-26 13:51:58 +01:00
Brian Warner
46a9c9eeb9 rewrite tor support
This shifts most reponsibility to the new txtorcon "Controller" object, where
it belongs. We no longer need a list of likely control-port locations, nor do
we need to keep track of the SOCKS port ourselves.

The one downside is that if a control-port is not reachable, then this does
not fall back to using a plain SOCKS port (usually tcp:localhost:9050).
txtorcon no longer uses txsocksx, so it no longer advertises a simple way to
use Tor without the control port. This shouldn't affect users who run the
TorBrowserBundle, or who are running a tor daemon which they can control
directly, but it may break for users who want to use a pre-existing tor
daemon that they don't have permissions to speak control-port to.
2017-05-24 16:49:06 -07:00
Brian Warner
7955a36bfd switch to new API
This renames all the existing API methods, to use a consistent
"d=get_XYZ()" (for Deferred mode) or "dg.wormhole_got_XYZ()" (for Delegated
mode). It updates cmd_send/cmd_receive/cmd_ssh to use the new API.

Since we now have get_welcome(), apps handle the Welcome message with a
Deferred callback instead of registering a "welcome handler". This lets us
make sure we've finished printing any server message-of-the-day or "you
should update your client" message to stdout before using stdio to ask for
the wormhole code. (Previously, the code-input prompt was overwritten by the
server message, and it was ugly). refs #145. This approach adds an extra
roundtrip to the receiver, but we can fix that (see #145 for details).

Because of that change, the server-is-being-slow message is printed at a
slightly different time, so those tests needed some extra work to exercise it
properly.
2017-05-15 02:13:24 -07:00
Brian Warner
ebe9df312e signal errors to w.when_code() waiters too
This fixes the case where "wormhole send" would wait forever (upon network
error) instead of terminating with a useful error message.

Testing this will have to wait until we land the branch that abandons the
wormhole if the first connection fails, since that's the easiest way to
provoke a network error before when_code() has fired.
2017-04-23 16:07:07 -04:00
Brian Warner
ef56336eab fix DelegatedWormhole 2017-04-19 10:50:24 -04:00
Brian Warner
323d5a896f debug_set_trace: include _SortedKey 2017-04-19 10:50:18 -04:00
Brian Warner
992db1846c minor TODO comments 2017-04-06 19:44:27 -07:00
Brian Warner
83e55f1f3e add w.when_key(), fix w.when_verified() to fire later
Previously, w.when_verified() was documented to fire only after a valid
encrypted message was received, but in fact it fired as soon as the shared
key was derived (before any encrypted messages are seen, so no actual
"verification" could occur yet).

This fixes that, and also adds a new w.when_key() API call which fires at the
earlier point. Having something which fires early is useful for the CLI
commands that want to print a pacifier message when the peer is responding
slowly. In particular it helps detect the case where 'wormhole send' has quit
early (after depositing the PAKE message on the server, but before the
receiver has started). In this case, the receiver will compute the shared
key, but then wait forever hoping for a VERSION that will never come. By
starting a timer when w.when_key() fires, and cancelling it when
w.when_verified() fires, we have a good place to tell the user that something
is taking longer than it should have.

This shifts responsibility for notifying Boss.got_verifier, out of Key and
into Receive, since Receive is what notices the first valid encrypted
message. It also shifts the Boss's ordering expectations: it now receives
B.happy() before B.got_verifier(), and consequently got_verifier ought to
arrive in the S2_happy state rather than S1_lonely.
2017-04-06 18:27:41 -07:00
Brian Warner
9717b67d1b comment out serialize() for now
until it's implemented fully
2017-04-06 12:27:06 -07:00
Brian Warner
7c6332b770 wormhole: comments 2017-04-06 12:22:45 -07:00
Brian Warner
a1f0d1bbf7 debug_set_trace(): cleanups, remove dead code 2017-04-06 12:22:45 -07:00
Brian Warner
76f5960517 rewrite welcome handler 2017-04-06 12:22:45 -07:00
Brian Warner
53a911cc80 finish Boss tests 2017-04-06 12:22:44 -07:00
Brian Warner
4bd9d3579c go back to "input_code" instead of "type_code" 2017-04-06 12:22:44 -07:00
Brian Warner
5f9894ca63 API updates, make most tests pass, disable others
* finally wire up "application versions"
* remove when_verifier (which used to fire after key establishment, but
  before the VERSION message was received or verified)
* fire when_verified and when_version at the same time (after VERSION is
  verified), but with different args
2017-04-06 12:22:44 -07:00
Brian Warner
aebee61816 fix close behavior: Deferreds should errback once closed 2017-04-06 12:22:44 -07:00
Brian Warner
ddb83e9d59 wormhole: handle w.close() after error-induced closure 2017-04-06 12:21:00 -07:00
Brian Warner
9ca657a7c6 reenable TorManager 2017-04-06 12:21:00 -07:00
Brian Warner
105d9cc59f work on WelcomeHandler, still incomplete 2017-04-06 12:21:00 -07:00
Brian Warner
e9f3107127 deliver app-versions up to Wormhole 2017-04-06 12:21:00 -07:00
Brian Warner
60a61c995b implement w.derive_key() 2017-04-06 12:21:00 -07:00
Brian Warner
c499fce9f5 change API (wormhole.create), start on serialization 2017-04-06 12:21:00 -07:00
Brian Warner
b7b8df17be rename NameplateLister to Lister (unique prefix L) 2017-04-06 12:21:00 -07:00
Brian Warner
610db612ba improve error handling
errors raised while processing a received message will cause the Wormhole to
close-with-error, and any pending Deferreds will be errbacked
2017-04-06 12:21:00 -07:00
Brian Warner
4793208d4e rewrite debug tracing, add to all machines 2017-04-06 12:21:00 -07:00
Brian Warner
41b7bcfed5 working on fixes 2017-04-06 12:21:00 -07:00
Brian Warner
b7df5e21eb more tests, still failing 2017-04-06 12:21:00 -07:00
Brian Warner
ef1904bc52 get null test working (open and immediate close) 2017-04-06 12:21:00 -07:00
Brian Warner
5d6989614b work on top-level stuff 2017-04-06 12:21:00 -07:00
Brian Warner
7e7b43e910 start on top-level driver, wormhole.py 2017-04-06 12:21:00 -07:00
Brian Warner
825370fdd2 cleanups, remove misc.py 2017-04-06 12:21:00 -07:00
Brian Warner
d4bedeafbf general fixes 2017-04-06 12:21:00 -07:00
Brian Warner
a2ed35ceb8 remove old files, lots of type work 2017-04-06 12:21:00 -07:00
Brian Warner
16c477424c more demo work 2017-04-06 12:21:00 -07:00
Brian Warner
3c9c0e58ab move to _connection.py, add more state machines
Starting on defining manager state machines for nameplates, mailboxes, the
PAKE key-establishment process, and the bit that knows it can drop the
connection when both nameplates and mailboxes have been released.
2017-04-06 12:21:00 -07:00
Brian Warner
14c8e76364 onConnect, start manual tests, doesn't work yet 2017-04-06 12:21:00 -07:00
Brian Warner
b826e8c73c hack args till they work, add ALLOW_CLOSE
the diagram is a lot simpler if the only way to shut things down is to
terminate the whole process
2017-04-06 12:21:00 -07:00
Brian Warner
d136028fa8 try adding args 2017-04-06 12:21:00 -07:00
Brian Warner
73f3d86107 state machine should be complete, I think 2017-04-06 12:21:00 -07:00
Brian Warner
b3763f9e78 show "you can use tabs" reminder if code was input without completion
refs #15
2017-01-12 16:14:42 -08:00
Brian Warner
62b069dea6 Wormhole: control stderr 2017-01-12 16:14:42 -08:00
Brian Warner
e500f4a100 rx: tolerate duplicate peer messages
closes #121
2016-12-26 15:27:14 -05:00
Brian Warner
face9423dd internals: ensure _API_establish_key is not called twice 2016-12-16 01:33:17 -08:00
laharah
01318d1130 added notification to cmd_receive plus reactor cleanup
Added a try finally block around verify to ensure notification
deferreds are being cleaned out of the reactor
2016-12-16 01:03:01 -08:00
laharah
a2ab1863cf added the new key waiter to be cleaned up on error in wormhole
Also, set new print statment to print to args.stdout
2016-12-16 01:03:01 -08:00
laharah
680b01b3fc added api hooks to get notification about key excange
added more coverage to establish key API hook
2016-12-16 01:03:01 -08:00
Brian Warner
cdb5c19010 websockets: turn on autoPingInterval to expire stale connections
With this, both clients and servers will send a PING at least once every
minute, and will drop connections that haven't seen any traffic for 10
minutes.

This should help keep NAT table entries alive, and will drop connections
that are no longer viable because their NAT entries have expired.

closes #60
2016-07-03 21:51:56 -07:00
meejah
7fab6b3dff Change UsageError -> InternalError, use click.UsageError for human-visible errors 2016-06-22 02:14:34 -06:00
meejah
e16b53817e Refactor to use Click 2016-06-22 01:11:07 -06:00