aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-netdir/src
Commit message (Collapse)AuthorAgeFilesLines
* arti-client: add exit selection with GeoIP country codeseta2023-09-181-0/+2
| | | | | | | | | | | | | | | | | | | | This threads the country codes work through the rest of the codebase: - `tor-dirmgr` will now enable GeoIP with the embedded database when the `geoip` future is enabled - This can be extended later using the `DirMgrConfig` to allow specifying a custom database; this is not done here, though - `tor-circmgr`'s `SupportedCircUsage` and `TargetCircUsage` fields gain new `country_code` members to allow filtering circuits by country - These are `()` in builds where the `geoip` feature is not enabled -- doing it this way means we don't have to copy and paste huge swathes of code, since we can't use `#[cfg]` in patterns - `ExitPathBuilder` gains (hacked-in) support for choosing a relay with the correct country code - Due to the lack of conjuction, we just copy and paste a small bit, pending further refactoring - `StreamPrefs` now lets you specify a country code, letting embedders make use of the feature
* hs: Intro point selection: TODO re checking the stable flag (fmt)Ian Jackson2023-08-291-1/+1
| | | | Apply erroneous formatting as demanded by rustfmt.
* hs: Intro point selection: TODO re checking the stable flagIan Jackson2023-08-291-0/+1
|
* hs: Intro point selection: Actually call is_hs_intro_point()Ian Jackson2023-08-291-2/+6
| | | | | | | | Call site as per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1550#note_2936401 Plus a TODO comment with an opinion from me about this API. (Note not a TODO HSS so this is on the back burner.)
* tor-netdir: Add TODO about WeightRole::HsRendIan Jackson2023-08-291-0/+1
| | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1550#note_2936400
* tor-netdir: Support for seleting HS intro pointsIan Jackson2023-08-292-0/+10
| | | | | | I'm quite unsure about this. Hence the TODOs. I think the API is right, though.
* Run maint/add_warning to add lint block everywhereIan Jackson2023-08-236-0/+6
|
* tor-netdir: Use an owned HsBlindId instead of a reference.Gabriela Moldovan2023-08-221-4/+4
| | | | `HsBlindId` is `Copy`.
* tor-netdir: Replace flat_map() with cartesian_product().Gabriela Moldovan2023-08-221-7/+2
|
* tor-netdir: Make `hs_dirs_upload` take an iterator instead of a slice (fmt).Gabriela Moldovan2023-08-221-4/+6
|
* tor-netdir: Make `hs_dirs_upload` take an iterator instead of a slice.Gabriela Moldovan2023-08-221-7/+10
|
* tor-netdir: Add TODO about making HsDirOp private.Gabriela Moldovan2023-08-221-0/+3
| | | | When `hs_dirs` is removed this won't n't need to be public anymore.
* tor-hsclient: Use hs_dirs_download instead of the deprecated hs_dirs.Gabriela Moldovan2023-08-221-1/+1
|
* tor-netdir: Deprecate hs_dirs().Gabriela Moldovan2023-08-221-0/+2
|
* tor-netdir: Add separate functions for computing hsdirs for upload/download.Gabriela Moldovan2023-08-221-0/+102
| | | | | | | | | | 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.
* tor-netdir: Add private helpers for selecting hsdirs.Gabriela Moldovan2023-08-221-0/+72
| | | | | | These will become useful when we split `hs_dirs()` into 2 separate functions (one for uploading/services, and another for downloading/clients).
* tor-netdir: Replace somewhat niche scan() usage with flat_map().Gabriela Moldovan2023-08-161-9/+7
|
* tor-netdir: Rework the logic for checking if a node has already been selected.Gabriela Moldovan2023-08-161-3/+1
| | | | | This just simplifies the expression a little bit. It still has the same behaviour.
* tor-netdir: Store the hsdir indices in a HashSet instead of a BTreeSet.Gabriela Moldovan2023-08-161-4/+4
|
* tor-netdir: Derive Hash for HsDirIndex.Gabriela Moldovan2023-08-161-1/+1
| | | | This will become useful later when we build a `HashSet` of `HsDirIndex`.
* tor-netdir: Explain what the ring_items_at filter is for.Gabriela Moldovan2023-08-161-0/+5
|
* tor-netdir: Only select nodes that haven't been used for lower-numbered ↵Gabriela Moldovan2023-08-161-15/+96
| | | | | | | | | | | | | | 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
* tor-netdir: Make ring_items_at() filter the items before returning.Gabriela Moldovan2023-08-162-2/+5
| | | | | | | | | 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.
* tor-netdir: Update ring_items_at() docs.Gabriela Moldovan2023-08-161-4/+3
| | | | | This updates the docs to reference the `spread` parameter (rather than `spread_fetch`).
* tor-netdir: Remove extraneous whitespace.Gabriela Moldovan2023-08-161-1/+1
|
* tor-netdir: Use hsdir_spread_store if we're uploading.Gabriela Moldovan2023-08-161-4/+9
| | | | | | The spread should be either `hsdir_spread_store` or `hsdir_spread_fetch`, depending on whether we're uploading or downloading descriptors.
* Run add_warnings on all files.Nick Mathewson2023-08-041-2/+2
|
* Add country codes to relays inside a NetDireta2023-07-132-3/+174
| | | | | | | | | | | | - 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.
* Run maint/add_warning to actually apply new lint allowsIan Jackson2023-07-106-0/+7
|
* Remove explicit allows for missing_panics_docs.Nick Mathewson2023-07-062-5/+0
| | | | These are no longer needed.
* Run add_warning to remove `missing_panics_doc` deny.Nick Mathewson2023-07-061-1/+0
| | | | Closes #950.
* netdir: add crosslinks to our definition of "usable".Nick Mathewson2023-06-291-13/+13
|
* netdir: document what we mean by a "usable" relay.Nick Mathewson2023-06-291-0/+8
|
* netdir: Conditionally expose some by_rsa APIs as experimental.Nick Mathewson2023-06-291-2/+13
| | | | | | | Network-health wants these to see whether a given relay is listed in the consensus. cc @juga
* netdir: Remove a TODO HSNick Mathewson2023-06-291-4/+0
| | | | The function this comment is asking us to write is `circtarget_from_pieces`.
* Downgrade TODO HS on HsDirParams::compute().expect()Nick Mathewson2023-06-292-4/+21
| | | | | | (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.)
* netdir: Defer a TODO HS but add a commentNick Mathewson2023-06-291-1/+12
| | | | | | 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.
* netdir: take n_replicas and spread_fetch from consensus parametersNick Mathewson2023-06-291-2/+12
| | | | | This makes them configurable, since we allow the user to override any consensus parameter.
* netdir: Downgrade/remove/defer some TODO hs entries.Nick Mathewson2023-06-292-7/+5
|
* netdir: remove some now-needless warning suppressions.Nick Mathewson2023-06-292-3/+0
|
* netdir: remove unnecessary wraps from srv_interval, extract_srvsNick Mathewson2023-06-291-13/+12
|
* netdir: Move voting_period() to netdoc::LifetimeNick Mathewson2023-06-291-14/+7
| | | | | 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.
* lints: Run maint/add_warning to actually apply new lintsIan Jackson2023-06-211-0/+2
|
* hscrypto: fix TODOs in time-period code.Nick Mathewson2023-06-131-7/+9
| | | | | | * 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.
* netdir: Wrap HsDir an Arc<>Nick Mathewson2023-06-091-5/+7
| | | | | | | | 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.
* Expand docs for NetDirProviderIan Jackson2023-06-081-0/+7
| | | | | | | | Apropos a question that arose on IRC, to which I felt the answer wasn't 100% unambiguous. Also, reference the usual implementation (it can't be a link because it's an upward reference).
* netdir, netdoc: Add accessors for protocol version status.Nick Mathewson2023-06-061-0/+19
| | | | | | | | | | | The consensus includes a listing for clients and for relays, saying which protocol versions are _required_ for participation on the network, and which versions are _recommended_. We have been parsing this, but not yet exposing it. This commit adds accessors to expose it, since we'll need that in order to create CircTargets for introduction points and rendezvous points.
* guardmgr, netdir: fix some needless-mut warningsNick Mathewson2023-05-181-2/+2
| | | | Found by clippy nightly
* netdir: New function to check consistency of a HasRelayIdsNick Mathewson2023-05-161-0/+142
| | | | | | | | | | | This function will be used to look up a relay by a set of LinkSpecs given from an incoming HsDesc or INTRODUCE2 message. It differs from other "lookup relay by IDs" functions in that it needs to be able to return "here's a relay", "couldn't found a relay", or "learned that this relay is impossible." Closes #855: This is the only new API needed for ChanTarget validation, I think.
* tor-netdir: Shuffle the list of HS dirs used for downloading descriptors.Gabriela Moldovan2023-05-041-10/+22
| | | | | | | | We'll probably need the hsdir list to be shuffled deterministically for testing purposes (this might be desirable, for example, when we write a test for HS descriptor download retries). Signed-off-by: Gabriela Moldovan <[email protected]>