summaryrefslogtreecommitdiff
path: root/crates/tor-proto/src/circuit
Commit message (Collapse)AuthorAgeFilesLines
* Circuit reactor: document some requirements and assumptionsJim Newsome2024-04-251-10/+42
| | | | | | | | There are some tricky bits here that implicitly assume particular behavior in other bits for correctness. Document these requirements and assumptions. Fixes arti#1373
* Add temporary allows for some dead code warningsIan Jackson2024-04-251-0/+1
|
* counted_map: Use educe(Default).Nick Mathewson2024-04-021-12/+4
|
* counted_map: Use PhantomData<fn(P)->P>Nick Mathewson2024-04-021-4/+4
| | | | This is always Send+Sync, and invariant with P.
* counted_map: Add some notes about correctness; downgrade unsafesNick Mathewson2024-04-022-13/+21
| | | | | (We're letting the "unchecked" suffix of this function be enough to indicate that it's risky to use.)
* streammap: Use an internal counted_hashmap to simplify invariant checkingNick Mathewson2024-03-282-43/+566
| | | | | | | | | | Instead of making `streammap.rs` responsible for keeping track of a count field, this lowers that functionality into a lower-level CountedHashMap type. Said type has a little more functionality than we need, to sketch out how we'd want to develop it moving forward if we find that it's useful elsewhere. Closes #1344.
* Make filter conditional, to fix build with hs-service disabled.Nick Mathewson2024-03-261-2/+3
|
* Refactor and simplify ClientCircSyncViewNick Mathewson2024-03-262-34/+24
| | | | | | | | With this patch, it holds only a reference to `&reactor.hops`, which greatly simplifies the reactor code's fight with the borrow checker. I've left some TODO comments about future directions here.
* Rename the old IncomingStreamRequestContext to StreamReqInfo.Nick Mathewson2024-03-261-4/+4
| | | | (Doing this to prevent us having two structs with the same name.)
* Add an IncomingStreamRequestFilter to check early propertiesNick Mathewson2024-03-262-9/+62
| | | | | | | Based on designs in #1124. Note that there is a TODO here about a hack I had to do to appease the borrow checker.
* Define a type for a synchronous (blocking) view of a circuit state.Nick Mathewson2024-03-263-0/+40
| | | | | We'll use this as an argument for the callback that checks stream requests to make sure they're permitted.
* proto: Make StreamMap keep a count of open streams.Nick Mathewson2024-03-261-0/+34
|
* proto: Prevent general state-transitions on StreamEntNick Mathewson2024-03-262-38/+60
| | | | | | We want to keep an accurate count of the number of open streams, so we have to stop exposing `&mut StreamEnt` outside of the streammap module.
* proto: Refactor circuit::streammap::StreamEntNick Mathewson2024-03-262-40/+51
| | | | | | | This is the first part of a refactoring that will let us keep code from the outside of `streammap` from changing a stream from one state to another. And we need to do _that_ so that StreamMap can count how many open streams it has.
* Push HandshakeRole down one level.Nick Mathewson2024-03-261-5/+4
|
* Provide spec links for relay crypto formats.Nick Mathewson2024-03-261-2/+10
|
* Clean up match statement a little.Nick Mathewson2024-03-261-7/+7
|
* We now need circuit::handshake to exist unconditionally.Nick Mathewson2024-03-261-2/+11
|
* Refactor the logic for constructing crypt layers.Nick Mathewson2024-03-262-64/+91
| | | | | | | | | | | 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-202-27/+40
| | | | | | 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-202-17/+50
|
* Paramaterize layer crypto objects by cell formatJim Newsome2024-03-202-3/+11
|
* Run maint/add_warning.Nick Mathewson2024-03-134-0/+4
|
* relay-cell: Update relay cell decoding API for prop340Jim Newsome2024-03-123-19/+77
| | | | | | | | | | | 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-24/+24
| | | | | For consistency with the terminology proposed in https://gitlab.torproject.org/tpo/core/torspec/-/issues/253
* tor-circmgr: Add a helper for displaying optional UniqIds.Gabriela Moldovan2024-02-271-1/+17
| | | | | | | | Some of the `tor_circmgr::Error` variants will include the `UniqId` of the corresponding circuit, so we'll need to be able to display it without the `Circ ` prefix. Part of #1297
* proto: Use log_ratelim to report problems delivering BEGIN messges.Nick Mathewson2024-01-171-3/+7
|
* Give an error on duplicate call to allow_stream_requests.Nick Mathewson2024-01-171-2/+2
| | | | Closes #1190
* proto: Close circuit _intentionally_ when Request Sink is dropped.Nick Mathewson2024-01-171-6/+27
| | | | | | | | | | | | | | | | | | | | | 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-11/+14
| | | | Closes #1189.
* Convert a TODO HSS about excessive BEGINs to #1189.Nick Mathewson2024-01-101-1/+1
|
* proto: Downgrade TODO HSS about HopNum in IncomingStreamRequestCommentNick Mathewson2024-01-101-5/+4
| | | | | | | These comments are about internal representations and future extensions. Also, add a fail-safe check to make sure that hop_num consistency is enforced.
* proto: Downgrade TODO HSS comments about hop lookupNick Mathewson2024-01-101-2/+2
|
* proto: Change some TODO HSS comments to refer to #1188Nick Mathewson2024-01-101-3/+3
|
* clippy nightly: For now, locally allow blocks_in_conditionsIan Jackson2024-01-021-0/+1
| | | | | | Filed https://gitlab.torproject.org/tpo/core/arti/-/issues/1176 proposing a final fix.
* clippy: Replace many calls to .get(0) with .first()Ian Jackson2024-01-021-1/+1
| | | | | FTR I don't think agree with clippy on this question, but then I often don't.
* Rename {Any}RelayCell to {Any}RelayMsgOuterNick Mathewson2023-12-144-21/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* debug log: Downgrade circuit lifecycle messages to traceIan Jackson2023-11-291-4/+4
| | | | | | This makes it possible to see the wood for the trees. This may be controversial, but I think it's an improvement.
* Downgrade some messages to traceIan Jackson2023-11-291-1/+1
| | | | | These messages are very verbose and I doubt anyone will want them, usually, even when debugging.
* Fix 'target' in doc comment for create_firsthop_ntorJim Newsome2023-11-271-1/+1
|
* Add `ClientCirc::extend_ntor_v3`Jim Newsome2023-11-271-0/+40
|
* tor-proto::circuit::reactor: handle server auxiliary handshake dataJim Newsome2023-11-271-10/+81
|
* Add Reactor::create_firsthop_ntor_v3Jim Newsome2023-11-271-0/+50
|
* Use HandshakeType in Extend2 and CircuitExtender::beginJim Newsome2023-11-271-2/+2
|
* tor-proto: make ClientHandShake and ServerHandshake generic over aux dataJim Newsome2023-11-151-22/+17
|
* ClientHandshake: extend to support ntorv3 extensionsJim Newsome2023-11-151-4/+16
|
* CircuitHandshake::Ntor::ed_identity clarify doc-commentJim Newsome2023-11-151-2/+2
| | | | | Use consistent phrasing when describing the two key fields to make it clear they're referring to the same relay.
* circuit: On SendMsgAndInstallHandler, tolerate None handlerNick Mathewson2023-11-021-0/+1
| | | | | | | | | | | | Previously it was possible for `handler` to be None only when `msg` was also None, which would make SendMsgAndInstallHandler into a no-op. Now, if `msg` is present but `handler` is absent, we use the previously installed handler, which I think was our intention. Without this patch, `Conversation::send_message` simply won't work. Fixes #1085.
* circuit::reactor: Remember that meta_handler is Send.Nick Mathewson2023-11-021-2/+2
| | | | | | (We already require that it is Send when the client gives it to us in circuit.rs, but we had previously forgotten that when we stored it in the Reactor.)
* Add a caret_int HandshakeType for HTYPE constantsJim Newsome2023-10-261-2/+2
|