aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-proto/src
Commit message (Collapse)AuthorAgeFilesLines
...
* proto: Introduce new relay initiator channel typesDavid Goulet2026-02-043-4/+188
| | | | | | | | | | | | | | | | | | | This commit adds the Unverified and Verified flavor of a relay channel specific to an initiator. We decided to use the type system for safety and avoid patterns like: "if chan.is_initiator() {...} else {...}" This allows us also to not duplicate code between initiator and responder code. The downside is that we expose these types outside of tor-proto meaning the caller needs to feature gate the usage of these types with the "relay" flag. Small price to pay for strong guarantees with the type system. Signed-off-by: David Goulet <[email protected]>
* proto: Move the ChannelAuthenticationData::build() function into the object ↵David Goulet2026-02-041-0/+85
| | | | | | | | | itself Previous function "build_auth_data()" is still around but will be removed in the upcoming commits. Signed-off-by: David Goulet <[email protected]>
* proto: Remove assumption that we are a relay from BWD docGabriela Moldovan2026-02-041-1/+1
| | | | This was leftover from back when the BWD was a relay-specific type.
* proto: Replace SendSendme with a more general-purpose command (fmt)Gabriela Moldovan2026-02-041-5/+4
|
* proto: Replace SendSendme with a more general-purpose commandGabriela Moldovan2026-02-043-13/+14
| | | | | This will soon be used for instructing the BWD to send other types of messages too.
* proto: Replace send_sendme() with general-purpose functionGabriela Moldovan2026-02-041-8/+12
| | | | | | | The backward reactor will soon need the ability to send other types of relay messages too: it will soon need the ability to respond to EXTEND2 by sending back an EXTENDED2, so I am preemptively making this function more general so we can reuse it.
* proto: Allow unused async in WIP reactor codeGabriela Moldovan2026-01-291-0/+2
| | | | This will need to become async soon.
* proto: Remove unused async from relay reactorGabriela Moldovan2026-01-291-1/+1
| | | | Fixes a clippy warning
* proto: Document that the hop list is shared with the BWDGabriela Moldovan2026-01-291-0/+11
|
* proto: Rename the FWD -> BWD channelGabriela Moldovan2026-01-293-18/+18
| | | | | | | 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-294-43/+43
| | | | | | | | | | 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: Update misleading comment about cmd_rxGabriela Moldovan2026-01-291-1/+1
|
* proto: Allow CircSynvView::new_relay() to be unusedGabriela Moldovan2026-01-291-0/+1
| | | | | This will change significantly in the near future, or disappear entirely.
* proto: Replace relay reactor with new generic reactorGabriela Moldovan2026-01-294-1747/+336
|
* proto: Add a new, implementation-agnostic circuit reactorGabriela Moldovan2026-01-297-5/+3063
|
* proto: Avoid locking in CircHopOutbound::ccontrol()Gabriela Moldovan2026-01-295-15/+37
| | | | | | | | 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: s/Forward/ForwardSender for clarityGabriela Moldovan2026-01-291-3/+3
| | | | | This renaming is needed because I will soon introduce a new `Forward` struct, with a completely different purpose.
* proto: Rip CC state out of CircHopInboundGabriela Moldovan2026-01-294-24/+6
| | | | | | 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-292-3/+6
| | | | This is not just for clients!
* proto: Add a new module for the generic circuit reactorGabriela Moldovan2026-01-292-0/+10
| | | | Currently empty, will be fleshed out in a future commit.
* proto; Factor HOPS constant out of maybenot_paddingGabriela Moldovan2026-01-292-3/+4
| | | | I am about to use this in other places too.
* proto: Move padding_disposition() to the shared padding moduleGabriela Moldovan2026-01-292-54/+74
|
* proto: Move CircPaddingDisposition to a new moduleGabriela Moldovan2026-01-293-13/+18
| | | | Relays will need to use it too.
* proto: Add a new ToRelayMsg utilGabriela Moldovan2026-01-294-0/+51
| | | | | | | | | 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-296-15/+23
| | | | | This will be used in the stream reactor too (and the stream reactor will eventually replace the corresponding client impl).
* Merge branch 'unused-async-lint' into 'main'gabi-2502026-01-283-2/+7
|\ | | | | | | | | | | | | maint/add_warning: Deny clippy::unused_async Closes #2328 See merge request tpo/core/arti!3613
| * proto: Add an exception for clippy::unused_asyncGabriela Moldovan2026-01-271-0/+1
| |
| * proto: Add exceptions for clippy::unused async in relay reactorGabriela Moldovan2026-01-271-0/+3
| | | | | | | | This code is still WIP, so I propose we ignore the lint for now.
| * proto: Remove unnecessary async in channel reactorGabriela Moldovan2026-01-271-2/+2
| | | | | | | | | | This resolves a warning triggered by the newly-introduced `#[deny(clippy::unused_async)]`.
| * maint/add_warning: Run script to add new warningGabriela Moldovan2026-01-271-0/+1
| | | | | | | | This adds the lint to all our crates.
* | Merge branch 'kist-doc' into 'main'Alexander Hansen Færøy2026-01-271-0/+1
|\ \ | |/ |/| | | | | clippy: Fix missing doc for non-Linux builds See merge request tpo/core/arti!3611
| * clippy: Fix missing doc for non-Linux buildsClara Engler2026-01-271-0/+1
| |
* | Merge branch 'ticket_2304' into 'main'Nick Mathewson2026-01-271-6/+4
|\ \ | |/ |/| | | | | | | | | arti: Downgrade "stream closed without END" warning to debug. Closes #2304 See merge request tpo/core/arti!3608
| * Apply 1 suggestion(s) to 1 file(s)Nick Mathewson2026-01-271-1/+1
| | | | | | Co-authored-by: carti-it <[email protected]>
| * tor-proto: Report CircuitClosed on unexpected stream rx closeNick Mathewson2026-01-221-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As near as I can tell, there are only three ways that the sender corresponding to this rx can be dropped: - `StreamMap::terminate` because the stream object itself was dropped. (But see #2323.) - `StreamMap::close_stream` because an END message or similar has been received. (But see #2322.) - The `StreamMap` has been dropped. The first two cases are already handled, and AFAICT the third can only happen when the circuit hop closes. That makes `CircuitClosed` the appropriate error here, not `StreamProto`. Part of a fix for #2304.
* | proto: Improve some comments in relay moduleDavid Goulet2026-01-222-1/+8
| | | | | | | | Signed-off-by: David Goulet <[email protected]>
* | proto: Enforce condition with type systemDavid Goulet2026-01-221-5/+6
| | | | | | | | | | | | | | | | This commits returns either Some(AUTH_CELL, CERTS) or None. We future proof ourselves against one Some and other None even if an error check is done before. Signed-off-by: David Goulet <[email protected]>
* | proto: Fix the link auth handling from the AUTH_CHALLENGEDavid Goulet2026-01-221-2/+3
| | | | | | | | Signed-off-by: David Goulet <[email protected]>
* | proto: Add missing use for testsDavid Goulet2026-01-221-1/+1
| | | | | | | | Signed-off-by: David Goulet <[email protected]>
* | proto: Use the channel codec channel typeDavid Goulet2026-01-226-21/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Improve comments on build_auth_data() about clog/slogDavid Goulet2026-01-221-0/+4
| | | | | | | | Signed-off-by: David Goulet <[email protected]>
* | proto: Remove Option<> around peer_ip for build_netinfo_cell()David Goulet2026-01-222-4/+5
| | | | | | | | Signed-off-by: David Goulet <[email protected]>
* | proto: Put rsa_id and rsa_cert_digest togetherDavid Goulet2026-01-222-14/+13
| | | | | | | | | | | | Avoid having one None and the other Some which would be a bug. Signed-off-by: David Goulet <[email protected]>
* | proto: Avoid magic hardcoded value for LINK_AUTHDavid Goulet2026-01-222-3/+3
| | | | | | | | | | | | | | Instead, use the static AUTHTYPE_ED25519_SHA256_RFC5705 value which is for now the only version we support. Signed-off-by: David Goulet <[email protected]>
* | proto: Enforce CERTS and AUTHENTICATE are always expected togetherDavid Goulet2026-01-221-0/+6
| | | | | | | | | | | | | | A Responder receiving cells from the Initiator, if it gets a CERTS, an AUTHENTICATE must also be present (and vice-versa). Signed-off-by: David Goulet <[email protected]>
* | proto: Remove async for VerifiableChannel::check()David Goulet2026-01-223-6/+3
| | | | | | | | Signed-off-by: David Goulet <[email protected]>
* | proto: Move cell sending out of check() and into finish()David Goulet2026-01-222-37/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | This is so check() only authenticate a channel. The finish() function now only sends back the missing cells and build the final Channel. To pull this off, the AUTHENTICATE cell and our IP addresses need to be copied into the VerifiedRelayChannel. This allows us to remove complexity into the check() function as well and future commit will remove the async. Signed-off-by: David Goulet <[email protected]>
* | proto: Remove uneeded code in the unverified inner check()David Goulet2026-01-221-25/+3
| | | | | | | | | | | | | | | | | | | | We can't get into the UnverifiedChannel::check() without wanting to verify our identities and authenticate. This validation has moved before calling check() for the relay channel type. Signed-off-by: David Goulet <[email protected]>
* | proto: Implement FinalizableChannel for an unverified relay channelDavid Goulet2026-01-222-33/+128
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reason for this is so we can use the type system to enforce that a client/bridge<-> relay channel can never become verified and thus in the code path of authentication. In other words, when check() is called, without an authentication cell, we can't authenticate or even verify the identities so we immediately return "self" which in this case is the UnverifiedRelayChannel. That channel can be finish()-ed to yield a Channel that can never be considered authenticated. Signed-off-by: David Goulet <[email protected]>
* | proto: Send relay channel NETINFO in check()David Goulet2026-01-222-19/+25
| | | | | | | | | | | | | | | | | | | | Once channel is verified and authenticate if need be, send the NETINFO. We require our advertised IP addresses for this so pass them to launch() as well to the UnverifiedRelayChannel. A cargo fmt change slipped in here, sorry about that. Signed-off-by: David Goulet <[email protected]>