summaryrefslogtreecommitdiff
path: root/crates/tor-proto/src/client
Commit message (Collapse)AuthorAgeFilesLines
* proto: Pass PeerAddr at the channel handshake finish for initiatorsDavid Goulet2026-02-192-12/+5
| | | | | | | | | | Responder relay handshake requires the peer address at the very start as it sends its NETINFO right away. For initiators, we only need it during the finalization process which is when the NETINFO is sent and the Channel is created. Signed-off-by: David Goulet <[email protected]>
* proto: Use the PeerAddr accross channel handshakeDavid Goulet2026-02-192-25/+13
| | | | | | | This is a large change but it is basically using PeerAddr in the channel builder through the channel handshake code and into the Channel itself. Signed-off-by: David Goulet <[email protected]>
* Merge branch 'circ-sync-view-streams' into 'main'gabi-2502026-02-165-57/+9
|\ | | | | | | | | | | | | proto: Replace circuit-scoped `CircSyncView` with per-hop alternative Closes #2351 See merge request tpo/core/arti!3680
| * proto: Rename CircSyncView to CircHopSyncViewGabriela Moldovan2026-02-162-4/+4
| | | | | | | | And update the docs
| * proto: Remove unused n_open_streams() functionsGabriela Moldovan2026-02-161-17/+0
| |
| * proto: Replace circuit-scoped n_open_streams() with per-hop alternativeGabriela Moldovan2026-02-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `IncomingStreamRequestFilter`s, and `CircSyncView`s, by extension, are used both by old relay implementation and the new one for implementing an out-of-reactor way of deciding how to handle an incoming stream. In the new circuit reactor design, we have a separate stream reactor for each hop. Upon receiving an incoming stream, the stream reactor will need to build one of these `CircSyncView` objects, and then pass it to an externally-provided `IncomingStreamRequestFilter`. Before this change, `CircSyncView::n_open_streams()` returned the total number of open streams, which wouldn't have worked with the new reactor design, because the per-hop stream reactor doesn't have a global view of all the hops, so its `CircSyncView` can't return the total number of streams (at least not without message passing, or sharing state with the other stream reactors).
| * proto: Replace CircSyncView with previously client-only CircSyncViewGabriela Moldovan2026-02-164-36/+1
| | | | | | | | | | | | | | | | | | | | Note: this commit only contains the removal of the old `CircSyncView`, and it of course doens't compile. A future commit will replace the removed file with the `syncview.rs` from the client module. This change is split over two commits because it makes reviewing easier (`git mv`ing the new file over the old results in a confusing diff, because `git` refuses to show it as a move).
| * proto: Adjust visibility in client::reactor::CircSyncViewGabriela Moldovan2026-02-161-3/+3
| | | | | | | | | | This is in preparation for replacing the top-level `CircSyncView` with it.
| * proto: Use absolute path in CircHopList importGabriela Moldovan2026-02-161-1/+1
| | | | | | | | This file will be moved to the top-level `circuit` module soon.
| * proto: Rename ClientCircSyncView to CircSyncViewGabriela Moldovan2026-02-163-6/+5
| | | | | | | | | | This will soon replace `CircSyncView` wholesale. The preliminary renaming will make the future diffs easier to review.
| * proto: Add an accessor for the CircHopOutbound of a CircHopGabriela Moldovan2026-02-161-0/+5
| | | | | | | | This will soon be needed for building a `CircSyncView`.
* | proto: Use is_multiple_of() as suggested by clippyGabriela Moldovan2026-02-161-1/+1
|/
* Merge branch 'early-relay' into 'main'gabi-2502026-02-121-13/+0
|\ | | | | | | | | | | | | proto: Pass *all* cells to handle_forward_cell() Closes #2339 See merge request tpo/core/arti!3674
| * Revert "proto: Add a new ToRelayMsg util"Gabriela Moldovan2026-02-121-13/+0
| | | | | | | | | | | | | | | | | | | | This reverts commit 04ab3cd848d7977baf58dd64ebfcad6aa54ecb17. Reverted because we no longer need to "peek" into the opaque `CircChanMsg` of a circuit reactor: now the implementation-dependent part of the reactor is in charge of handling the channel messages, and extracting `Relay` objects out of RELAY/RELAY_EARLY cells, which then get processed in the base reactor.
* | proto: Client channel need to consider PT for the targetDavid Goulet2026-02-121-6/+21
| | | | | | | | Signed-off-by: David Goulet <[email protected]>
* | proto: Enforce that channel method as unique SocketAddrDavid Goulet2026-02-121-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | During the channel handshake, we require the peer IP address for the canonicity check which requires the exact peer IP we are connected to. This commit adds a function that enforces this requirement on a ChannelMethod so anything else results in an error. It is to basically have stronger guarantee on the channel method we use in the handshake. Signed-off-by: David Goulet <[email protected]>
* | proto: Channel finish() now handles canonicityDavid Goulet2026-02-121-4/+13
|/ | | | | | | | | | | | | | All handshake pass the NETINFO cell, the advertised addresses (if any) and the peer address in order to build the Canonicity and build the channel with it. In order to pull this off, the "my_addrs" were added to several object along the NETINFO cell. We also pass the channel method when connecting (initiator) to a relay as we need this for this canonicity build. Signed-off-by: David Goulet <[email protected]>
* proto: Move CREATE helpers to a shared moduleGabriela Moldovan2026-02-052-65/+1
| | | | These will be used by the relay code too (for circuit extension).
* proto: Add missing clock_skew() to unverified channelsDavid Goulet2026-02-041-6/+3
| | | | Signed-off-by: David Goulet <[email protected]>
* proto: Make channel client to use a specific typeDavid Goulet2026-02-041-38/+43
| | | | | | Remove the use of traits, the caller will handle the specific type. Signed-off-by: David Goulet <[email protected]>
* proto: Avoid locking in CircHopOutbound::ccontrol()Gabriela Moldovan2026-01-291-1/+1
| | | | | | | | This is just because the generic reactor will soon need a clone of the CC object, so I am preemptively making this function return a ref to the underlying `Arc` instead. Technically, it would've been fine to just kept this method and add a separate one returning `&Arc<Mutex<..>>`, but I'd prefer keeping the API small.
* proto: Rip CC state out of CircHopInboundGabriela Moldovan2026-01-291-5/+1
| | | | | | Soon it won't need be needed here any more. I'm removing it, because having redundant handles to the CC state makes it difficult to see exactly where it's being used from.
* proto: Factor ReactorResultChannel into the shared reactor moduleGabriela Moldovan2026-01-291-3/+1
| | | | This is not just for clients!
* proto; Factor HOPS constant out of maybenot_paddingGabriela Moldovan2026-01-291-3/+1
| | | | I am about to use this in other places too.
* proto: Move padding_disposition() to the shared padding moduleGabriela Moldovan2026-01-291-54/+5
|
* proto: Move CircPaddingDisposition to a new moduleGabriela Moldovan2026-01-291-13/+1
| | | | Relays will need to use it too.
* proto: Add a new ToRelayMsg utilGabriela Moldovan2026-01-291-0/+13
| | | | | | | | | This will be used in a future commit, inside the new generic circuit reactor. We need it because RELAY cells are handled very similarly, so we need some way of finding out if a given generic chancell is actually a RELAY cell that we can handle in an implementation-agnostic way.
* proto: Move TimeoutEstimator to utilGabriela Moldovan2026-01-293-14/+7
| | | | | This will be used in the stream reactor too (and the stream reactor will eventually replace the corresponding client impl).
* proto: Use the channel codec channel typeDavid Goulet2026-01-221-1/+0
| | | | | | | | | | | | | | | | | Remove the channel type from Unverified and Verified channels and instead use the channel type in the underlying channel codec. The codec requires such type in order to restrict messages sets. Instead of duplicating it, this commit simply makes it that there is now only a single channel type attached to a channel structure. The resulting `struct Channel` in the end gets it copied from the channel codec as the framed_tls gets split and given to the `Reactor`. Down the line, we need a channel type attached to the `Channel` in order to know if it is a client or not and authenticated or not. Signed-off-by: David Goulet <[email protected]>
* proto: Remove async for VerifiableChannel::check()David Goulet2026-01-221-2/+1
| | | | Signed-off-by: David Goulet <[email protected]>
* proto: Make VerifiableChannel::check() asyncDavid Goulet2026-01-221-1/+2
| | | | | | | | | Relay initiator needs to send CERTS and AUTHENTICATE in that function after verifiying the channel. And thus require to be async. Signed-off-by: David Goulet <[email protected]>
* proto: Make CERTS cell optionnable for UnverifiedChannelDavid Goulet2026-01-221-1/+1
| | | | | | | | | | | | | | | This requires to make a series of cert and digest also optionnable in the VerifiedChannel. This change is needed because as a relay responder, you might get the CERTS or not depending on if the other side wants to authenticate. Client and bridges do not authenticate and thus it is expected to not have a CERTS cell. This leads to the UnverifiedChannel::check() function to return early with a VerifiedChannel without any identity attached to it. Signed-off-by: David Goulet <[email protected]>
* Merge branch 'ticket1599_02' into 'main'David Goulet2026-01-132-44/+37
|\ | | | | | | | | chanmgr: Ability for the ChanMgr to be channel type specific and launch relay channels See merge request tpo/core/arti!3563
| * proto: Seal the VerifiableChannel and FinalizableChannel traitsDavid Goulet2026-01-131-0/+14
| | | | | | | | | | | | They are public but avoid anyone outside implementing them. Signed-off-by: David Goulet <[email protected]>
| * proto: Add link_protocol() to VerifiableChannel traitDavid Goulet2026-01-131-12/+6
| | | | | | | | Signed-off-by: David Goulet <[email protected]>
| * proto: Add traits for public channel viewsDavid Goulet2026-01-132-48/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Add traits that will be returned outside tor-proto allowing us to not expose client and relay specific channels. The goal is for the tor-chanmgr to get those objects implementing those traits and can build and run the reactor without knowing the specific underlying type. This allows us to have less code duplication and less client/relay distinction in the chanmgr. Signed-off-by: David Goulet <[email protected]>
* | proto: Dedupe IncomingStreamRequestHandlerGabriela Moldovan2026-01-123-30/+13
|/
* proto: Add an immediate order for client CircuitEvent orderingDavid Goulet2025-12-101-4/+7
| | | | | | | With a protocol violation, we have to immediately deal with such event before emitting anything on the wire. Signed-off-by: David Goulet <[email protected]>
* proto: Rename CircuitAction and cie to CircuitEventDavid Goulet2025-12-102-75/+67
| | | | | | | | | | This mirrors also the relay reactor. We've introduced the ProtoViolation into a previous commit which is not an action but rather an "event" that happened on a circuit. And so, better semantic. No behavior change. Signed-off-by: David Goulet <[email protected]>
* proto: Rename Circuit{Action/Event}::Shutdown to ProtoViolationDavid Goulet2025-12-102-6/+7
| | | | Signed-off-by: David Goulet <[email protected]>
* proto: Add TODO in client reactor for bad cellDavid Goulet2025-12-101-0/+6
| | | | | | Because of https://gitlab.torproject.org/tpo/core/torspec/-/issues/385 Signed-off-by: David Goulet <[email protected]>
* proto: Make ClientCircChanMsg pub(super)David Goulet2025-12-101-1/+1
| | | | Signed-off-by: David Goulet <[email protected]>
* proto: Move unit tests and minor fixDavid Goulet2025-12-101-0/+20
| | | | | | Move the client specific unit tests into the client module. Signed-off-by: David Goulet <[email protected]>
* proto: Client circuit reactor now handles AnyChanMsgDavid Goulet2025-12-104-27/+32
| | | | | | | | | | | | | | | This commit removes the CircuitRx* based solely on the client circuit message and moves it into the top level of the crate so all reactors can use them. The client reactor then upon receiving the message, it converts the AnyChanMsg into a ClientCircChanMsg. On error, this leads to a shutdown of the entire reactor due to a fatal error. In order to pull this off, we added a CircuitAction::Shutdown that is handled as a priority. Signed-off-by: David Goulet <[email protected]>
* proto: Move ClientCircChanMsg into client moduleDavid Goulet2025-12-103-5/+25
| | | | | | | | Next commit will also move the Relay specific set into the relay module. These two sets are becoming specific to the reactor as the circuit reactor communication channel will use AnyChanMsg instead. Signed-off-by: David Goulet <[email protected]>
* Merge branch 'fix-relay-compile' into 'main'David Goulet2025-12-091-1/+1
|\ | | | | | | | | proto: Fix relay/hs-service feature gating See merge request tpo/core/arti!3534
| * proto: Fix relay/hs-service feature gatingGabriela Moldovan2025-12-081-1/+1
| | | | | | | | | | Without this, `tor-proto` doesn't compile if you enable the `relay` feature but not `hs-service`.
* | Remove unnecessary `doc(cfg(...))` attributesNeel Chauhan2025-12-043-4/+0
|/ | | | | | | | | Fixes part of #2193. (Edits from nickm: I selected the cases here that I could verify were correct from immediate context.) Edited-by: Nick Mathewson <[email protected]>
* proto: Add comment about create_firsthop_fastNick Mathewson2025-12-031-1/+2
|
* Merge branch 'relay-streams2' into 'main'David Goulet2025-12-026-566/+32
|\ | | | | | | | | proto: Start handling incoming streams in the relay reactor See merge request tpo/core/arti!3487