summaryrefslogtreecommitdiff
path: root/crates/tor-proto/src/stream
Commit message (Collapse)AuthorAgeFilesLines
* tor-proto: Make some imports more preciseIan Jackson2023-08-231-1/+3
| | | | | | | | A warning is getting in my way when I run cargo clippy -p tor-hsservice --all-features See also https://gitlab.torproject.org/tpo/core/arti/-/issues/1006#note_2932088
* tor-proto: Make update_state() and discard() return Result<(), Bug>.Gabriela Moldovan2023-08-091-5/+5
| | | | These functions only ever return `Bug` errors.
* tor-proto: Implement IncomingStream::discard().Gabriela Moldovan2023-08-081-2/+2
|
* tor-proto: Replace boolean flags with an IncomingStreamState enum.Gabriela Moldovan2023-08-081-18/+56
| | | | | | | | | | This commit introduces an `IncomingStreamState` enum, which indicates whether the stream was accepted, discarded, or rejected, or if it is still pending. The `is_rejected`/`is_accepted` boolean flags are no longer needed. Without this change, we'd need to introduce yet another boolean flag when we implement `discard()` (for the "discarded" state).
* Merge branch 'tor-proto-incoming-todo' into 'main'gabi-2502023-08-081-18/+15
|\ | | | | | | | | tor-proto: Replace IncomingStreamMsg with IncomingStreamRequest. See merge request tpo/core/arti!1477
| * tor-proto: Replace IncomingStreamMsg with IncomingStreamRequest.Gabriela Moldovan2023-08-071-18/+15
| | | | | | | | | | | | | | | | The two enums essentially serve the same purpose, so we don't need both of them. This also addresses the TODO that says we should return an error if `accept_data` is called for a RESOLVE stream.
* | tor-proto: Fix broken docs.Gabriela Moldovan2023-08-081-1/+1
| |
* | tor-proto: Make it obvious that we're discarding a Result.Gabriela Moldovan2023-08-081-1/+1
| |
* | tor-proto: Make StreamTarget::close return the oneshot::Receiver instead of ↵Gabriela Moldovan2023-08-081-10/+9
| | | | | | | | | | | | | | | | | | | | | | | | blocking. Instead of having 2 version of `StreamTarget::close` (a blocking one and a nonblocking one), we can just return the `oneshot::Receiver` for receiving the reactor's response and let the caller of `StreamTarget::close` decide whether to block. This allows us to reduce some code duplication in the `IncomingStream` implementation.
* | tor-proto: Make take_inner() use mut_inner() to check the inner value.Gabriela Moldovan2023-08-081-3/+6
|/
* tor-proto: Implement `Drop` for `IncomingStream`.Gabriela Moldovan2023-08-071-11/+64
|
* tor-proto: Keep track of whether the `IncomingStream` was accepted.Gabriela Moldovan2023-08-071-0/+5
| | | | | The behaviour of `IncomingStream::drop` is going to depend on whether the stream was accepted or not.
* tor-proto: Rename misleading field in `DataCmdChecker`.Gabriela Moldovan2023-08-071-13/+16
| | | | | | | | This is a follow-up from !1451. This commit solves a `TODO HSS` introduced when `DataCmdChecker` got an additional constructor (`new_connected`) for creating "pre-connected" streams. See f6745d31 for more details.
* tor-proto: Implement IncomingStream::{accept_data, request, reject}.Gabriela Moldovan2023-08-031-6/+32
|
* tor-proto: Remove extraneous space.Gabriela Moldovan2023-08-031-1/+1
|
* tor-proto: Add constructors for pre-connected DataStreams.Gabriela Moldovan2023-08-031-2/+41
| | | | | | | | | When accepting a new stream, hidden services, exit relays and dirauths don't wait for a `CONNECTED` cell from the initiator. This commit adds constructors for building `DataStream`s and `DataCmdChecker`s that can immediately receive data cells (and don't expect to receive `CONNECTED` cells at all).
* tor-proto: Add a constructor for IncomingStream.Gabriela Moldovan2023-08-031-0/+13
|
* tor-proto: Add imports for commonly used types.Gabriela Moldovan2023-08-031-4/+4
|
* tor-proto: Add IncomingCmdChecker for IncomingStream.Gabriela Moldovan2023-08-031-2/+59
|
* Remove explicit allows for missing_panics_docs.Nick Mathewson2023-07-061-6/+1
| | | | These are no longer needed.
* proto: downgrade some "TODO HS" comments to "HSS"Nick Mathewson2023-06-211-5/+5
| | | | | These are all related to issues that will come up for the service side of the onion service implementation.
* Add "TODO RPC" notes around DataStreamCtrl per review.Nick Mathewson2023-05-242-0/+16
|
* proto: Add stream-status functionality to DataStreamCtrl.Nick Mathewson2023-05-241-2/+106
| | | | There are some weaknesses and problems here; see TODO notes.
* proto: Create a `DataStreamCtrl` type.Nick Mathewson2023-05-222-1/+108
| | | | | | | | | | | | | | | | | The idea here is that we want to make DataStream visible to the RPC system without requiring that the RPC session hold the DataStream itself (or the Reader, or the Writer). We could solve this problem by making _all_ the state in the DataStream shared, but that would introduce unnecessary extra locking in our critical path. Instead we're creating the notion of a "control handle" that lets you manage and observe a stream without actually owning the stream. Right now the only supported functionality is asking for the stream's circuit. Part of #847
* Refactor ClientCirc APIs to use Arc<ClientCirc>.Nick Mathewson2023-05-161-1/+1
| | | | | | | | | | | | Now ClientCirc is no longer `Clone`, and the things that need it to be `Clone` instead return and use an Arc<ClientCirc> We're doing this so that ClientCirc can participate in the RPC system, and so that its semantics are more obvious. Closes #846. Thanks to the type system, this was a much simpler refactoring than I had feared it would be.
* Add some missing importsIan Jackson2023-03-281-1/+4
| | | | | | | | Now nailing-cargo +stable clippy -p tor-hsclient --all-features --all-targets actually works. squash! Add some missing imports
* Add an experimental circuit accessor to DataStream.Nick Mathewson2023-03-231-2/+28
| | | | Closes #784.
* proto: Tweak documentation and names around CmdChecker.Nick Mathewson2023-02-273-8/+16
|
* tor-proto: Introduce CmdChecker, and define it for our streams.Nick Mathewson2023-02-173-0/+147
| | | | | | | | The role of CmdChecker is to verify that messages are arriving at the appropriate sequence on a stream, with respect to the other messages that have been received. Once the stream becomes half-closed, the CmdChecker is also in charge of consuming incoming messages on the stream and making sure that they are well-formed.
* tor-proto: note implications for future HS workNick Mathewson2023-02-151-0/+2
|
* tor-proto: Push stream message parsing into the stream objects.Nick Mathewson2023-02-153-31/+67
| | | | | This closes #525, and ensures, at last, that we don't parse any message that we wouldn't accept.
* tor-cell: Rename RelayMsg and RelayCell-related types.Nick Mathewson2023-02-073-14/+14
| | | | Thanks to rust-analyzer for making this simple.
* tor-cell: Remove RelayMsg methods that are duplicated in RelayMsgClass.Nick Mathewson2023-02-072-0/+2
|
* tor-proto: Draft API to handle incoming BEGIN requests.Nick Mathewson2023-01-171-0/+67
| | | | Onion services (and later, exits and caches) will need this.
* proto: Only ready a DataStream if CONNECTED was succesfully receivedDavid Goulet2022-05-311-1/+4
| | | | Signed-off-by: David Goulet <[email protected]>
* Move skip_fmt into tor-basic-utilsIan Jackson2022-03-041-1/+1
| | | | | | | Code motion and the minimal mechanical changes. As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/375#note_2783078
* Replace manual Debug impls with educe in tor-protoIan Jackson2022-03-021-32/+23
| | | | We now print slighly more information.
* tor-proto datastream: Fix typo in Debug implIan Jackson2022-02-251-1/+1
| | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/353#note_2781632
* Fix rustfmtIan Jackson2022-02-241-1/+1
|
* tor-proto datastream: Do not dump packet data in DataWriterImplIan Jackson2022-02-241-2/+9
|
* tor-proto datastream: import std::fmt::Debug trait nameIan Jackson2022-02-241-2/+2
|
* impl Debug for DataStream (and its components)Ian Jackson2022-02-242-0/+17
| | | | | | | | | My proximate motivation is that tls-api wants its inner streams to be Debug. But in general, I agree with the Rust API Guidelines notion that almost everything should be Debug. I have gone for the "dump all the things" approach. A more nuanced approach would be possible too.
* Update tor-proto errors to latest API.Nick Mathewson2022-02-151-1/+1
|
* Make tor-proto::Error implement HasKind.Nick Mathewson2022-02-151-1/+1
| | | | | | This took some refactoring, and gave an opportunity to notice a few error variants that weren't being used, or didn't mean what they said on the tin.
* tor-proto: use InternalError for internal errors.Nick Mathewson2022-02-151-3/+15
|
* Add a blank line between doc and comment.Ian Jackson2022-01-111-0/+1
|
* Improve the layout of crate exports; add runtime convenience functionseta2022-01-111-5/+35
| | | | | | | | | | | | | | | | | | | | This commit addresses multiple problems highlighted by arti#182: - `arti-client` had some types in its public API that weren't accessible without importing another crate (`CfgPath`, `DataReader`, `DataWriter`). This has been fixed. - In addition, the doc comments for `DataReader` and `DataWriter` were cleaned up to be of better quality, now that they're public. - It was impossible to use `arti-client` without also importing `tor-rtcompat`. This is now fixed by the addition of two convenience methods: `TorClient::bootstrap_with_tokio` and `TorClient::bootstrap_with_async_std`. - Potentially controversially: `tor-rtcompat` now returns *concrete* types from methods like `current_runtime`, instead of `impl Runtime`. - This was needed in order to actually be able to name the `TorClient` type that results from using these methods. - This does mean we lose API flexibility, but on balance I think this is a good thing, because the API we *do* have is actually usable...
* tor-proto: document an infelicitous behavior.Nick Mathewson2021-12-161-3/+4
| | | | | This was an XXXX before. Now it explains why the behavior is safe for now, but maybe not forever.
* Get rid of unbounded stream sender, and RawCellStreameta2021-11-123-76/+47
| | | | | | | | | | | | | | | | | | | | | Previously, the reactor would use an `UnboundedSender` to send things to the `RawCellStream`, in order that the reactor wouldn't block if you failed to read from the latter. This is bad, though, since it means people can just run us out of memory by sending lots of things. To fix this, we make the new `StreamReader` type (which does the reading parts from `RawCellStream`) keep track of the stream's receive window and issue SENDMEs once *it* has consumed enough data to require it, thus meaning that we shouldn't get sent enough data to fill the channel between reactor and `StreamReader` (and, if we do, that's someone trying to flood us, and we abort the circuit). As hinted to above, the `RawCellStream` was removed and its reading functionalities replaced by `StreamReader`; its writing functionalities are handled by `StreamTarget` anyway, so we just give out one of those for the write end. This now means we don't need any mutexes! note: this commit introduces a known issue, arti#230
* Completely overhaul the tor-proto circuit reactoreta2021-11-121-22/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rather like e8e9699c3c239d6c30f9ad414f15d3bad6ec03fd ("Get rid of tor-proto's ChannelImpl, and use the reactor more instead"), this admittedly rather large commit refactors the way circuits in `tor-proto` work, centralising all of the logic in one large nonblocking reactor which other things send messages into and out of, instead of having a bunch of `-Impl` types that are protected by mutexes. Congestion control becomes a lot simpler with this refactor, since the reactor can manage both stream- and circuit-level congestion control unilaterally without having to share this information with consumers, meaning we can get rid of some locks. The way streams work also changes, in order to facilitate better handling of backpressure / fairness between streams: each stream now has a set of channels to send and receive messages over, instead of sending relay cells directly onto the channel (now, the reactor pulls messages off each stream in each map, and tries to avoid doing so if it won't be able to forward them yet). Additionally, a lot of "close this circuit / stream" messages aren't required any more, since that state is simply indicated by one end of a channel going away. This should make cleanup a lot less brittle. Getting all of this to work involved writing a fair deal of intricate nonblocking code in Reactor::run_once that tries very hard to be mindful of making backpressure work correctly (and congestion control); the old code could get away with having tasks .await on things, but the new reactor can't really do this (as it'd lock the reactor up), so has to do everything in a nonblocking manner.