Commit Graph

88 Commits

Author SHA1 Message Date
Ian Jackson f19d8e0397 ptmgr: Fix kind for E::StatedirCreateFailed
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/901#note_2858456
2022-11-30 15:21:39 +00:00
Nick Mathewson dacb3eafda ptmgr: report an error if PT transports don't match requested.
(I think this may be impossible now, since we check in ipc.rs, but
IMO it's best to check.)
2022-11-29 20:01:19 -05:00
Nick Mathewson fdc49b1fed Register transport in pt reactor even if it has no pending requests 2022-11-29 19:35:38 -05:00
Nick Mathewson 9765fdc2e6 ptmgr: Use anonymize_home when displaying paths in errors 2022-11-29 19:30:50 -05:00
Nick Mathewson f6311c83f7 ptmgr: Use PluggableTransport::identity in logs.
This lets us avoid logging the user's path.
2022-11-29 19:20:44 -05:00
Nick Mathewson bb0749cd42 Centralize the "find an identifier for the pt name" logic in one place. 2022-11-29 19:13:32 -05:00
Nick Mathewson 21e7e52ad5 Merge remote-tracking branch 'eta/ptreactor-v1' into merge_ptreactor
Resolved several conflicts while doing so; mostly with !893 and
!895.
2022-11-29 18:55:49 -05:00
eta 9b4fc50625 tor-ptmgr: add PtReactor
This fleshes out the PtReactor that was previously a stub, making it
actually do reactor-ey things. Note that this is entirely untested, and
might not work at all. Hopefully it does, though.
2022-11-29 20:13:32 +00:00
Ian Jackson 211a832f6d Clarify internal error. 2022-11-29 17:22:16 +00:00
Nick Mathewson 75cba2ce80 ptmgr: Refine RetryTime for ChildSpawnFailed. 2022-11-29 10:44:09 -05:00
Nick Mathewson 29ea66ecb9 ptmgr: Rename ClientTransportFailed, document, and correct its RetryTime. 2022-11-29 10:42:26 -05:00
Nick Mathewson d9dc30bc13 ptmgr: Replace StdioUnavailable with a PtError. 2022-11-29 10:36:51 -05:00
Nick Mathewson 7f923b9dfe Rename LocalLoginFailed to ExternalToolFailed. 2022-11-29 10:32:59 -05:00
Nick Mathewson 820657b6bc PtMgr: Use a persistent state directory for PT state.
This makes a `pt_state` directory inside .local/share/arti (or the
local equivalent), right next to our existing `state` dir.

Ideally we would use a separate directory for each PT, but we have a
very fuzzy "what is a specific PT" notion.

Closes #667
2022-11-28 17:29:32 -05:00
Nick Mathewson 3fa86f41a6 Revise the API of "PtMgr::reconfigure"
I prefer that it not take `&mut self`, since PtMgr already has
interior mutability.

I also need it to take `tor_config::Reconfigure` argument, in case
it gains any more smarts about validation in the future.
2022-11-28 17:29:23 -05:00
Nick Mathewson c99017b0d6 ptmgr: Note a TODO issue around TempDir. 2022-11-28 17:29:23 -05:00
Nick Mathewson 4b5be3685f ptmgr: Fill in some error-related code; resolve TODOs. 2022-11-28 17:29:23 -05:00
Nick Mathewson 1fa9296f9c ptmgr: clear up unused_import exceptions. 2022-11-28 17:29:23 -05:00
Nick Mathewson 6bde90ce01 PtMgr: New features section in README.md
Per convention, have a `full` feature.

Also, downgrade the 'TODO pt-client' entries in README::limitations,
since they are not blockers for 1.1.0.
2022-11-28 17:29:23 -05:00
Nick Mathewson 8d0ac9bdc8 ptmgr: Mark PtMessage and next_message as experimental-api.
These are implementation details and we don't want to mark them as
stable.

To do this, I needed to apply some additional options to the example
code's configuration in Cargo.toml.
2022-11-28 17:29:23 -05:00
eta 3b41c78d6f Draft: Pluggable transport manager
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`.
2022-11-28 13:52:21 -05:00
eta 2f75702cec Replace TransportRegistry with AbstractPtMgr
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.
2022-11-22 18:09:06 +00:00
eta 1c9f6fb179 tor-ptmgr: make configuration use builders, plumb into arti-client
This brings the draft configuration mechanisms in tor-ptmgr in line with
the config in other crates, using builders. It also plumbs the config
type through into the main `arti-client` config, and adds some example
lines to `arti-example-config.toml`.
2022-11-16 11:39:25 +00:00
Nick Mathewson 936920b26e bump rust-version to 1.60 in every crate. 2022-11-10 10:57:33 -05:00
Nick Mathewson 932fe48eaf Run add_warnings. 2022-11-03 11:06:02 -04:00
trinity-1686a d29f38603d set all crate edition to 2021 2022-11-01 00:17:33 +01:00
eta 84a2624401 Merge branch 'fuzz_ptmgr_ipc' into 'main'
ptmgr: Add a fuzzer for ptmessage.

See merge request tpo/core/arti!814
2022-10-27 14:51:35 +00:00
Nick Mathewson 42fefe021d ptmgr: Add a fuzzer for ptmessage. 2022-10-26 16:59:48 -04:00
Nick Mathewson cb7eb3b00d ptmgr::ipc: Try an alternate approach to initial quotes.
This lets us use `chars()` rather than `char_indices()`.
2022-10-26 14:49:24 -04:00
eta a118a639ed tor-ptmgr/ipc: First cut of pluggable transport spawning
The new `ipc` module inside `tor-ptmgr` implements the Pluggable
Transport Specification version 1 (`pt-spec.txt`,
https://gitlab.torproject.org/tpo/core/torspec/-/blob/main/pt-spec.txt).

This enables module users to spawn pluggable transport binaries inside a
child process asynchronously, and receive structured information about
how to connect to the transports provided by said binaries.

Internally, this is structured as a pure set of serialisers and
deserialisers for the protocol in the specification (in the form of
environment variables, and the PT's stdout), a wrapper to run the PT
binary and enable accessing its output asynchronously, and a user-facing
wrapper that handles ensuring all the requested transports launched
properly.

The included `run-pt` example is an exceedingly minimal wrapper program
that was useful in testing. More tests can and should be added in a
further MR.

closes arti#394; part of arti#69
2022-10-26 16:07:30 +01:00
Nick Mathewson 85284ef847 Merge branch 'factory_redux' into 'main'
chanmgr: Build and use chanmgr factory APIs

See merge request tpo/core/arti!769
2022-10-13 12:58:28 +00:00
Ian Jackson f84d8777db cargo fmt to remove blank lines
Apparently cargo fmt doesn't like these, which my perl rune didn't
delete.

This commit is precisely the result of `cargo fmt`.
2022-10-12 15:29:04 +01:00
Ian Jackson d9910dba08 Replace all README copies in src/lib.rs with includes
The feature we want is `#[doc = include_str!("README.md")]`, which is
stable since 1.54 and our MSRV is now 1.56.

This commit is precisely the result of the following Perl rune:
  perl -i~ -0777 -pe 's{(^//!(?!.*\@\@).*\n)+}{#![doc = include_str!("../README.md")]\n}m' crates/*/src/lib.rs
2022-10-12 15:29:03 +01:00
Nick Mathewson 28caae68d1 chanmgr: Clean up async-ness on factory types.
The traits that launch connections need to be async; the traits that
don't, shouldn't be async.

Additionally, we need a few more "Sync" annotations here for the
futures to work.
2022-10-12 10:15:00 -04:00
Nick Mathewson 102e3c221d Bump minor version of tor-rtcompat and most of its dependents
(Since the APIs for the `Schedule::sleep*` functions changed, this
is a breaking change in tor-rtcompat.  Therefore, the Runtime trait
in tor-rtcompat is now a different trait.  Therefore, anything that
uses the Runtime trait in its APIs has also broken.)
2022-10-03 10:01:46 -04:00
Nick Mathewson 388e0cbab5 Bump crates that have had backward compatible API changes. 2022-10-03 09:52:34 -04:00
Nick Mathewson 52ca64fe0d Add a few comments based on review. 2022-09-23 14:08:53 -04:00
Nick Mathewson e412d7400c Add the skeleton of a tor-ptmgr crate
When complete, this crate will handle launching and using pluggable
transports on demand.
2022-09-23 14:08:24 -04:00