summaryrefslogtreecommitdiff
path: root/crates/tor-proto/src/circuit.rs
Commit message (Collapse)AuthorAgeFilesLines
* proto: Add a test for closing streams.Nick Mathewson2024-05-291-1/+74
| | | | | | | | | | | | | This test verifies that when we invoke the code to close a stream, an END message is actually sent. The test comes in two versions: * `drop_stream` closes the stream by dropping it. It currently passes on main. * `close_stream` closes the stream by running `AsyncWriteExt::close` on the writer. It is a regression test for #1368. It currently fails on main.
* proto: Improve documentation about DataStream lifetimes and closingNick Mathewson2024-05-291-1/+10
| | | | | | | 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-0/+14
| | | | | | | | | | | | | | | | | | | 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: Make Channel explicitly Arc<.>Nick Mathewson2024-05-161-5/+10
| | | | | | | | | | | | | | | | Previously, Channel was a type that you could Clone that implicitly its state. Now, Channel always appears as an Arc<Channel>. This change has several benefits: * It makes the relationship between Channel struct and the underlying channel more clear. * It enables Channel to participate in the RPC system, where everything has to be an Arc<.> * It enables us to have a Weak<Channel>, if we ever want to. * It will let us move various members out of ChannelDetails. We did this change a while ago with ClientCirc.
* proto: Fix compilation with stream-ctrl but not experimental-api.Nick Mathewson2024-05-141-1/+1
|
* Make filter conditional, to fix build with hs-service disabled.Nick Mathewson2024-03-261-0/+3
|
* Rename the old IncomingStreamRequestContext to StreamReqInfo.Nick Mathewson2024-03-261-2/+2
| | | | (Doing this to prevent us having two structs with the same name.)
* Add an IncomingStreamRequestFilter to check early propertiesNick Mathewson2024-03-261-1/+24
| | | | | | | Based on designs in #1124. Note that there is a TODO here about a hack I had to do to appease the borrow checker.
* We now need circuit::handshake to exist unconditionally.Nick Mathewson2024-03-261-0/+4
|
* Refactor the logic for constructing crypt layers.Nick Mathewson2024-03-261-13/+4
| | | | | | | | | | | The key insights here are: - That relay cell format and crypto protocols aren't orthogonal: Once we have GCO, it will require V1. - That we only need the actual functions for layer construction to be generic; we don't need to proliferate generic parameters everywhere. - That the circuit::handshake module already does most of what we want.
* Add and use RelayCellFormatTraitJim Newsome2024-03-201-2/+10
| | | | | | This lets us paramaterize types and functions by a particular relay cell format. We use this e.g. to statically parameterize the cell crypto functions, thereby removing some run-time branching in the hot path.
* Propagate RelayCellFormat selection up to where format decisions will be madeJim Newsome2024-03-201-1/+9
|
* Run maint/add_warning.Nick Mathewson2024-03-131-0/+1
|
* relay-cell: Update relay cell decoding API for prop340Jim Newsome2024-03-121-7/+25
| | | | | | | | | | | 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.
* tor-proto: Add function for peeking at pending circ unique ID.Gabriela Moldovan2024-02-271-0/+5
| | | | | | | | | `tor_circmgr::Error::Protocol` will soon include an optional `UniqId`. Since `Protocol` errors can be caused by pending circuits, we need to be able to peek at their `UniqId`. Part of #1297
* Merge branch 'send_incoming_request_failures' into 'main'gabi-2502024-01-171-9/+8
|\ | | | | | | | | | | | | Several clean-ups around failures in incoming stream request handlers. Closes #1190, #1189, and #1188 See merge request tpo/core/arti!1892
| * Give an error on duplicate call to allow_stream_requests.Nick Mathewson2024-01-171-6/+0
| | | | | | | | Closes #1190
| * proto: Close circuit _intentionally_ when Request Sink is dropped.Nick Mathewson2024-01-171-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In theory, it might be better to just un-register the IncomingStreamRequestHandler when the Receiver for the stream requests is dropped. However, there are two reasons not to do so: 1. It's tricky. We never actually poll on the corresponding Sink, so there isn't a place where the Reactor would expect to get a prompt notification of closure. We only find out that the Receiver has been dropped when an attempt to send on the Sink returns an `is_disconnected` error. 2. It's unnecessary. In the Tor protocols, once we have decided to accept incoming stream requests on a circuit, we want to continue to do so until one of the parties closes the circuit. I've documented this in several comments, in case whe want to get fancier in the future. Closes #1188.
| * proto: Send END when buffer of IncomingRequests is fullNick Mathewson2024-01-171-2/+0
| | | | | | | | Closes #1189.
* | Remove TODO for #1191Nick Mathewson2024-01-171-3/+0
|/ | | | | | The bug described here was already fixed as #1065 via !1681. Closes #1191.
* proto: Convert a TODO HSS to ticket #1191Nick Mathewson2024-01-101-1/+1
|
* Downgrade and convert TODO HSSs to #1190.Nick Mathewson2024-01-101-2/+2
| | | | | | | | | These are about making allow_incoming_streams give an error if a handler is already installed. I'm calling these non-MUST, since they don't affect the actual API here, and we already have comments telling you not to do that. We can add them later.
* Convert a TODO HSS about excessive BEGINs to #1189.Nick Mathewson2024-01-101-1/+2
|
* proto: Downgrade TODO HSS about HopNum in IncomingStreamRequestCommentNick Mathewson2024-01-101-0/+8
| | | | | | | These comments are about internal representations and future extensions. Also, add a fail-safe check to make sure that hop_num consistency is enforced.
* Rename {Any}RelayCell to {Any}RelayMsgOuterNick Mathewson2023-12-141-15/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Test extend_ntor_v3Jim Newsome2023-11-271-10/+33
|
* Parameterize circuit-extension test by handshake typeJim Newsome2023-11-271-55/+68
|
* Add `ClientCirc::extend_ntor_v3`Jim Newsome2023-11-271-0/+38
|
* Circuit reactor: test ntor-v3 "create"Jim Newsome2023-11-271-43/+101
|
* Add PendingClientCirc::create_firsthop_ntor_v3Jim Newsome2023-11-271-0/+43
|
* Merge remote-tracking branch 'public/hs_begin'Nick Mathewson2023-11-161-0/+1
|\
| * hsrproxy: Send back DONE reasons.Nick Mathewson2023-10-231-0/+1
| | | | | | | | | | This is in keeping with the behavior of C tor, and of torspec!179.
* | Send less information in onion service BEGIN messagesNick Mathewson2023-11-151-0/+5
| | | | | | | | | | | | | | | | | | 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.
* | tor-proto: make ClientHandShake and ServerHandshake generic over aux dataJim Newsome2023-11-151-4/+3
| |
* | ServerHandshake: extend to support ntorv3 extensionsJim Newsome2023-11-151-5/+22
| |
* | Add a caret_int HandshakeType for HTYPE constantsJim Newsome2023-10-261-1/+2
| |
* | Change `CircId` to never be zeroJim Newsome2023-10-251-8/+8
| | | | | | | | | | | | | | | | | | | | This changes the internal representation to be `NonZeroU32` instead of just `u32`. Various places where a circuit ID is optional now use `Option<CircId>`. Fixes a bug in `CircIdRange::sample` that would previously return a circuit ID of 0, when the rng returned 0x8000_0000 for a low range.
* | Convert StreamId to NonZeroU16Jim Newsome2023-10-251-29/+31
|/
* Fix rustdoc link warnings/errors.Nick Mathewson2023-10-201-1/+1
|
* proto: Revise the behavior of IncomingStream::discard().Nick Mathewson2023-10-191-4/+3
| | | | | | | | | | | | | 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.
* proto: Remove TODOs about panics on double-close.Nick Mathewson2023-10-191-17/+2
| | | | | | | Now that `StreamMap::terminate` no longer panics, and now that it permits the kind of double-call that we allow, we can close #1065. Closes #1065.
* Add comments about another problem with close_pending().Nick Mathewson2023-10-171-0/+7
| | | | See #1065 for more information here.
* proto: Make StreamTarget::close() misuse less likely.Nick Mathewson2023-10-171-2/+5
| | | | | | | | | 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.
* oneshot: Use veneer in tor-protoIan Jackson2023-10-111-1/+2
|
* tor-proto: Make allow_stream_requests() not return a ResultNick Mathewson2023-09-271-4/+4
| | | | | | | The function never yields anything but an `Ok`, so we can simplify its type. (Not a stable feature, so no semver entry needed)
* Run maint/add_warning to add lint block everywhereIan Jackson2023-08-231-0/+1
|
* Use "typos-cli" to fix a bunch of typos.Nick Mathewson2023-08-221-1/+1
|
* proto: fix a comment to refer to circuits, not channels.Nick Mathewson2023-08-221-1/+1
|
* Merge branch 'send_raw_msg' into 'main'Nick Mathewson2023-08-221-0/+27
|\ | | | | | | | | | | | | proto: new ClientCirc::send_raw_msg function. Closes #1010 See merge request tpo/core/arti!1525
| * proto: Add crossrefs between start_conversation and send_raw_msgNick Mathewson2023-08-221-0/+6
| |