Commit Graph

273 Commits

Author SHA1 Message Date
Nick Mathewson f1eba83ebd Fix a few clippy warnings 2020-12-17 15:23:55 -05:00
George Kadianakis e4594810fc Handle an error in circuit.rs without crashing. 2020-12-17 21:16:49 +02:00
George Kadianakis 52afa87ecd Simplify RelayCellBody::recognized() method.
self is no longer mutable.

Co-authored-by: David Goulet <dgoulet@torproject.org>
2020-12-17 21:16:43 +02:00
Nick Mathewson cae16665cb Basic support for IPv6 and begin flags.
We now have a way to tell a circuitmgr whether we require ipv4/ipv6
support for a target address in an exit policy, and we use similar
logic to set begin flags.
2020-12-15 14:41:03 -05:00
Nick Mathewson 90fc798646 Fix some rustdoc warnings. 2020-12-09 09:46:39 -05:00
Nick Mathewson 26a0654b05 Make RSAIdentity implement Copy. 2020-12-08 17:07:30 -05:00
Nick Mathewson a1f1dac4eb Resolve a few nightly-only clippy issues 2020-12-07 16:14:36 -05:00
Nick Mathewson a52585d9d6 Mark some XXXX issues as XXXX-A1. 2020-12-07 16:07:59 -05:00
Nick Mathewson 01de0cafc5 Run cargo fix --edition-idioms 2020-12-02 15:14:29 -05:00
Nick Mathewson efa6dd708b Expose UniqId types for channels and circuits 2020-12-01 14:00:07 -05:00
Nick Mathewson ea0cb1d2cc Rename LogId -> UniqId. 2020-12-01 13:44:25 -05:00
Nick Mathewson 3fe97baa2a Derive more types for circuit and channel LogIds 2020-12-01 13:21:46 -05:00
Nick Mathewson 31773e0251 Enforce uniqueness on circuit and channel logids 2020-12-01 13:20:41 -05:00
Nick Mathewson e18b4e07cb Upgrade a couple of dependencies 2020-11-28 14:17:42 -05:00
Nick Mathewson 5188263429 Refactor first-hop handling types a bit
This lets us have the notion of "get the first hop of a path as some
kind of a chantarget", which will make it easier to write other path
types.
2020-11-17 16:46:23 -05:00
Nick Mathewson cb59ae3933 Move closed-check for circuits into an atomicbool. 2020-11-13 09:08:15 -05:00
Nick Mathewson 4a83f21ae9 Light refactoring on remaining ChannelImpl functions 2020-11-13 08:39:01 -05:00
Nick Mathewson 4b1ed6c39c Turn the channel "closed" method into an AtomicBool
This lets us make the test for closed channels non-async.
2020-11-13 08:34:30 -05:00
Nick Mathewson 11b257e1ae Move a few immutable fields from ChannelImpl outside the lock.
Since these don't change while the channel is alive, we don't need
the lock to protect them.
2020-11-13 08:17:36 -05:00
Nick Mathewson 6e5db3a0e7 Make Arc<>-ness of ClientCirc explicit. 2020-11-12 12:58:33 -05:00
Nick Mathewson ac174c7666 Make the Arc-ness of channels more explicit.
Previously every channel was a secret Arc<>, which I think is bad
style, and which stopped us from using weak references in other
places.
2020-11-12 12:34:50 -05:00
Nick Mathewson af16ec18a3 update some dependencies 2020-11-11 09:14:26 -05:00
Nick Mathewson 4d24fff9c0 Upgrade dependencies 2020-11-10 12:27:10 -05:00
Nick Mathewson 9c7ed1fdde upgrade a few packages. 2020-11-05 16:56:29 -05:00
Nick Mathewson c0f9d94b34 Refactor DataStream to be splittable, and have internal locking.
This lets me fix the deadlock in the proxy code.
2020-11-04 12:10:09 -05:00
Nick Mathewson 954108e0ee stream: Update to enable more fine-grained locking
Not sure this is quite right, or quite deadlock free, but it lets
us read/write cells on a stream we haven't locked.
2020-11-04 11:50:23 -05:00
Nick Mathewson 80b70881af Add a tiny bit of cleanup logic to tor-circmgr 2020-11-02 14:21:14 -05:00
Nick Mathewson fbbc14d4fb Tests for tor-chanmgr. 2020-10-30 15:45:53 -04:00
Nick Mathewson 8d8ce482c9 chanmgr: don't return closing channels. 2020-10-30 09:51:52 -04:00
Nick Mathewson f399851bcf Implement a channel-manager type to get or launch channels on request. 2020-10-30 09:51:31 -04:00
Nick Mathewson 67e39450fb Remove duplication of ipaddr argument in handshake. 2020-10-29 17:03:12 -04:00
Nick Mathewson f8d526a85a Function to check whether a channel matches a target. 2020-10-29 17:03:12 -04:00
Nick Mathewson 4cf972d69b tor-proto API: Use new_ref, not clone.
Semantically, cloning a Channel or Circuit is actually increasing an
internal reference count.  We should name the functions to reflect
that, to be more explicit about what we're doing.
2020-10-29 12:11:36 -04:00
Nick Mathewson 5989b843cc Add a simple test for stream creation. 2020-10-27 14:40:23 -04:00
Nick Mathewson 705d9c061f Add a test for extending a circuit with ntor. 2020-10-27 14:26:22 -04:00
Nick Mathewson 911185ec38 circuit: test meta-cell receiving 2020-10-27 13:41:31 -04:00
Nick Mathewson b90ca2acd7 Downgrade an XXXXM3 message. 2020-10-27 13:11:57 -04:00
Nick Mathewson f8e1e6976f Unify interface for detecting stream close. 2020-10-27 13:09:17 -04:00
Nick Mathewson 4cded7a05a Add a test for sending a cell. 2020-10-27 13:03:39 -04:00
Nick Mathewson 8f5d239c21 Expand test to handle building circuit with ntor. 2020-10-27 12:23:18 -04:00
Nick Mathewson 483425ba4b Make a test for create_firsthop_fast. WOW that was hard. 2020-10-27 11:55:24 -04:00
Nick Mathewson dcf0936396 Make circuit reactors also have a run_once() method for testing. 2020-10-27 11:54:11 -04:00
Nick Mathewson 5bd85e57ec Add a fake, reactorless channel, for use in testing circuits 2020-10-27 10:16:05 -04:00
Nick Mathewson e2f7fe3827 Remove use of Cell<> in tor_proto.
I was confused about what this was for, I guess.
2020-10-27 10:14:28 -04:00
Nick Mathewson 94042b60b8 Rename CircIDRange to CircIdRange 2020-10-27 09:51:28 -04:00
Nick Mathewson ee9ad7f59d Run "cargo upgrade". 2020-10-26 14:56:06 -04:00
Nick Mathewson b93e4b76c8 Remove a bunch of dbg! calls. 2020-10-26 14:33:14 -04:00
Nick Mathewson a796f7bf6a Use event_listener to find out about sendme replenishment.
Previously we would fail if a sendme window was exhausted and two
tasks were waiting for it to be replenished at the same time.
2020-10-26 14:25:46 -04:00
Nick Mathewson 4348faff3c Resolve a bunch of XXXM3 comments in tor-proto. 2020-10-26 14:03:25 -04:00
Nick Mathewson 4d9c08669e Improve documentation in tor-proto 2020-10-26 13:08:46 -04:00
Nick Mathewson db94abadcc rudimentary test for channelbuilder. 2020-10-26 09:29:59 -04:00
Nick Mathewson 1b86818085 Tests for sending bad/good cell types on a channel 2020-10-26 09:23:42 -04:00
Nick Mathewson 498bc3633d Clean up some XXXXs in channel::reactor.rs 2020-10-26 09:23:10 -04:00
Nick Mathewson 6d6cff5176 Tests for receving incoming DESTROY cell. 2020-10-26 09:06:52 -04:00
Nick Mathewson 937d924b0a channel::reactor: Tests for handling incoming RELAY cells 2020-10-26 09:06:52 -04:00
Nick Mathewson 46c991a087 Test for rejecting CREATED cells 2020-10-26 09:06:52 -04:00
Nick Mathewson 494c4679b5 Add a CircEnt::DestroySent circuit state.
A circuit enters DestroySent after it's sent a DESTROY cell. We use
this state to make sure that we don't receive too many cells on a
destroyed circuit, _and_ so that we don't block such cells
completely.
2020-10-26 09:06:52 -04:00
Nick Mathewson 32b025de1d Use better return type in advance_from_opening 2020-10-25 23:37:25 -04:00
Nick Mathewson 8c09981427 Use from_bytes name for Ed25519Identity 2020-10-25 20:32:47 -04:00
Nick Mathewson fa01a50f32 Rename CircID and StreamID to end with Id instead, for consistency 2020-10-25 20:29:01 -04:00
Nick Mathewson fbf200ae6f Add some tests for channel reactor and related code. 2020-10-25 15:09:06 -04:00
Nick Mathewson 0e91d97f76 Add a test for running and shutting down reactors.
This took a long time since I needed to learn about futures and
executors, but I think it'll work out okay.
2020-10-25 14:12:51 -04:00
Nick Mathewson e20bfaab0f channel: Refactor the point when we split the framed codec.
We used to do this during creating the channel in Channel::new, but
now we do it one step before, so that it's easier to construct
channels for testing.
2020-10-25 12:42:53 -04:00
Nick Mathewson 510a27f2d3 channel: Move looping part of run_impl() into run().
This lets us turn run-impl() into a run_once() function for easier
testing.
2020-10-25 12:06:36 -04:00
Nick Mathewson d1e5d54c24 Move cell logging into ChannelImpl 2020-10-23 10:19:56 -04:00
Nick Mathewson e1b741f0fc circuit: Remove the needlessly separated ReactorCore type. 2020-10-23 09:49:33 -04:00
Nick Mathewson 913db08384 channel: Remove the needlessly separated ReactorCore type. 2020-10-23 09:47:40 -04:00
Nick Mathewson 9ef63a01e3 Test for finish-handshake function 2020-10-23 09:04:10 -04:00
Nick Mathewson b80b0b7019 handshake: tests for invalid signatures 2020-10-23 08:52:21 -04:00
Nick Mathewson 9b46f04f58 Add tests for handshakes certifying the wrong thing 2020-10-23 08:45:40 -04:00
Nick Mathewson 04f22a122e Tests for handshakes with missing certs
Also handle tor_cell::Error::ChanProto better.
2020-10-23 08:34:35 -04:00
Nick Mathewson f13c759f0f Use an enum for the return value of StreamMap::terminate 2020-10-22 13:42:45 -04:00
Nick Mathewson 2de91b1c16 Initial tests for tor_proto::circuit::streammap 2020-10-22 13:35:18 -04:00
Nick Mathewson b5f019ccf1 Tests for tor_proto::circuit::halfstream 2020-10-22 12:36:39 -04:00
Nick Mathewson 60e7d3f3c1 tor-proto: Add tests for circuit::sendme 2020-10-22 12:07:28 -04:00
Nick Mathewson 19c48a2de5 Add tests for tor_proto::circuit::celltypes 2020-10-21 17:59:58 -04:00
Nick Mathewson 9d1c279f65 Test a trivial succeeding case of link cert validation 2020-10-21 15:40:58 -04:00
Nick Mathewson 11cd138c74 Fix a security issue (!) in link handshake validation.
When making sure that the peer had the right RSA identity, we
were comparing the RSA identity with itself, not with the RSA
identity we expected.

