Commit Graph

585 Commits

Author SHA1 Message Date
Gabriela Moldovan 4edff7e670
tor-proto: Update the stream map if we get an END message.
This handles the previously not handled `message_closes_stream == true`
case.
2023-08-03 16:39:42 +01:00
Gabriela Moldovan 907d8cf255
tor-proto: Add TODO regarding allow_stream_requests corner case. 2023-08-03 16:38:19 +01:00
Gabriela Moldovan f30c5897cc
tor-proto: Remove outdated comments. 2023-08-03 16:36:58 +01:00
Gabriela Moldovan 0f9bed5160
tor-proto: Add a test for allow_stream_requests. 2023-08-03 16:35:43 +01:00
Gabriela Moldovan 37154dca95
tor-proto: Implement allow_stream_requests. 2023-08-03 16:34:09 +01:00
Gabriela Moldovan ffa8056437
tor-proto: Handle RELAY_BEGIN cells if we have an incoming req handler. 2023-08-03 16:33:58 +01:00
Gabriela Moldovan f06e0e2df0
tor-proto: Implement IncomingStream::{accept_data, request, reject}. 2023-08-03 16:32:29 +01:00
Gabriela Moldovan 445c052420
tor-proto: Add StreamTarget function for sending CtrlMsg::CloseStream .
This will be used by `IncomingStream` to implement `reject()`.
2023-08-03 16:31:05 +01:00
Gabriela Moldovan b9daaa245c
tor-proto: Add reactor control commands for accepting/closing incoming streams.
This adds a new `AwaitIncomingStream` control message for registering an
interest in an incoming stream.

This also adds a `ClosePendingStream` control message for explicitly
closing a stream with a given END message (needed for implementing
`IncomingStream::reject`).
2023-08-03 16:29:26 +01:00
Gabriela Moldovan 950d0da0b5
tor-proto: Add types for sharing stream request info with the reactor. 2023-08-03 16:27:48 +01:00
Gabriela Moldovan 18b01f94cc
tor-proto: Add a helper for adding a stream entry with a specific stream ID.
This adds a new `add_ent_with_id` function for adding a new entry to the
`StreamMap`. The existing `add_ent` function auto-generates a new stream
ID, which is not good if we're a hidden service, as stream IDs are
supposed to be chosen by the OP (client). When accepting a new stream,
services, exit relays, and dir auths need to use the stream ID received
in the BEGIN cell (instead of generating a new stream ID).
2023-08-03 16:25:46 +01:00
Gabriela Moldovan 4abfe30f41
tor-proto: Remove extraneous space. 2023-08-03 16:24:30 +01:00
Gabriela Moldovan f6745d31a9
tor-proto: Add constructors for pre-connected DataStreams.
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).
2023-08-03 16:23:11 +01:00
Gabriela Moldovan 4133a9464e
tor-proto: Add a constructor for IncomingStream. 2023-08-03 16:21:55 +01:00
Gabriela Moldovan dc0b904492
tor-proto: Add imports for commonly used types. 2023-08-03 16:20:45 +01:00
Gabriela Moldovan 3d5c712c55
tor-proto: Add IncomingCmdChecker for IncomingStream. 2023-08-03 16:18:35 +01:00
Nick Mathewson 1e96d1b95a Remove semver.md files now that 1.1.7 is out. 2023-08-01 12:55:52 -04:00
Nick Mathewson 3acdf102c7 Increment patchlevel versions of crates with minor changes
These crates are at version 0.x.y, so we don't need to distinguish
new-feature changes from other changes:

```
tor-basic-utils
fs-mistrust
tor-error
tor-geoip
tor-checkable
tor-linkspec
tor-netdoc
tor-netdir
tor-persist
tor-ptmgr
tor-hsservice
```

This crate has a breaking change, but only when the semver-breaking
feature `experimental-api` is enabled:

```
tor-config
```

This crate is at version 1.x.y, but has no new public APIs, and
therefore does not need a minor version bump:

```
arti
```
2023-08-01 10:57:55 -04:00
Nick Mathewson 6f2ae59603 Update minor versions on crates that have had breaking changes
These crates had first-order breaking changes:

```
retry-error
tor-keymgr
tor-proto
tor-hsclient
tor-rtmock
```

