aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-proto/src/circuit/reactor.rs
Commit message (Collapse)AuthorAgeFilesLines
* tor-proto: 'expect' -> 'allow' in `CircReactorHandle`Steven Engler2026-08-111-2/+2
| | | | | | | | | | This fixes an `unfulfilled_lint_expectations` warning. tor-proto conditionally sets a global `allow(unused)`, and if you have an `expect(unused)` field within an `allow(unused)` struct, rust seems to warn with 'unfulfilled_lint_expectations'. https://github.com/rust-lang/rust/issues/160942
* proto: Add {backward|forward} prefix to circ_id in logsDavid Goulet2026-08-031-2/+2
| | | | Signed-off-by: David Goulet <[email protected]>
* proto: Rename uniq_id to circ_unique_id mostly in loggingDavid Goulet2026-08-031-2/+2
| | | | | | | | | We have decided that instead of "uniq_id" in logging, we'll use the "<domaine>-[<type>]-id" syntax to indicate who is that unique ID. This commit only renames circuit's unique ID to "circ_uniq_id". Signed-off-by: David Goulet <[email protected]>
* proto: Log both UniqId and CircId when possibleDavid Goulet2026-08-031-2/+8
| | | | | | | | | | This commit only affects logging. Whenever possible, log both the UniqId and CircId. This also changes the log lines which is now "uniq_id=" and "circ_id=" as the UniqId is internal and circ_id (CircId) is protocol level. Signed-off-by: David Goulet <[email protected]>
* tor-proto: fix tests when `feature = relay`Steven Engler2026-07-291-1/+1
| | | | | | | | | | | | ```text $ cargo test -p tor-proto --features relay [...] error[E0405]: cannot find trait `IncomingStreamRequestFilter` in this scope --> crates/tor-proto/src/circuit/reactor.rs:631:10 | 631 | impl IncomingStreamRequestFilter for AllowAllStreamsFilter { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope ```
* proto: Add expect(unused) where neededGabriela Moldovan2026-06-291-0/+2
| | | | | | | | | | | Now that relays no longer use `CtrlCmd::AwaitStreamRequests`, some of these fields are unused. I'm leaving them in for now, but we should remove them if they're still unused after we finish the circ reactor impl. I'm not removing `AwaitStreamRequests`, because it will be needed by onion services, when we replace the old client circuit reactor with the new one.
* proto: Update tests to use the new stream exportsGabriela Moldovan2026-06-171-4/+4
| | | | The tests don't compile otherwise.
* maint: Run maint/add_warning to deny string slicesClara Engler2026-06-091-0/+1
| | | | | | | | | | | | This commit executes maint/add_warning with the just added change to deny string slices except in tests. I recommend auditing this by checking out the previous commit followed by running the script yourself and then verifying that the diff is identical to this commit. This commit makes cargo clippy fail. We will add exceptions in the next commit.
* proto: Update reactor docs to reflect ForwardHandler changeGabriela Moldovan2026-03-251-6/+37
|
* proto: Use AllowAllStreamsFilter in relay builds tooGabriela Moldovan2026-03-251-2/+2
|
* proto: Move AllowAllStreamsFilter to crate-pub test moduleGabriela Moldovan2026-03-251-0/+16
| | | | This will soon be used by the relay tests too.
* proto: Add option to create RELAY_EARLY via rmsg_to_ccmsg() (fmt)Gabriela Moldovan2026-03-251-1/+5
|
* proto: Add option to create RELAY_EARLY via rmsg_to_ccmsg()Gabriela Moldovan2026-03-251-2/+8
| | | | This will be needed for the relay circuit reactor tests.
* proto: Move rmsg_to_ccmsg to crate-pub test moduleGabriela Moldovan2026-03-251-0/+33
| | | | We'll soon need this for the relay reactor tests too.
* proto: Give handle_meta_msg() a handle to the runtimeGabriela Moldovan2026-02-051-0/+1
|
* proto: Add an implementation-dependent reactor event streamGabriela Moldovan2026-02-051-0/+2
| | | | | This will enable us to obtain implementation-dependent asynchronous events (such as the outcome of an extend handshake).
* proto: Move channel provider out of the generic reactorGabriela Moldovan2026-02-051-9/+0
| | | | | | The channel provider is relay-specific, so I am moving it to the relay `ForwardHandler` implementation. This enables us to get rid of some of the feature gating from the generic reactor.
* proto: Rename the FWD -> BWD channelGabriela Moldovan2026-01-291-3/+3
| | | | | | | In the backward reactor, we call this the `forward_reactor_rx` (because it receives commands from the foward reactor), and in the forward reactor we call it `backward_reactor_tx` (because it sends commands to the backward reactor).
* proto: Rename chan senders and sinks for clarityGabriela Moldovan2026-01-291-8/+8
| | | | | | | | | | We settled on * `inbound_chan{tx, rx}`, for the inbound channel (the channel towards the guard, if we are a client, or towards the client if we are a relay) * `outbound_chan{tx, rx}`, for the outbound channel (the channel towards the exit, if we are a middle relay)
* proto: Add a new, implementation-agnostic circuit reactorGabriela Moldovan2026-01-291-5/+544
|
* proto: Factor ReactorResultChannel into the shared reactor moduleGabriela Moldovan2026-01-291-0/+5
| | | | This is not just for clients!
* proto: Add a new module for the generic circuit reactorGabriela Moldovan2026-01-291-0/+9
| | | | Currently empty, will be fleshed out in a future commit.
* tor-proto: Add a tunnel module.David Goulet2025-02-201-1946/+0
| | | | | | | | | | | | | Move StreamTarget to the tunnel module and the circuit module. From now on streams will be implemented on tunnels, not circuits. This moves `StreamTarget` to the tunnel module. A future change will replace `ClientCirc` with `ClientTunnel` inside `StreamTarget`. This is mostly code motion, best reviewed with `--color-moved`. Signed-off-by: David Goulet <[email protected]>
* tor-proto: Change the visibility of a series of structGabriela Moldovan2025-02-201-9/+9
| | | | | | | We're about to need this in `tor_proto::tunnel` which is from the Conflux work. In the spirit of upstreaming as much as possible, it is done now.
* tor-proto: Add a newtype wrapper for LegId.Gabriela Moldovan2025-02-201-4/+12
| | | | | We will eventually need to expose this in `tor-proto`'s public API, so it'll need to be an opaque type.
* tor-proto: Add LegId type that can be used as a slotmap key.Gabriela Moldovan2025-02-201-0/+8
| | | | | This will soon be used by the reactor-internal `ConfluxSet` as a unique identifier for the circuit legs stored in its `SlotMap`.
* tor-proto: Move CreateHandshakeWrap to reactor module (fmt).Gabriela Moldovan2025-02-181-3/+1
|
* tor-proto: Move CreateHandshakeWrap to reactor module.Gabriela Moldovan2025-02-181-1/+3
| | | | | This moves the `CreateHandshakeWrap` and its implementors to `reactor::create` (none of these are used outside of the reactor).
* tor-proto: Fold the CommandHandler into ControlHandler.Gabriela Moldovan2025-02-111-5/+5
| | | | | | | | This gets rid of a bit of a duplicated code. It also moves `CtrlCmd` closer to `CtrlMsg`. Offshoot from my WIP conflux branch for #1838
* tor-proto: add `ClientCirc::first_hop_clock_skew`Steven Engler2025-02-101-0/+10
|
* tor-proto: Remove unnecessary param in handshake handler.Gabriela Moldovan2025-02-061-1/+1
| | | | | | | | | The `Reactor` argument is never used, so we can just remove it from the trait. Removing this arg also simplifies #1838 for me (I am moving some code around, and the calls to `handle_sever_aux_data` no longer have access to the `Reactor`).
* tor-proto: Make ControlHandler::handler return non-optional result.Gabriela Moldovan2025-02-061-3/+3
| | | | | | The commands for which the function returned `Ok(None)` have been refactored into `CtrlCmd`, so we no longer need `handle()` to return an `Option`.
* tor-proto: Turn some CtrlMsgs into CtrlCmds.Gabriela Moldovan2025-02-061-11/+15
| | | | | | | All `CtrlMsg`s to which the reactor did not respond by sending a cell down the channel are now `CtrlCmd`s. Most of this is code motion, best reviewed with `--color-moved`.
* tor-proto: Make shutdown a CtrlCmd.Gabriela Moldovan2025-02-061-20/+18
|
* proto: Move the begin cell handling into CircHopDavid Goulet2025-02-041-36/+27
| | | | | | | Move the BEGIN cell handling into CircHop following the previous commit that move more code into CircHop. Signed-off-by: David Goulet <[email protected]>
* proto: Move the close stream action into CircHopDavid Goulet2025-02-041-51/+55
| | | | | | | | | | | | | | | | | This is the first commit of a series to make CircHop own the code of its related actions. This commit moves the "close stream" code into CircHop now owning the action and offloading the Reactor code. In order to do this, and future changes like for example handling BEGIN, the CircHop needs to be aware of its hop number. This change also allows us to add the hop number to logging. It also copies the reactor unique ID to each hop for logging purposes. Future commit will continue to move more code into CircHop. Signed-off-by: David Goulet <[email protected]>
* proto: Remove ConversationInHandlerDavid Goulet2025-02-041-55/+0
| | | | | | | | | | | | | | | | | | | It is unused but most importantly it allows any RELAY cell to be sent from anywhere in the code which is really not desirable because it is skipping congestion control. It also allows us to remove the `control_tx` from the reactor which is one less channel to track/understand/think about. This opens up the door to all sorts of problems especially side channel that can be exploited if we are not careful. We can always bring this back if we need it but for now, it is unused and allows us to remove the `CtrlMsg::SendRelayCell` control message. No code behavior change. Signed-off-by: David Goulet <[email protected]>
* proto: Introduce a reactor ControlHandlerDavid Goulet2025-02-041-217/+8
| | | | | | | | | | | | | This object only mission is to handle a control message (CtrlMsg). It encapsulates a reference to the reactor and its lifetime is only the time it takes to handle the message. Main goal of this is to try to reduce reactor.rs size into logical containers. No code behavior change. Signed-off-by: David Goulet <[email protected]>
* tor-proto: Remove outdated docs about AsyncMutex use.Gabriela Moldovan2025-01-301-7/+0
|
* tor-proto: Remove unnecessary time_prov argument.David Goulet2025-01-301-28/+17
|
* tor-proto: Remove unnecessary Mutex around chan_sender.David Goulet2025-01-301-44/+20
|
* tor-proto: Resolve clippy warning about mut refs in debug_assert.Gabriela Moldovan2025-01-291-6/+7
| | | | | | It's unclear to me why this warning didn't fire before! The the circuit reactor had this exact same `debug_assert` prior to the refactoring, taking a mutable reference to the `StreamMap`.
* tor-proto: Add a clippy allow and corresponding TODO.Gabriela Moldovan2025-01-291-0/+1
|
* tor-proto: Remove now-unused Reactor::send_outbound().Gabriela Moldovan2025-01-291-74/+0
| | | | This is now handled in `Reactor::ready_streams_iterator()`.
* tor-proto: Remove old Reactor::run_once().Gabriela Moldovan2025-01-291-66/+0
| | | | | | | | | This is replaced by the new `Reactor::run_once()` impl. Note: this removal is in a separate commit to make the diff of the refactoring commits easier to review (the diff between the old and the new impl is not meaningful because the new impl is practically a rewrite).
* tor-proto: Remove now-unused CellStatus enum.Gabriela Moldovan2025-01-291-9/+0
| | | | This is replaced by `Option<RunOnceCmdInner>`.
* tor-proto: Rewrite circuit reactor run_once() loop to use select! (fmt).Gabriela Moldovan2025-01-291-26/+26
|
* tor-proto: Rewrite circuit reactor run_once() loop to use select!.Gabriela Moldovan2025-01-291-174/+626
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This rewrites the circuit reactor main loop to use `select_biased!` to poll multiple futures simultaneously. The new `run_once()`, like the old, first waits for an initial `CtrlMsg::Create`. Then, it uses a `select_biased!` to poll the `chan_sender` sink and shutdown channel for readiness. When the channel sink is ready, we poll the `control` and `input` channels like before, as well as the new `ready_streams` `Stream` (`ready_streams` is a `futures::Stream` that replaces the previous `send_outbound()` function). Most of the implementation remains unchanged, except the `handle_input`, `handle_cell` and `handle_control` functions no longer send anything on the `chan_sender` channel. Instead, they may do some (synchronous) processing, and send instructions for the remaining work that needs to be done (for example, for writing the cell to the `chan_sender` channel). These instructions are handled at the end of `run_once()`, and are encoded in the `RunOnceCmdInner` enum. What this change does **not** do: * the control channel *still* bypasses congestion control. We could fix this by making the various reactor functions send the `RunOnceCmdInner` commands to `run_once()` via a channel (instead of returning them). This would enable the reactor to stop reading the commands (except for handle `Sendme`, which would be handled separately) if it's blocked on congestion control.
* tor-proto: Use SendRelayCell within CtrlMsg::SendRelayCell.Gabriela Moldovan2025-01-291-1/+1
|
* tor-proto: Add enums for representing run_once() commands.Gabriela Moldovan2025-01-291-0/+104
|