summaryrefslogtreecommitdiff
path: root/crates/arti-relay/src/relay.rs
Commit message (Collapse)AuthorAgeFilesLines
* proto: Pass an IncomingStreamRequestFilter factory to the create handlerGabriela Moldovan2026-06-291-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements what we discussed in `doc/dev/notes/relay-streams.md` (lines 218-234): > Currently, to allow incoming stream requests on a circuit, > you first need to call `RelayCirc::allow_stream_requests()` > to install a `CmdChecker` and `IncomingStreamRequestFilter`. > This is not ideal, because `allow_stream_requests()` will need to be > called unconditionally, on each `RelayCirc`, > right after it's created in the `CreateHandler` impl > (which in turn, would mean making `handle_create()` async too, > because `allow_stream_requests()` is async, which wouldn't be great). > > So, the first step here is to rework the `RelayCirc` API to make relay circuits > be constructable with a list of allowed `RelayCmd`s and `IncomingStreamRequestFilter` > from the get-go ([#2582]), and to get rid of `allow_stream_requests()`, > which will enable the `CREATE*` handler to remain non-`async`. > > In any case, the `CREATE*` handler will still require some changes, > because it needs to be initialized with an `IncomingStreamRequestFilter`, I am not sure using an `IncomingStreamRequestFilter` "factory" is necessarily the right approach here, but the circuit `Reactor`'s constructor needs to take an `IncomingStreamRequestFilter`, and `IncomingStreamRequestFilter` is not `Clone` (and FWIW, I think it's better if we don't make it `Clone`). One obvious limitation is that the `IncomingStreamRequestFilter` of the circuit reactor is fixed for the entire lifetime of the circuit. In practice, I don't think this is going to be a problem, because the arti-relay `IncomingStreamRequestFilter` is only going be used for * preventing single-hop exit streams * per-circuit rate-limiting. Both of these checks will require the filter to have access to a recent `NetDir`, which is straightforward if the filter has an Arc<dyn NetDirProvider> (as mentioned in doc/dev/notes/relay-streams.md, `NetDirProvider` has a handy non-async `timely_netdir()` function we can use). And since these checks are based on consensus params, we don't really need to ever update an already-built circuit with a new `IncomingStreamRequestFilter` (because all `IncomingStreamRequestFilter` will have the ability to obtain a fresh `NetDir` as needed). Nevertheless, I left a TODO about this, because I expect this type to change once we figure out all the other pieces needed for #1448.
* relay: Recompute valid_until cache in view constructorDavid Goulet2026-05-281-1/+1
| | | | | | | | | | | | | The recompute of the valid_until cache is done now in the constructor of FullKeyView so the view is directly usable once built. Else, the caller always need to call the recompute function which is error prone especially when used as a throwaway view. Also, without this change, building the view and then attempting to log the public keys would fail. Signed-off-by: David Goulet <[email protected]>
* relay: Rename try_generate_keys()David Goulet2026-05-281-3/+2
| | | | | | | | | | Rename it to init_keys() so it capture the semantic of initialization especially that now it returns a InitKeyMaterial. This is so we don't use this function outside initialization in the future. Signed-off-by: David Goulet <[email protected]>
* relay: Make FullKewView solely owned by the crypto taskDavid Goulet2026-05-281-23/+19
| | | | | | | | | | | | | | | | | | | This moves commit makes it that FullKewView is not visible outside the crypto task. For this, we need to keep the KeyMgr in the inert tor relay struct until it is passed to the crypto task. The public keys logging is moved to the run() function of the crypto task and the try_generate_keys() now returns an InitKeyMaterial struct which contains the channel authentication key material (for ChanMgr) and the Ntor keys for the CREATE2 handler. This way, we cut the need of the FullKeyView in the main thread. Related to #2548 Signed-off-by: David Goulet <[email protected]>
* relay: Crypto task now listens for new consensusDavid Goulet2026-05-261-0/+1
| | | | Signed-off-by: David Goulet <[email protected]>
* relay: Set the FullKeyView in InerTorRelayDavid Goulet2026-05-261-16/+13
| | | | | | | | | | | | | This is so we early set the FullKeyView and we use it accross the code from initialization. The try_generate_keys() now takes a view and locks it to make its changes. And we also make build_proto_relay_auth_material() use a view to simplify its code and also stop relying on the KeyMgr for key accessors. Signed-off-by: David Goulet <[email protected]>
* relay: Spawn new crypto reactorDavid Goulet2026-05-261-14/+15
| | | | | | This also remove unused code from this change. Signed-off-by: David Goulet <[email protected]>
* tor-rtcompat+misc: add `NetStreamProvider::ListenOptions`Steven Engler2026-05-071-1/+4
| | | | | | | | | This adds the trait type `ListenOptions` to `NetStreamProvider` and adds this `ListenOptions` as an argument to `NetStreamProvider::listen()`. You probably want to look at the changes in tor-rtcompat first, then the rest of this commit is updating the various places we use `NetStreamProvider`.
* proto: Make the CreateRequestHandler::new() take the ntor keysDavid Goulet2026-04-211-2/+8
| | | | Signed-off-by: David Goulet <[email protected]>
* arti-relays: Pass a CreateRequestHandler to the crypto task (fmt)Gabriela Moldovan2026-04-091-3/+8
|
* arti-relays: Pass a CreateRequestHandler to the crypto taskGabriela Moldovan2026-04-091-1/+2
| | | | This will need to be updated each time the ntor keys change.
* relay: Pass advertise SocketAddr to channel builder instead of IpAddrDavid Goulet2026-04-091-1/+1
| | | | | | | | | | This trickles down to the tor-proto channel handshake code. But, the real need is in the channel builder in order to validate the outbound channel target. Fixes #2440 Signed-off-by: David Goulet <[email protected]>
* arti-relay: add support for a `CreateRequestHandler`Steven Engler2026-04-081-1/+53
|
* proto: Rename RelayIdentities to RelayChannelAuthMaterialDavid Goulet2026-03-301-5/+5
| | | | | | | | | | | | This object contains a melting pot of public keys, private keys and certificates. Rename it to reflect that it is channel authentication material and not "identities. https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/3791#note_3374454 Signed-off-by: David Goulet <[email protected]>
* relay: Make the crypto tasks use the runtime wallclockDavid Goulet2026-03-171-1/+1
| | | | | | This way we can unit tests properly. Signed-off-by: David Goulet <[email protected]>
* Fix windows cargo warningsTobias Stoeckmann2026-03-151-1/+3
| | | | Disable use-statements which are only needed for unix.
* arti-relay: Log relay identitiesSteven Engler2026-03-121-0/+5
|
* tor-basic-utils: move `iter_join` from arti-relaySteven Engler2026-03-031-1/+2
| | | | Will clean this up in the following commit.
* chanmgr: Responder relay channel now use the builder my_addrsDavid Goulet2026-02-241-15/+3
| | | | | | No need to pass from the arti relay binary our addresses when handling an incoming channel, use the one in the channel builder that an initiator channel uses.
* relay: Set ChanMgr with our addressesDavid Goulet2026-02-241-2/+3
| | | | Signed-off-by: David Goulet <[email protected]>
* relay: Update ChanMgr on key rotationDavid Goulet2026-02-241-1/+2
| | | | Signed-off-by: David Goulet <[email protected]>
* arti-relay: fix stale commentSteven Engler2026-02-231-1/+1
| | | | This method was renamed previously.
* relay: Get rid of start_task() for readabilityDavid Goulet2026-02-231-5/+9
| | | | Signed-off-by: David Goulet <[email protected]>
* relay: Generate relay identities at initDavid Goulet2026-02-231-4/+12
| | | | Signed-off-by: David Goulet <[email protected]>
* relay: Remove unused ephemeral keystoreDavid Goulet2026-02-231-5/+1
| | | | Signed-off-by: David Goulet <[email protected]>
* relay: Move try_generate_keys() into crypto taskDavid Goulet2026-02-231-34/+2
| | | | | | | Move rotating keys into a function so we can use it in try_generate_keys() that is used at startup. Signed-off-by: David Goulet <[email protected]>
* relay: Add a crypto task for key rotationDavid Goulet2026-02-231-1/+7
| | | | | | | | | | | | | This task crypto module has a rotate key task that is in charge of rotating keys from our KeyMgr based on the valid until. To do so, we add a RotatableKeySpec trait to help us specify our to rotate a specific key. Allows us to have a generic rotate/generate function for all our keys. Task runs every 60 seconds. Taken from C-tor. Signed-off-by: David Goulet <[email protected]>
* relay: Add a TLS acceptor in the ChanBuilderDavid Goulet2026-02-091-7/+10
| | | | | | | | | | | | | | | This requires the `TlsKeyAndCert` so be passed on the TLS acceptor settings. We assume that `RelayIdentities` has this information. The ChanBuilder::new() was getting a bit too convoluted and feature gated to instead we introduce new_client() and new_relay() and remove the need for `with_identities()`. Because of this, the ChanMgr::new() now returns a `Result<>`. Related to #1597 Signed-off-by: David Goulet <[email protected]>
* arti-relay: launch the client's background tasksSteven Engler2026-02-031-6/+19
|
* arti-relay: rename 'bootstrap()' method to 'init()'Steven Engler2026-02-031-6/+7
| | | | This method won't really be used for bootstrapping anymore.
* arti-relay: move code into a "client" objectSteven Engler2026-02-031-64/+17
|
* relay: Pass advertised addresses to the channel handlerDavid Goulet2026-01-221-3/+15
| | | | | | | | | | | We need the advertised addresses for the NETINFO cell when opening a relay channel. Keep them in the TorRelay object so we can pass them to the ChanMgr channel handler. This will also help with config reload where only the local values in TorRelay will need to be updated. Signed-off-by: David Goulet <[email protected]>
* chanmgr: Introduce a ChanMgrConfig structDavid Goulet2026-01-131-2/+2
| | | | | | | | | | | | This struct is used to pass configuration parameters to the ChanMgr when building it. At the moment, it holds the ChannelConfig and RelayIdentities (feature gated) which will be used in subsequent commits. Note that relays do require RelayIdentities to build channels. Signed-off-by: David Goulet <[email protected]>
* chanmgr: Remove KeyMgr from constructorDavid Goulet2026-01-131-1/+0
| | | | | | | We'll rely on a RelayIdentities to pass in the right keys to the ChanMgr instead of the entire KeyMgr. Signed-off-by: David Goulet <[email protected]>
* arti-relay: added more commentsSteven Engler2025-12-181-0/+7
|
* arti-relay: some small cleanupSteven Engler2025-12-171-4/+6
|
* arti-relay: add a `GuardMgr`, `CircMgr`, and `DirMgr`Steven Engler2025-12-171-1/+78
|
* arti,arti-relay: change info keystore path msg to debugSteven Engler2025-12-111-2/+5
|
* arti-relay: listen at configured OR portsSteven Engler2025-11-121-13/+55
|
* arti-relay: `TorRelay::run` now takes an owned `self`Steven Engler2025-11-121-1/+1
|
* arti-relay: remove `Clone` from `TorRelay`Steven Engler2025-11-121-1/+0
| | | | I don't expect that we'll need this.
* arti-relay: update some comments from past few commitsSteven Engler2025-11-111-1/+3
|
* arti-relay: add OR port listener taskSteven Engler2025-11-051-2/+22
| | | | | This does not yet get the OR port from the config, and the channel manager doesn't yet do anything with the incoming connection.
* arti-relay: add error context to house keeping taskSteven Engler2025-11-051-5/+11
|
* arti-relay: use `Void` for `TorRelay::run`Steven Engler2025-10-271-7/+10
|
* arti-relay: add line breaks between `InertTorRelay` fieldsSteven Engler2025-10-211-0/+5
|
* arti-relay: add a `MemoryQuotaTracker`Steven Engler2025-10-211-3/+12
|
* arti-relay: small refactoringSteven Engler2025-10-211-7/+6
|
* arti-relay: generate keys only when bootstrappingSteven Engler2025-10-211-3/+3
| | | | | We don't want to create new files just when creating a `InertTorRelay`. We should only generate the keys before bootstrapping.
* arti-relay: copy `state_mgr.try_lock()` from arti-clientSteven Engler2025-10-211-1/+8
|