summaryrefslogtreecommitdiff
path: root/crates/tor-netdir/src/lib.rs
Commit message (Collapse)AuthorAgeFilesLines
* Upgrade rand crates to 0.10.Wesley Aptekar-Cassels2026-05-121-11/+11
| | | | | | | | | | | When the circ-padding feature is enabled, we use maybenot, which does not yet support rand 0.10. In the meantime, enabling this feature pulls in rand 0.9. This is not ideal, but should be okay as a temporary situation. This also replaces the use of ReseedingRng (which was removed in 0.10) with the reseeding_rng crate. This is somewhat less performant, but it should be okay.
* geoip: Make asn data conditional.Nick Mathewson2026-04-151-1/+1
| | | | | | | | | | | | This abolishes the NetDefn type, and turns DenseRangeDb into a map to one or (optionally!) two types. For the DBs we ship, which don't have asn information, this saves about 2.5 MiB. (It also probably saves a bit more, since the niche optimization didn't apply to NetDefn as it existed before, since it tried to distinguish Some(None,None) from None.)
* geoip: Migrate code to DenseRangeMap.Nick Mathewson2026-04-151-1/+1
| | | | | This required correcting some errors in our previous ersatz geoip databases.
* NetDir::pick_relay: add a little more info to error reportsJim Newsome2026-04-021-1/+6
| | | | In particular to help debug arti#1907
* NetDir::pick_relay: add some trace loggingJim Newsome2026-04-021-1/+6
|
* Fix word duplicate typosTobias Stoeckmann2026-03-151-1/+1
|
* Allow clippy::collapsible_if to triggerGabriela Moldovan2026-02-161-0/+1
| | | | | | | | | `clippy::collapsible_if` started triggering after bumping the MSRV to 1.88. Since this triggers from a lot of places, and since there even are a couple of instances where we explicitly allow `clippy::collapsible_ifs`, I've opened #2342 for deciding what to do about it.
* maint/add_warning: Run script to add new warningGabriela Moldovan2026-01-271-0/+1
| | | | This adds the lint to all our crates.
* Merge branch 'ticket1223' into 'main'Nick Mathewson2025-12-041-1/+51
|\ | | | | | | | | | | | | Refactor common code that builds circtargets for HS. Closes #1223 See merge request tpo/core/arti!3530
| * Refactor common code that builds circtargets for HS.Nick Mathewson2025-12-041-1/+51
| | | | | | | | | | | | | | | | | | This code was duplicated across hsclient and hsservice. Logically, it belongs in netdir, since that's where we have the latest required-protocol information, and the ability to look up relays by IDs. Closes #1223
* | Remove unnecessary `doc(cfg(...))` attributesNeel Chauhan2025-12-041-3/+0
|/ | | | | | | | | Fixes part of #2193. (Edits from nickm: I selected the cases here that I could verify were correct from immediate context.) Edited-by: Nick Mathewson <[email protected]>
* RelayFlags: Use RelayFlag enum variant names everywhereIan Jackson2025-11-181-1/+1
| | | | | | | Abolish the constants with the transitional names. This also abolishes the controversial name `H_S_DIR`, which Rust case transformation rules generated from `HSDir`.
* RelayFlags: Use the singular RelayFlag for naming individual flagsIan Jackson2025-11-181-2/+2
| | | | | | | | | | | | | | We're going to separate RelayFlag from RelayFlags. We could continue to provide a bunch of constant values for RelayFlags, for each individual type, but that would involve an ad-hoc derive, and would still be a bit of an unusual API. Instead, we're going to make ``RelayFlag` a normal enum. In this commit, we change everyone to refer to it by its singular name. Hopefully separating out this bulk change makes both this, and the core commit, easier to review.
* tor-netdoc: Remove the RelayFlags type alias in netstatusIan Jackson2025-11-181-1/+1
| | | | I would do `#[deprecated]` but empirically that has no effect...
* Fix name of clippy lint to unchecked_time_subtraction (2)Ian Jackson2025-11-061-2/+2
| | | | Run maint/add_warning
* tor-netdoc: RouterStatus: unify `orport_addrs` and `addrs` methodsIan Jackson2025-10-061-2/+2
| | | | | | | We had two functions with different return types but identical semantics. Replace them with one function returning `impl Iterator`. Make it return owned addresses. These are small.
* tor-linkspec: Change HasAddrs::addrs to return an IteratorIan Jackson2025-10-061-4/+3
| | | | | | | | This will let us model the actual structure of routerstatus entries in netdocs more closely. They don't have the addresses in a single list. When this code was written this would have been much more awkward, but now we have RPITIT.
* Remove "doc_auto_cfg" incantation from all crates.Nick Mathewson2025-09-291-1/+1
| | | | This feature has been removed from nightly, in favor of doc_cfg.
* tor-netdir: Removed dependency on `static_assertions`hashcatHitman2025-09-011-2/+1
| | | | | | | | Replaced use of [`static_assertions::const_assert`] with the newly available "assert in const" pattern. This completely removes the dependency on `static_assertions` for `tor-netdir`. Signed-off-by: hashcatHitman <[email protected]>
* tor-netdoc: Combine ConsensusRouterStatus and GenericRouterStatusIan Jackson2025-08-261-10/+10
| | | | Now we only need one type.
* tor-netdoc: Abolish RouterStatus trait in favour of generic methodsIan Jackson2025-08-261-2/+2
| | | | | Our approach to sharing code between md and plain consensuses is now the new "variety" system, not generics.
* Fix warnings and errors from edition 2024.Nick Mathewson2025-08-071-28/+20
| | | | | | | | | | The two main causes of errors were: - Since some of the lifetime rules have changed, we no longer need to do as many "bind a variable and immediately return it" patterns, and so clippy now warns about them. - We needed to adjust the explicit captures (`use<...>`) in a couple of our RPIT instances.
* Switch Cargo.toml files to edition 2024.Nick Mathewson2025-08-071-13/+17
| | | | | | | | | | | | | | First, run ``` git grep -l "^edition =" | xargs perl -i -pe 's/^edition *=.*/edition = "2024"/;' ``` Second, manually verify that all Cargo.toml files have changed, and nothing else has changed. Third, run cargo fmt again.
* Fix errors from rustdoc nightly.Nick Mathewson2025-08-051-1/+1
|
* Typo fixes (automatic and hand-verified)Nick Mathewson2025-07-091-1/+1
| | | | Made with https://crates.io/crates/typos-cli
* Temporarily suppress mismatched_lifetime_syntaxes.Gabriela Moldovan2025-07-071-0/+1
| | | | See #2060.
* proto: Move NegotiatedHopSettings to a higher levelNick Mathewson2025-06-101-0/+10
| | | | | | We will construct this object based on the circuit parameters _and_ on the target's supported protocol versions, so we need to do so when we have both pieces of info.
* NetDir::pick_n_relays: avoid some unwarranted warningsJim Newsome2025-06-051-3/+4
| | | | | | | | | | | | | | | | Previously we logged a warning whenever `choose_multiple_weighted` returns `Ok(iter)`, whenever `iter` contains fewer relays than requested. However, this is expected behavior of `choose_multiple_weighted` if the filtered list of relays doesn't have the requested number of relays, in which case it should return all of the relays in the filtered list. In particular, this condition occurs regularly in test networks when looking for candidate relays to add to the potential guard set while excluding those already in the potential guard set. We still warn if the returned list is fewer than requested, *and* fewer than available in the filtered list.
* tor-netdir: Warn on one more case of insufficient itemsNick Mathewson2025-04-291-1/+12
| | | | | | Now that choose_multiple_weighted can once more return fewer items than requested, we should warn when it does so, to be consistent with our other cases of warning about #1907.
* tor-netdir: test for rand 0.9.1 behavior instead of 0.9.0Nick Mathewson2025-04-291-3/+9
| | | | | | | | Rand 0.9.1 reverted the changes that caused #1903, in https://github.com/rust-random/rand/pull/1623. This broke our test that made sure that rand wasn't going to change their behavior _again_ :)
* Rename recommended_protocols to protocol_statuses.Nick Mathewson2025-04-161-3/+3
| | | | | This name reflects its purpose better than the original one, since it includes required protocols as well as recommended ones.
* netdir: Add a recommended_protocols() to NetDirProviderNick Mathewson2025-04-161-0/+10
|
* dirmgr, netdir: Store protocol requirments as soon as they are validated.Nick Mathewson2025-04-161-0/+4
|
* Fix another miscapitalized "MicroDesc"Nick Mathewson2025-04-161-1/+1
|
* netdir: Add a (hopefully) temporary workaroundNick Mathewson2025-03-251-3/+27
| | | | | Instead of doing the more sensible thing when every relay has weight 0, give a warning message.
* netdir: Another test for choose_multiple_weighted.Nick Mathewson2025-03-251-0/+17
| | | | | | Here we test the (arguably inconsistent behavior) where can we return fewer items than requested if no item had zero weight. (If this ever becomes an error, we need to modify the calling code.)
* netdir: Warn on unexpected WeightedErrorsNick Mathewson2025-03-251-5/+13
| | | | | | WeightedError::InsufficientNonzero is expected under some circumstances, but the other instances would mean that we have a bug.
* netdir: add a test to verify weighted samplingNick Mathewson2025-03-251-3/+37
| | | | | We want to make sure that behavior for 0-weighted elements is consistent for choose_multiple_weighted and choose_weighted.
* tor-netdir: Handle InsufficientNonZero error.Nick Mathewson2025-03-201-0/+8
| | | | Possible fix for #1902.
* squash! Upgrade rand dependency to 0.9.Nick Mathewson2025-03-181-1/+1
| | | | - Several methods have been moved out of SliceRandom.
* squash! Upgrade rand dependency to 0.9.Nick Mathewson2025-03-181-1/+1
| | | | - The rand::distributions module has been renamed to rand::distr
* netdir: Consider RelayFamilyIds based on family rulesNick Mathewson2025-02-251-9/+9
| | | | | | | This implements the client side of proposal 321. It's a breaking change in netdir, since in_same_family now takes an extra argument.
* relay-selection: Add FamilyRules to exclude_relays_in_same_family.Nick Mathewson2025-02-251-0/+63
| | | | | | | | | | | | When we're trying to exclude relays by family, we need to know which lists to look at. This information ultimately comes from the network parameters. We could avoid this change if we just told clients "look at all family information all the time", but that's not what the proposal says. This is a breaking change.
* clippy: deny `mod_module_files`Steven Engler2025-01-061-0/+1
| | | | | | Denies 'mod.rs' files for consistency. https://rust-lang.github.io/rust-clippy/master/index.html#mod_module_files
* Resolve clippy::empty_line_after_doc_comments warnings.Nick Mathewson2024-12-031-1/+0
| | | | These are new in Rust 1.83.
* add_warnings, *: Allow clippy::needless_lifetimesNick Mathewson2024-12-031-0/+1
| | | | | | | | In 1.83, this warning triggers on many of our crates. We're thinking of fixing them all, but for now, we're going to disable the warning. This is part of #1765.
* tor-netdir: Add timeliness param to wait_for_netdir_to_list.Wesley Aptekar-Cassels2024-11-251-1/+2
|
* Move helpers from tor-hsservice to tor-netdir.Wesley Aptekar-Cassels2024-11-251-1/+79
| | | | | These helpers seem potentially broadly useful, and only really discoverable if they're here.
* tor-netdir: Allow access to the `ConsensusBuilder` when building test netdirs.Gabriela Moldovan2024-09-091-7/+7
| | | | | This allows us to set SRVs for example (needed because by default, the test `NetDir` is built from a consensus that doesn't contain any SRVs).
* Fix new "clippy::needless-maybe-sized" warning on nightlyNick Mathewson2024-07-281-1/+1
| | | | | This warning complains when we say `where T: SomeTrait + ?Sized` when `SomeTrait` is inherently Sized.