Commit Graph

206 Commits

Author SHA1 Message Date
Ian Jackson 3d6e6fcf0d Fix minimal-versions (.then_some is too new) 2023-02-09 16:07:16 +00:00
Ian Jackson 4b7f2e84bf tor-netdir: Make is_hsdir_for_ring crate-local
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1012#note_2876824
2023-02-09 16:07:16 +00:00
Ian Jackson 4ca661a4dc tor-netdir: Document fill_from_previous_netdir semver 2023-02-09 14:57:29 +00:00
Nick Mathewson 8cda5a1a3e Clarify which netdir index is meant 2023-02-09 14:56:30 +00:00
Nick Mathewson 33b8ebd67e Fix typos 2023-02-09 14:48:56 +00:00
Ian Jackson 1f3f659536 Fix compilation with various feature combinations 2023-02-09 14:35:57 +00:00
Ian Jackson 335043658e hsdir: rustfmt
Deferred formatting changes which would have obscured the commits they
were prompted by.
2023-02-09 13:01:37 +00:00
Ian Jackson 3dd0d381d0 hsdir: Actually compute the hash ring 2023-02-09 13:01:37 +00:00
Ian Jackson f5c3c1f277 hsdir: Be able to enumerate the hidden service directories
* Provide an accessor for the HSDIR flag
* Provide a function for testing a relay for hsdir inclusion
* Provide an iterator on NetDir that returns the hsdirs
2023-02-09 13:01:37 +00:00
Ian Jackson f12277141b hsdir: Ring calculation plumbing
* Implement Netdir::compute_rings in terms of a new
  HsDirRing::compute, that currently does nothing.

