summaryrefslogtreecommitdiff
path: root/crates/tor-proto/src/stream
Commit message (Collapse)AuthorAgeFilesLines
* Fix clippy::doc_lazy_continuationIan Jackson2024-07-081-1/+1
|
* proto: Try to clarify why StreamReader has a StreamTarget.Nick Mathewson2024-05-292-3/+10
|
* proto: Improve documentation about DataStream lifetimes and closingNick Mathewson2024-05-291-0/+30
| | | | | | | In particular, clarify that dropping the DataWriter on its own does nothing unless the DataReader is also dropped. Related to #1368.
* proto: Make DataWriter::close actually do something.Nick Mathewson2024-05-291-7/+21
| | | | | | | | | | | | | | | | | | | Previously we had a bug where `<DataWriter as AsyncWrite>::close` (or `shutdown` in tokio-land) would not actually have any effect. It _would_ drop the `StreamTarget` held by the `DataWriter`, but since the `DataReader` also held a `StreamTarget`, the MPSC channel would not get closed, and the circuit reactor would not realize that the stream wanted to shut down. Now we use `mpsc::Sender::close_channel` to make our closes effectual. Closes #1368. Additionally, we fix a bug where `poll_close()` never actually did anything if the buffer had nothing in it when it was called. Previously, `poll_flush_impl()` would exit immediately if it had no data to flush. That isn't what we want when we are closing!
* proto: Explicitly enforce maxima on SENDME windows.Nick Mathewson2024-05-141-1/+1
| | | | | | | | | | | | | | No actual bug here, just technical debt: For `SendWindow`s, our tag system already ensured that we rejected any SENDME that didn't correspond to an appropriate drain. Still, it doesn't hurt to check. For `RecvWindow`s, it would have been a protocol violation if we ever did this, but it makes sense to make it an internal error if we try. Part of #1383.
* proto: Fix compilation with stream-ctrl but not experimental-api.Nick Mathewson2024-05-141-1/+1
|
* proto: Expose wait_for_connection as a part of the DataStream API.Nick Mathewson2024-05-091-1/+1
|
* Rename the old IncomingStreamRequestContext to StreamReqInfo.Nick Mathewson2024-03-261-3/+1
| | | | (Doing this to prevent us having two structs with the same name.)
* Add an IncomingStreamRequestFilter to check early propertiesNick Mathewson2024-03-261-1/+46
| | | | | | | Based on designs in #1124. Note that there is a TODO here about a hack I had to do to appease the borrow checker.
* Run maint/add_warning.Nick Mathewson2024-03-131-0/+1
|
* relay-cell: Update relay cell decoding API for prop340Jim Newsome2024-03-121-2/+2
| | | | | | | | | | | Prop 340: https://spec.torproject.org/proposals/340-packed-and-fragmented.html This updates the decoding API to support multiple versions of the relay cell encoding, including the new encoding proposed in prop340 that supports relay message packing and fragmentation. This commit doesn't actually add support for that new encoding yet.
* Rename UnparsedRelayCell -> UnparsedRelayMsgJim Newsome2024-03-125-15/+15
| | | | | For consistency with the terminology proposed in https://gitlab.torproject.org/tpo/core/torspec/-/issues/253
* tor_cell: never construct empty DATA messages.Nick Mathewson2024-02-132-11/+11
| | | | | | | We never actually constructed these before, but now we enforce it at the API level. Part of #1269.
* Rename {Any}RelayCell to {Any}RelayMsgOuterNick Mathewson2023-12-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is pure renaming, done automatically with rust-analyzer. Comment fixes and other cleanups will be in the subsequent commits. We're doing this renaming because we need a name for the combination of a `RelayMsg` and an `Option<StreamId>` that we use when we have a `RelayMsg` we intend to route to a given stream or circuit internally. Previously we called this a `RelayCell`, but that name was already somewhat inaccurate, and will become _very_ inaccurate with the arrival of prop340, which breaksthe 1:1 relationship between relay cells and relay messages. (If we didn't do this renaming now, we'd soon be making the relationship between `UnparsedRelayCell`and `RelayCell` many-to-many, which would be ridiculous and confusing.) The `RelayMsgOuter` name is a placeholder: We expect that we'll want to rename this type, and may also want to rename `RelayMsg`, and unify our vocabulary in other areas too. But such a renaming will have to wait for a larger discussion affecting the specifications, so that we can use the same vocabulary everywhere.
* Send less information in onion service BEGIN messagesNick Mathewson2023-11-151-1/+34
| | | | | | | | | While looking for differences, we found that C tor always omits the flags and the hostname from a BEGIN message sent on an onion service circuit. In torspec!179, we specified that behavior. This patch brings arti into conformance. Closes #1077.
* Convert StreamId to NonZeroU16Jim Newsome2023-10-251-1/+1
|
* proto: Revise the behavior of IncomingStream::discard().Nick Mathewson2023-10-191-9/+12
| | | | | | | | | | | | | Because dropping a `StreamTarget` causes the circuit reactor to send an End, the previous do-nothing implementation of `discard()` wasn't sufficient to cause the request to be ignored without sending an End. This commit modifies our "close pending stream" behavior to only optionally send an End message. To avoid confusion, I'm using a new `CloseStreamBehavior` enum rather than an `Option<End>`, since we had previously used `None` in some cases to indicate a default (misc) end message.
* IncomingStream:: flatten IncomingStreamInner.Nick Mathewson2023-10-191-13/+11
|
* IncomingStream: Remove state.Nick Mathewson2023-10-191-67/+4
| | | | | | Now that every state-change function consumes the IncomingStream, there is no longer any reason to keep track of an internal state enum.
* Note a bug in IncomingStream::discard.Nick Mathewson2023-10-191-0/+2
|
* Remove IncomingStreamInner from its Option.Nick Mathewson2023-10-191-34/+7
| | | | | Now that IncomingStream doesn't implement Drop, we can just destructure it.
* Remove impl Drop from IncomingStreamNick Mathewson2023-10-191-11/+4
| | | | | Since dropping a StreamTarget will send an End, we don't need to call reject_internal in this case.
* proto: Make StreamTarget::close() misuse less likely.Nick Mathewson2023-10-171-3/+4
| | | | | | | | | It turns out that we can make `IncomingStream::reject()` consume self, thus making it impossible to hit the double-close error from outside the `tor-proto` crate. Also, we rename `StreamTarget::close()` to `close_pending()` to better reflect its limited applicability.
* proto::stream::incoming: Use bit-array representation for command listNick Mathewson2023-10-121-7/+84
| | | | | This should be smaller and faster than vec, and save some allocations. It could also avoid a tiny sidechannel.
* tor-proto: remove a now-unneeded allow in stream::incomingNick Mathewson2023-10-121-2/+0
|
* oneshot: Apply deferred rustfmt churnIan Jackson2023-10-111-1/+1
| | | | cargo fmt, precisely.
* oneshot: Use veneer in tor-protoIan Jackson2023-10-111-1/+1
|
* 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.