Commit Graph

5090 Commits

Author SHA1 Message Date
Nick Mathewson 6591842458 Refactor configured_bridges
Now it is an Option, and is set to None if bridges aren't enabled.

This simplifies `replace_bridge_config` a bit, and forces us to
check for `None` in a few more places.
2022-11-08 08:10:15 -05:00
Nick Mathewson 2a5b4d21e3 GuardMgr: Document that providers should only be installed once.
Enforce this with assert!() and a documented panics section.
2022-11-08 08:10:15 -05:00
Nick Mathewson 9fda8d17c4 GuardMgr: Fix build with bridge-client disabled. 2022-11-08 08:10:15 -05:00
Nick Mathewson 6bcce19655 GuardMgr: Remove no-longer-relevant `TODO pt-client` comments
Also remove a bunch of now-unnecessary `allow(dead_code)`
annotations.
2022-11-08 08:10:15 -05:00
Nick Mathewson 1418ec13a8 GuardMgr: Rename an error variant 2022-11-08 08:10:15 -05:00
Nick Mathewson 3943c6cd1e GuardMgr: Spelling fixes and normalizations. 2022-11-08 08:10:15 -05:00
Nick Mathewson 3f3d82ee48 GuardMgr: do not use fallbacks when in bridge mode. 2022-11-08 08:10:15 -05:00
Nick Mathewson 5c3bb3d7e1 GuardMgr: When possible, return a FirstHop that can be a CircTarget
We do this by checking the FirstHops we're about to return, and when
they correspond to bridges, looking up an appropriate BridgeRelay
in the current BridgeSet (if we can).
2022-11-08 08:10:15 -05:00
Nick Mathewson 25d7924832 GuardMgr: Refactor UniverseRef to contains Arcs.
We already _have_ these Arc<>s whenever we construct a UniverseRef,
so there's no real point in using &refs and making these so
hard to construct.
2022-11-08 08:10:15 -05:00
Nick Mathewson 7fa08140cf GuardMgr: Remove an outdated "Limitations" comment.
Found while grepping for NetDir.
2022-11-08 08:10:15 -05:00
Nick Mathewson e1ef939ebd GuardMgr: do not block netdir if we are using bridges
The `GuardMgr` code has functionality to tell the DirMgr "Hey,
don't switch to the new NetDir yet: we still need more guard
information!"  But we never want to do that if we're selecting
bridges, since they don't come from the NetDir.
2022-11-08 08:10:15 -05:00
Nick Mathewson 1a4fbb2c3f GuardMgr: Add UniverseType to make code more explicit.
Instead of duplicating the logic about which guard sample uses which
universe, we explicitly ask it, and then use that universe.  This
will avoid trouble if/when we introduce more samples.
2022-11-08 08:10:15 -05:00
Nick Mathewson d395ae75a5 GuardMgr: Launch a background task to keep the list of bridge
descriptors updated as appropriate.
2022-11-08 08:10:15 -05:00
Nick Mathewson e93ee14270 GuardMgr: Exit keep-netdir-updated task early if GuardMgr disappears. 2022-11-08 08:10:15 -05:00
Nick Mathewson 697a355a21 GuardMgr: Pass correct universe to "Bridges" `GuardSet`.
This can probably be done in a simpler way, but for the moment I
would prefer to try to minimize the amount of code I'm changing
here.
2022-11-08 08:10:15 -05:00
Nick Mathewson f4149cd133 GuardMgr: Change BridgeSet, BridgeRelay to use more references
This will match our needs better and help avoid some `Arc<>`s.

It will be especially helpful for avoiding `Arc`s we don't
actually have.
2022-11-08 08:10:15 -05:00
Nick Mathewson 51a98883c8 GuardMgr: Store bridge configuration.
I'm using an Arc<[]> here though I think that there's a chance
that a simple Vec<> would suffice. Since it's an internal type,
nothing will break if we change it later.

Also, we now switch into and out of the Bridges guard sample
as needed.  However, that selection is not (yet) built from the
list of bridges.  That will come soon.
2022-11-08 08:10:15 -05:00
Nick Mathewson 188b9c0f86 GuardMgr: Remove duplicate code in set_filter 2022-11-08 08:10:15 -05:00
Nick Mathewson 04bcf69749 GuardMgr: Clarify intent with update_active_set.
Also fix its behavior when using bridges.
2022-11-08 08:10:15 -05:00
Nick Mathewson ad47b28f2f GuardMgr: Split `update_internal` into two functions.
The first part changes which guard set is active based on based on
the parameters, which always come from a NetDir; the second changes
the contents of the active guard set, based on a Universe.
2022-11-08 08:10:15 -05:00
Nick Mathewson 95a95076a7 Refactor external guardmgr APIs: Stop taking NetDir arguments.
These arguments were used only for legacy (testing) purposes; the
tests now use `TestNetDirProvider`.  This lets us simplify our
internal logic for passing a `NetDir` to our samples, and prepare
for having a `BridgeSet` to pass there instead.