Found via unit testing (!).
2020-10-21 15:37:55 -04:00
Nick Mathewson 53c27f7956 Infrastructure for testing handshake cert-validation code 2020-10-21 14:48:19 -04:00
Nick Mathewson 48d0984d2f More tests for handshake connect function 2020-10-21 14:09:20 -04:00
Nick Mathewson e0344dd78b Start a basic test for the first part of the handshake. 2020-10-21 14:09:20 -04:00
Nick Mathewson a94dc1c7f1 LogId test: tolerate concurrent tests. 2020-10-21 14:09:20 -04:00
Nick Mathewson b528c914ff Start on some tests for pieces of tor-proto::channel 2020-10-21 12:45:36 -04:00
Nick Mathewson 3f3e98d190 Follow API convention about mutable getters.
They're supposed to be called field_mut().
2020-10-21 08:12:46 -04:00
Nick Mathewson 743c3167e8 Rename as_message to into_message.
According to the API guidelines, "as_" is only for
borrowed->borrowed conversions.
2020-10-21 08:05:33 -04:00
Nick Mathewson 486693115a Add a close() method for streams 2020-10-20 14:46:59 -04:00
Nick Mathewson 425ee8376b Add new `terminate()` method to circuits and channels.
These aren't called "close" because they're more destructive than
that: they can be called even if other parties are using the circuit
or channel.

