summaryrefslogtreecommitdiff
path: root/crates/tor-netdir/src
Commit message (Collapse)AuthorAgeFilesLines
* Note a calculation we can clean up after doing spec work.Nick Mathewson2024-02-201-1/+3
|
* Add caveats on is_flagged_guard, and note possible deprecationNick Mathewson2024-02-201-1/+15
|
* Add and use "UncheckedRelay::is_suitable_as_guard"Nick Mathewson2024-02-201-0/+5
|
* Only pick Fast relays as introduction points.Nick Mathewson2024-02-201-1/+1
| | | | This matches the behavior of C tor. Part of #1100.
* Require that guards are Fast and Stable.Nick Mathewson2024-02-201-0/+5
| | | | | | This matches the behavior of C tor. Part of #1100.
* netdir: Add Relay::is_flagged_{fast,stable} methods.Nick Mathewson2024-02-121-0/+14
|
* Rename parameters for intro-point lifetime to match the spec.Nick Mathewson2024-01-311-4/+4
| | | | | | | | | | (Also, correct the comments that describe them.) We may as well match the spec names when they aren't completely bogus. We are already renaming these parameters for this release, so it isn't an additional breaking change.
* Rename our aliases for hs_intro_*_lifetime.Nick Mathewson2024-01-251-2/+2
| | | | | | The old names were somewhat inaccurate. (I would have considered keeping and deprecating the old names, but we already have breaking changes in tor-netdir.)
* tor-netdir: Add a unit test for HsDirParams::offset_within_srv_period.Gabriela Moldovan2024-01-241-0/+37
|
* tor-hsservice: Make offset_within_srv_period() work with timestamps from ↵Gabriela Moldovan2024-01-241-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | newer periods. This fixes a bug where `offset_within_srv_period()` returns `None`, instead of the offset of `when` from the start of the SRV of the previous time period: ``` 2024-01-24T15:24:46Z ERROR tor_hsservice::svc::publish::reactor: descriptor upload failed for HS service allium-cepa2 and time period TimePeriod { interval_num: 19745, length: IntegerMinutes { value: 1440 }, epoch_offset_in_sec: 43200 }: error: Programming error: internal error (bug) at /../arti/crates/tor-hsservice/src/svc/publish/reactor.rs:218:13: current wallclock time not within SRV range?! (now=SystemTime { tv_sec: 1706109886, tv_nsec: 246572852 }, SRV_start=SystemTime { tv_sec: 1705968000, tv_nsec: 0 }) ``` We need to be able to calculate this offset even if `now` is not within the SRV range (because we upload the descriptor to the HsDirs of the *previous* time period too). Note a similar bug exited in `offset_within_period()` (which no longer exists) too! That one was fixed in !1744: ``` Hidden services can have multiple "active" time periods for which they generate descriptors. We need to be able to compute the offset of a timestamp from the start of a given time period, even if that timestamp falls within the "next" time period (for example, when publishing descriptors for the "previous" time period, the `when` timestamp will fall outside the `(start, end)` range of the "previous" time period). ```
* tor-netdir: Make hs_dirs_{upload, download} take separate args instead of tuple.Gabriela Moldovan2024-01-241-2/+4
| | | | Prompted by https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1904#note_2987777
* tor-netdir, tor-hscrypto: Add function for computing SRV period offset.Gabriela Moldovan2024-01-241-3/+22
| | | | Part of #1166
* tor-netdir: Simplify `hs_dirs_upload` by only returning the `Relay`.Gabriela Moldovan2024-01-241-20/+15
| | | | | | | | The publisher is the only user of `hs_dirs_upload`. It turns out it never actually uses the first element of the yielded `Item`s, so we can simplify `hs_dir_upload` to only return the HsDir `Relay`s. Part of #1166
* tor-netdir: Make hs_all_time_periods return HsDirParams.Gabriela Moldovan2024-01-241-3/+3
| | | | | | | | | The descriptor publisher uses this function to obtain the list of relevant time periods. It will soon also need to know the `srv_lifespan` associated with each time period, so we change this function to return `HsDirParams`. Part of #1166
* netdir: Make hs_dirs_upload() yield &HsDirParams.Nick Mathewson2024-01-231-2/+3
| | | | Closes #1254.
* Expose HsDirParams, and give it accessors.Nick Mathewson2024-01-232-2/+24
|
* hsservice: Make HsDirParams include the SRV lifespan.Nick Mathewson2024-01-232-11/+16
| | | | This is part of #1254.
* netdir: Only choose Stable relays as introduction points.Nick Mathewson2024-01-161-3/+1
| | | | | | This implements Relay::is_hs_intro_point. Close #1240.
* netdir: flag every testnet relay as Fast and StableNick Mathewson2024-01-161-1/+5
| | | | | As we enforce these flags in more places, it will be handy for our default network to have them for its relays.
* netdir: Downgrade a TODO in a deprecated, unused function.Nick Mathewson2024-01-141-1/+5
|
* netdir: Make TODOs on is_hs_intro_point refer to #1240Nick Mathewson2024-01-141-3/+3
|
* netdir: Downgrade or remove several "TODO HSS" comments.Nick Mathewson2024-01-141-7/+5
| | | | These are not release-blockers.
* netdir: Explain why there is no HsRend WeightRule.Nick Mathewson2024-01-141-1/+5
|
* clippy: Add an allow to work around a clippy bugIan Jackson2024-01-021-0/+3
| | | | | | | | | | clippy in current stable thinks |(a, b)| (a, b) is always the identity function, but due to match ergonomics, it might be an implicit copy. This is fixed in nightly by https://github.com/rust-lang/rust-clippy/pull/11792
* Improve documentation in/around DosParams extensionNick Mathewson2023-11-201-6/+13
| | | | | | It does not help that C tor has a set of parameters and a set of configuration options with exactly the same names which configure the same thing in two slightly different ways.
* tor-hsservice: Rewrite map() as a for-loop (fmt).Gabriela Moldovan2023-10-031-1/+2
|
* tor-netdir: Fix broken condition.Gabriela Moldovan2023-10-031-4/+5
| | | | | | | | | | | | | The statement ``` if hsids.all(|(_hsid, period)| rings.any(|(_, _, tp)| tp == period)) { ``` had 2 bugs: * the condition is reversed (it should be negated: we need to bail if one of the specified `hsids` cannot be found on any of our rings) * `rings.any()` mutates the `rings` iterator, causing `hs_dirs_upload` to return fewer HSDirs than expected
* 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.