summaryrefslogtreecommitdiff
path: root/crates/tor-proto/src/circuit
Commit message (Collapse)AuthorAgeFilesLines
* proto: Tweak documentation and names around CmdChecker.Nick Mathewson2023-02-272-1/+17
|
* tor-proto: Rename end_received.Nick Mathewson2023-02-172-8/+9
| | | | It can now indicate _any_ cell that means we can forget about a stream.
* Use CmdChecker in our stream handling code.Nick Mathewson2023-02-173-93/+80
| | | | | | | | | | This change makes sure that open streams and half-closed streams have the same stream-type-dependent state machines with respect to which cells are acceptable. Fixes #774. Fixes #769.
* tor-proto: Add a TODO about simplifying a common pattern.Nick Mathewson2023-02-151-0/+8
|
* tor-proto: Push stream message parsing into the stream objects.Nick Mathewson2023-02-153-20/+21
| | | | | This closes #525, and ensures, at last, that we don't parse any message that we wouldn't accept.
* tor-proto: Defer parsing of messages send to half-closed streamsNick Mathewson2023-02-153-42/+94
| | | | | | This includes a partial solution for #769, but also turned up another bug (#774) while I was working on it. I'll close them both once I have a real solution.
* tor-proto: stop reactor (and kill circuit) if meta handler failsNick Mathewson2023-02-151-4/+7
| | | | | | | If the meta handler reports an error, then the circuit has violated its protocol, and needs to be shut down. Fixes #773.
* tor-proto: defer meta-cell parsing to the last moment.Nick Mathewson2023-02-151-33/+23
|
* tor-proto: Use UnparsedRelayCell to start deferring cell processing.Nick Mathewson2023-02-152-22/+43
| | | | | In general, we want to avoid parsing these cells until we are fairly sure that they are something we would accept.
* tor-cell: Refactor relay cells to copy much lessNick Mathewson2023-02-151-2/+2
| | | | | | | | | | | | | We now manipulate raw relay cell bodies as (an alias for) `Box<[u8;509]>` rather than as (an alias for) `[u8;509]`. This enables us to do much less copying. It will become more important soon, as we defer parsing relay cell bodies even longer. Related to #7. We also use SliceWriter to avoid allocating a Vec<> for every relay message we want to encode, and instead encode directly into the cell.
* tor-cell: Make RelayEarly a separate type.Nick Mathewson2023-02-092-4/+4
| | | | This allows us to remove a shenanigan from `restricted_msg!{}`.
* tor-cell: Have restrict_msg add conversion functions.Nick Mathewson2023-02-091-2/+2
| | | | | | | | | | | | | | | | Every FooMsg type now implements Into<AnyFooMsg>, and TryFrom<FooMsg>. Additionally, it now implements From<X> for every distinct type that it supports. This last part lets us discard a bunch of code. Unfortunately, I needed some downright hackish trickery in order to get these macros to avoid generating `From<AnyFooMsg> for AnyFooMsg` and conflicting with the blanket implementation. The trickery to deal with RelayEarly and Relay being the same type was not necessarily worth it; I will be separating them and removing said trickery in the next commit.
* tor-cell: Rename RelayMsg and RelayCell-related types.Nick Mathewson2023-02-074-48/+54
| | | | Thanks to rust-analyzer for making this simple.
* tor-cell: Rename ChanMsg and ChanCell-related types.Nick Mathewson2023-02-072-27/+27
|
* tor-cell: Remove RelayMsg methods that are duplicated in RelayMsgClass.Nick Mathewson2023-02-072-2/+2
|
* tor-cell: Remove ChanMsg methods that are duplicated in ChanMsgClass.Nick Mathewson2023-02-072-2/+5
|
* Allow clippy::unchecked_duration_subtraction in testsNick Mathewson2023-01-274-0/+4
| | | | | This panics on error, and we're fine with a panic on misbehavior in tests.
* Merge branch 'sensitive' into 'main'eta2023-01-261-3/+4
|\ | | | | | | | | tor-proto: Mark stream ids in errors as sensitive See merge request tpo/core/arti!986
| * tor-proto: Mark stream ids in errors as sensitiveIan Jackson2023-01-241-3/+4
| | | | | | | | Pursuant to #556
* | tor-proto: comment fixes and more TODO hsNick Mathewson2023-01-241-2/+6
| |
* | tor-proto: Expose support for doing onion service handshakesNick Mathewson2023-01-171-0/+33
|/ | | | | | This is a little tricky, but I think that we're not actually exposing too much here. I expect we'll need to tweak this stuff between now and our final version.
* tor-proto: impl Display for CreateResponseIan Jackson2023-01-061-0/+12
| | | | Don't print the handshake value, but do print the display reason.
* test lint blocks: Add many many automaticallyIan Jackson2022-12-124-0/+32
| | | | | This is precisely the result of running the rune in maint/adhoc-add-lint-blocks.
* tor-linkspec: Remove the old OwnedFoo::new() functionsNick Mathewson2022-10-061-2/+11
| | | | These are now builders.
* add feature annotation not added by doc_auto_cfgtrinity-1686a2022-08-241-0/+1
|
* tor-proto: Make "testing" feature that exports some thingsIan Jackson2022-08-161-2/+5
| | | | | We are going to want this for through-the-layers padding control testing.
* Final (?) API revisions for tor-linkspecNick Mathewson2022-08-101-16/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this change, each individual identity type becomes optional. The functions that expose them unconditionally are now in a "legacy" trait that only some downstream types are expected to implement. There are new convenience APIs in HasRelayIds: * to return Option<&keytype>, * to see if one identity-set contains another. This commit will break several downstream crates! For the reviewer's convenience, I will put the fixes for those crates into a series of squash! commits on this one. tor-netdir ---------- Revise tor-netdir to accept optional identities. This required some caveats and workarounds about the cases where we have to deal with a key type that the tor-netdir code does not currently recognize at all. If we start to add more identity types in the future, we may well want more internal indices in this code. tor-proto --------- In order to make tor-proto support optional identities, there were fewer changes than I thought. Some "check" functions needed to start looking at "all the ids we want" rather than at "the two known IDs"; they also needed to accommodate that case where we don't have an ID that we demand. This change will also help with bridges, since we want to be able to connect to a bridge without knowing all of its IDs up front. The protocol currently _requires_ the two current ID types in some places. To deal with that, I added a new `MissingId` error. I also removed a couple of unconditional identity accessors for chanmgr; code should use `target().identity(...)` instead. tor-chanmgr ----------- This is an incomplete conversion: it does not at all handle channel targets without Ed25519 identities yet. It still uses those identities to index its internal map from identity to channel; but it gives a new `MissingId` error type if it's given a channel target that doesn't have one. We'll want to revise the map type again down the road when we implement bridges, but I'd rather not step on the channel-padding work in progress right now. tor-guardmgr ------------ This change is mostly a matter of constructing owned identity types more sensibly, rather than unwrapping them directly. There are some places marked with TODOs where we still depend on particular identity types, because of how the directory protocol works. This will need revisiting when we add bridge support here. tor-circmgr ----------- These changes are just relatively simple API changes in the tests.
* tor-proto: split and elaborate tor_bytes::Error instancesNick Mathewson2022-06-231-1/+2
| | | | | | | | | Some of these were for decoding particular objects (we now say what kind of objects), and some were unrelated tor_cert errors that for some reason we had shoved into a tor_bytes::Error. There is now a separate tor_cert::CertError type, independent from tor_cert's use of `tor_bytes::Error` for parsing errors.
* tor-proto: Split CellErr based on activity.Nick Mathewson2022-06-231-1/+4
| | | | | | Failing to encode is fundamentally different from failing to decode. We now treat those separately, and describe _what_ we failed to encode or decode.
* tor-proto: clean up error names and messagesNick Mathewson2022-06-231-4/+4
| | | | | This avoids adding additional information for now; that will come on the next commits.
* tor-proto: err: Provide ChannelClosed as a separate unit errorIan Jackson2022-06-211-3/+3
|
* squash! Bump every crate's edition to 2021.Nick Mathewson2022-04-252-4/+0
| | | | | Remove all `use` statements for `TryFrom` and `TryInto`. These are now redundant in Rust 2021.
* Define accessors for circuit hops.Nick Mathewson2022-03-171-0/+14
| | | | Closes #415
* tor-proto: Remember peer information in circuit and channelNick Mathewson2022-03-172-12/+33
| | | | | | | | | Each channel now remembers an OwnedChanTarget. Each circuit now remembers a vector of OwnedChanTarget to represent the path that it was constructed for. Part of #415.
* ClientCirc: Move n_hops into a new Path type.Nick Mathewson2022-03-172-3/+27
| | | | This will help with #415
* impl Debug for DataStream (and its components)Ian Jackson2022-02-241-2/+2
| | | | | | | | | My proximate motivation is that tls-api wants its inner streams to be Debug. But in general, I agree with the Rust API Guidelines notion that almost everything should be Debug. I have gone for the "dump all the things" approach. A more nuanced approach would be possible too.
* Update tor-proto errors to latest API.Nick Mathewson2022-02-154-11/+13
|
* tor-proto: use InternalError for internal errors.Nick Mathewson2022-02-154-15/+32
|
* Merge branch 'eta/reactor-2.5' into 'main'eta2022-02-031-33/+60
|\ | | | | | | | | Fix severe reactor ordering problems See merge request tpo/core/arti!282
| * Fix severe reactor ordering problemseta2022-02-031-33/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A number of severe problems with the circuit reactor were fixed which could cause reordering of cells (which causes relays to terminate the circuit with a protocol violation, as they become unable to decrypt them). These mostly revolve around improper usage of queues: - The code assumed that a failure to place cells onto the channel would persist for the duration of a reactor cycle run. However, under high contention, this wouldn't always be the case. - This leads to some cells getting enqueued while others go straight through, before the enqueued cells. - To fix this, we block sending cells out of the channel while there are still some enqueued. - The hop-specific queues queued after encryption, not before. This was very brittle, and led to frequent mis-ordering. - This was fixed by making them not do that. This is arti!264 / 5bce9db5628126be2b736f228211174fe4132918 without the refactor part.
* | Merge branch 'typos' into 'main'eta2022-02-031-1/+1
|\ \ | | | | | | | | | | | | Fix typos See merge request tpo/core/arti!285
| * | Fix typosDimitris Apostolou2022-02-021-1/+1
| |/
* / Remove many needless borrows and slicesIan Jackson2022-02-021-1/+1
|/ | | | | | | Found via clippy::needless_borrow. In some cases I removed needless `[..]` too. See also: needless_borrow suggestion doesn't go far enough https://github.com/rust-lang/rust-clippy/issues/8389
* clippy: Rename a `decode_chanmsg` from `handle_`Ian Jackson2022-01-191-1/+1
| | | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/249#note_2771025 It doens't really handle it.
* clippy: Rename a `from_foo` method that doesn't do conversionIan Jackson2022-01-191-1/+1
|
* Describe when we will need SendmeAcceptMinVersionNick Mathewson2022-01-121-0/+8
| | | | | | (spoiler: not until we have a relay implementation) Closes #53.
* Change RequireSendmeAuth to an enum.Nick Mathewson2022-01-121-24/+61
| | | | | | | | This is a fine example of why booleans are risky: it's far to easy to pass "animate:bool" into "inanimate:bool" like we did here. This is a followup from our fix to #294.
* Fix a boolean inversion in auth_sendme_optional.Nick Mathewson2022-01-121-1/+2
| | | | | | | | | | | | | Previously we were requiring authenticated sendme cells exactly when we should be permitting the old format, and vice versa. This bug was caused by using a boolean to represent one property, but with giving that boolean two different senses without inverting at the right time. The next commit will prevent a recurrence. Closes #294
* Document SendmeEmitMinVersion statusNick Mathewson2022-01-121-0/+4
| | | | | (We don't need to look at SendmeEmitMinVersion since higher values are not yet defined.)
* tor-proto: Allow one meta-cell handler at a time.Nick Mathewson2021-12-161-10/+18
| | | | | Previously the code would let us try to install a meta-cell handler before the old one was done, leading to possible confusion.