This is for arti#21.
2020-10-20 14:28:44 -04:00
Nick Mathewson c554db9881 Missing file and docs 2020-10-20 13:46:43 -04:00
Nick Mathewson 6e5d248418 Add a TODO for register_meta_handler API 2020-10-20 13:41:34 -04:00
Nick Mathewson 4f567e4a94 Work on closing flooding-based side-channels
We need to make sure that we're dropping cells that we don't
recognize or want, so that we can't be flooded with bogus junk.
2020-10-20 13:22:16 -04:00
Nick Mathewson b0cdd025a1 Add some helpful logs in circuit code. 2020-10-20 12:40:08 -04:00
Nick Mathewson 7ce158ed1e Add reasonable logging (I hope!) to channel 2020-10-20 11:45:53 -04:00
Nick Mathewson 1dc3fc214a Implement From, not Into.
These traits are inverses of one another, but implementing From is
always preferred since rust 1.41 relaxed the "orphan rules".
2020-10-19 17:40:43 -04:00
Nick Mathewson c7a2efe72b Add and use remaining CertType values in tor-cert 2020-10-19 14:17:25 -04:00
Nick Mathewson 378aa6d639 Add an enumeration for destroy reasons. 2020-10-19 13:13:55 -04:00
Nick Mathewson 295a791a82 Improvements to Relay type in tor-netdir.
Now, a Relay is always valid.  This required some changes to the
API: all_relays() has to return a new UncheckedRelay type that might
or might not be valid, and the functions on Relay and ChanTarget
that return ed25519 identities need to return an Ed25519Identity,
not an ed25519::PublicKey.

This change required some new encoding/decoding/conversion functions
on Ed25519Identity.
2020-10-19 09:22:49 -04:00
Nick Mathewson 5523134607 Mark must-resolve XXXX issues with "XXXXM3".
"M3" is for "milestone 3" -- my target to fix the technical debt
that I think will be bad if we ship even a pre-alpha with it.

These aren't necessarily _all_ must-resolve, but they're all
must-look-at.

Closes #15
2020-10-18 17:38:59 -04:00
Nick Mathewson 5173ee960f tor-proto: Add a ClientCircChanMsg type.
This wraps exactly the ChanMsg values that are valid on open client
circuits, so that we can be sure that only those cells are sent to a
ClientCirc's reactor.
2020-10-15 14:23:12 -04:00
Nick Mathewson 34962c3c9f tor-proto: Add a "CreateResponse" type.
CreateResponse includes exactly those cells that are a correct
response to a CREATE2/CREATE_FAST, so we can be sure that only those
cells are actually passed to a PendingClientCirc.
2020-10-15 14:09:19 -04:00
Nick Mathewson 3408c9ad26 Run "cargo upgrade". 2020-10-15 13:32:02 -04:00