Commit Graph

316 Commits

Author SHA1 Message Date
Ian Jackson 42df88d6bf Run maint/add_warning to add lint block everywhere 2023-08-23 10:34:00 +01:00
Gabriela Moldovan b1c54adae7
tor-netdir: Use an owned HsBlindId instead of a reference.
`HsBlindId` is `Copy`.
2023-08-22 15:48:07 +01:00
Gabriela Moldovan 59b94ed06c
tor-netdir: Replace flat_map() with cartesian_product(). 2023-08-22 15:48:04 +01:00
Gabriela Moldovan 3e193ebd63
tor-netdir: Make `hs_dirs_upload` take an iterator instead of a slice (fmt). 2023-08-22 15:48:00 +01:00
Gabriela Moldovan d651b3e3a2
tor-netdir: Make `hs_dirs_upload` take an iterator instead of a slice. 2023-08-22 15:47:57 +01:00
Gabriela Moldovan 3090259b55
tor-netdir: Add TODO about making HsDirOp private.
When `hs_dirs` is removed this won't n't need to be public anymore.
2023-08-22 15:47:54 +01:00
Gabriela Moldovan b0c3fc73ca
tor-hsclient: Use hs_dirs_download instead of the deprecated hs_dirs. 2023-08-22 15:47:51 +01:00
Gabriela Moldovan 83f26aebde
tor-netdir: Deprecate hs_dirs(). 2023-08-22 15:47:47 +01:00
Gabriela Moldovan 47e24dc8eb
tor-netdir: Add separate functions for computing hsdirs for upload/download.
The hsdir selection algorithm for uploads and downloads is different
enough to justify splitting `hs_dirs` into 2 different functions.
More specifically, when selecting the relays to upload a service's
descriptors to, the service's `hsids` need to be matched up with the
correct `ring` (using the time period) before applying `select_nodes` to
pick the replicas. This is not the case when downloading, because
for downloads select relays from the current ring.
2023-08-22 15:47:44 +01:00
Gabriela Moldovan 7e4c850efd
tor-netdir: Add private helpers for selecting hsdirs.
These will become useful when we split `hs_dirs()` into 2 separate
functions (one for uploading/services, and another for
downloading/clients).
2023-08-22 15:47:41 +01:00
Nick Mathewson e699607ef8 Upgrade num_enum dependency to 0.7 2023-08-21 13:47:08 -04: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
Nick Mathewson cec6d0ce33 Run add_warnings on all files. 2023-08-04 07:45:04 -04:00
Nick Mathewson 3422169ff4 Merge branch 'bump_versions_117' into 'main'
Vesion bumps for 1.1.7.

See merge request tpo/core/arti!1458
2023-08-01 15:40:26 +00: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 9ce6f0a0eb Run "fixup features" in preparation for a release. 2023-08-01 08:32:20 -04:00
eta 41bb03c6cc Add country codes to relays inside a NetDir
- When the `geoip` feature flag of `tor-netdir` is enabled, perform
  GeoIP lookups for all relays added to the directory and add the
  resulting country code to the `Relay` struct.
  - The GeoIP database is provided in a new
    `PartialNetDir::new_with_geoip` constructor.
- A new trait was also added to `tor-linkspec`, `HasCountryCode`, to
  enable getting this data out from other crates.

Part of onionmasq#47.
2023-07-13 17:47:00 +01:00
Ian Jackson 473447a82e Run maint/add_warning to actually apply new lint allows 2023-07-10 13:49:51 +01: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 27bd990a79 Remove semver.md files for 1.1.6 2023-06-30 10:28:53 -04: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 d164a9dac2 Mark all {hs,onion-serivce}-client features as non-experimental. 2023-06-29 13:09:37 -04:00
Nick Mathewson 9790f820f7 netdir: add crosslinks to our definition of "usable". 2023-06-29 08:53:59 -04:00
Nick Mathewson a902f320b5 netdir: document what we mean by a "usable" relay. 2023-06-29 08:53:59 -04:00
Nick Mathewson 7ac362eba7 netdir: Conditionally expose some by_rsa APIs as experimental.
Network-health wants these to see whether a given relay is listed in
the consensus.

cc @juga
2023-06-29 08:53:59 -04:00
Nick Mathewson 76376b2abd netdir: Remove a TODO HS
The function this comment is asking us to write is `circtarget_from_pieces`.
2023-06-29 08:19:37 -04:00
Nick Mathewson c565a67689 Downgrade TODO HS on HsDirParams::compute().expect()
(Adding comments explaining that these errors are really
unlikely to occur, unless there is a bug in our code or in Rust's
time handling.)
2023-06-29 08:19:37 -04:00
Nick Mathewson 768452d9e5 netdir: Defer a TODO HS but add a comment
This issue with walking over the ring is  an issue we really must
solve on the services timeframe, as is the one about looking only at
the rings for which a blinded ID is germane.
2023-06-29 08:19:37 -04:00
Nick Mathewson 2bdf10db84 netdir: take n_replicas and spread_fetch from consensus parameters
This makes them configurable, since we allow the user to override
any consensus parameter.
2023-06-29 08:19:37 -04:00
Nick Mathewson 3db0f74e22 netdir: Downgrade/remove/defer some TODO hs entries. 2023-06-29 08:19:37 -04:00
Nick Mathewson 0c43801598 netdir: remove some now-needless warning suppressions. 2023-06-29 08:19:37 -04:00
Nick Mathewson a9da1283bc netdir: remove unnecessary wraps from srv_interval, extract_srvs 2023-06-29 08:19:37 -04:00
Nick Mathewson 4803f6447d netdir: Move voting_period() to netdoc::Lifetime
I was going to add a comment about "doing this if we need the voting
period anywhere else" but it turns out that we also use it in dirmgr.
2023-06-29 08:19:37 -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
Alexander Færøy d1658a120e Merge branch 'stderr' into 'main'
lints: Promote clippy::print_stderr and clippy::print_stdout

See merge request tpo/core/arti!1271
2023-06-21 16:41:10 +00:00
Nick Mathewson 0505579497 Upgrade to strum 0.25. 2023-06-21 09:12:36 -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 0add7df458 hscrypto: fix TODOs in time-period code.
* Return a more informative error type (instead of Option)
* Check that time periods are an integer number of seconds
* Decide not to change the semantics of an argument.
2023-06-13 12:39:52 -04:00
Nick Mathewson 0313ca9f62 netdir: Wrap HsDir an Arc<>
This change reduces the cost of cloning a `NetDir`.  It's fine
since–although we replace the HsDir once–we never modify it once it
exists.

Closes #883.
2023-06-09 16:08:57 -04:00