summaryrefslogtreecommitdiff
path: root/crates/tor-guardmgr/src/vanguards
Commit message (Collapse)AuthorAgeFilesLines
* tor-guardmgr: Convert a TODO into a NOTE.Gabriela Moldovan2024-09-101-1/+2
| | | | | | | | | This behavior is OK, so this doesn't need to be a TODO. See the discussion at https://gitlab.torproject.org/tpo/core/arti/-/issues/1352#note_3015217 Closes #1352
* Fix typosDimitris Apostolou2024-09-031-1/+1
|
* tor-guardmgr: Fix broken doc link.Gabriela Moldovan2024-06-031-1/+1
|
* tor-guardmgr: Unconditionally define VanguardConfig.Gabriela Moldovan2024-06-031-16/+0
| | | | | | | | | We want to export the `VanguardConfig` even if the `vanguards` feature is disabled (we will need to unconditionally include it in the arti config). Note that if `vanguards` are disabled, the `VanguardMode` from the `VanguardConfig` can only be `Dsiabled`.
* tor-guardmgr: Map NoSuitableRelay errors to ErrorKind::NoPath.Gabriela Moldovan2024-05-091-2/+1
|
* tor-guardmgr: Add an error variant for when the vanguard mode is unsuitable.Gabriela Moldovan2024-05-091-1/+11
|
* tor-guardmgr: Return a BootstrapRequired error if all the sets are empty.Gabriela Moldovan2024-05-091-0/+5
| | | | | | | | | Previously, `select_vanguard` returned a `NoSuitableRelay` error if it was unable to select a relay to use as a vanguard. We now distunguish the "there are no suitable relays in the vanguard sets" (`NoSuitableRelays`) error case from the "our vanguard sets are empty" (`BootstrapRequired`) one.
* tor-guardmgr: Add a BootstrapRequired error for VanguardMgr.Gabriela Moldovan2024-05-091-0/+9
|
* tor-guardmgr: Move VanguardMgrError to a separate module.Gabriela Moldovan2024-05-091-0/+46
| | | | | This is about to grow another variant, so I'm moving it to a dedicated `err` module.
* tor-guardmgr: Remove TODO about removing Vanguard abstraction.Gabriela Moldovan2024-05-091-3/+0
| | | | | I think it's alright to keep it: it gives us the flexibility to extend it later on, if needed.
* tor-guardmgr: Remove a TODO HS-VANGUARDS.Gabriela Moldovan2024-05-091-3/+0
| | | | | | This TODO doesn't really need to be implemented: we can test the `VanguardMgr` just the same without it (`GuardMgrInner` is similar, in that it doesn't mock the rng).
* tor-guardmgr: Make remove_unlisted return the number of unlisted vanguards.Gabriela Moldovan2024-04-301-2/+4
| | | | For symmetry with remove_expired.
* tor-guardmgr: Make remove_expired return the number of expired vanguards.Gabriela Moldovan2024-04-301-17/+23
| | | | Prompted by https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2109#note_3024672
* tor-guardmgr: Prevent misleading logs when not rotating vanguards.Gabriela Moldovan2024-04-291-0/+10
| | | | | `rotate_expired()` now only logs that it is rotating the vanguards if some existing vanguards have actually expired.
* tor-guardmgr: Add a TODO about using the vanguard consensus params.Gabriela Moldovan2024-04-291-0/+3
|
* tor-guardmgr: Remove old TODO about making VanguardMode a VanguardParam.Gabriela Moldovan2024-04-291-3/+0
| | | | | | | | | `VanguardParams` already contains the `vanguards_enabled` and `vanguards_hs_service` `VanguardMode` params. We still intend to abolish `VanguardConfig` in favour of deriving the `VanguardMode` from the consensus params (#1382), but this is not the right place for such a TODO.
* tor-guardmgr: Remove unnecessary clippy allows.Gabriela Moldovan2024-04-292-2/+0
| | | | None of these should be unused anymore.
* tor-guardmgr: Remove unnecessary VanguardSetsTrackedMut contraption.Gabriela Moldovan2024-04-221-163/+16
| | | | | | | | The VanguardMgr now unconditionally flushes the vanguard sets to disk each time there's a consensus change, and every time a vanguard expires. Prompted by https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2090#note_3021013
* tor-guardmgr: Remove pick_{l2,l3}_relay, add l2(), l3() accessors.Gabriela Moldovan2024-04-221-25/+10
| | | | Prompted by https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2090#note_3021016
* tor-guardmgr: Make vanguard logs begin with an uppercase letter for consistency.Gabriela Moldovan2024-04-221-1/+1
| | | | | Our log messages begin with an uppercase letter in the rest of the code base.
* tor-guardmgr: Add logging around vanguard rotation.Gabriela Moldovan2024-04-221-3/+19
|
* tor-guardmgr: Derive PartialEq for VanguardSets.Gabriela Moldovan2024-04-221-3/+3
| | | | This will be useful for testing.
* tor-guardmgr: Make VanguardSet private.Gabriela Moldovan2024-04-221-18/+10
| | | | | | This doesn't need to be `pub(super)` anymore, `VanguardMgr` now manipulates the `VanguardSets` exclusively through `VanguardSetsTrackedMut`.
* tor-guardmgr: Move vanguard set replenishing logic to VanguardSetsTrackedMut.Gabriela Moldovan2024-04-221-13/+272
| | | | | | A lot of this is code motion: the code added to `VanguardSetsTrackedMut` was copied from the `VanguardMgr` impl, so I recommend reviewing this with `git diff --color-moved=zebra`.
* tor-guardmgr: Add VanguardSetsTrackedMut for mutating VanguardSets.Gabriela Moldovan2024-04-221-0/+54
| | | | | | | | | This enables us to track when `VanguardMgr`'s `VanguardSets` is *actually* mutated. This will soon be useful because we only want to flush the `VanguardSets` to storage if we actually added or removed some relays from the set.
* tor-guardmgr: Add some accessors for VanguardSets.Gabriela Moldovan2024-04-221-0/+43
| | | | | These will be useful later, when we place the `l2_vanguards` and `l3_vanguards` from `VanguardMgr` with a `VanguardSets`.
* tor-guardmgr: VanguardSet::remove_{unlisted,expired} returns whether the set ↵Gabriela Moldovan2024-04-221-5/+14
| | | | | | | | | changed. The two removal functions now return whether any values were removed from the `VanguardSet`. Their return values are currently ignored, but will soon be used for deciding whether to flush the `VanguardSet`s to disk (if full vanguards are enabled).
* tor-guardmgr: Introduce an abstraction over the two vanguard sets.Gabriela Moldovan2024-04-221-0/+19
| | | | | | | `VanguardSets` (not to be confused with `VanguardSet`) will soon be used as: * a helper for serializing the L2 and L3 `VanguardSet`s * an abstraction over the two vanguard sets
* tor-guardmgr: Derive Default for VanguardSet.Gabriela Moldovan2024-04-221-1/+6
| | | | | | | | | | We will soon replace `VanguardSet::new` with `VanguardSet::default`: `new()` currently expects a set of `VanguardParams` (from which the target size of the set is derived), but we don't have a `VanguardParams` until we obtain a `NetDir`. Moreover, it doesn't make sense to attempt to set the target size of the `VanguardSet` before obtaining a `NetDir`, because we can't actually populate the set without a `NetDir` (we can't select relays).
* tor-guardmgr: By default, use full vanguards for onion services.Gabriela Moldovan2024-04-221-2/+2
| | | | | | | By default, HS clients should be using lite vanguards, and HS services full vanguards. See https://gitlab.torproject.org/tpo/core/torspec/-/merge_requests/258#note_3011734
* tor-guardmgr: Remove unnecessary mutable reference.Gabriela Moldovan2024-04-151-1/+1
|
* tor-guardmgr: Remove outdated TODO.Gabriela Moldovan2024-04-151-6/+0
| | | | It was addressed in !2083
* tor-guardmgr: Remove outdated documentation.Gabriela Moldovan2024-04-151-3/+0
| | | | | This is no longer true because of !2082. The `VanguardSet` *does* own its `TimeBoundVanguards`.
* tor-guardmgr: Remove unused TimeBoundVanguard implementations.Gabriela Moldovan2024-04-151-24/+0
| | | | These are not used anymore as of !2082, so we can remove them now.
* tor-guardmgr: Add the two VanguardModes to VanguardParams.Gabriela Moldovan2024-04-111-0/+12
| | | | | | | | We have two vanguard modes, one for when arti is running as a client, and a separate one for when it's running as a service. Both modes are extracted from the `NetParameters`, so they belong in `VanguardParams`.
* tor-guardmgr: Replace vanguard heap with a simpler approach.Gabriela Moldovan2024-04-101-27/+25
| | | | | | | | | | | | | | | | | | As mentioned in https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2075#note_3016306 using a heap isn't the best way to manage the vanguards: * in the default case, which will apply to most users, the L2 and L3 set sizes are 4 and 8 respectively. Using a heap doesn't make sense for such small sets * the use of `Weak<TimeBoundVanguard>`s will be an inconvenience later on, when we implement vanguard set persistence, since `Weak` isn't serializable or deserializable This switches to a simpler apporach, where the `VanguardMgr` computes the soonest expiration timestamp of its `VanguardSet`s by iterating over all the vanguards in each set. Closes #1366
* tor-guardmgr: Remove unnecessary call to discard_expired().Gabriela Moldovan2024-04-101-1/+0
|
* tor-guardmgr: Validate lifetimes before constructing VanguarParams.Gabriela Moldovan2024-04-101-4/+35
| | | | | If the [min, max] lifetime interval for a vanguard layer is the empty set (i.e. min > max), we return the default lifetime.
* tor-guardmgr: Explain why we're making a uniform choice.Gabriela Moldovan2024-04-091-0/+3
|
* tor-guardmgr: Add tests for the vanguard manager.Gabriela Moldovan2024-04-051-0/+16
|
* tor-guardmgr: Replenish the vanguard sets as needed.Gabriela Moldovan2024-04-051-0/+24
|
* tor-guardmgr: Implement From<&VanguardSet> for RelayIdSet.Gabriela Moldovan2024-04-051-1/+20
|
* tor-guardmgr: Implement VanguardSet::pick_relay.Gabriela Moldovan2024-04-051-9/+32
| | | | Closes #1340
* tor-guardmgr: Make TimeboundVanguard fields pub(super).Gabriela Moldovan2024-04-051-2/+2
|
* tor-guardmgr: Store the TimeboundVanguards in a binary heap.Gabriela Moldovan2024-04-051-5/+29
|
* tor-guardmgr: Give VanguardSets a target set size.Gabriela Moldovan2024-04-051-1/+11
| | | | | The target is the number of vanguards the `VanguardMgr`s will try to maintain in the `VanguardSet`.
* tor-guardmgr: Derive getters for VanguardParams.Gabriela Moldovan2024-04-051-1/+7
|
* tor-guardmgr: Pass an rng to select_vanguard.Gabriela Moldovan2024-04-051-1/+3
| | | | | This function will need to randomly select a vanguard, so it needs an `Rng`.
* tor-guardmgr: Implement TryFrom<&NetParameters> for VanguardParams.Gabriela Moldovan2024-04-051-3/+18
|
* tor-guardmgr: Fix typo in VanguardSet docs.Gabriela Moldovan2024-04-051-1/+1
|