aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-chanmgr
Commit message (Collapse)AuthorAgeFilesLines
...
* tor-chanmgr: Introduce the BootstrapReporter API, publicize ChanBuildereta2022-11-286-41/+111
| | | | | | | | | | | | | | | | | | | | | | | | 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).
* Draft: Pluggable transport managereta2022-11-282-14/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | This commit implements `PtMgr`, a pluggable transport manager responsible for keeping track of spawned PTs and spawning them to satisfy client requests on demand. It does this in two parts: the `PtMgr` type exported to the rest of the code, and the background `PtReactor` that actually does the spawning; this design ensures that only one attempt to spawn a PT is active at a time, and will prove useful later for implementing e.g. timeouts. A few changes were necessary to the rest of the code in order to make this all work out. Namely: - `TransportRegistry`'s API didn't make any sense for two reasons: - It wasn't feasible for implementors to implement `ChannelFactory`, since that'd require constructing a `ChanBuilder` (which requires a bootstrap reporting event sender). - Treating the PT manager as a registry is over-general; it's only necessary for it to spawn pluggable transports, so saddling it with other concerns didn't make any sense. - (It's possible to get extensibility for arbitrary user customization by just letting the user swap in a new `ChannelFactory`, anyway.) - Therefore, the `PtMgr` implements the new `AbstractPtMgr` trait, which is far more narrowly focused; this only exists to solve a dependency loop, and is documented as such. - This provides a `TransportHelper` instead of a `ChannelFactory`.
* Make ChannelMethod non-exhaustiveIan Jackson2022-11-241-0/+6
| | | | | | | | | Enums with variants conditional on cargo features must be non-exhaustive, because cargo features are supposed to be additive, meaning that enabling a feature (which might happen due to some random distant thing) ought not to break things using that enum. There were surprisingly few places to fix this.
* tor-chanmgr: Invent [Box]ChanSensitive for two error payloadsIan Jackson2022-11-233-4/+13
| | | | | | | | | | | This 1. Makes the errors smaller (in the case of Io's PtTargetAddr; ChannelBuild's addresses are already indirected in a Vec). 2. Redacts (currently, scrubs) the PtTargetAddr and SocketAddr when safe logging is enabled These are the remaining error variants in tor-chanmgr that contain information that should become sensitive as part of bridge support.
* tor-chanmgr: Replace OwnedChanTarget with LoggedChanTarget in errorsIan Jackson2022-11-232-9/+9
| | | | | | | | | This 1. Makes the errors smaller 2. Redacts (currently, scrubs) the chantarget when safe logging is enabled This commit doesn't treat other should-be-sensitive inforemation in errors just yet. That will come in a moment.
* ChanMgr: Another attempt to build on CI.Nick Mathewson2022-11-231-1/+7
|
* ChanMgr: Rename Factory -> CompoundFactoryNick Mathewson2022-11-232-5/+5
|
* ChanMgr: Fix a few more conditional-compilation issuesNick Mathewson2022-11-233-0/+3
|
* ChanMgr: Remove Arc aliases.Nick Mathewson2022-11-231-12/+6
|
* Mark set-default-factory API as experimental.Nick Mathewson2022-11-232-5/+4
|
* Make ChannelFactory and AbstractPtMgr require Send+SyncNick Mathewson2022-11-232-6/+6
|
* ChanMgr: Implement functions that replace channel factories.Nick Mathewson2022-11-234-21/+113
| | | | | | | 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-225-18/+60
| | | | | | 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.
* Merge branch 'main' into 'abstract-pt-mgr'Nick Mathewson2022-11-223-4/+11
|\ | | | | | | # Conflicts: # crates/tor-chanmgr/src/factory.rs
| * Merge branch 'mark-bridges-not-experimental' into 'main'Nick Mathewson2022-11-182-4/+9
| |\ | | | | | | | | | | | | | | | | | | Mark bridge and PT-related APIs as non-experimental. Closes #643 See merge request tpo/core/arti!865
| | * chanmgr: Make "pt-client" non-experimental.Nick Mathewson2022-11-182-4/+9
| | |
| * | ChanMgr: Log every conection attempt at debug.Nick Mathewson2022-11-171-0/+2
| | |
* | | Replace TransportRegistry with AbstractPtMgreta2022-11-224-42/+33
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It doesn't make much sense to have the pluggable transport manager be a registry, so replace its interface with a more narrowly defined, less generic version. Other changes: - instead of returning a &-reference, it returns an owned Arc, which should make the ptmgr easier to implement while allowing efficient reuse - provision for error handling is added, but will probably be revised in a future commit pending discussion - tor-ptmgr code that would generate warnings as a result of this change is temporarily removed This is a split out version of arti!886, intended so work on arti#659 can proceed.
* | chanmgr: rename new_test_channel_map to new_test_state.Nick Mathewson2022-11-161-5/+5
| |
* | chanmgr::mgr::*: misc spelling fixes and normali[sz]ationsNick Mathewson2022-11-162-6/+6
| |
* | Fix up documentation that referred to a ChannelMap.Nick Mathewson2022-11-162-18/+17
| |
* | ChanMgr: Rename map.rs to state.rsNick Mathewson2022-11-163-9/+9
| | | | | | | | This is another pure renaming.
* | ChanMgr: Rename ChannelMap to MgrStateNick Mathewson2022-11-162-7/+7
|/ | | | | | | | | 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.
* bump rust-version to 1.60 in every crate.Nick Mathewson2022-11-101-1/+1
|
* ChanMgr: downgrade and remove a few TODO-ptclient commentsNick Mathewson2022-11-082-5/+1
| | | | renamings are now #623. Code movement can happen later.
* Suppress two clippy::large_enum_variant warningsNick Mathewson2022-11-031-0/+1
| | | | These are newly present on 1.65. We can address them later.
* Run add_warnings.Nick Mathewson2022-11-031-0/+1
|
* Require derive_more 0.99.3Ian Jackson2022-11-031-1/+1
| | | | | | | | 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.
* Merge branch 'guards_as_bridges_part1' into 'main'Nick Mathewson2022-10-241-4/+2
|\ | | | | | | | | Allow GuardMgr to expose bridges as guards (part 1) See merge request tpo/core/arti!785
| * guardmgr: Refactor the interior of FirstHop.Nick Mathewson2022-10-241-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | 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".
* | tor-chanmgr: Suppress an unused imports warning for `use super::*`Ian Jackson2022-10-211-0/+1
|/ | | | | If pt-client is disabled, there are in fact no tests, so the module is empty. But we would always want `use super::*` here.
* Oops: Mark some imports as pt-client only.Nick Mathewson2022-10-211-3/+9
| | | | This causes CI problems, and is entirely my fault.
* transport: Escape = signs in keys only.Nick Mathewson2022-10-201-8/+13
| | | | | | | This is a compromise between C tor (never escapes = signs) and the spec (calls for escaping all = signs). In C tor there is no way to actually construct a key with an = sign in it, so this difference should be undetectable.
* Clarify comment on ExternalProxyPlugin.Nick Mathewson2022-10-201-1/+2
|
* transport: rename "ExtraneousData" to "UnexpectedData"Nick Mathewson2022-10-201-5/+5
|
* chanmgr: Add the code necessary to use SOCKS PTs via a TransportHelperNick Mathewson2022-10-204-5/+254
| | | | | This is mostly a matter of encoding parameters in the format used for socks authentication.
* chanmgr: Begin a socks-client implementation.Nick Mathewson2022-10-203-0/+219
| | | | | | | This code is _not_ conditional, since we want to support running with a proxy even if we don't support pluggable transports. We may eventually want to refactor this into a new create.
* Fix various typos (using typos tool and hand-inspection)Nick Mathewson2022-10-183-5/+5
|
* chanmgr: Add an error case if a final_attempt neither succeeds or failsNick Mathewson2022-10-182-1/+11
| | | | | 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-182-54/+97
| | | | | | | 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
|
* Clarify a comment about the desired structure of ChanMgrNick Mathewson2022-10-181-1/+2
|
* Comments to explain effects of return in closure.Nick Mathewson2022-10-181-2/+6
|
* chanmgr: Remove "Ident" from AbstractChannelNick Mathewson2022-10-185-84/+24
| | | | | 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-184-312/+312
| | | | | | | | | | | | | | | | | | 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-182-8/+46
| | | | | This will let us migrate from `HashMap<Ed25519Identity, Entry>` to `ByRelayIds<Entry>`.
* chanmgr: Require HasRelayIds for AbstractChannel::BuildSpecNick Mathewson2022-10-182-24/+50
| | | | | | 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-182-1/+43
| | | | | 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-182-48/+12
| | | | | | | | 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.