summaryrefslogtreecommitdiff
path: root/crates/tor-chanmgr/src/mgr.rs
Commit message (Collapse)AuthorAgeFilesLines
* oneshot: Apply deferred rustfmt churnIan Jackson2023-10-111-1/+1
| | | | cargo fmt, precisely.
* oneshot: Use veneer in tor-chanmgrIan Jackson2023-10-111-1/+1
|
* Run maint/add_warning to add lint block everywhereIan Jackson2023-08-231-0/+1
|
* Merge branch 'clippy-allow' into 'main'Ian Jackson2023-07-111-0/+1
|\ | | | | | | | | clippy: Allow some of our existing code patterns See merge request tpo/core/arti!1396
| * Run maint/add_warning to actually apply new lint allowsIan Jackson2023-07-101-0/+1
| |
* | rng ranges: Use gen_range_checked().expect() in obvious cases (fmt)Ian Jackson2023-07-101-2/+3
| |
* | rng ranges: Use gen_range_checked().expect() in obvious casesIan Jackson2023-07-101-2/+3
|/ | | | In each of these, it is locally obvious that the range is nonempty.
* Allow clippy::unchecked_duration_subtraction in testsNick Mathewson2023-01-271-0/+1
| | | | | This panics on error, and we're fine with a panic on misbehavior in tests.
* test lint blocks: Add many many automaticallyIan Jackson2022-12-121-0/+8
| | | | | This is precisely the result of running the rune in maint/adhoc-add-lint-blocks.
* chanmgr: remove a now-stale TODO.Nick Mathewson2022-11-291-2/+0
|
* tor-chanmgr: Introduce the BootstrapReporter API, publicize ChanBuildereta2022-11-281-3/+20
| | | | | | | | | | | | | | | | | | | | | | | | This commit makes the `ChanBuilder` type in `tor-chanmgr` usable by consumers outside of that crate, like the doc comment for `ChannelFactory` says you need to be able to do in order to turn your `TransportHelper` into something useful. As part of doing this, the `event_sender` its constructor takes needed to be dealt with, since it was a crate-internal type that came from inside the `ChanMgr`. Enter `BootstrapReporter`: an opaque wrapper around that sender, now provided as an additional argument to `ChannelFactory::connect_via_transport`. You can now construct a `ChanBuilder` outside this crate, and it'll still be able to report its bootstrap status by unwrapping this new type that's threaded through from the `ChanMgr`. (This was a fair deal of manually threading the type through all the layers in this crate!) Note that you cannot implement bootstrap updating using something that isn't `ChanBuilder` yet due to the type being entirely opaque (but, of course, we can figure out exactly what API the reporter should have later, and add that capability in).
* ChanMgr: Fix a few more conditional-compilation issuesNick Mathewson2022-11-231-0/+1
|
* ChanMgr: Implement functions that replace channel factories.Nick Mathewson2022-11-231-0/+8
| | | | | | | This commit makes it possible to replace the default channel factory (used when there is no PtMgr), and to replace the PtMgr. This is part of #659.
* ChanMgr: move the AbstractChanFactory into MgrState.Nick Mathewson2022-11-221-8/+6
| | | | | | We will want the freedom to replace this, so it needs to go behind a lock. We need to be able to Clone it cheaply now, so we're using an Arc instead of a Box.
* chanmgr::mgr::*: misc spelling fixes and normali[sz]ationsNick Mathewson2022-11-161-1/+1
|
* Fix up documentation that referred to a ChannelMap.Nick Mathewson2022-11-161-1/+4
|
* ChanMgr: Rename map.rs to state.rsNick Mathewson2022-11-161-9/+9
| | | | This is another pure renaming.
* ChanMgr: Rename ChannelMap to MgrStateNick Mathewson2022-11-161-2/+2
| | | | | | | | | We're doing this because the type now holds "all the mutable state in a ChanMgr", not just the map. This is a pure renaming; no documentation has been updated. Part of #606.
* Suppress two clippy::large_enum_variant warningsNick Mathewson2022-11-031-0/+1
| | | | These are newly present on 1.65. We can address them later.
* chanmgr: Add an error case if a final_attempt neither succeeds or failsNick Mathewson2022-10-181-0/+2
| | | | | This can happen in weird corner cases, so it's probably best to report it rather than having an "internal error."
* Refactor flow control in get_or_launch.Nick Mathewson2022-10-181-51/+94
| | | | | | | Now, instead of duplicate checks in various cases, we simply go through the loop one last time. This allows us to simplify some of our other logic around here.
* chanmgr: Split get_or_launch into sub-functions.Nick Mathewson2022-10-181-92/+95
| | | | | This function had grown huge and hard to reason about. Before I make it even worse, let's split it up.
* chanmgr: Refactor choose_action code into its own function.Nick Mathewson2022-10-181-86/+92
|
* Comments to explain effects of return in closure.Nick Mathewson2022-10-181-2/+6
|
* chanmgr: Remove "Ident" from AbstractChannelNick Mathewson2022-10-181-33/+16
| | | | | Thanks to our previous changes, we no longer need this type, or the methods that access it.
* chanmgr: replace the HashMap<> with a ByRelayIds.Nick Mathewson2022-10-181-62/+167
| | | | | | | | | | | | | | | | | | This is necessary so that we can look up channels (open and pending) by all of the Ids that we know about them. The operations needed here are pretty complex: to get them right, I've replaced most of the accessors on the inner `ChannelMap` with a function that holds the lock while another `FnOnce` is called. This still gets us the invariant that we can't accidentally await while holding the lock on the `ChannelMap`. I've removed the tests for the accessors that are no longer there. There are some subtleties here. Now that we have more than one kind of Id, it's possible to have a partial match. I've tried to explain all these cases in the comments. }
* chanmgr: Add identities to pending state in map.Nick Mathewson2022-10-181-7/+14
| | | | | This will let us migrate from `HashMap<Ed25519Identity, Entry>` to `ByRelayIds<Entry>`.
* chanmgr: Require HasRelayIds for AbstractChannel::BuildSpecNick Mathewson2022-10-181-21/+40
| | | | | | This is mostly a testing only change for now too, but soon I'll use it to deal with the fact that we need to know the IDs to actually build a channel at all.
* chanmgr: Require HasRelayIds for AbstractChannel.Nick Mathewson2022-10-181-1/+22
| | | | | This is mostly a testing-only change for now, but soon I'll use it so we can have IdMap for our channel map.
* chanmgr: Remove the Poisoned state from the map type.Nick Mathewson2022-10-181-10/+0
| | | | | | | | The `ByRelayIds` type doesn't have a type equivalent to `hash_map::Entry`, since it's a set type rather than a map type. Therefore, the only plausible way to do entry mutation will be to remove the old entry and insert a new one. And so, we no longer need a "poisoned" state.
* Rename mgr::ChannelFactory to mgr::AbstractChannelFactoryNick Mathewson2022-10-121-15/+18
| | | | | | | | | This is an internal type (distinct from factory::ChannelFactory) that we use to make the code in `tor_chanmgr::mgr` agnostic about what a channel actually is, and how it is actually launched. Therefore, I'm renaming it and giving better documentation in a couple of places, to prevent confusion.
* channel usage: Rename CU::UserTraffic from CU::ExitIan Jackson2022-08-171-14/+26
| | | | | As suggested in https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/657#note_2827246
* channel engage_padding_activities: swap docs to tor0protoIan Jackson2022-08-171-10/+2
| | | | This allow us to make a working cross-reference.
* Rename ChannelsParams types to ChannelPaddingInstructions (fmt)Ian Jackson2022-08-171-2/+8
| | | | Run rustfmt; no other changes.
* Rename ChannelsParams types to ChannelPaddingInstructionsIan Jackson2022-08-171-5/+5
| | | | | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/657#note_2826167 This makes some lines too long; I will run rustfmt in a separate commit for clarity.
* Channel: Make mutable() and engage_padding_activities infallibleIan Jackson2022-08-171-5/+3
| | | | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/657#note_2826151 This gets rid of quite some Bug error paths.
* Move ChannelUsage from tor_proto to tor_chanmgrIan Jackson2022-08-171-7/+25
| | | | | | | | | | | 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-11/+21
| | | | | | | | | 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.
* chanmgr testing: FakeChannel: retain the ChannelsParamsUpdatesIan Jackson2022-08-161-1/+4
|
* chanmgr configuration: Avoid sending needless initial update(s)Ian Jackson2022-08-161-2/+5
| | | | | | | | | | | Change ChannelsParams::initial_update to compare fields with their default values, and, if they're the same as the default, not to include them in the returned update. And if that update is then empty, return None. The overall effect is to avoid the call to chan.reparameterize if we're using the builtin default parameters, which is usual.
* chanmgr configuration: Hadle lack of a NetDirIan Jackson2022-08-161-9/+1
| | | | | | Now that the code that actually handles the netdir information can cope with its lack, we can change the types of the various netdir parameters and get rid of the foolish Bugs.
* Introduce ChannelConfigIan Jackson2022-08-161-4/+17
| | | | | 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-161-13/+23
| | | | | | | | | | | | | 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.
* chanmgr: Introduce get_or_launch_internalIan Jackson2022-08-161-0/+10
| | | | This is going to be useful in a moment.
* channel reparameterize: Change error typeIan Jackson2022-08-161-5/+3
| | | | This is going to be able to fail in other ways too, sadly.
* dormancy: Plumb through to chanmgr reconfigure_generalIan Jackson2022-08-161-6/+19
| | | | | | | | | | | | | | | 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.
* chanmgr: reconfigure_general: Rename fn and change typesIan Jackson2022-08-161-0/+11
| | | | | | | | | | | | | | | This function is going to become the code for controlling channels, in general. (Including padding control.) Right now it doesn't do most of the things. In this commit: * Change the prototype and the name now. * Pass `()` for the dormancy and config, adding TODOs. * Provide update_netdir method on AbstractChanMgr, and call that, rather than having the ChanMgr go directly into the channel. (That will enable us to test that `update_netdir` method with test cases that don't have a complete ChanMgr.)
* channel params: Rename initial_update (from total_update)Ian Jackson2022-08-161-1/+1
| | | | The semantics of this are going to become a bit more subtle.
* chanmgr: tests: Introsuce new_test_abstract_chanmgrIan Jackson2022-08-161-8/+9
| | | | This is going to change. Centralise it first.
* channel padding: Rename ChannelsParams from ChannelsConfigIan Jackson2022-06-211-9/+9
| | | | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/586#note_2814276 Change names and comments and docs everywhere.