Commit Graph

339 Commits

Author SHA1 Message Date
Ian Jackson 85035c7c5a bridge desc: Make BridgeDescProvider DynClone
This allows the use of Box<dyn BridgeDescProvider> in callers,
since Box<dyn BridgeDescProvider> is now Clone.
2022-11-07 11:56:41 +00:00
Dimitris Apostolou 9c7d1802f5
Fix typos 2022-11-06 06:51:58 +02:00
Nick Mathewson 7d079ade3b Merge branch 'warning' into 'main'
tor-guardmgr: use imported WeightThreshold in one place

See merge request tpo/core/arti!825
2022-11-03 16:25:37 +00:00
Ian Jackson 7d6f5d5eab guardmgr config: Provide bridge information to new and reconfigure 2022-11-03 15:48:07 +00:00
Ian Jackson aa375e2e09 tor-guardmgr: use imported WeightThreshold in one place
Without this, an unused import warning is generated when building
without features.
2022-11-03 15:44:32 +00:00
Ian Jackson 5bc3934fb4 bridges config: Provide uninhabited placeholder
This will avoid having to make bridge-related trait features in
GuardMgr conditional, which would be non-additive.
2022-11-03 15:43:41 +00:00
Ian Jackson 6c64be06a6 guardmgr config: Introduce and require new GuardMgrConfig trait
It doesn't seem to me like it makes sense to provide the backward
compatibility here.
2022-11-03 15:43:41 +00:00
Ian Jackson 2bfce54959 guardmgr config: Pass fallback list from config by reference
This does involve additional cloning.  However, soon it will mean that
we can pass the whole `TorClientConfig` by reference.
2022-11-03 15:43:41 +00:00
Nick Mathewson 932fe48eaf Run add_warnings. 2022-11-03 11:06:02 -04:00
Ian Jackson 48f48841e1 Require derive_more 0.99.3
0.99.[012] have a bug https://github.com/JelteF/derive_more/issues/114
which makes the Deref derive for bridgedesc::StateGuard not work
and therefore breaks minimal-versions CI.

It seems simpler to require the newer version everywhere.
2022-11-03 11:37:23 +00:00
Nick Mathewson 66f34ee774 Merge branch 'guards_as_bridges_part3' into 'main'
GuardMgr: decouple NetDir from guards and sample code.

See merge request tpo/core/arti!815
2022-11-02 12:41:03 +00:00
Nick Mathewson c2ed381c99 Refactor CandidateStatus API to simplify code in descs.
This removes some duplication.
2022-11-02 08:07:32 -04:00
Nick Mathewson fc0c12510a GuardMgr: Fix and improve comments based on review. 2022-11-02 08:07:32 -04:00
Nick Mathewson 6828178dec guardmgr: fix rustdoc references. 2022-11-02 08:07:32 -04:00
Nick Mathewson 08473872ab guardmgr: Refactor candidate info; add `full_dir_info`
Previously we always set `dir_info_missing` to `false` for new
guards, since new guards could only be taken from ones that were
present in the NetDir.  But for bridges, we don't download their
info until _after_ we have chosen them as guards.
2022-11-02 08:07:11 -04:00
Nick Mathewson 5867318a35 guardmgr: Implement Universe for bridges.
Now we can use a group of bridges as the basis for a sample of
guards.
2022-11-02 08:06:43 -04:00
Nick Mathewson 79dade342a guardmgr: Universe API should look up by ChanTarget
This will be necessary for bridges.
2022-11-02 08:06:43 -04:00
Nick Mathewson 82e9a57012 guardmgr: take sampled guards from Universe.
This is a trickier case, since we have to deal with weights.
2022-11-02 08:06:43 -04:00
Nick Mathewson 7733146c8c guardmgr: Continue porting porting code to use Universe.
Two more simple cases that can use Universe instead of Netdir.
2022-11-02 08:06:20 -04:00
Nick Mathewson fbcacea993 guardmgr: Begin to decouple guards from NetDir.
In this and the upcoming commits I'll be changing how guards related
to `NetDir` and to `Relay`.  Previously, a guard could only come
from (or be updated from) a `Relay` in a `NetDir`.  Soon it will be
able to be built from a bridge as well.

To do this, I'm defining a `Universe` trait (name negotiable) that
represents a set of things that may be guards.  I'm going to
continue extending its functionality until there are no more
methods in guard.rs or sample.rs that take `NetDir`.

This commit removes most of the usage of `NetDir` and `Relay` in
`guard.rs`.
2022-11-02 08:05:51 -04:00
Nick Mathewson b5f498021d guardmgr: Rename microdescriptor_missing to dir_info_missing 2022-11-02 07:59:56 -04:00
Nick Mathewson 39ea0518ee guardmgr: Allow guards to be constructed from any ChanTarget. 2022-11-02 07:59:56 -04:00
Nick Mathewson 1cb6ea1e77 guardmgr: Include PtTarget in guards.
Use a vector, since we may (someday) want to allow a Guard to have
multiple PtTargets.
2022-11-02 07:59:56 -04:00
trinity-1686a e6e064ac8a remove unused dependancies 2022-10-29 13:29:55 +02:00
Nick Mathewson 29c46d08b5 Merge branch 'guards_as_bridges_part2' into 'main'
Use ByRelayIds to hold guards in GuardSet