This is a breaking change to `guardmgr` and `circmgr`.
2022-11-08 08:10:15 -05:00
Nick Mathewson 339bd8bde0 Mock implementation of a NetDirProvider for testing.
I'm about to remove the old testing APIs from GurdMgr that took in a
NetDir in each function: adding this will make that possible.
2022-11-08 08:10:15 -05:00
Nick Mathewson 6b94bc5e4c Add an accessor for the latest BridgeDescList. 2022-11-08 08:10:15 -05:00
Nick Mathewson faf51702ac Implement GuardMgr::install_bridge_desc_provider 2022-11-08 08:10:15 -05:00
Nick Mathewson 5cb9e1987e Require Send+Sync for BridgeDescProvider
We require these for NetDirProvider, so this shouldn't be a big reach.
2022-11-08 08:10:11 -05:00
Ian Jackson 93a150229a sqlite cache: Document reasoning about timestamps
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/831#note_2851764
2022-11-08 13:00:51 +00:00
Nick Mathewson 897bac680f linkspec: Rename "maybe rename this?" TODOs in favor of #623 2022-11-07 12:27:50 -05:00
Nick Mathewson f5364065f3 PtTargetSettings: Enforce correctness at lower level.
This resolves a number of TODOs.
2022-11-07 12:21:22 -05:00
Nick Mathewson 06972f171d Remove a blank line 2022-11-07 12:19:02 -05:00
Nick Mathewson bc28793166 Downgrade TODO on chan_method
This is not something we need to solve for 1.1.0 (and it might not
need to be solved ever).
2022-11-07 11:49:49 -05:00
Nick Mathewson d448809e49 Merge branch 'hilev_spelling' into 'main'
Spelling fixes and normalizations on some high-level crates

See merge request tpo/core/arti!835
2022-11-07 15:48:06 +00:00
Nick Mathewson b423a40478 Remove TODO about third ChannelMethod variant.
We didn't find a use for this.
2022-11-07 10:39:13 -05:00
Nick Mathewson e832a90c4b Remove TODO about inlining PtTargetSettings.
Since there are (or soon will be) parsing restrictions on this type,
we don't want to inline it as a simple Vec.
2022-11-07 10:36:20 -05:00
Nick Mathewson b295518a42 Spelling fixes and normalizations on some high-level crates 2022-11-07 10:21:58 -05:00
Nick Mathewson c4b82aa8a8 Merge branch 'bdm-dyn-clone' into 'main'
bridge desc: Make BridgeDescProvider DynClone

See merge request tpo/core/arti!834
2022-11-07 13:20:14 +00:00
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
Nick Mathewson 3130cd2020 Merge branch 'typos' into 'main'
Fix typos

See merge request tpo/core/arti!833
2022-11-06 15:48:17 +00:00
Dimitris Apostolou 9c7d1802f5
Fix typos 2022-11-06 06:51:58 +02:00
Ian Jackson 5b66a5e199 bridge desc tests: Test caching and if-modified-since 2022-11-04 19:08:32 +00:00
Ian Jackson 78f7916a88 bridge desc tests: Break out queues_are_empty helper 2022-11-04 19:08:32 +00:00
Ian Jackson 40c21b7d19 bridge desc tests: Provide a sqlite connection
The current test case doesn't use this.
2022-11-04 19:08:32 +00:00
Ian Jackson 636bff3193 bridge desc: Implement storage functions at the DB layer 2022-11-04 19:08:32 +00:00
Ian Jackson 6bb2eb9902 bridge desc: Make Downloaded be Debug 2022-11-04 19:08:32 +00:00
Ian Jackson 5bc1d40a2b bridge desc: Implement cache reuse logic and if-modified-since
This introduces the new API functions to Store.
But currently they are all no-ops.
So all this machinery doesn't actually do anything.

Also, it changes the API to the mockable downloader, to allow it to
support if-modified-since.  So this isn't used either.  But it is more
convenient to do this all at once in BridgeDescManager, since care
needs to be taken about the intraction between if-modified-since and
the persistent cache.
2022-11-04 19:08:32 +00:00
Ian Jackson 279a169031 bridge desc: Rename one more variable to text 2022-11-04 19:02:23 +00:00
Ian Jackson eaaa61a8e2 bridge desc: Catch panics in the download functionality 2022-11-04 19:02:23 +00:00
Ian Jackson 3f3f27193c bridge desc: Provide a Store to the bridge desc manager
We use the one in the dirmgr.  That means that our constructor now has
to take a dirmgr.  And, the dirmgr must have a circmgr.

This is all rather odd, TBH.

Add .. to the binding of the return values from setup, as
future-proofing.

The tests now need to provide a Store too.  Make the sqlite::new_empty
function pub(crate) so we can use it.

We must retain the _db_tmp_dir, since when it goes away the tmp
directory is deleted and the db goes readonly.
2022-11-04 19:02:23 +00:00
Ian Jackson 1fa9dd62b3 bridge desc tests: Apply tracing_test::traced_test
This lets us see the log messages.  They look fine, as it happens.
2022-11-04 19:02:23 +00:00
Ian Jackson 9424b0970d tor-dirmgr: impl AsRef<dyn Error> for Error
This allows use with tor_error::Report.
2022-11-04 19:01:24 +00:00
Ian Jackson f3957a50b6 tor-netdoc: RouterDesc: Add published accessor
The bridge descriptor manager is going to want this.
2022-11-04 19:01:24 +00:00