Commit Graph

1012 Commits

Author SHA1 Message Date
Brian Warner
7f90999775 test_full: finish test, although it still fails 2019-02-10 16:59:07 -08:00
Brian Warner
53ad951c11 DilatedConnectionProtocol/Role: prettier repr 2019-02-10 16:57:16 -08:00
Brian Warner
ebc63e52e0 add description to inbound connections 2019-02-10 16:52:17 -08:00
Brian Warner
74c416517f scids are four-byte strings, not integers
be consistent about it
2019-02-10 16:23:20 -08:00
Brian Warner
2ec7b8e662 update_ack_watermark takes seqnum, not record 2019-02-10 16:22:30 -08:00
Brian Warner
bf25dc68cf connector: use disconnect(), not loseConnection() 2019-02-10 15:57:55 -08:00
Brian Warner
0c9d2c927a fix hashability of dilation objects 2019-02-10 15:57:39 -08:00
Brian Warner
e4264971d7 add dilate/test_full, still failing 2019-02-10 11:51:54 -08:00
Brian Warner
a2a149946b test_connect: skip integration test when Noise is unavailable 2019-02-10 11:51:54 -08:00
Brian Warner
7f03adda3a dilate.test_connect: basic integration test
This mocks out the mailbox connection, and makes sure that endpoints are
constructed.
2019-02-10 11:51:54 -08:00
Brian Warner
059338a257 Add Dilator.stop(), fix delivery of connection made/lost messages
Dilator.stop() now shuts everything down, and returns a Deferred when it all
stops moving. This needed some Manager state machine changes (to notify
Dilator when it enters the STOPPED state). This also revealed problems in the
delivery of connector_connection_made() (which was misnamed) and
connector_connection_lost() (which wasn't being called at all).
2019-02-10 11:51:54 -08:00
Brian Warner
39fed50071 add no_listen=False to Manager and Dilator
This is only used by tests so far (and will simplify the integration test
that hasn't landed yet), but is not yet wired up to Boss, so there's no way
for applications to enable it yet.
2019-02-10 11:51:54 -08:00
Brian Warner
64618bcb64 manager: tidy up repr, leave out keys and some other fields 2019-02-10 11:51:54 -08:00
Brian Warner
b538dd6758 dilation.outbound: registerProducer goes on transport, not Protocol 2019-02-10 11:51:54 -08:00
Brian Warner
53ffbe1632 fix Noise handshake ordering
I mistakenly believed that Noise handshakes are simultaneous. In fact, the
Responder waits until it sees the Initiator's handshake before sending its
own. I had to update the Connection state machines to work this way (the
Record machine now has set_role_leader and set_role_follower), and update the
tests to match.

For debugging I added a `_role` property to Record, but it should probably be
removed.
2019-02-10 11:51:54 -08:00
Brian Warner
d1ff97f988 make some dilation objects hashable
necessary to include them in a set like _pending_connectors
2019-02-10 11:51:54 -08:00
Brian Warner
be2dc01a94 wormhole.py: add debug switch to enable dilation (for tests) 2019-02-10 11:47:28 -08:00
Brian Warner
6bd7e85a53 test_transit sometimes fails with EADDRINUSE on travis 2019-02-10 11:22:04 -08:00
Brian Warner
4083beeb6c wormhole.py: disable dilate() API until ready
more importantly, turn off the "we can do Dilation" advertisement for now,
since we really can't
2018-12-24 14:34:02 -05:00
Brian Warner
29c269ac8d get tests to work on py2.7
only install 'noiseprotocol' (which is necessary for dilation to work) if the
"dilate" feature is requested (e.g. `pip install magic-wormhole[dilate]`)
2018-12-24 00:07:06 -05:00
Brian Warner
a458fe9ab9 finish test coverage/fixes for connector.py 2018-12-23 15:23:27 -05:00
Brian Warner
6ad6f8f40f test and fix half of connector.py
still to do:

* relay delays
* connection race
* cancellation of losing connections
* shutdown of all connections when abandoned
2018-12-23 15:23:27 -05:00
Brian Warner
e7cb1df785 factor out HKDF 2018-12-23 15:23:27 -05:00
Brian Warner
b4c90b40a2 move parse_hint/encode_hint into _hints.py, add tests 2018-12-23 15:23:27 -05:00
Brian Warner
d64c94a1dc test_hints: finish coverage of hints.py 2018-12-23 15:23:27 -05:00
Brian Warner
1bb5634d0e factor Hints tests out of test_transit into a new file 2018-12-23 15:23:27 -05:00
Brian Warner
7720312c8f factor out parse_tcp_v1_hint 2018-12-23 15:23:27 -05:00
Brian Warner
2f4e4d3031 factor out describe_hint_obj and endpoint_from_hint_obj 2018-12-23 15:23:27 -05:00
Brian Warner
bd1a199f3e start factoring Hints out to separate file
shared between old transit.py and new _dilation/connector.py
2018-12-23 15:23:27 -05:00
Brian Warner
3b7c9831f6 appease flake8 somewhat 2018-12-23 15:23:27 -05:00
Brian Warner
40dadfeb71 finish fixing/testing manager.py 2018-12-23 15:23:27 -05:00
Brian Warner
e55787c693 get most of Manager working and tested
still need to test the subchannel interfaces, and ping/pong/kcm
2018-12-23 15:23:27 -05:00
Brian Warner
78358358bc manager: hush flake8 2018-12-23 15:23:27 -05:00
Brian Warner
7084cbcb6f test_manager: fix 2018-12-23 15:23:27 -05:00
Brian Warner
a4234cdecf test_machines: fix for change to got_wormhole_versions 2018-12-23 15:23:27 -05:00
Brian Warner
8a1a8b1f9c manager: factor out make_side for testing and override 2018-12-23 15:23:27 -05:00
Brian Warner
7e168b819e manager: clean up versions, merge state machines 2018-12-23 15:23:27 -05:00
Brian Warner
d4a551c6b8 boss: remove sides from call to D.got_wormhole_versions() 2018-12-23 15:23:27 -05:00
Brian Warner
74e5d9948b move old-follower.py out of src, kept for temporary reference 2018-12-23 15:23:27 -05:00
Brian Warner
a594a85427 Revert "Boss/Receive: add 'side' to got_message"
This reverts commit 1fece5701c9de5e470526d2e7e9cfd7b461977e0.
2018-12-23 15:23:27 -05:00
Brian Warner
d65fcaa1a6 more flake8 fixes 2018-12-23 15:22:57 -05:00
Brian Warner
5f61531445 more flake8 fixes, in wormhole.py and _interfaces.py 2018-12-23 15:22:57 -05:00
Brian Warner
bf0c93eddc more flake8 fixes 2018-12-23 15:22:57 -05:00
Brian Warner
05900bd08b fix some flake8 complaints 2018-12-23 15:22:57 -05:00
Brian Warner
34686a346a add dilation code
(this compresses several months of false starts and rearchitecting)
2018-12-23 15:21:08 -05:00
Brian Warner
cd6ae6390f _rendezvous: add note to use EventualQueue 2018-12-23 15:20:25 -05:00
Brian Warner
6cfabba31a add reactor/cooperator to Wormhole and Boss calls 2018-12-23 15:20:25 -05:00
Brian Warner
a693b1fc48 Boss/Receive: add 'side' to got_message
this will be used later by Dilation
2018-12-23 15:20:25 -05:00
Brian Warner
e260369be1 __main__.py: stop breaking automat-visualize 2018-12-23 15:20:24 -05:00
Brian Warner
eb7c04e366 observer.py: add EmptyableSet 2018-12-23 15:18:38 -05:00
Brian Warner
e6b4ccb565 Merge branch 'pr318' 2018-12-09 14:28:56 -08:00
Edward Betts
010d1843c0 Correct spelling mistakes 2018-11-23 07:38:21 +00:00
Mario Rodas
504ddb0d91 Add inlineCallbacks decorator to test_wormholes testcase 2018-11-19 23:38:29 -05:00
Brian Warner
4e97bb041a fix/hush some flake8 warnings
test_ipaddrs.py had an invalid regexp, caught by the latest version of flake8

The new flake8 complains about both W503 (line break inside a conditional
before a binary operator) and W504 (line break *after* the operator). I think
break-before is the new preferred style, but for now I'm just going to ignore
them both and leave the code alone.
2018-11-13 10:21:41 -08:00
Brian Warner
74da87bec2 change __main__.py to use relative imports
This should fix `python -m wormhole` on py2. Closes #315.
2018-11-13 09:59:36 -08:00
Brian Warner
6d4eb8e69b add test_keys to nail down symmetric encryption format
This establishes what our mailbox protocol does to encrypt the
individual (post-SPAKE2) messages, which combines NaCl SecretBox and our own
key-derivation choices. I'd like to move off of NaCl/libsodium and I think
some RFC7539-implementing library might be compatible, and with these test
vectors I can check that. I also want to copy these tests into the Rust port.
2018-08-21 10:12:23 -07:00
Brian Warner
4531513602 cmd_send/receive: work around python3.7.0 bug
See https://bugs.python.org/issue26175 . tempfile.SpooledTemporaryFile
doesn't fully implement the IOBase abstract class, which breaks because
py3.7.0's new zipfile module tries to delegate .seekable down to the wrapped
file and causes an AttributeError.

refs #306
2018-07-01 14:27:32 -07:00
Brian Warner
41fabd39ba test_machines: remove no-longer relevant comment
The flake8 config excludes E741, which would complain about using
'l' (lower-case ell) as a variable name. We use this for the Lister object in
one test that uses single-character variable names for all the machines ('b'
for Boss, 'm' for Mailbox, etc). That comment was added before excluding
E741. If we ever restore that warning, we might want to rename the variable.
2018-06-16 16:33:27 -07:00
Brian Warner
fc177726e1 cli.py: move timing check back to top
We care about how long it takes to import all the wormhole-specific things,
to investigate user-perceived latency from the time the command is launched
to the time they can actually interact with it. So we need to record
`time.time()` before doing the rest of the imports, even though pep8 says all
imports should be done before any non-importing statements.
2018-06-16 16:27:11 -07:00
Brian Warner
1444e32746 extreme measures to appease last pep8 complaint
a singly-parenthesized 'if' condition will always line up with the 'then'
body, won't it
2018-06-16 16:22:40 -07:00
Brian Warner
dada79d85c fix remaining pep8 complaints 2018-06-16 16:19:38 -07:00
Brian Warner
b5b8cd1260 Merge branch 'master' into pr296 2018-06-16 16:09:38 -07:00
Thomas Waldmann
a333a02366 use pyinstaller to build wormhole fat/standalone binary
tested with/on:
- ubuntu linux 18.04 amd64
- pyinstaller 3.3.1 (pip install pyinstaller)
- python 3.6.5

There is a good chance it also works on FreeBSD, maybe also on macOS.

The change in __main__.py was required because otherwise it complains about
__main__ not being a package when trying the dot-relative import.
2018-06-02 18:05:45 +02:00
Vasudev Kamath
12dcd6a184 Make code pep-8 compliant 2018-04-21 13:00:08 +05:30
Brian Warner
5c84f6a373 wormhole: slightly different way to unicode-encode the version
(this is somewhat more in line with how this distinction is made elsewhere in
the code)
2018-04-03 17:10:46 -07:00
Brian Warner
0dd3a12546 cosmetic changes, remove debug print 2018-04-03 17:05:33 -07:00
Baime
1197e5fb6d fix py 3.x versioneer issue 2018-03-23 18:19:31 +01:00
Baime
e77a2d605b bind passes tuple, fixed implementation issues 2018-03-23 17:33:48 +01:00
Baeumla
82dc4a4e2e py 2.7 3.x fix 2018-03-09 10:20:03 +01:00
Baeumla
0322d341e8 py 2.7 fix 2018-03-09 09:31:59 +01:00
Baeumla
4f8aa5a69e report clinet version on bind 2018-03-08 11:54:27 +01:00
Brian Warner
be47f53e7c wormhole: switch to observers for all APIs
Tests can pass an EventualQueue into wormhole.create(), to override the
default. This lets the tests flush the queue without using a haphazard
real-time delay.

closes #23

(in fact, we added multiple-Deferreds-per-API a while ago, but this does it
in a much cleaner fashion, and with the safety of an eventual-send)
2018-02-26 17:50:40 -08:00
Brian Warner
caabb3510c add OneShotObserver and SequenceObserver, with tests
This factors out the various "give me a Deferred for an value that may or may
not eventually be successfully generated" routines in _DeferredWormhole. It
uses an eventual-send to fire the Deferreds to avoid plan-coordination
hazards when the attached callbacks then call back into the Wormhole object
before the rest of the state transition has finished.
2018-02-26 17:50:40 -08:00
Brian Warner
43965d5289 add eventual-send queue
We defer starting a new timer until we've completely emptied the queue, since
we know we'll get to any new events added inside one of our callbacks. The
old design in Foolscap (which copied the list, cleared the original, then
fired everything in the copy) didn't look at these new events. OTOH, this
pop(0)-until-empty approach makes it easier to get into an infinite loop (any
callback which queues a new callback will get priority over anything else).
But the code is simpler.
2018-02-26 17:50:40 -08:00
Brian Warner
1c21119a73 add test_ipaddrs, adapted from tahoe's test_iputil 2018-02-22 21:32:44 -08:00
Brian Warner
9cb763e83a add "pragma: no cover" to set_trace() and debug code
we've got some tests to exercise this, so it shouldn't bitrot completely, but
there are some branches-not-taken warnings that I think are spurious
2018-02-22 09:42:43 -08:00
Brian Warner
e7d0dbbb88 oops, typo 2018-02-21 01:57:07 -08:00
Brian Warner
9ae2307a72 fix tests 2018-02-21 00:38:19 -08:00
Brian Warner
37a7ed7adc WIP: remove unused server tests, minor syntax fixes. still fails. 2018-02-20 23:54:28 -08:00
Brian Warner
9957044a99 WIP: start replacing ServerBase with imported server
doesn't work yet at all
2018-02-20 23:46:29 -08:00
Brian Warner
77201966b4 remove server-related source files, munin plugins
setup.py: pin to magic-wormhole-mailbox-server 0.1.0, the current version
2018-02-20 23:46:29 -08:00
Brian Warner
d42ac47ac8 let tests override KEY_TIMER/VERIFY_TIMER to tolerate slow test hosts
I've seen intermittent failures in
test_cli.PregeneratedCode.test_text_subprocess where the host was slow (or
overloaded) enough that the "Waiting for sender.." pacifier message was
displayed, which flunks the test because we're looking for a specific output
string. We patch this 1-second timer in the non-subprocess tests, but you
can't patch across a process boundary.

This patch adds an undocumented environment variable that lets you override
the timer values. The test then sets it to something large.

For future consideration: another approach would be to change the test to
tolerate the extra message. This would be trickier to validate, though.
2018-02-20 18:14:57 -08:00
Brian Warner
6061ec7869 _key: note places where we should use eventual-send
This will be necessary to avoid reentrancy hazards, in case the application
code makes other wormhole API calls from the callbacks for
get_unverified_key(), get_verifier(), or get_message().
2018-02-14 02:12:33 -08:00
Brian Warner
af406a600e _rlcompleter: use blockingCallFromThread for all Helper APIs
We were missing two (the calls to choose_nameplate() and choose_words() that
happen after the input() function has finished, but while we're still inside
the thread that makes it safe for input() to block). This almost certainly
caused the crash seen in issue #280.

Update the tests to match: CodeInputter.finish must now be called with
deferToThread from inside tests, or the internal blockingCallFromThread must
be stubbed out.
2018-02-14 01:13:30 -08:00
Brian Warner
3847339f43 _input: reject attempts to call Helper from a non-main thread
This causes two threads to use the reactor at the same time, with horrible
results. The _rlcompleter code currently violates this requirement, causing
occasional failures if the messages arrive in just the wrong way (refs #280).
2018-02-14 00:56:18 -08:00
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
c6fbaf5a4d _version.py: hush lgtm.com alert
This needs to be upstreamed into Versioneer, as it will disappear the next
time we upgrade.
2018-01-02 08:19:08 +01:00
Brian Warner
624072c111 hush more lgtm.com -discovered static-analysis problems 2018-01-02 08:18:45 +01:00
Brian Warner
443c402f60 remove WormholeClosedError, simplify control paths in cmd_send/receive
lgtm.com noticed some unreachable code paths, and it turns out that nothing
in the rest of the code base could ever raise WormholeClosedError (I guess it
was leftover from before the big API refactoring). Both sender and receiver
are simpler without the unnecessary checks and state variables.
2018-01-01 16:56:18 +01:00
Brian Warner
e13f3e3e13 hush some unreachable-code errors found by lgtm.com
This comments out some "if 0: debug()" stuff I keep around to investigate
problems, since lgtm thinks of it as accidentally-unreachable code.

I also deleted a server usage command
entirely (src/wormhole/server/cmd_usage.py show_usage) which was disabled
while I rewrote that schema: the new plan is to move the server into a new
repository altogether, and use a completely different approach to the
usage database.
2018-01-01 16:53:18 +01:00
Brian Warner
67253bde55 test_cli: make timers more reliable
A slow Travis-CI host caused one the 1.0s KEY_TIMER to fire by accident,
making the test fail because it wasn't expecting to see the "please be
patient" message. Fixed this by increasing the timeout to a very large value
when we aren't explicitly testing it.
2017-12-19 13:41:05 -08:00
Brian Warner
c7c7c0381c update -0 and --text output too 2017-12-19 12:54:16 -08:00
David Harrigan
9b1f99b994 Change the send command output to help copy and pasting to others
A tiny update to show the command to execute along with the code required on
the same line, rather than split across two lines. This small change helps
when sending the information to others using copy and paste.

Fixes #266

-=david=-
2017-12-14 21:13:12 +00:00
Brian Warner
1bbd756fa6 test_transit: fix the miscaptured-loop-variable bug I always make 2017-12-01 13:00:05 -08:00
Brian Warner
8a7c6faf4a more test simplification with assertNoResult 2017-11-29 16:54:03 -06:00
Brian Warner
8227d963a3 test_transit: simplify by using successResultOf/failureResultOf 2017-11-29 15:03:03 -06:00
Brian Warner
d87792a7c7 finish removing Transit from code and CLI command args 2017-11-13 12:03:21 -08:00
Brian Warner
a804365536 remove most of Transit server, use external package instead 2017-11-13 11:34:17 -08:00
Brian Warner
d1a829d86f server.py: tolerate (disabled) --transit=
We were unconditionally asking the Transit server object for get_stats(),
which doesn't work if there isn't one.
2017-11-07 20:50:40 -06:00
Brian Warner
1c5f29337e add notes, make test TODO instead of SKIP 2017-11-01 17:46:09 -07:00