Additionally, these broke because they re-exposed RetryError:

```
tor-circmgr
```

Additionally, these broke because they may re-expose something from
tor-proto:

```
    arti-client
    tor-chanmgr
    tor-dirclient
    tor-dirmgr
    tor-guardmgr
```

Additionally, these broke for other fiddly reasons:

`tor-ptmgr` implements traits from tor-chanmgr, which has a breaking
change above.

`arti-hyper` exposes types from arti-client in its API.
2023-08-01 10:51:25 -04:00
Gabriela Moldovan ecfec3b827
tor-proto: Rename create_firsthop() to wait_for_create(). 2023-07-27 10:56:18 +01:00
Gabriela Moldovan 6f22c16ecc
tor-proto: Update handle_control docs. 2023-07-26 19:36:54 +01:00
Gabriela Moldovan 331ec1033a
tor-proto: Add functions for handling Shutdown and AddFakeHop messages.
This helps reduce code duplication, as `CtrlMsg::Shutdown` and
`CtrlMsg::AddFakeHop` are now handled in multiple places.
2023-07-26 19:36:50 +01:00
Gabriela Moldovan fee4baa17f
tor-proto: Extract first-hop creation to a separate function.
I think it's safe to handle `ChanMsg::Create` separately, because
there's nothing for the reactor to do until the first hop of the circuit
is created (so blocking on this _should_ be alright).
2023-07-26 19:36:47 +01:00
Gabriela Moldovan 98b9be0f2d
tor-proto: Create a function for handling the initial CREATE cell.
This logic from `create_firsthop()` was extracted (copied) from
`Reactor::run_once()`. A future commit will update `Reactor::run_once()`
to use `create_firsthop()`.
2023-07-26 19:35:04 +01:00
Ian Jackson f6d5cae574 tor-circmgr: Add two possibly-needed docsrs annotations
I don't know if these are needed because the rules are not documented
afaict.  But it seems like probably they ought to be there?
2023-07-12 15:32:26 +01:00
Ian Jackson 1fa692d63d tor-proto: Conversation: drop two otiose cfg(feature)
These fns are in a feature-gated impls on feature-gated structs.
2023-07-12 15:31:30 +01:00
Ian Jackson 3acc2af4f3 Merge branch 'clippy-allow' into 'main'
clippy: Allow some of our existing code patterns

See merge request tpo/core/arti!1396
2023-07-11 09:37:42 +00:00
Alexander Færøy 6be6352b98 Merge branch 'conversation' into 'main'
Overhaul send_control_message

See merge request tpo/core/arti!1367
2023-07-10 13:14:11 +00:00
Ian Jackson 473447a82e Run maint/add_warning to actually apply new lint allows 2023-07-10 13:49:51 +01:00
Ian Jackson 80f397fb0b Merge branch 'allow_missing_panics' into 'main'
add_warning: Tolerate clippy::missing_panics_doc

Closes #950