* Actually call Netdir::compute_rings (since now it doesn't panic).

* Make Netdir::compute_rings not be pub.  We do this unconditionally,
  rather than exposing the distinction between a netdir-without-hsdir
  and a netdir-with-hsdir.
2023-02-09 13:01:37 +00:00
Ian Jackson fe1113bd6b hsdir representation: Introduce HsDirs generic type
This already allows us to get rid of some duplication, and will be
useful more widely in a moment.
2023-02-09 13:01:37 +00:00
Ian Jackson d63c44f96d hsdir: Implement HS hash ring index calculations 2023-02-09 13:01:37 +00:00
Ian Jackson a12df180b5 hsdir: Make HsDirIndex be AsRef<[u8; ]> 2023-02-09 12:56:47 +00:00
Ian Jackson 3f04e7f43e hsdir: impl Eq for HsDirParams
This will allow us to tell if we can reuse parts of a ring.
2023-02-09 12:56:18 +00:00
Ian Jackson 5fcae642d6 hsdir: Rename HsRingParams to HsDirParams
The file which contains this type is called hsdir_params.rs.  We have
a general problem with slight confusion about when to includen "dir"
and when to include "ring".

Resolve this in favour of the rule now added to the module-level doc
comment.
2023-02-09 12:56:18 +00:00
Ian Jackson 962c879005 hsdir_params: Rename some variables for consistency
These variables are going to be struct fields, which will sort of
enforce consistent naming.  The struct fields are going to appear in a
moment.  We'll call the fields "current" and "secondary" after the
naming in the test cases.

And import hsdir_params::HsRingParams, which we're going to make more
references to.
2023-02-09 12:56:18 +00:00
Ian Jackson 5f52015239 hsdir: Replace open-coded params fields and args with HsRingParams
This will enable us to pass these around more conveniently.

And make empty_from_params take an owned params, which it would like.
2023-02-09 12:56:18 +00:00
Ian Jackson 8d4552de8b hsdir: Remove a done TODO - this *is* now a TiSlice 2023-02-09 12:56:18 +00:00
Ian Jackson cd0c38ae6c tor-netdir: Provide Netdir::md_by_idx
We'll need this shortly.
2023-02-09 12:56:18 +00:00
Ian Jackson 6acf9cf5e8 tor-netdir: Store previous netdir (if required by features) 2023-02-09 12:56:18 +00:00
Ian Jackson f69d7f96ac tor-netdoc: Change fill_from_previous_netdir
* Remove the return value, which was not used anywhere.
  Also remove the code to calculate the return value.

* Take an Arc<NetDir> rather than a reference.  We are going to want
  this for HS support.  This has no overall effect on the lifetime of
  the4 Arc, which was owned at the one call site and then imediately
  dropped.

* Change the documentation to explain what the function's role is in
  the netdir API, rather than the fiddly details of what it actually
  does internally.  Relegate the latter to a code comment.
  (When we have HS, this will do more, or, at least, make further
  arrangements.)
2023-02-09 12:56:18 +00:00
Ian Jackson 1e3d20bdba tor-netdir: Use typed-index-collections for router index (fix hsdir)
This was omitted in !1004.  (Because this code isn't actually wired up
yet, it typechecked anyway.  But we need to fix it.)
2023-02-09 12:56:18 +00:00
Ian Jackson 4626ccfcaa hs time handling: Make TimePeriod contain length as IntegerMinutes
Locally, the only functional effect is that now we refuse to handle
non-whole-number-of-minutes lengths - but since the consensus
parameter can't represent those, there's no overall functional change.
2023-02-09 12:56:18 +00:00
Nick Mathewson 99ec1c9818 tor-hscrypto: Rename key types to correspond to new spec names. 2023-02-08 12:27:36 -05:00
Ian Jackson d469aef72a Tidy up docs about RouterStatusIdx
Always use "index" and not "position".

Remove wording which is otiose given the type name.
2023-02-01 19:40:17 +00:00
Ian Jackson 2dbffa1208 tor-netdir: Use typed-index-collections for router status index 2023-02-01 19:40:17 +00:00
Ian Jackson b7e41c3981 tor-netdir: Provide ConsensusRelays extension trait (fmt) 2023-02-01 19:39:14 +00:00
Ian Jackson 4eee59ddb7 tor-netdir: Provide ConsensusRelays extension trait
Call it everywhere instead of the inherent method on MdConsensus.
(Verified by ad-hoc temporarily renaming MdConsensus::relays().)
2023-02-01 19:39:09 +00:00
Ian Jackson 155b9ed581 Change two in-code references to the wrong feature name
As per
  https://gitlab.torproject.org/tpo/core/arti/-/issues/756
I think this is going in the wrong direction, but it is better to fix
it so that the names agree for now, pending a decision on the naming.
2023-02-01 18:46:54 +00:00
Nick Mathewson 7c1b6a5a81 Bump the patch version of every crate that had API additions
These crates had API or behavior changes that may affect downstream
crates. Fortunately, they're all version 0.x, and don't need minor
bumps for this.
2023-02-01 10:36:29 -05:00
Nick Mathewson 66f594a4b6 Bump the patch-level version of crates with _minor_ changes.
These changes influence behavior, but not effect compatibility.
(If I messed up, and any crate except for `arti` has non-breaking
API changes, that's still fine, since they are all version
0.x.)
2023-02-01 10:23:58 -05:00
Nick Mathewson f6cbd180a1 netdir: remove duplicate code in param calculation 2023-01-28 12:43:08 -05:00
Nick Mathewson 4e7a552171 netdir: remove the vestigial smallvec implementation I added
It's cute, but I don't think it will help performance, and I'm
undecided about whether the semantic implications are true.
2023-01-28 12:43:08 -05:00
Nick Mathewson 268a723e49 Turn compute_ring_params into a method. 2023-01-28 12:43:08 -05:00
Ian Jackson a51c76178e Several suggestions on gitlab. 2023-01-28 12:43:08 -05:00
Nick Mathewson 5236c5cf88 netdir: Implement ring-param constructors and time period accessors
This logic is a bit tricky, so I've tried to document it and add
fairly good tests.  The silver lining is that the external API for
all of this logic will make it invisible and hidden.

There are some cases where I added functions that I think might
eventually get lowered into MdConsensus: But I don't want to lower
too much right now, since the convention for our netdoc accessors is
that they are fairly unsophisticated, and they show you the document
as it is.

Closes #686
2023-01-28 12:43:08 -05:00
Nick Mathewson a6dd92843e Allow clippy::unchecked_duration_subtraction in tests
This panics on error, and we're fine with a panic on misbehavior in
tests.
2023-01-27 08:28:02 -05:00
Nick Mathewson ed74c62931 Elide a bunch of lifetimes.
Clippy now warns about these; I'm not sure how these warnings snuck
up on us.
2023-01-27 08:28:02 -05:00
Nick Mathewson bf04641c68 Disable clippy::unlinlined-format-args
This warning kind of snuck up on us! (See #748)  For now, let's
disable it.  (I've cleaned it up in a couple of examples, since
those are meant to be more idiomatic and user-facing.)

Closes #748.
2023-01-27 08:27:47 -05:00
Nick Mathewson 7030cbe460 Merge branch 'onion-netdir-apis' into 'main'
Add onion service APIs to tor-netdir

See merge request tpo/core/arti!966
2023-01-11 16:08:18 +00:00
Nick Mathewson de3f10f492 netdir: add network parameters related to onion services
These are available unconditionally, since they represent
comparatively little storage and processing effort.

See param-spec.txt section 8 for the original information here.
2023-01-11 09:10:08 -05:00
Nick Mathewson 5b74ef7af9 Adjust onion service ring APIs in light of prop#342
* It is the NetDir's responsibility to tell the caller what the time
  period is.
* There can be up to two secondary time periods.
* Each time period has a single SRV.
* Secondary time periods only apply for onion services, when they
  publish.
* When publishing, the correct input is a time period.
2023-01-11 09:04:13 -05:00
Nick Mathewson f24f8d295c Sketch APIs for the onion service directory ring.
These are a bit complex internally, but the API they present is
pretty simple.  I've left some discussion of points where the design
isn't totally fleshed out, and where we need to look harder at the
spec.

Part of #716.
2023-01-11 09:04:13 -05:00
Ian Jackson 125a455bdc test lint blocks: Add many many automatically
This is precisely the result of running the rune in
maint/adhoc-add-lint-blocks.
2022-12-12 18:00:30 +00:00
Ian Jackson baf78361e8 test lint blocks: Do some semi-manually
This is the hunks from running the rune in maint/adhoc-add-lint-blocks
but which require some subsequent manual fixup: usually, deleting
now-superfluous outer allows, but in some cases manually putting back
lints that the adhoc script deleted.
2022-12-12 18:00:29 +00:00
Nick Mathewson e0aeda3071 Remove semver.md files now that 1.1.0 is released. 2022-11-30 17:10:29 -05:00
Nick Mathewson 38bef96b99 Bump the minor version of every crate.
We made this job easy this time around: by incrementing our MSRV, we
have forced ourselves to do at least a minor bump everywhere.
2022-11-30 15:10:16 -05:00
Nick Mathewson 936920b26e bump rust-version to 1.60 in every crate. 2022-11-10 10:57:33 -05:00
Nick Mathewson 339bd8bde0 Mock implementation of a NetDirProvider for testing.
I'm about to remove the old testing APIs from GurdMgr that took in a
NetDir in each function: adding this will make that possible.
2022-11-08 08:10:15 -05:00
Nick Mathewson 932fe48eaf Run add_warnings. 2022-11-03 11:06:02 -04:00