See merge request tpo/core/arti!808
2022-10-27 21:09:47 +00:00
Nick Mathewson 557a07677e guardmgr: Rename and clarify of non-persistent-state copy fns
These will need a bigger overhaul: see #612 and #611.
2022-10-27 16:40:35 -04:00
Ian Jackson 4f171acaf7 Clarify fix_consistency 2022-10-27 16:40:35 -04:00
Ian Jackson 7180079112 Clarify what it means to be "an identity" for a primary guard. 2022-10-27 16:40:35 -04:00
Ian Jackson 15d464a929 tor-guardmgr: Add big doc comment about guard id handling 2022-10-27 16:40:35 -04:00
Ian Jackson 26a7aa9aa6 BridgeDescProvider: Make BridgeDescEvent repr(u16) and derive traits
This will enable us to impl FlagEvent for it.
2022-10-27 15:57:54 +01:00
Ian Jackson a56efbfdf0 impl Hash for BridgeConfig and various PT information
The bridge descriptor manager wants to index data structures by the
BridgeConfig.
2022-10-27 15:57:54 +01:00
Ian Jackson a89daba1c8 tor-guardmgr: bridges: export BridgeDescError at toplevel 2022-10-27 15:57:54 +01:00
Nick Mathewson 20016df6fa guardmgr: Use new ambiguity-tolerant contains in state handling
This has subtleties; the comments try to explain them.
2022-10-25 11:15:53 -04:00
Nick Mathewson d65c351b33 guard sample: Change semantics of `contains` to handle ambiguity.
This is necessary for the (somewhat undesirable) lookup_ids function
to return an ID that the dirmgr can actually use to report successes
and failures.

As noted, lookup_ids will create problems down the road when we
implement relays. We should refactor it out before then.
2022-10-25 11:15:53 -04:00
Nick Mathewson 28f2e2997e Replace contains_relay with can_add_relay().
To see if we can add a relay as a guard, we need a conservative
test: any IDs in common with the given relay prevent us from adding
it.
2022-10-25 11:15:53 -04:00
Nick Mathewson 3a994c32dc Convert guard samples to use ByRelayIds.
This required a number of changes, which I've tried to document.
I've taken a conservative approach to modification, and I'm not
using any of the by_*_mut() functions (yet).  For cases which
potentially modify the whole set, I'm using into_values() and
collect() to ensure that it's re-indexed correctly, even though the
identities don't change.

I introduce some "TODO pt-client" comments here which I will resolve
in the next commit(s).
2022-10-25 11:15:53 -04:00
Ian Jackson f7e5892e40 BridgeDescEvent: Change the sole variant to SomethingChanged
And explain what this all means.
2022-10-25 15:32:56 +01:00
Nick Mathewson 8528d61a78 impl HasRelayIds for GuardId. 2022-10-25 09:23:28 -04:00
Nick Mathewson 40ec12b0cb Merge branch 'guards_as_bridges_part1' into 'main'
Allow GuardMgr to expose bridges as guards (part 1)

See merge request tpo/core/arti!785
2022-10-24 13:30:02 +00:00
Nick Mathewson bb117a4bd4 guardmgr: Refactor the interior of FirstHop.
Now it contains either an `OwnedChanTarget` or an `OwnedCircTarget`,
which will let `GuardMgr` return bridges that can be used to make
circuits.

As part of this change, it was necessary to revise some
address-modification functions that applied to filters and
`OwnedChanTarget`.  Now they do the smart thing, and remove only the
address that are in the `ChanMethod`.  This means that the addresses
from HasAddrs are still accurate about which addresses the relay
"has".
2022-10-24 08:59:12 -04:00
Ian Jackson 0924fb3623 tor-guardmgr: descs: Make BridgeDescError DynClone 2022-10-21 16:22:17 +01:00
Ian Jackson f4ec3e6cec tor-guardmgr: descs: Make BridgeDescError into a trait 2022-10-21 16:22:13 +01:00
Nick Mathewson fa1d2f453a guardmgr: Hold FallbackDir in fallback::set::Entry
This resolves an old TODO, and will simplify our work a little.
2022-10-21 09:21:43 -04:00
Nick Mathewson 19fdf196d8 guardmgr: Add bridges sample, encode sample ID in FirstHopId.
The most important part of this commit is to make sure that each
`FirstHopId` includes the `GuardSetSelector` from which the guard
was selected.  Doing this lets us be certain that when we report
that a guard has succeeded or failed, we're reporting it in the
right context.

Additionally, this commit uses strum to make an iterator over the
samples, so that we can make sure that our "for each sample" code is
robust against future changes, and we don't miss the bridge sample.
2022-10-21 09:21:43 -04:00
Ian Jackson 803131c1ea Merge branch 'bridge-internal-apis' into 'main'
Use BridgeConfig to identify bridges in two places

See merge request tpo/core/arti!781
2022-10-20 16:14:14 +00:00
Ian Jackson 9c7ea41322 impl ChanTarget etc. for BridgeConfig 2022-10-20 14:16:34 +01:00
Ian Jackson 11c61a3d7f bridge descriptors: Change types of the descriptor cache
Now keyed by Arc<BridgeConfig>, and the values can be errors.

Currently there is no implementation so there can't be any errors,
but the error enum will become nonempty.
2022-10-20 13:28:23 +01:00
Nick Mathewson 2845ee24bf fix a couple of spelling errors in guardmgr 2022-10-19 07:49:39 -04:00
Nick Mathewson b4cc98b21b Merge branch 'readmes' into 'main'
Abolish maint/readme and use doc include

Closes #603

See merge request tpo/core/arti!768
2022-10-12 15:16:18 +00:00
Ian Jackson f84d8777db cargo fmt to remove blank lines
Apparently cargo fmt doesn't like these, which my perl rune didn't
delete.

This commit is precisely the result of `cargo fmt`.
2022-10-12 15:29:04 +01:00