aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-netdir/src/hsdir_params.rs
Commit message (Collapse)AuthorAgeFilesLines
* maint: Run maint/add_warning to deny string slicesClara Engler2026-06-091-0/+1
| | | | | | | | | | | | This commit executes maint/add_warning with the just added change to deny string slices except in tests. I recommend auditing this by checking out the previous commit followed by running the script yourself and then verifying that the diff is identical to this commit. This commit makes cargo clippy fail. We will add exceptions in the next commit.
* netdir: Add a debug_assert to ensure the voting interval is non-zeroGabriela Moldovan2026-05-211-0/+44
| | | | | This also adds a test, just make sure creating a `Lifetime` with voting interval = 0 is actually impossible (and stays that way).
* netdir: Add a test for start_of_sr_protocol_run()Gabriela Moldovan2026-05-211-0/+77
|
* netdir: Make start_of_sr_round() fallibleGabriela Moldovan2026-05-211-10/+12
| | | | | It's better to return a `Bug` than to panic if the consensus valid-after is invalid.
* netdir: Remove a no longer needed constantGabriela Moldovan2026-05-211-3/+0
|
* netdir: Remove start_of_day_containing()Gabriela Moldovan2026-05-211-29/+0
| | | | This is no longer used.
* netdir: Fix SRV lifetime calculation for non-standard voting periodsGabriela Moldovan2026-05-211-3/+25
| | | | | | | | | | | | | | Fixes Arti's SRV lifetime calculation for the case where the voting interval != 1h, and the consensus doesn't have explicit timestamps for the SRVs. Credit goes to dgoulet for this fix! See also [this thread], and #2458 for the broader context. Closes #2522 [this thread]: https://gitlab.torproject.org/tpo/core/arti/-/work_items/2458#note_3401343
* hsdir_params: add debug log when we fall back to disaster paramsJim Newsome2026-04-021-2/+4
|
* Fix name of clippy lint to unchecked_time_subtraction (2)Ian Jackson2025-11-061-1/+1
| | | | Run maint/add_warning
* tor-netdoc: Apply much rustfmt churnIan Jackson2025-08-261-1/+1
|
* tor-netdoc: Remove generics from Consensus and its contentsIan Jackson2025-08-261-2/+2
|
* tor-netdoc: netstatus: Move everything variety-specificIan Jackson2025-08-261-2/+2
| | | | | | | | | This is much code motion. This splits many types into two. For example, `Conensus` is now`plain::Consensus<RS>` and `md::Consensus<RS>`. We're going to get rid of the generics later in this branch.
* Switch Cargo.toml files to edition 2024.Nick Mathewson2025-08-071-1/+1
| | | | | | | | | | | | | | 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.
* Resolve clippy::empty_line_after_doc_comments warnings.Nick Mathewson2024-12-031-1/+1
| | | | These are new in Rust 1.83.
* Run maint/add_warning.Nick Mathewson2024-03-131-0/+1
|
* Fix typos in doc commentsTobias Stoeckmann2024-03-061-1/+1
|
* 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, tor-hscrypto: Add function for computing SRV period offset.Gabriela Moldovan2024-01-241-3/+22
| | | | Part of #1166
* Expose HsDirParams, and give it accessors.Nick Mathewson2024-01-231-1/+19
|
* hsservice: Make HsDirParams include the SRV lifespan.Nick Mathewson2024-01-231-11/+15
| | | | This is part of #1254.
* Run maint/add_warning to add lint block everywhereIan Jackson2023-08-231-0/+1
|
* Run maint/add_warning to actually apply new lint allowsIan Jackson2023-07-101-0/+1
|
* Downgrade TODO HS on HsDirParams::compute().expect()Nick Mathewson2023-06-291-0/+15
| | | | | | (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: 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.
* 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.
* Rename onion-* cargo features to hs-* in tor-* cratesIan Jackson2023-02-281-4/+4
| | | | Fixes #756
* Fix compilation with various feature combinationsIan Jackson2023-02-091-1/+8
|
* hsdir representation: Introduce HsDirs generic typeIan Jackson2023-02-091-5/+5
| | | | | This already allows us to get rid of some duplication, and will be useful more widely in a moment.
* hsdir: Implement HS hash ring index calculationsIan Jackson2023-02-091-1/+0
|
* hsdir: impl Eq for HsDirParamsIan Jackson2023-02-091-1/+1
| | | | This will allow us to tell if we can reuse parts of a ring.
* hsdir: Rename HsRingParams to HsDirParamsIan Jackson2023-02-091-10/+14
| | | | | | | | | 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.
* hsdir_params: Rename some variables for consistencyIan Jackson2023-02-091-9/+9
| | | | | | | | | | 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.
* hsdir: Replace open-coded params fields and args with HsRingParamsIan Jackson2023-02-091-0/+1
| | | | | | This will enable us to pass these around more conveniently. And make empty_from_params take an owned params, which it would like.
* hs time handling: Make TimePeriod contain length as IntegerMinutesIan Jackson2023-02-091-2/+2
| | | | | | 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.
* netdir: remove duplicate code in param calculationNick Mathewson2023-01-281-23/+31
|
* netdir: remove the vestigial smallvec implementation I addedNick Mathewson2023-01-281-1/+1
| | | | | It's cute, but I don't think it will help performance, and I'm undecided about whether the semantic implications are true.
* Turn compute_ring_params into a method.Nick Mathewson2023-01-281-54/+60
|
* Several suggestions on gitlab.Ian Jackson2023-01-281-0/+2
|
* netdir: Implement ring-param constructors and time period accessorsNick Mathewson2023-01-281-0/+463
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