Commit Graph

434 Commits

Author SHA1 Message Date
Brian Warner
bc6537e758 test_cli: ignore deprecation noise for py2.7/py3.5 so tests won't fail 2021-01-10 15:02:05 -08:00
sneakypete81
d4a2c70d52
Remove unused format parameters (#385)
Fixes pyflakes unused argument warning
2020-04-12 11:47:28 -07:00
Edward Betts
6477f239e8 Correct spelling mistakes 2020-02-20 11:13:36 +00:00
Brian Warner
0c43499850 test_transit: fix test to tolerate proper virtualized reactor 2020-02-06 22:48:25 -08:00
Brian Warner
5a60b247f5 accept 'wss' in relay_url, use TLS for those connections
Do the same under Tor.

If the hostname is missing, use 443 when using TLS, or 80 when not.

refs #144
2020-01-16 18:58:39 -08:00
Brian Warner
6be50a4f0a dilate/test_manager: tolerate Mock endpoints
This test was incorrectly exercising a member of the endpoint record returned
by `Manager.get_endpoints()`. In the test environment, the `.listen` Endpoint
is actually a Mock, so calling e.g. `listen()` on `endpoints.listen` returns
another Mock instead of a Deferred. Twisted's `assertNoResult` used to
tolerate this silently, but as of Twisted-19.10 it throws an error, causing
the test to fail.

The fix is to assert that the record has attributes with the right names, but
not assume they behave like normal Endpoints, and not call `.listen()` on
them.

closes #366
2019-12-20 17:03:00 -08:00
Brian Warner
d7e244740c tests: cover --verify too, at least for --text 2019-08-17 17:06:22 -07:00
Brian Warner
49c36b0277 dilation side needs to be 16-chars to match transit relay 2019-08-11 22:20:49 -07:00
Brian Warner
1219fd08ca subchannel: enforce separation between half-close and full-close API 2019-08-11 22:20:49 -07:00
Brian Warner
1c8c2997c7 subchannel: tolerate multiple pre-open inbound DATA messages 2019-08-11 22:20:49 -07:00
Brian Warner
327e72e6ac update subchannel state machine for half-close
also handle open-but-not-yet-connected subchannels better
2019-08-11 15:24:39 -07:00
Brian Warner
b233763082 subchannel: deliver queued connectionMade before any data
The previous implementation would call the control/receiving Protocol
completely backwards: dataReceived first, then connectionLost, then finally
connectionMade. Which didn't work at all, of course.
2019-08-11 14:20:33 -07:00
Brian Warner
4d57465444 oops, fix test_describe on py2 2019-08-11 14:19:25 -07:00
Brian Warner
16b6245f44 test describe_inbound, format IPv6 better 2019-08-11 14:10:29 -07:00
Brian Warner
b633602a02 update test_manager to match 2019-07-13 19:25:50 -07:00
Brian Warner
85cb003498 WIP: rewrite w.dilate API to return endpoints synchronously
test_manager still needs rewriting
2019-07-12 00:01:55 -07:00
Brian Warner
443d248972 manager: call inbound.set_listener_endpoint() before start()
This should fix the immediate issue of the remote side opening a
subchannel (and sending data on it) before the local side even sees the
Endpoints, so before it can register a listening factory to receive the OPEN.

We were already buffering early OPENs in the SubchannelListenerEndpoint, but
this makes sure that endpoint is available (for the manager's Inbound half to
deliver) them as soon as the dilation connection is established.

The downside to buffering OPENs (and all data written to inbound subchannels)
is that the application has no way to reject or pause them, until it
registers the listening factory. If the application never calls
`listen_ep.listen()`, we'll buffer this data forever (or until the wormhole
is closed). The upside is that we don't lose a roundtrip waiting for an ack
on the OPEN. See ticket #335 for more details.

refs #335
2019-07-08 01:12:39 -07:00
Brian Warner
d1aefa815d fix subchannel open/close, add test
I think I just managed to forget that inbound_close requires we respond with
a close ourselves. Also outbound open means we must add the subchannel to the
inbound table, so we can receive any data on it at all.
2019-07-06 01:50:29 -07:00
Brian Warner
8043e508fa make SubChannel IDs integers, not 4-bytes
I'm sure I had a good reason for avoiding integers, but it makes logging and
testing more difficult, and both sides are using integers to generate them
anyways (so one side can pick the odd ones, and the other can pick the even
ones).
2019-07-06 01:10:34 -07:00
Brian Warner
a74cc99e6a dilate: test sending data while the connection is offline 2019-07-05 23:16:25 -07:00
Brian Warner
ee8c1acffa dilate/test_full: test reconnection 2019-07-05 15:54:19 -07:00
Brian Warner
38f512e4cc open sc0 early, since messages can arrive attached to the KCM
Without this, the Follower would see data for subchannel 0 before it had a
chance to create the SubChannel object that could accept it. We already have
a mechanism for inbound data to be queued inside the SubChannel until the
endpoint has had a chance to create the Protocol object: we rely on that
mechanism here. We just need to create the SubChannel before telling the
Manager to start, even though we don't reveal the SubChannel to the
caller (via the control endpoint) until the connection is known to succeed.

This helps a manual test get data from one side to the other without throwing
exceptions.
2019-05-07 11:41:30 -07:00
Brian Warner
d612b58dd8 connection: tolerate merged KCM and first record
When the follower's connection is accepted, they'll observe a single
dataReceived chunk containing both the leader's KCM and the leader's first
actual data record. The state machine considers the KCM for an eventual-turn
before selecting the connection, so the data record will arrive while the
connection isn't quite ready for it (if consider() were immediate, this
wouldn't be a problem, but Automat doesn't deal with reentrant calls very
well). So we queue any records that arrive before we're selected.
2019-05-07 11:41:30 -07:00
Brian Warner
55056bd324 make no_listen= an argument to w.dilate() rather than create()
It wasn't exposed in create(), and I need it for more tests. This might not
be the best approach, I'll have to play with it a bit to tell.
2019-05-07 11:41:30 -07:00
Brian Warner
bc863de634 dilate/test_full: enable, it works now 2019-02-10 18:02:29 -08:00
Brian Warner
c27680b910 terminator: shut down Dilator after everything else stops
This makes w.stop() the right way to shut everything down including any
Dilator connections (in-progress, active, or in-shutdown).
2019-02-10 18:01:14 -08:00
Brian Warner
7f90999775 test_full: finish test, although it still fails 2019-02-10 16:59:07 -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
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
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
6bd7e85a53 test_transit sometimes fails with EADDRINUSE on travis 2019-02-10 11:22:04 -08: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
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