See merge request tpo/core/arti!1380
2023-07-07 12:53:46 +00:00
Nick Mathewson 4caf86349c Remove explicit allows for missing_panics_docs.
These are no longer needed.
2023-07-06 14:36:13 -04:00
Nick Mathewson 03f9f9987a Run add_warning to remove `missing_panics_doc` deny.
Closes #950.
2023-07-06 14:32:23 -04:00
Nick Mathewson 07b4b11d7a Avoid matches!(x, None), matches!(x, Ok(_))
This appeases clippy-nightly.
2023-07-06 14:26:48 -04:00
Ian Jackson 27ad9ca249 tor-proto: run rustfmt 2023-06-30 18:43:20 +01:00
Ian Jackson a97cb2af6a tor-proto conversations: semver 2023-06-30 18:43:20 +01:00
Ian Jackson 2a67468d27 tor-proto conversations: Update a TODO
The feature name is wrong now.
2023-06-30 18:43:20 +01:00
Ian Jackson 78e4f9e86b tor-proto conversations: Drop a TODO
I think this name is fine.
2023-06-30 18:43:20 +01:00
Ian Jackson 226bca984b tor-proto conversation API: Provide ConversationInHandler 2023-06-30 18:43:20 +01:00
Ian Jackson 800f390a9d tor-proto circuit: Plumb async Context through
handle_msg is going to want this in a moment.
2023-06-30 18:28:41 +01:00
Ian Jackson c599258b85 tor-proto conversation API: Soften a warning
If the circuit is just being used by us (which is likely, if we're
using this API) then the only reactor we're blocking is our own.
2023-06-30 18:28:41 +01:00
Ian Jackson 287c458731 tor-proto conversation API: Implement Conversation
Now, after you call start_conversation_last_hop, you can send more
messages if you like.
2023-06-30 18:28:41 +01:00
Ian Jackson 77903a295f tor-proto: Make the handler in SendMsgAndInstallHandler optional
We're going to want to do almost-the-same thing but without installing
a new handler.
2023-06-30 18:14:34 +01:00
Ian Jackson 20f1e065b3 tor-proto conversation API: Return a Conversation
This is just a placeholder for now, but it'll be a thing you can send
more messages with.
2023-06-30 18:03:17 +01:00
Ian Jackson 2882e3a93e tor-proto conversation API: Rename to start_conversation_last_hop
Was send_control_message.
2023-06-30 18:02:56 +01:00
Ian Jackson 3812e3ccdd tor-proto conversation API: Make starting message optional
We're going to let people start a conversation and either expect to
receive first, or send messages ad-hoc later.
2023-06-30 18:02:15 +01:00
Ian Jackson b162d005a7 tor-proto conversation API: Rename to ConversationFinished
Was UninstallHandler.  We are going to talk more about conversations
and less about handlers (although, the fact of there being a handler
will still be visible).
2023-06-30 18:02:04 +01:00
Ian Jackson 408c8f30ad tor-proto circuit: Make reactor::run_once modulae-private
Nothing else wants this and having it pub(super) is confusing.
2023-06-30 17:34:50 +01:00
Nick Mathewson de13a7319b Bump patchlevel versions on crates with smaller changes
Done with the commands below.

The following crates have had various changes, and should get a
patchlevel bump. Since they are pre-1.0, we do not need to
distinguish new APIs from other changes.

```
cargo set-version --bump patch -p arti-client
cargo set-version --bump patch -p safelog
cargo set-version --bump patch -p tor-bytes
cargo set-version --bump patch -p tor-cert
cargo set-version --bump patch -p tor-circmgr
cargo set-version --bump patch -p tor-config
cargo set-version --bump patch -p tor-consdiff
cargo set-version --bump patch -p tor-dirclient
cargo set-version --bump patch -p tor-dirmgr
cargo set-version --bump patch -p tor-error
cargo set-version --bump patch -p tor-hsservice
cargo set-version --bump patch -p tor-linkspec
cargo set-version --bump patch -p tor-llcrypto
cargo set-version --bump patch -p tor-netdir
cargo set-version --bump patch -p tor-netdoc
cargo set-version --bump patch -p tor-proto
cargo set-version --bump patch -p tor-rpcbase
cargo set-version --bump patch -p tor-socksproto
```

This crate has new features, but no new non-experimental Rust APIs.
So even though it is post-1.0, it gets a patchlevel bump.

```
cargo set-version --bump patch -p arti
```
2023-06-30 08:42:21 -04:00
Nick Mathewson 65e81bf0ca Bump minor versions on crates with breaking changes
Done with:
```
cargo set-version --bump minor -p tor-hsclient
cargo set-version --bump minor -p arti-rpcserver
cargo set-version --bump minor -p tor-hscrypto
cargo set-version --bump minor -p tor-cell
```
2023-06-30 08:38:16 -04:00
Nick Mathewson a88fa71f25 Resolve XXXs from fixup-features.
Some of these seem spurious: it looks like fixup-features resolved
an issue and then complained about it too.  I'll investigate further.
2023-06-29 17:14:00 -04:00
Nick Mathewson 23c67d92e6 Run "fixup-features". 2023-06-29 17:09:52 -04:00
Nick Mathewson d164a9dac2 Mark all {hs,onion-serivce}-client features as non-experimental. 2023-06-29 13:09:37 -04:00
Nick Mathewson 2944d4f91f proto: ClientCirc: remove now-obsolete note on Clone-ness 2023-06-28 15:26:22 -04:00
Nick Mathewson 644c51173a proto: document ClientCirc lifecycle better. 2023-06-28 15:26:22 -04:00
Nick Mathewson e8e95ec03b proto: document channel lifecycle better. 2023-06-28 15:26:22 -04:00
Nick Mathewson f778d32a0e Merge branch 'ticket_914' into 'main'
Remove support for receiving unauthenticated SENDMEs.

