aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-proto/src/channel.rs
Commit message (Collapse)AuthorAgeFilesLines
* tor-proto: make 'testing_exports' available to own unit testsSteven Engler8 days1-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | This fixes: ```text $ cargo test -p tor-proto --features relay error[E0603]: enum import `CtrlMsg` is private --> crates/tor-proto/src/relay/reactor.rs:463:33 | 463 | use crate::channel::CtrlMsg; | ^^^^^^^ private enum import | note: the enum import `CtrlMsg` is defined here... --> crates/tor-proto/src/channel.rs:117:5 | 117 | use testing_exports::*; | ^^^^^^^^^^^^^^^^^^ note: ...and refers to the enum import `CtrlMsg` which is defined here... <snip> ``` There are a few ways we could fix this, but I don't see an advantage of one over another.
* proto: Make Channel::send_control() pub(crate) for testingGabriela Moldovan8 days1-0/+1
| | | | | | The relay circuit reactor tests will soon need the ability to send control messages (for allocating a circuit id for the circuit reactor under test).
* proto: Rename CircId and UniqId variable nameDavid Goulet2026-08-031-3/+3
| | | | | | | | | | | | | | | A CircId is now a circ_id and a UniqId is a unique_id so we stop confusing them in the code. Furthermore, channel_id that are CircId are now circ_id. Channel IDs are different and encoded internally into a UniqId. This is the first step to clarify semantic before we change the logging to log both unique ID and circ ID. No behavior change. Signed-off-by: David Goulet <[email protected]>
* tor-proto: add 'test_utils' mod for channel testsSteven Engler2026-07-291-0/+3
| | | | These help to establish connected channel objects to be used for tests.
* proto: Replace CircuitRx{Sender,Receiver} with new channel typeGabriela Moldovan2026-06-081-0/+3
| | | | | | | | | | This is needed for relays as part of #2490. Note that changing this type affects the client implementation too (i.e. clients will start prioritizing inbound DESTROY, discarding any queued data without forwarding it to their local streams). But that's okay, because it will generally only affect misbehaving clients, and clients unlucky enough to encounter a hibernating relay.
* proto: Wrap PeerInfo in Arc<>Gabriela Moldovan2026-04-231-5/+5
| | | | | | To avoid copying the same information for every circuit, as suggested by @opara in https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/3906#note_3399497
* proto: Remove expect(unused) from channel PeerInfoGabriela Moldovan2026-04-231-1/+0
| | | | This is used in the relay circuit reactor.
* proto: Add an accessor for the PeerInfo of a channelGabriela Moldovan2026-04-231-0/+6
|
* tor-proto: give our rsa ident to the channel reactorSteven Engler2026-04-161-1/+5
| | | | This will be needed for ntor handshakes.
* proto: Remove re-export of MsgBuf in unit testsDavid Goulet2026-04-141-3/+1
| | | | Signed-off-by: David Goulet <[email protected]>
* proto: Move channel client handshake tests into client moduleDavid Goulet2026-04-141-0/+2
| | | | | | | | | No behavior change. Make the const cells public as they will be useful for more upcoming unit tests especially on the relay side. Signed-off-by: David Goulet <[email protected]>
* tor-proto: replace a tuple with a dedicated structSteven Engler2026-04-091-5/+6
|
* tor-proto: give our ed ident to the channel reactorSteven Engler2026-04-091-2/+10
| | | | This will be needed for ntor handshakes.
* proto: Add ClogDigest and SlogDigest typesDavid Goulet2026-04-081-1/+1
| | | | | | | | | Introduce those types in order to avoid mixing them up as the previous AuthLogDigest was just a type alias over [u8; 32] Fixes #2441 Signed-off-by: David Goulet <[email protected]>
* Merge branch 'create-fast' into 'main'opara2026-04-081-23/+76
|\ | | | | | | | | Add support for handling CREATE_FAST cells and launching a circuit reactor See merge request tpo/core/arti!3846
| * tor-proto: replace use of `ChannelDirection` with `CircIdRange`Steven Engler2026-04-081-19/+8
| |
| * tor-{proto,chanmgr}: change how channels accept a CREATE* handlerSteven Engler2026-04-081-50/+73
| | | | | | | | | | | | | | | | | | | | | | Instead of giving the `CreateRequestHandler` to the channel after it's constructed, we integrate it into the handshake so that we can give it to the channel constructor. The `ChannelType` is no longer part of the `Channel`. Some of the tests could be cleaned up slightly now that the channel doesn't need the `ChannelType`, but I don't want to conflict with !3853.
| * tor-proto: add `Channel::set_create_request_handler()`Steven Engler2026-04-081-2/+41
| | | | | | | | | | | | We can't pass the request handler during the `Channel` constructor since it would require conditionally compiled function arguments, which aren't nice.
| * tor-proto: add `CreateRequestHandler`Steven Engler2026-04-081-0/+2
| | | | | | | | for handling CREATE* messages on channels.
| * tor-proto: change channel to use `Runtime`Steven Engler2026-04-081-9/+9
| | | | | | | | | | When used for relay channels, the channel reactor will soon need to spawn relay circuit reactors.
* | Merge branch 'memquota-add-parent' into 'main'gabi-2502026-04-081-6/+4
|\ \ | |/ |/| | | | | | | | | memquota: Add new add_parent() API Closes #2427 See merge request tpo/core/arti!3829
| * proto: Link the memquota circ acc with the outbound chan accGabriela Moldovan2026-03-301-6/+4
| | | | | | | | Closes #2427
* | proto: Add a type alias for SLOG/CLOG digestDavid Goulet2026-03-301-0/+1
|/ | | | | | https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/3791#note_3374457 Signed-off-by: David Goulet <[email protected]>
* proto: Add TODO about relay memquota setupGabriela Moldovan2026-03-261-0/+6
|
* proto: Use the inbound CircuitAccount when extending circuitGabriela Moldovan2026-03-261-1/+1
| | | | | This was previously creating a new CircuitAccount in `new_outbound_circ()`, and then immediately dropping it.
* tor-proto: require cells from responder to be orderedSteven Engler2026-03-031-1/+0
|
* safelog: Rename MaybeSensitive::hidden/visible()David Goulet2026-03-031-2/+2
| | | | | | Rename them to respectively sensitive() and not_sensitive(). Signed-off-by: David Goulet <[email protected]>
* proto: Setup the channel PeerInfo in the specialized finish()David Goulet2026-03-031-6/+5
| | | | | | | | | | | Every specific types know if the peer is sensitive or not so now the finish() of each of these channel types builds the right PeerInfo with MaybeSensitive. This is passed on the Channel so from that point on, the Channel will never leak peer data in the logs. Signed-off-by: David Goulet <[email protected]>
* chanmgr: Use CircIdRange::Low for relay channelsDavid Goulet2026-02-251-1/+5
| | | | | | Closes #1601 Signed-off-by: David Goulet <[email protected]>
* proto: Remove Default of PeerInfo/Addr and use const insteadDavid Goulet2026-02-191-2/+2
| | | | Signed-off-by: David Goulet <[email protected]>
* proto: Fix clippy errorsDavid Goulet2026-02-191-3/+1
| | | | Signed-off-by: David Goulet <[email protected]>
* proto: Put a PeerInfo in ChannelDavid Goulet2026-02-191-1/+9
| | | | Signed-off-by: David Goulet <[email protected]>
* proto: Use the PeerAddr accross channel handshakeDavid Goulet2026-02-191-2/+10
| | | | | | | 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]>
* proto: Remove unused ChannelBuilderDavid Goulet2026-02-191-77/+3
| | | | Signed-off-by: David Goulet <[email protected]>
* chan: Use Canonicity when choosing a channelDavid Goulet2026-02-121-3/+10
| | | | Signed-off-by: David Goulet <[email protected]>
* proto: Channel finish() now handles canonicityDavid Goulet2026-02-121-3/+7
| | | | | | | | | | | | | | 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: Implement a Canonicity structDavid Goulet2026-02-121-1/+51
| | | | | | | | | | | | | | | | | This struct will be put in a Channel and derived from the received NETINFO cell. This follows the C-tor implementation for which we have two indicator of canonicity: 1. Peer is canonical: the address they advertise in the NETINFO cell matches the one we see on the TCP connection. 2. Canonical to peer: the peer sees us as canonical. Those flag will get used to select "the best" channel. Signed-off-by: David Goulet <[email protected]>
* proto: Add Channel function for launching outbound relay circuitsGabriela Moldovan2026-02-051-0/+47
| | | | This is currently very similar to its client counterpart.
* proto: Remove unused traits after type refactoringDavid Goulet2026-02-041-73/+0
| | | | Signed-off-by: David Goulet <[email protected]>
* proto: Move TimeoutEstimator to utilGabriela Moldovan2026-01-291-1/+2
| | | | | This will be used in the stream reactor too (and the stream reactor will eventually replace the corresponding client impl).
* proto: Improve some comments in relay moduleDavid Goulet2026-01-221-1/+2
| | | | 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: Move cell sending out of check() and into finish()David Goulet2026-01-221-5/+0
| | | | | | | | | | | | | 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: Authenticate a relay channelDavid Goulet2026-01-221-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is a bit loaded but it is coherent. First, we set Eq and PartialEq to the channel message Authenticate so we can compare it with the one we expected. Second, the AuthenticationCell enum is introduced to store either an AUTH_CHALLENGE or an AUTHENTICATE since one side of the handshake can only have one. This allows us to store one or the other in UnverifiedRelayChannel. Depending on what we have, the authentication process is different as it dictates which side we are on (initiator vs responder). Keep in mind that the handshake code enforces receiving a AUTH_CHALLENGE along side CERTS. And same goes for AUTHENTICATE which means that if we have an AUTH_CHALLENGE in the UnverifiedRelayChannel, it is certain that the other side wants to authenticate and we are the initiator. Finally, the sending of CERTS and AUTHENTICATE by the initiator is now in UnverifiedRelayChannel::check() done right after verifying the channel CERTS and holding a "VerifiedChannel" object. This means that the last piece, sending the `NETINFO` by the initiator will be done in the check() but in a future commit. This leaves the VerifiableChannel::finish() to send nothing and only finalize the channel with the NETINFO (canonicity). 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-0/+7
| | | | | | | | | | | | | | | 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]>
* proto: Fix comments documentationDavid Goulet2026-01-131-1/+1
|
* proto: Seal the VerifiableChannel and FinalizableChannel traitsDavid Goulet2026-01-131-2/+10
| | | | | | They are public but avoid anyone outside implementing them. Signed-off-by: David Goulet <[email protected]>
* proto: Improve channel trait commentsDavid Goulet2026-01-131-0/+7
| | | | Signed-off-by: David Goulet <[email protected]>
* proto: Add link_protocol() to VerifiableChannel traitDavid Goulet2026-01-131-0/+4
| | | | Signed-off-by: David Goulet <[email protected]>