Commit Graph

8051 Commits

Author SHA1 Message Date
gabi-250 b450461dae Merge branch 'hss_circparams' into 'main'
hsservice: Use correct circparameters_from_netparameters fn

See merge request tpo/core/arti!1520
2023-08-18 12:58:30 +00:00
Nick Mathewson af4fcf83ad hsservice: Use correct circparameters_from_netparameters fn
I had incorrectly thought that this function was private.
2023-08-18 08:14:51 -04:00
Nick Mathewson b831bcca9f Merge branch 'allow_stream_req-hop-num' into 'main'
tor-proto: Make ClientCirc::allow_stream_requests take a HopNum.

Closes #1009

See merge request tpo/core/arti!1519
2023-08-18 12:06:29 +00:00
Nick Mathewson 42cd6c2983 Merge branch 'ipt-relay' into 'main'
tor-hsservice: Change IptEstablisher::new to take RelayIds

See merge request tpo/core/arti!1517
2023-08-18 12:01:38 +00:00
Gabriela Moldovan a1913e15f9
tor-proto: Add test where an incoming stream comes from an unexpect hop.
This adds a test that checks if the reactor is shut down if it receives
an incoming stream request from an unexpected hop.

Part of #1009
2023-08-18 12:14:16 +01:00
Gabriela Moldovan 67a77680dd
tor-proto: Make ClientCirc::allow_stream_requests take a HopNum.
For consistency with the other `ClientCirc` APIs,
`ClientCirc::allow_stream_requests` now takes a `HopNum` argument. Upon
receiving an incoming stream request, the reactor now checks if the
request came from the hop specified in `allow_stream_requests` (and if
it came from a different hop, the circuit is closed).

Part of #1009
2023-08-18 12:14:01 +01:00
Ian Jackson 61f58daadd tor-hsservice: Change IptEstablisher::new to take RelayIds
The IptEstablisher needs to continuously maintain the IPT even as the
netdir is updated.  Whereas, the IPT manager just wants to select the
relay from the netdir once and then only think about the relay
identity.

So it makes sense for the establisher to do necessary lookups of the
relay's ids in the netdir.
2023-08-17 15:54:54 +01:00
Ian Jackson 64c8b38c25 tor-hsservice: Define drop behaviour of IPT establisher status 2023-08-17 14:42:26 +01:00
Ian Jackson f4dfc14694 tor-async-utils: Deprecate DropNotifyEofSignallable::is_eof
This was introduced in c82cda85d6
  tor-basic-utils: DropNotifyWatchSender: use DropNotifyEofSignallable

and already, then, the is_eof() method is redundant.
2023-08-17 14:41:56 +01:00
Nick Mathewson f63852f449 Merge branch 'rendezvous_handshake' into 'main'
hsservice: new rend_handshake module

See merge request tpo/core/arti!1512
2023-08-17 13:29:18 +00:00
Ian Jackson 360c90a9d8 tor-hsservice errors: Distinguish operational errors by context
At the very least, I need FatalError to be distinct:
IptEstablisher::new ought not to fail unless everything is terrible.