Closes #914

See merge request tpo/core/arti!1283
2023-06-28 10:54:05 +00:00
pinkforest 4be2e3ce0f Back down x25519-dalek to 2.0.0-pre.1 from 2.0.0-rc.2
=========================
Notes from nickm:

(This differs from pinkforest's original MR: It removes the
Cargo.lock changes and the version bump on tor-llcrypto.)

Minimal Cargo.lock changes from downgrade.

(These are exactly those changes generated by running "build" and
"test".)

There are several reasons to do this:

  * It's best to bump all of our dalek dependencies at once to rc.3
    or later, rather than the piecemeal approach we've been stuck
    with so far.

  * We don't want to do this bump right now, since there are some
    tricky questions about clamping we need to figure out (see
    #808), and we need to make sure we get them right, and we're in
    a distracted this week.

  * We _do_ need to move away from 2.0.0-rc.2 right now, since
    it was causing a failure in `cargo install arti`, and then it
    got yanked.

Thanks to pinkforest for helping us out here and explaining all of
this!

Fixes #926.

Commit-edited-by: Nick Mathewson <nickm@torproject.org>
2023-06-27 13:55:24 -04:00
Nick Mathewson 0bffdf23a4 Upgrade to itertools 0.11.0
The breaking changes here do not seem to affect us.
2023-06-26 09:30:54 -04:00
Nick Mathewson f4a4c11627 proto: Remove support for receiving unauthenticated SENDMEs
We haven't generated these since Tor 0.3.5, which is no longer
supported on the network.

Closes #914.
2023-06-26 08:38:24 -04:00
Nick Mathewson 1249d803fb Merge branch 'proto-better-path' into 'main'
Better API for getting circuit paths

Closes #787

See merge request tpo/core/arti!1286
2023-06-22 17:53:23 +00:00
Nick Mathewson 8a6836cf4a proto: Resolve/downgrade some path-related "TODO HS" items 2023-06-22 09:45:47 -04:00
Nick Mathewson f80a1189a5 proto: Implement Redactable and Display for PathEntry. 2023-06-22 09:45:47 -04:00
Nick Mathewson f2fc086594 proto: Add ClientCirc::path_ref(), deprecate path().
The new path_ref() method returns an Arc<Path>, which gives a much
better API for reasons discussed in the new documentation of path().

(We could just replace path() if we'd prefer, but IMO having
path_ref() here isn't so bad.)
2023-06-22 09:45:47 -04:00
Nick Mathewson b64cf3f6f0 proto: Make Path and PathEntry at least minimally useful
(I'm not 100% sure about having both hops() and iter(). Should I
remove one?)
2023-06-22 09:45:47 -04:00
Nick Mathewson 1e1a76f7ac proto: Expose an opaque PathEntry.
The new PathEntry struct wraps the old PathEntry enum, which has
been renamed to HopDetail.  It's an opaque struct because we want to
be able to put new information in the enum as we think best.
2023-06-22 09:45:47 -04:00
Nick Mathewson e6735cdd9d proto: Make Path public
(You can't get one yet or do much with it.)
2023-06-22 08:37:34 -04:00
Nick Mathewson 8609b9f92a proto: Remove Mutex from Path.
Now Path is a regular struct with no interior mutability, and we use
Arc::make_mut() for the case when we need to add a hop.
2023-06-22 08:37:18 -04:00
Nick Mathewson 2d3739bfe1 proto: Move Path into a separate shared mutable structure
(We're about to remove the interior mutability from Path.)
2023-06-22 08:23:51 -04:00
Nick Mathewson ea99e728d2 proto: Downgrade a comment about unauthenticated SENDMEs
We never actually need to allow these again; see #914
2023-06-21 15:42:19 -04:00
Nick Mathewson fa9a3821a6 proto::circuit:🤝 downgrade a "TODO HS". 2023-06-21 15:09:02 -04:00
Nick Mathewson 5912509b05 proto: Put client and service hs_ntor behind individual features
This lets us keep the service-side hs-ntor handshake experiemental
for now.
2023-06-21 15:06:20 -04:00
Nick Mathewson cc8c3c0d7d proto: Resolve some hs_ntor "TODO HS" comments. 2023-06-21 14:58:54 -04:00
Nick Mathewson a317476520 proto: downgrade some "TODO HS" comments to "HSS"
These are all related to issues that will come up for the service
side of the onion service implementation.
2023-06-21 14:52:50 -04:00
Ian Jackson 161b9844da lints: Run maint/add_warning to actually apply new lints 2023-06-21 12:15:41 +01:00
Nick Mathewson 25db56777c Lower tor-proto::util::ct::lookup to tor-llcrypto
This is mostly code movement; you may want to review it with
`--color-moved`.

I'm doing this so we can also use the function in netdoc for
looking up hsdesc authentication.
2023-06-16 12:24:05 -04:00
Nick Mathewson 40840b1f3a proto: Make sure that auth tags are truncated to 20 bytes
Onion service hops (pointlessly) use SHA3-256 for their
authentication, but they truncate it to 20 bytes (assuming I'm
reading the C right.)

See torspec#204 for clarification here.
2023-06-13 11:04:23 -04:00
Nick Mathewson beecf3c92c proto: Convert MsgHandler API to expect a message, not a cell.
Closes #887.
2023-06-12 14:55:26 -04:00
Nick Mathewson f78c5a5a42 proto: Add a commment about a problem in my hs_ntor plans.
I am pretty sure that C tor works around this somehow; we should
figure out how!
2023-06-12 13:15:59 -04:00
Nick Mathewson c38ba16a81 proto: code movement and reindentation in hs_ntor 2023-06-12 13:15:59 -04:00
Nick Mathewson 7255b122d7 proto: Remove now-unused hs_ntor APIs 2023-06-12 13:15:59 -04:00
Nick Mathewson bb6115103a proto: refactor hs_ntor to reuse state.
We want the ability to send the same handshake request in parallel
on multiple introduce circuits.  This implies encoding the client
handshake more than once.

(Sadly we can't _actually_ do this in the protocol as it stands,
since the onion service can use a separate KP_hss_ntor for each
introduction point; I'll add a comment to that effect later.)
2023-06-12 13:15:59 -04:00
Ian Jackson 4ee4de2d0a Apply 1 suggestion(s) to 1 file(s) 2023-06-12 13:49:18 +00:00
Nick Mathewson c76fbff125 proto: Have send_control_message take an AnyRelayMsg.
When we break the 1:1 relationship of message and cell, we'll want
this API to take messages, not cells.

This API is experimental, so we don't need to call it a semver
break.

Closes #881.
2023-06-09 15:28:01 -04:00
Nick Mathewson 58babcb756 proto: Correct the docs on send_control_message
Formerly we said that it would not return until the handler
was uninstalled.  This is incorrect: it returns as soon as the
message is sent and the handler installed.

Closes #885.
2023-06-09 15:22:15 -04:00
Ian Jackson e35cd4f115 Fix a silly clippy warning
Fixes
  nailing-cargo +stable clippy -p tor-hsclient --all-features --all-targets
2023-06-08 15:29:06 +01:00
Nick Mathewson e7ebb31009 Merge branch 'remove_arrayref' into 'main'
Remove use of arrayref

Closes #872

See merge request tpo/core/arti!1214
2023-06-06 00:37:31 +00:00
Ian Jackson 660726b2f0 tor-circmgr: send_control_message: Add reference to MR discussion 2023-06-05 13:54:49 +01:00
Ian Jackson bfe575bc64 tor-circmgr: send_control_message: Change a rename proposal
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1218#note_2908119
2023-06-05 13:51:01 +01:00
Ian Jackson 9b36697282 tor-circmgr: send_control_message: Fix reference to circuit 2023-06-05 13:50:51 +01:00
Ian Jackson e35d4e6a46 tor-circmgr: send_control_message: API change proposal
I am hoping we can merge this as a "TODO (Diziet)",  even though I
think it may be controversial.  Ie merging this doesn't represent a
decision to do as I suggest.
2023-06-05 13:19:58 +01:00
Ian Jackson eecbf85b4c tor-circmgr: Propose to rename `MetaCellDisposition::UninstallHandler` 2023-06-05 13:19:58 +01:00
Ian Jackson a9ff778ba5 tor-circmgr: send_control_message: Clarify some corner cases
Also, no longer talk about handlers being "installed".  That's not
something that's exposed by this API.

And, say that `send_control_message` can be called again only
after *`send_control_message`* returns, not when `handle_msg` has
returned `UinstallHandler`.  IMO this makes more sense.

Explain that we can't maintain a continuous watch while holding a
conversation with the peer.  (This is surely an API bug.)
2023-06-05 13:19:58 +01:00
Nick Mathewson 469f62a983 Remove semver.md files from 1.1.5 2023-06-01 14:08:24 -04:00
Nick Mathewson 46d2a768a1 tor-proto: Remove use of arrayref. 2023-06-01 10:32:00 -04:00
Nick Mathewson daf5ecc153 Bump crate versions in preparation for v1.1.5 release.
Generated with the following commands:

```
cargo set-version --bump minor -p tor-cell
cargo set-version --bump minor -p tor-linkspec
cargo set-version --bump minor -p tor-proto
cargo set-version --bump minor -p tor-netdoc
cargo set-version --bump minor -p tor-circmgr

cargo set-version --bump patch -p tor-cert
cargo set-version --bump patch -p tor-basic-utils
cargo set-version --bump patch -p tor-rpcbase
cargo set-version --bump patch -p tor-llcrypto
cargo set-version --bump patch -p tor-hscrypto
cargo set-version --bump patch -p tor-checkable
cargo set-version --bump patch -p tor-async-utils
cargo set-version --bump patch -p caret
cargo set-version --bump patch -p fs-mistrust
cargo set-version --bump patch -p safelog
cargo set-version --bump patch -p retry-error
cargo set-version --bump patch -p tor-error
cargo set-version --bump patch -p tor-config
cargo set-version --bump patch -p tor-events
cargo set-version --bump patch -p tor-units
cargo set-version --bump patch -p tor-rtcompat
cargo set-version --bump patch -p tor-rtmock
cargo set-version --bump patch -p tor-protover
cargo set-version --bump patch -p tor-bytes
cargo set-version --bump patch -p tor-socksproto
cargo set-version --bump patch -p tor-consdiff
cargo set-version --bump patch -p tor-netdir
cargo set-version --bump patch -p tor-congestion
cargo set-version --bump patch -p tor-persist
cargo set-version --bump patch -p tor-chanmgr
cargo set-version --bump patch -p tor-ptmgr
cargo set-version --bump patch -p tor-guardmgr
cargo set-version --bump patch -p tor-dirclient
cargo set-version --bump patch -p tor-dirmgr
cargo set-version --bump patch -p tor-hsclient
cargo set-version --bump patch -p tor-hsservice
cargo set-version --bump patch -p arti-client
cargo set-version --bump patch -p arti-rpcserver
cargo set-version --bump patch -p arti-config
cargo set-version --bump patch -p arti-hyper
cargo set-version --bump patch -p arti
cargo set-version --bump patch -p arti-bench
cargo set-version --bump patch -p arti-testing
```
2023-06-01 10:03:05 -04:00
Nick Mathewson 8d32e1f65f Run fixup-features script and resolve its complaints. 2023-05-31 08:04:10 -04:00
Nick Mathewson 6703f3d52a Merge branch 'stream_ctrl' into 'main'
Experimental new stream-ctrl feature

Closes #847

See merge request tpo/core/arti!1198
2023-05-24 20:01:40 +00:00
Nick Mathewson e4758a754e Add "TODO RPC" notes around DataStreamCtrl per review. 2023-05-24 15:25:33 -04:00
Nick Mathewson a397ca77d9 proto: Add stream-status functionality to DataStreamCtrl.
There are some weaknesses and problems here; see TODO notes.
2023-05-24 15:25:33 -04:00
Nick Mathewson 03c81ae5aa proto: Make PathEntry::Virtual feature-conditional.
This fixes a warning when building tor-proto without the
`rpc-common` feature.
2023-05-23 10:59:37 -04:00