summaryrefslogtreecommitdiff
path: root/crates/tor-circmgr/src/path
Commit message (Collapse)AuthorAgeFilesLines
* Refactor external guardmgr APIs: Stop taking NetDir arguments.Nick Mathewson2022-11-082-13/+5
| | | | | | | | | 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`.
* guardmgr config: Introduce and require new GuardMgrConfig traitIan Jackson2022-11-032-2/+6
| | | | | It doesn't seem to me like it makes sense to provide the backward compatibility here.
* Circmgr: construct paths using either Relay or OwnedCircTargetNick Mathewson2022-10-241-24/+80
| | | | | | | | | | | Previously we could only use Relay for this case, which won't work any more: a Bridge is not a `tor_netdir::Relay`. Instead we allow the GuardMgr to give us something that knows how to convert itself into an OwnedCircTarget. This change required a far amount of follow-on revisions and refactoring, but it should all be internal to the path-building logic.
* Allow "clippy::single_char_pattern" in tests.Ian Jackson2022-10-121-0/+1
| | | | | | | This lint exists for perf reasons, and this is rarely relevant in tests. Using double quoted str is generally cognitively less burdensome.
* Add the necessary APIs for bridge-based circuit construction.Nick Mathewson2022-09-261-0/+1
|
* tor-netdir: Collapse by_id and by_relay_id into a single fn.Nick Mathewson2022-08-101-1/+2
| | | | | | There are some downstream changes required for this to work, but they are all just unit tests that could no longer infer the type of an Ed25519 key.
* Final (?) API revisions for tor-linkspecNick Mathewson2022-08-102-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this change, each individual identity type becomes optional. The functions that expose them unconditionally are now in a "legacy" trait that only some downstream types are expected to implement. There are new convenience APIs in HasRelayIds: * to return Option<&keytype>, * to see if one identity-set contains another. This commit will break several downstream crates! For the reviewer's convenience, I will put the fixes for those crates into a series of squash! commits on this one. tor-netdir ---------- Revise tor-netdir to accept optional identities. This required some caveats and workarounds about the cases where we have to deal with a key type that the tor-netdir code does not currently recognize at all. If we start to add more identity types in the future, we may well want more internal indices in this code. tor-proto --------- In order to make tor-proto support optional identities, there were fewer changes than I thought. Some "check" functions needed to start looking at "all the ids we want" rather than at "the two known IDs"; they also needed to accommodate that case where we don't have an ID that we demand. This change will also help with bridges, since we want to be able to connect to a bridge without knowing all of its IDs up front. The protocol currently _requires_ the two current ID types in some places. To deal with that, I added a new `MissingId` error. I also removed a couple of unconditional identity accessors for chanmgr; code should use `target().identity(...)` instead. tor-chanmgr ----------- This is an incomplete conversion: it does not at all handle channel targets without Ed25519 identities yet. It still uses those identities to index its internal map from identity to channel; but it gives a new `MissingId` error type if it's given a channel target that doesn't have one. We'll want to revise the map type again down the road when we implement bridges, but I'd rather not step on the channel-padding work in progress right now. tor-guardmgr ------------ This change is mostly a matter of constructing owned identity types more sensibly, rather than unwrapping them directly. There are some places marked with TODOs where we still depend on particular identity types, because of how the directory protocol works. This will need revisiting when we add bridge support here. tor-circmgr ----------- These changes are just relatively simple API changes in the tests.
* Introduce a RelayIdSet and use it in place of HashSet<RelayId>.Nick Mathewson2022-08-101-8/+11
| | | | | This makes lookups a little more efficient. I do with that HashSet just supported this use-case, but for now this seems our best option.
* Teach guard restrictions about RelayId.Nick Mathewson2022-08-101-2/+7
| | | | | This implementation is (sadly) too copy-heavy or now, because HashSet<RelayId> can't be indexed with RelayIdRef.
* Introduce HasRelayIds::same_relay_ids.Nick Mathewson2022-08-021-4/+4
| | | | | This method tells if two HasRelayIds contain exactly the same set of Relay identities, and is generally useful for debugging.
* tor-linkspec: Refactor out traits to represent a relay's ID set.Nick Mathewson2022-08-022-2/+2
| | | | | | | | | | | | | | We want the set of identities supported by a relay to be extensible in the future with minimal fuss; we'd also like to make working with these ID sets more convenient. To handle that, this commit adds a new trait for "Something that has the same IDs as a relay" and a new object for "an owned representation of a relay's IDs." This commit introduces a similar trait for "Something with a list of SocketAddr, like a relay has." There's no owned equivelent for that, since Vec<SocketAddr> is already a thing. Closes #428.
* CircMgr: Remove directory liveness testing.Nick Mathewson2022-07-261-14/+2
|
* circmgr: Refactor DirPathBuilder::pick_path.Nick Mathewson2022-07-121-9/+7
| | | | | We no longer needs to have a "return" at the end of each match block.
* circmgr: Use FilterCounts to explain why we couldn't build pathsNick Mathewson2022-07-122-14/+35
|
* circmgr: Use FilterCounts to explain why we couldn't find an exit.Nick Mathewson2022-07-121-9/+24
|
* Add more information to failed-to-select fallback errors.Nick Mathewson2022-07-071-1/+1
| | | | Also re-order the filters to be a little more logical.
* clippy: Consolidate many lints in maint/add_warningIan Jackson2022-06-241-1/+8
| | | | | | Found these by disabling the nightly dbg macro special case. Now, we have a mechanism for globally adding suppressions to tests, we can use that instead.
* tor-netdir: testnet: Make construct_netdir infallible (rustfmt)Ian Jackson2022-06-132-15/+5
| | | | | Run rustfmt. Separate commit to make review of the substantive commit easier.
* tor-netdir: testnet: Make construct_netdir infallibleIan Jackson2022-06-132-5/+0
| | | | | This is a *lot* of unwraps. The function takes no parameters and is used only for testing. It ought to be infallible.
* Use testing_rng() in tests throughout our crates.Nick Mathewson2022-06-022-8/+10
| | | | | | This only affects uses of thread_rng(), and affects them all more or less indiscriminately. One test does not work with ARTI_TEST_PRNG=deterministic; the next commit will fix it.
* Note a TODO in exitpath construction.Nick Mathewson2022-05-111-0/+6
|
* Merge branch 'socket-addr-list-builder' into 'main'Ian Jackson2022-05-041-12/+16
|\ | | | | | | | | FallbackDir: orports: Introduce and use VecBuilder See merge request tpo/core/arti!474
| * FallbackDir: Use VecBuilder for orportsIan Jackson2022-05-041-12/+16
| | | | | | | | | | | | | | And drop the ad-hoc orport() method. This brings FallbackDir's orports field in line with our list builder API. The general semver note in "configuation" seems to cover most of this.
* | GuardUsage: restrictions: Use list builderIan Jackson2022-05-041-1/+2
|/ | | | | | | | | | | | | | Although these do not appear in the config, it does have a builder. It seems sensible to get rid of this ad-hoc list manipulation site, and replace it with our standard list builder API. define_list_builder_helper requires that the builder element type be Deserialize. Currently GuardUsageRestriction is a transparent, public enum, so we aren't really exposing anything. We could introduce GuardUsageRestrictionBuilder now, but since it's not in the config and thereofore only in the public API of the lower crates, we can definitely put that off.
* Fix grammar and typosSamanta Navarro2022-04-271-1/+1
|
* squash! Bump every crate's edition to 2021.Nick Mathewson2022-04-251-1/+0
| | | | | Remove all `use` statements for `TryFrom` and `TryInto`. These are now redundant in Rust 2021.
* DirPathBuilder::pick_path: re-order match cases for clarity.Nick Mathewson2022-03-301-16/+18
|
* circmgr: Use guard-manager's view of the fallbacks when possible.Nick Mathewson2022-03-302-13/+33
| | | | | | | | | | | | | | | | | | If we're building a path with the guard manager involved, we now ask the guard manager to pick our first hop no matter what. We only pick from the fallback list ourselves if we're using the API with no guard manager. This causes some follow-on changes where we have to remember an OwnedChanTarget object in a TorPath we've built, and where we gain the ability to say we're building a path "from nothing extra at all." Those are all internal to the crate, though. Closes #220, by making sure that we use our guards to get a fresh netdir (if we can) before falling back to any fallbacks, even if our consensus is old. Compilation should be fixed in the next commit.
* Turn FallbackList into a real type, and store one in GuardMgr.Nick Mathewson2022-03-302-14/+12
| | | | | | | | | | | | | | The guard manager is responsible for handing out the first hops of tor circuits, keeping track of their successes and failures, and remembering their states. Given that, it makes sense to store this information here. It is not yet used; I'll be fixing that in upcoming commits. Arguably, this information no longer belongs in the directory manager: I've added a todo about moving it. This commit will break compilation on its own in a couple of places; subsequent commits will fix it up.
* Move fallback.rs into guardmgr.Nick Mathewson2022-03-301-1/+1
| | | | | | | This is the logical place for it, I think: the GuardMgr's job is to pick the first hop for a circuit depending on remembered status for possible first hops. Making this change will let us streamline the code that interacts with these objects.
* Remove allow(clippy::disallowed_methods) lint.Nick Mathewson2022-03-301-3/+0
|
* Merge branch 'no-system-time' into 'main'eta2022-03-301-11/+20
|\ | | | | | | | | | | | | Don't use SystemTime::now() Closes #306 See merge request tpo/core/arti!365
| * use wallclock where possible in teststrinity-1686a2022-02-261-0/+3
| |
| * fix teststrinity-1686a2022-02-251-10/+15
| |
| * remove most usage of SystemTime::nowtrinity-1686a2022-02-251-1/+2
| |
* | circmgr: Change API for using FallbackDirsNick Mathewson2022-03-211-2/+3
|/ | | | | | It'll soon more convenient to pass in FallbackDirs as a slice of references, rather than just a slice of FallbackDirs: I'm going to be changing how we handle these in tor-dirmgr.
* tor-circmgr: errors: Use autoconversion for BugIan Jackson2022-02-171-2/+2
|
* Add kinds for *most* circmgr errors.Nick Mathewson2022-02-162-11/+16
| | | | There are a couple of tricky ones I'll do separately.
* circmgr: Port InternalError to use Bug.Nick Mathewson2022-02-161-1/+5
|
* Don't create circuits if the consensus is stale by over 72 hoursNeel Chauhan2021-12-121-0/+7
|
* Merge branch 'bug183a_redux' into 'main'eta2021-12-071-6/+5
|\ | | | | | | | | | | | | Squash, refactor, and test !139 (Don't use same family as exit when picking a guard) Closes #183 See merge request tpo/core/arti!173
| * Move the "real families" code into tor-netdir.Nick Mathewson2021-12-061-15/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Just as `in_same_family` is a member of Relay, so the function for getting all the real family members of a relay should belong in the same crate. This change also removes the `family()` accessor: it gives the _claimed_ family rather than the _acknlowedged_ family, and is therefore a bit dangerous. There's still a hole in this logic; I've noted it in the Limitations section. If we get a microdescriptor for a relay in between creating and using the guard restriction, it might be omitted from the family list.
| * Use hashset _inside_ GuardRestriction.Nick Mathewson2021-12-061-6/+4
| | | | | | | | This approach saves us from a linear search when picking guards.
| * Change GuardUsage to have Vec of restrictions.Nick Mathewson2021-12-061-5/+4
| | | | | | | | | | | | | | | | There's not much reason to use a HashSet here, since we're just going over the whole list. This reverts commit 16e8489abbea1581b8e2 and does a little more refactoring.
| * Implement guard family restriction codeNeel Chauhan2021-12-061-4/+16
| |
* | Resolve roughly half of the XXXXs.Nick Mathewson2021-12-061-4/+0
|/ | | | | | | | We want to only use TODO in the codebase for non-blockers, and open tickets for anything that is a bigger blocker than a TODO. These XXXXs seem like definite non-blockers to me. Part of arti#231.
* add semicolons if nothing returnedDaniel Eades2021-11-252-2/+2
|
* Fix a few typos.Nick Mathewson2021-11-241-1/+1
| | | | Also fix some commonwealth spellings that had slipped in.
* Flatten enforce_distance into path_rules.Nick Mathewson2021-11-181-8/+8
| | | | Also use the path_rules name consistently throughout the code.
* Disable a check in exitpathNick Mathewson2021-11-021-1/+2
| | | | | This check relies on families being enforced correctly, which is not the case when specifying a fixed exit and using guards. (See #183)