summaryrefslogtreecommitdiff
path: root/crates/tor-circmgr/src
Commit message (Collapse)AuthorAgeFilesLines
* Shorten the duration needed in preemptive::test::does_not_predict_old_ports.Alexander Færøy2022-08-311-2/+3
| | | | | | | | | | | This patch shortens the duration of the `does_not_predict_old_ports` test in the preemptive module. AppVeyor spawns its VMs/containers per build, so the `Instant::now()` call returns a value smaller than `60 * 60 + 1` which causes the subtraction to overflow and thus panic. Thanks to @trinity-1686a for the help here. See: tpo/core/arti#563.
* circmgr: treat usage as sensitive.Nick Mathewson2022-08-251-1/+6
|
* enable doc_auto_cfg feature on every crate when documenting for docs.rstrinity-1686a2022-08-241-0/+1
|
* Merge branch 'channel' into 'main'Ian Jackson2022-08-174-16/+75
|\ | | | | | | | | Channel padding See merge request tpo/core/arti!657
| * channel usage: Rename CU::UserTraffic from CU::ExitIan Jackson2022-08-173-6/+6
| | | | | | | | | | As suggested in https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/657#note_2827246
| * Move ChannelUsage from tor_proto to tor_chanmgrIan Jackson2022-08-173-6/+5
| | | | | | | | | | | | | | | | | | | | | | Replace Channel::note_usage with Channel::engage_padding_activities, which unconditionally causes the channel to (start to) do netflow padding things. The condition now lives in chanmgr. Addresses https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/657#note_2826094
| * chanmgr: Use NetDirProvider::params and Arc<dyn..Netparameters>Ian Jackson2022-08-171-0/+1
| | | | | | | | | | | | | | | | | | This gets rid of many Result(). Many parameters are renamed. Test cases of the now-impossible branch are removed. Deleting the match from padding_parameters will come in a moment. I've split off that commit since it has much whitespace noise. for now, change the error type to Void.
| * Introduce ChannelConfigIan Jackson2022-08-161-1/+6
| | | | | | | | | | This commit is just the necessary plumbing. The config is currently empty. We'll add something to it, for padding control, later.
| * Provide ChannelUsage and plumb it all the way downIan Jackson2022-08-164-14/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | Channel padding depends on what the channel is being used for. We therefore need to let the channel code know this information. The implementation of the per-channel padding control logic will be in the new note_usage function, which for now is simply a stub. A future commit will introduce a `PaddingControlState` which lives in the channel frontend; consult the doc comment for that type to see why the plumbing through the channel manager terminates in the channel frontend.
| * dormancy: Plumb through to chanmgr reconfigure_generalIan Jackson2022-08-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The chanmgr remembers the last dormancy state it was told. We invent a chanmgr-specific Dormancy which the arti-client code knows how to convert from the richer top-level dormant status. This avoids having to have everyone know all the variants of the top-level state. To call reconfigure_general, we must also obtain and plumb through a netdir. Right now we must return an internal error if there is in fact no netdir, because reconfigure_general does not yet cope with a missing netdir. Nothing actually *uses* the dormancy yet.
* | Additionally, mark the LostUsablityRace error as a "reset".Nick Mathewson2022-08-161-1/+5
| |
* | Mark some circuit-building errors as "transient".Nick Mathewson2022-08-162-15/+71
|/ | | | | | | | | | | | A "transient" error is one that does not indicate a true failure, but rather an _expected_ need to retry. When we hit one of these, we do not count it against the total number of permitted failures. (We do impose a higher limit on "real failures plus transient failures", though, to prevent infinite loops in the event of a programming error. Closes #517.
* tor-netdir: Collapse by_id and by_relay_id into a single fn.Nick Mathewson2022-08-103-8/+11
| | | | | | 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.
* Use accessors in two places where tests look at specific keys.Nick Mathewson2022-08-101-7/+17
| | | | | | (It's safe to require these specific keys, since we constructed the objects for testing, and we know for certain that they contain given keys.)
* Avoid a simple usage of ed_identity() in circmgr testsNick Mathewson2022-08-021-2/+1
|
* Introduce HasRelayIds::same_relay_ids.Nick Mathewson2022-08-023-14/+18
| | | | | This method tells if two HasRelayIds contain exactly the same set of Relay identities, and is generally useful for debugging.
* guardmgr: Change APIs that used to take IDs.Nick Mathewson2022-08-021-10/+8
| | | | These are the other inspiration for #428.
* tor-linkspec: Refactor out traits to represent a relay's ID set.Nick Mathewson2022-08-025-4/+5
| | | | | | | | | | | | | | 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.
* fix runtime issues on iostrinity-1686a2022-07-301-4/+6
|
* CircMgr: Remove directory liveness testing.Nick Mathewson2022-07-262-23/+2
|
* CircMgr: Update to new NetDirProvider APINick Mathewson2022-07-261-8/+7
| | | | | Everything here wants a timely directory, except that it is okay to build timeout-testing circuits with a stale one.
* Apply 1 suggestion(s) to 1 file(s)Ian Jackson2022-07-131-1/+1
|
* 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-124-20/+58
|
* circmgr: Use FilterCounts to explain why we couldn't find an exit.Nick Mathewson2022-07-122-14/+40
|
* tor-circmgr: Clarify and improve Protocol error.Nick Mathewson2022-07-122-1/+23
|
* tor-circmgr: minor error message edits.Nick Mathewson2022-07-121-5/+5
|
* 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.
* Run maint/add_warning crates/*/src/{lib,main}.rsIan Jackson2022-06-231-0/+3
| | | | Update all lint blocks
* Do not include error source() in display() format.Nick Mathewson2022-06-211-5/+5
| | | | | | | | | According to doc/Errors.md, and in keeping with current best practices, we should not include display an error's `source()` as part of that error's display method. Instead, we should let the caller decide to call source() and display that error in turn. Part of #323.
* CircMgr: Enable reachable_addrs filter.Nick Mathewson2022-06-172-1/+21
|
* Add a configuration option for reachable_addrsNick Mathewson2022-06-171-0/+28
| | | | (This doesn't do anything yet.)
* tor-netdir: testnet: Make construct_netdir infallible (rustfmt)Ian Jackson2022-06-134-21/+7
| | | | | Run rustfmt. Separate commit to make review of the substantive commit easier.
* tor-netdir: testnet: Make construct_netdir infallibleIan Jackson2022-06-134-7/+0
| | | | | This is a *lot* of unwraps. The function takes no parameters and is used only for testing. It ought to be infallible.
* Merge branch 'use-testing-rng'Nick Mathewson2022-06-074-11/+15
|\
| * Use testing_rng() in tests throughout our crates.Nick Mathewson2022-06-024-11/+15
| | | | | | | | | | | | 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.
* | Move responsibility for GuardMgr NetDir updates to GuardMgr.Nick Mathewson2022-06-071-32/+24
| | | | | | | | | | | | | | | | | | | | | | Previously it was the job of a task in CircMgr to do this; but we're going to want to give GuardMgr full access to the latest NetDir for this, and for other code-simplification reasons. With this change I'm deprecating a couple of functions in tor-circmgr. It's no longer necessary for us to have an artificial external way for you to feed new NetDirs to a circmgr. (I could just remove them, but I want practice deprecating.)
* | Remove now-redundant Send+Sync constraints alongside NetDirProviderNick Mathewson2022-06-071-4/+4
| |
* | lints: Add let_unit_value allow to all cratesIan Jackson2022-05-311-0/+1
| | | | | | | | | | From running add_warning, with manual picking of the right hunks/lines.
* | lints: Add lint block delimiters to every crateIan Jackson2022-05-311-0/+2
|/ | | | | | This was the result of: maint/add_warning crates/*/src/{lib,main}.rs and then manually curating the results.
* Resolve the new `derive_partial_eq_without_eq` lint.Nick Mathewson2022-05-233-5/+5
| | | | It's a little overzealous sometimes, but it's mostly to the good.
* impl_standard_builder: Have it generate FooConfig::builderIan Jackson2022-05-121-18/+0
| | | | | This deletes many handcoded impls. It also generates lots of impls that we previously didn't have.
* Merge branch 'builder-default-bis' into 'main'eta2022-05-121-26/+4
|\ | | | | | | | | impl_standard_builder followup See merge request tpo/core/arti!505
| * Rename impl_standard_builder from impl_default_via_builderIan Jackson2022-05-121-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | I have Plans for this macro. In particular: * I have a wip branch which tests that the Builder can be deserialised from an empty config (ie, that config reading of a config with a blank section for this item works). * I think we should autogenerate $Config::builder(), and promote that, rather than $ConfigBuilder::default(). This macro could do that.
| * config: Replace more handwritten impl DefaultIan Jackson2022-05-121-26/+4
| |
* | Merge branch 'ticket_412_467' into 'main'Nick Mathewson2022-05-121-0/+6
|\ \ | |/ |/| | | | | | | | | Teach DirMgr to use slightly untimely directories Closes #467 and #412 See merge request tpo/core/arti!500