Add a the Spawn variant to FatalError (that we'll need soon) and the
Bug variant (which it seems likely we might need).

This also gets rid of the crate-level Result alias.
2023-08-17 13:28:44 +01:00
Ian Jackson e1405cdb11 tor-hsservice errors: Return ReconfigureError from reconfigure
This is what we do elsewhere.
2023-08-17 13:28:44 +01:00
Ian Jackson 5e047da9cc tor-hsservice errors: Use Bug for methods that oughtn't to fail
If the service encouters operational errors, surfacing them here is
not helpful.  So these methods ought to work, if they weren't called
erroneously.
2023-08-17 13:19:21 +01:00
Nick Mathewson 2d2bf1c945 hsservice: new rend_handshake module
This code has most of what we need to go from an INTRODUCE2 message
we've just received to the point where we've connected to the
rendezvous point and we're waiting for a stream of BEGIN messages.
Unfinished pieces are marked with TODO HSS.

Most of #980.
2023-08-17 08:18:21 -04:00
gabi-250 7d3741e8dd Merge branch 'always_bug-from' into 'main'
tor-bytes: deprecate always_bug with From trait

See merge request tpo/core/arti!1500
2023-08-17 12:17:32 +00:00
Ian Jackson e3b9371ddf tor-hsservice errors: Make stop() infallible
The semantics of an Err return from this are unclear.  Was it stopped?
And what kind of error might we even return?
2023-08-17 13:16:50 +01:00
Ian Jackson c391ac2a90 tor-hsservice errors: Use `crate::Result` rather than imports
We want to change the error return types of many methods, so we need a
way to name `std::result::Result`.

We could use `StdResult`, but, actually, properly distinguishing the
kinds of errors that can occur in various contexts means we don't
actually want a single Error type for the whole crate, so
`crate::Result` is going to go away.
2023-08-17 13:12:23 +01:00
Emil Engler 73059827f0
tor-bytes: deprecate always_bug with From trait
This commit deprecates the `EncodeError::always_bug` function with a
`From<EncodeError> for Bug` trait, which is a more semantically correct
way to perform this action.
2023-08-17 13:52:29 +02:00
gabi-250 4c2f8d5a9e Merge branch 'handshake-tests' into 'main'
test: add a test for missing NETINFO cells

See merge request tpo/core/arti!1501
2023-08-17 10:17:01 +00:00
Nick Mathewson c8b721aa5d Merge branch 'all_crates_warnings' into 'main'
Resolve all warnings that appear from `maint/every-crate`

See merge request tpo/core/arti!1507
2023-08-16 18:20:21 +00:00
gabi-250 fdb411f287 Merge branch 'netdir-todo' into 'main'
tor-netdir: Only select nodes that haven't been used for lower-numbered replicas.

See merge request tpo/core/arti!1494
2023-08-16 17:52:07 +00:00
Nick Mathewson b0a30da76c arti-client: fix conditional unused_import and dead_code warnings 2023-08-16 13:44:18 -04:00
Nick Mathewson 94eaaa7f61 Merge branch 'ipt-e' into 'main'
tor-hsservice: Have IptEstablisher::new() return the status watch

See merge request tpo/core/arti!1511
2023-08-16 17:41:57 +00:00
Nick Mathewson 9217278ac1 guardmgr: Fix a dead-code warning when built without bridge support. 2023-08-16 13:41:40 -04:00
Nick Mathewson e67152abb9 tor-proto: Fix dead_code when building without experimental-api 2023-08-16 13:41:40 -04:00
Nick Mathewson 6227539446 cell: Add accessors to IntroduceHandshakePayload 2023-08-16 13:23:46 -04:00
Ian Jackson 8e58ab54ba tor-hsservice: Have IptEstablisher::new() return the status watch (fmt) 2023-08-16 18:12:04 +01:00
Ian Jackson c161f41b57 tor-hsservice: Have IptEstablisher::new() return the status watch
The IPT manager is going to want to separate the IptEstablisher
struct (which contains the Drop signal) from the watch receiver.

We could add an accessor to clone the watch, but the copy in the
IptEstablisher would be redundant.

This makes new()'s signature a bit funky but it's an internal method
so I think that's fine.
2023-08-16 18:12:04 +01:00
Ian Jackson 62c50bfe75 Apply some churn from rustfmt (beta) 2023-08-16 18:11:22 +01:00
Gabriela Moldovan 7a030f8661
tor-netdir: Replace somewhat niche scan() usage with flat_map(). 2023-08-16 17:57:33 +01:00
Gabriela Moldovan d395fe356e
tor-netdir: Rework the logic for checking if a node has already been selected.
This just simplifies the expression a little bit. It still has the same
behaviour.
2023-08-16 17:57:29 +01:00
Gabriela Moldovan af99a4a7b9
tor-netdir: Store the hsdir indices in a HashSet instead of a BTreeSet. 2023-08-16 17:57:21 +01:00
Gabriela Moldovan 80f059a171
tor-netdir: Derive Hash for HsDirIndex.
This will become useful later when we build a `HashSet` of `HsDirIndex`.
2023-08-16 17:57:08 +01:00
Gabriela Moldovan b26ecd6553
tor-netdir: Explain what the ring_items_at filter is for. 2023-08-16 17:57:02 +01:00
Gabriela Moldovan ecb3783f5e
tor-netdir: Only select nodes that haven't been used for lower-numbered replicas.
This implements the part of the spec that says a node that has already
been selected for a lowered-numbered replica, shouldn't be considered
when choosing `spread` nodes for any other higher-numbered replicas.

Note: previously, the test added in this commit wouldn't have passed
(because `NetDir::hs_dirs` used to return duplicate relays under some
circumstances).

Part of #960
2023-08-16 17:56:55 +01:00
Gabriela Moldovan 315684af84
tor-netdir: Make ring_items_at() filter the items before returning.
This makes `ring_items_at()` take an extra parameter which specifies
whether an item is acceptable or not. The newly added filtering
capabilities will be used to implement the part of the spec that says
that if a node was selected for a replica, then it shouldn't be
considered when choosing `spread` nodes for any other higher-numbered
replicas.
2023-08-16 17:56:52 +01:00
Gabriela Moldovan 5d30d34b13
tor-netdir: Update ring_items_at() docs.
This updates the docs to reference the `spread` parameter (rather than
`spread_fetch`).
2023-08-16 17:56:49 +01:00
Gabriela Moldovan 619718956d
tor-netdir: Remove extraneous whitespace. 2023-08-16 17:56:45 +01:00
Gabriela Moldovan e6635b139d
tor-netdir: Use hsdir_spread_store if we're uploading.
The spread should be either `hsdir_spread_store` or
`hsdir_spread_fetch`, depending on whether we're uploading or
downloading descriptors.
2023-08-16 17:56:42 +01:00
gabi-250 fa29202b60 Merge branch 'upload-descriptor' into 'main'
tor-dirclient: Add support for uploading descriptors.

See merge request tpo/core/arti!1505
2023-08-16 15:47:26 +00:00
Gabriela Moldovan 310b4bf35e
tor-dirclient: Fix clippy lints. 2023-08-16 16:14:13 +01:00
Gabriela Moldovan c3ea366539
tor-dirclient: Remove unused `StringBody` trait. 2023-08-16 16:14:09 +01:00
Gabriela Moldovan cd6c4674dc
tor-dirclient: Make Requestable return requests with String bodies.
It's simpler to always use a `String` to represent directory request bodies.
We no longer need the `StringBody` trait.
2023-08-16 16:14:06 +01:00
Gabriela Moldovan 2a7ba4ceb0
tor-dirclient: Rename StringBody::str() to StringBody::as_str(). 2023-08-16 16:14:02 +01:00
Gabriela Moldovan aa3e60b994
tor-dirclient: Deprecate download() instead of removing it. 2023-08-16 16:13:58 +01:00
Gabriela Moldovan 6625b2c55f
tor-dirclient: Extend format test to check the body is formatted too (fmt) 2023-08-16 16:13:50 +01:00
Gabriela Moldovan 966150f9b2
tor-dirclient: Extend format test to check the body is formatted too. 2023-08-16 16:13:46 +01:00
Gabriela Moldovan e71703ad90
tor-dirclient: Move request building to a test helper function. 2023-08-16 16:13:42 +01:00
Gabriela Moldovan 636a18bd7d
tor-dirclient: Add `HsDescUploadRequest`.
The hsdir publisher will send the `HsDescUploadRequest`s to the
appropriate directory using `send_request()`.
2023-08-16 16:13:34 +01:00
Gabriela Moldovan 8ce948bef9
tor-dirclient: Make the body type of a `Requestable` type configurable.
Previously, the `Requestable` trait assumed the body of the request
would always be empty (`http::Request<()>`). This change replaces the
hardcoded `()` body type with the `Requestable::Body` associated type
(which will allow implementors to create requests with non-empty
bodies). This will enable us to reuse the `Requestable` trait for
building `POST` requests for uploading descriptors.
2023-08-16 16:13:30 +01:00