aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-proto/src/channel/circmap.rs
Commit message (Collapse)AuthorAgeFilesLines
* proto: Avoid sending DESTROY if we have received DESTROYGabriela Moldovan9 days1-0/+18
| | | | | | | | | | | | | | | This change prevents the channel reactor from sending DESTROY cells on already-closed (or non-existent) circuits. Upon receiving a DESTROY cell, the channel reactor removes the corresponding circuit entry, if any, from its circmap. It then passes the DESTROY to the circuit reactor for handling. The circuit reactor handles it by shutting down, and calling `Channel::close_circuit()` on drop. Previously, this would unconditionally send a DESTROY cell, which caused #2648 and #2646. This affects both clients and relays, because both circuit reactors call `Channel::close_circuit()` on drop. Closes #2648, #2646
* proto: Ignore CREATED* with unrecognized CircIdsGabriela Moldovan2026-08-111-8/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we're a relay, we need to tolerate CREATED* with unrecognized CircIds: for example, if we time out[^1] while trying to extend the circuit by another hop, we will send a DESTROY to the extending hop, which can race with the CREATED* response. In other words, a CREATED* cell arriving on a closed circuit shouldn't be treated as a protocol violation. There are, however, a few cases where a CREATED* with an unknown CircId *is* a protocol violation (and probably *should* cause us to close down the channel): * if the CREATED* is moving in the forward direction (towards the exit), or * if we have not previously sent a CREATE* with that particular CircId As before, distinguishing these from the "closed circuit" case above would involve some tricky logic, and the benefits are unclear, while the downsides of closing a channel when we shouldn't have are significant. It seems better to just drop these cells for now. Closes #2655 [^1]: at the time of writing, we don't have timeouts for the circuit extension logic, so what I've described here cannot actually happen today. However, we *do* have a TODO for it, so the time outs I've described here will be implemented at some point
* proto: Remove a now-done TODOGabriela Moldovan2026-08-041-3/+0
| | | | We now have `add_relay_ent()` for this, so we can remove the TODO.
* proto: Rename "hs" to "hc"Gabriela Moldovan2026-08-041-2/+2
| | | | | I think this might have been c&p from the half-stream code ("hs" = "half-stream"). "hc" ("half-circuit") seems like a better name.
* align DestroyReason with torspec!490ramdoys2026-07-281-2/+2
|
* 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 the tests to use the new CircuitRx{Receiver,Sender}sGabriela Moldovan2026-06-081-1/+2
|
* tor-proto: replace use of `ChannelDirection` with `CircIdRange`Steven Engler2026-04-081-1/+1
|
* tor-proto: rename `CircIdRange::is_allowed_by_peer()` to `is_allowed_for_peer()`Steven Engler2026-04-081-2/+2
|
* tor-proto: support relay circs in channel's `CircMap`Steven Engler2026-04-081-0/+57
|
* tor-proto: rename `CircEnt::Open` to `CircEnt::OpenOrigin`Steven Engler2026-04-081-11/+13
| | | | And rename `CircMap::add_ent()` to `add_origin_ent()`.
* tor-proto: add `CircIdRange::is_allowed_by_peer()`Steven Engler2026-03-311-0/+8
|
* tor-proto: add `CircIdRange::integer_range()`Steven Engler2026-03-311-6/+15
|
* proto: Client circuit reactor now handles AnyChanMsgDavid Goulet2025-12-101-1/+1
| | | | | | | | | | | | | | | 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: Remove extra slashes in doc commentsGabriela Moldovan2025-12-011-2/+2
|
* Fix name of clippy lint to unchecked_time_subtraction (2)Ian Jackson2025-11-061-1/+1
| | | | Run maint/add_warning
* proto: Move celltypes out of clientGabriela Moldovan2025-10-131-1/+2
| | | | | Some of these are relay-specific, so it makes more sense to pull this into a top-level module.
* padding: Report when outbound cells are flushed.Nick Mathewson2025-09-021-1/+11
| | | | | | (This is what required us to stick a padding controller handle in each CircEnt, and what required us to accompany each queued cell with a QueuedPaddingCellInfo. Ouch!)
* padding: Give CircEnt in a Channel a handle for the PaddingController.Nick Mathewson2025-09-021-72/+82
| | | | | This requires some annoying plumbing to make sure that the right types wind up in the right places.
* proto: Turn CircEnt variants into struct-like format.Nick Mathewson2025-09-021-9/+38
| | | | (I'm about to add more fields.)
* proto: Rename the `tunnel` module to `client`.Gabriela Moldovan2025-08-181-2/+2
| | | | | | The implementation from `tunnel` is client-specific, so we are renaming the module accordingly. The more generic parts will be pulled into a separate module in a future commit.
* Switch Cargo.toml files to edition 2024.Nick Mathewson2025-08-071-3/+3
| | | | | | | | | | | | | | First, run ``` git grep -l "^edition =" | xargs perl -i -pe 's/^edition *=.*/edition = "2024"/;' ``` Second, manually verify that all Cargo.toml files have changed, and nothing else has changed. Third, run cargo fmt again.
* proto: temporarily suppress warning; see #2003.Nick Mathewson2025-05-151-2/+2
|
* squash! Upgrade rand dependency to 0.9.Nick Mathewson2025-03-181-2/+2
| | | | - The rand::distributions module has been renamed to rand::distr
* tor-proto: Add a tunnel module.David Goulet2025-02-201-2/+2
| | | | | | | | | | | | | 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: Specify which of the 2 senders is used for sending cells.Gabriela Moldovan2024-11-201-1/+1
|
* Apply deferred rustfmt churnIan Jackson2024-10-091-5/+2
|
* memquota: Use an mq_queue for channel->circuit RX queueIan Jackson2024-10-091-3/+3
| | | | | | Fixes #1682. (This involves some noise in the tests.)
* memquota: Introduce type aliases for channel->circuit RX queueIan Jackson2024-10-091-5/+4
| | | | | This is neater and will make changing the type (in a moment) less noisy.
* extract tor_async_utils::oneshot into ::oneshot-fused-workaroundJim Newsome2024-08-281-2/+1
| | | | | | | | | | | | | | Having this in the `tor-async-utils` crate prevents us from doing both of the following without introducing a circular dependency: * using it in `tor-rtmock` (which we currently do, particularly in tests). * using `tor-rtmock` to test things in `tor-async-utils`. We don't do this yet, but it is generally sensible to do so. In particular we want to move the `stream_peak` module there, which is currently tested with `tor-rtmock`. Moving this into its own crate avoids this circular dependency.
* Run maint/add_warning.Nick Mathewson2024-03-131-0/+1
|
* Change `CircId` to never be zeroJim Newsome2023-10-251-16/+12
| | | | | | | | | | This changes the internal representation to be `NonZeroU32` instead of just `u32`. Various places where a circuit ID is optional now use `Option<CircId>`. Fixes a bug in `CircIdRange::sample` that would previously return a circuit ID of 0, when the rng returned 0x8000_0000 for a low range.
* oneshot: Use veneer in tor-protoIan Jackson2023-10-111-2/+4
|
* Run maint/add_warning to add lint block everywhereIan Jackson2023-08-231-0/+1
|
* Run maint/add_warning to actually apply new lint allowsIan Jackson2023-07-101-0/+1
|
* Allow clippy::unchecked_duration_subtraction in testsNick Mathewson2023-01-271-0/+1
| | | | | This panics on error, and we're fine with a panic on misbehavior in tests.
* test lint blocks: Add many many automaticallyIan Jackson2022-12-121-0/+8
| | | | | This is precisely the result of running the rune in maint/adhoc-add-lint-blocks.
* Use testing_rng() in tests throughout our crates.Nick Mathewson2022-06-021-1/+2
| | | | | | This only affects uses of thread_rng(), and affects them all more or less indiscriminately. One test does not work with ARTI_TEST_PRNG=deterministic; the next commit will fix it.
* Replace as_mut with deref impl for MutCircEntYuan Lyu2022-02-161-16/+24
|
* Make CircMap open_ent_count O(1)Yuan Lyu2022-02-161-17/+62
|
* Expire channels that have been unused for too longYuan Lyu2022-02-041-0/+21
|
* 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
* fix/silence clippy lints in test modulesDaniel Eades2021-09-081-0/+1
|
* Move all crates into a `crates` subdirectory.Nick Mathewson2021-08-271-0/+242
This will cause some pain for now, but now is really the best time to do this kind of thing.