aboutsummaryrefslogtreecommitdiff
path: root/crates/arti-client/src/client.rs
Commit message (Collapse)AuthorAgeFilesLines
* arti-client: use PreferredRuntime by default, doc cleanupseta2022-02-281-49/+42
| | | | | | | | | | | | | | | | | | | | | | This makes using the `PreferredRuntime` the first-class option inside `arti-client`, freeing users who don't want to think about runtimes from having to do so. `TorClient::create_unbootstrapped` and `builder` now automatically use this runtime, leaving only `builder_custom` for users who wish to manually specify a runtime. This lets us clean up the docs a lot: mentions of using custom runtimes are now relegated to nearer the end of the crate-level documentation, and we mostly just link to `tor_rtcompat`'s docs to explain more there. Instead, we take some more time to explain how you use the builder API to create clients synchronously. Other doc cleanups included getting rid of the explanation of `TorAddr` in the main crate-level doc; this is already well-documented elsewhere, and is something users should discover organically later. fixes arti#326
* Merge branch 'get-runtime' into 'main'Ian Jackson2022-02-251-0/+11
|\ | | | | | | | | TorClient: Add get_runtime() convenience method See merge request tpo/core/arti!350
| * TorClient:runtime(): rename from get_runtimeIan Jackson2022-02-251-1/+1
| | | | | | | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/350#note_2781368
| * TorClient: Add get_runtime() convenience methodIan Jackson2022-02-241-0/+11
| |
* | arti-client: Unlock the state manager on failure to bootstrapeta2022-02-241-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | `StateMgr` got a new `unlock()` method that does what it says on the tin. We now call it from `bootstrap()` using the new `util::StateMgrUnlockGuard`, which works in a manner similar to the `BoolResetter` from `tor_dirmgr`. (A decent small little task in future might be to unify these types in some sort of general arti utility crate?) closes arti#335
* | Make a TorClientBuilder API.Nick Mathewson2022-02-181-43/+28
|/ | | | | | | | This is a defensive API choice to protect against the possibility that we'll want to add a bunch of other non-config options in the future. Closes #350
* Merge branch 'eta/lazy-init' into 'main'eta2022-02-161-13/+75
|\ | | | | | | | | | | | | arti-client: add ability to automatically bootstrap Closes #278 See merge request tpo/core/arti!322
| * arti-client: add ability to automatically bootstrapeta2022-02-161-13/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | The new `BootstrapBehavior` enum controls whether an unbootstrapped `TorClient` will bootstrap itself automatically (`Ondemand`) when an attempt is made to use it, or whether the user must perform bootstrapping themselves (`Manual`). The `lazy-init` example shows how you could write a simple `get_tor_client()` function that used a global `OnceCell` to share a Tor client across an entire application with this API. closes arti#278
* | Move persistent state flush from client to circmgrYuan Lyu2022-02-151-14/+0
|/
* Simplify wait_for_bootstrap to use a Mutex.Nick Mathewson2022-02-141-37/+11
| | | | | | | | Since the only purpose of this function is to make sure that no bootstrapping task is running, a simple futures::lock::Mutex should do the job just fine. Closes #337.
* Rename bootstrap_existing to bootstrap.Nick Mathewson2022-02-111-10/+8
| | | | (Looks like this one got missed.)
* Merge branch 'eta/unbootstrapped-clients' into 'main'Nick Mathewson2022-02-111-63/+204
|\ | | | | | | | | | | | | Allow creating unbootstrapped `TorClient`s (and `DirMgr`s) Closes #293 See merge request tpo/core/arti!298
| * Allow creating unbootstrapped `TorClient`s (and `DirMgr`s)eta2022-02-111-63/+204
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit changes how the `TorClient` type works, enabling it to be constructed synchronously without initiating the bootstrapping process. Daemon tasks are still started on construction (although some of them won't do anything if the client isn't bootstrapped). The old bootstrap() methods are now reimplemented in terms of the new create_unbootstrapped() and bootstrap_existing() methods. This required refactoring how the `DirMgr` works to enable the same sort of thing there. closes #293
* | Write some examples for TorClient::connect()Nick Mathewson2022-02-111-5/+64
|/ | | | | | These should explain better what you can pass as an address, and what you should do if you _really need_ to provide a SocketAddr or something.
* Update launch of chan expiration task to new APINick Mathewson2022-02-081-4/+6
| | | | This fixes a compilation error.
* Rename TorResult to Result.Nick Mathewson2022-02-081-12/+12
| | | | | | | This is closer to common usage. (Not that we all agree with common usage, but it's closer to what people expect.)
* arti_client: Rename Error to ErrorDetail.Nick Mathewson2022-02-081-16/+16
| | | | | | | This is closer to what we described in Errors.md. Also, remove the (sometimes private) Result alias: it was only used in one or two places, and never exposed in public.
* Merge branch 'error-improvements' into 'main'eta2022-02-081-48/+75
|\ | | | | | | | | Hopefully uncontroversial improvements to new Error code See merge request tpo/core/arti!291
| * Make SpawnError wrappers contain a 'spawning' stringNick Mathewson2022-02-041-28/+38
| | | | | | | | | | (By our convention, these errors should say what we were trying to spawn when the error occurred.)
| * Make the Error detail type non-exported from arti-clientNick Mathewson2022-02-041-20/+37
| | | | | | | | | | | | | | | | | | | | | | At least by default, we should have Error be private, and not expose it as part of our APIs. To keep functionality in `arti`, I had to add an `ExitTimeout` error kind. For interface consistency, I also re-exported ErrorKind and HasError from `arti_client`.
* | Expire channels that have been unused for too longYuan Lyu2022-02-041-0/+23
|/
* errors: Drop "Error" and "Failed" from various enum variantsIan Jackson2022-02-041-1/+1
|
* errors: Handle exit circuit creation failure the new wayIan Jackson2022-02-041-1/+4
|
* errors: Handle circmgr setup errors differentlyIan Jackson2022-02-041-1/+2
| | | | | | | | | | | | | The motivation for doing this now is to remove the `#[from]` so we would spot where operationsl circuit setup failures were handled. (But it turns out that they are turned into internal errors!) Perhaps this will want to become a different error type from circmgr in due course, but for now we simply use a bespoke variant of TorError. It will want its own Kind. The TODO in the HasKind impl marks this (amongst much else here).
* errors: Refer to err::Error in some bits of arti_clientIan Jackson2022-02-041-1/+2
| | | | We are going to make the top-level Error type conditionally hidden.
* errors: Introduce TorErrorIan Jackson2022-02-041-4/+18
| | | | Still much to do here.
* Make the native-tls crate optional.Nick Mathewson2022-01-261-8/+8
| | | | | | | | | | | This commit puts the native-tls crate behind a feature. The feature is off-by-default in the tor-rtcompat crate, but can be enabled either from arti or arti-client. There is an included script that I used to test that tor-rtcompat could build and run its tests with all subsets of its features. Closes #300
* Make current/create functions into runtime member functions.Nick Mathewson2022-01-261-3/+2
| | | | | This should help avoid some amount of temptation towards API proliferation.
* Rename FooRuntime to FooNativeTlsRuntime for consistency.Nick Mathewson2022-01-261-6/+8
|
* Unify TokioRuntime and TokioRuntimeHandleNick Mathewson2022-01-261-5/+3
| | | | | | | | | Having separate types here doesn't justify the (very limited) benefit of distinguishing between the case where we have created an executor that we own and the case where we have a handle to an already-running tokio executor. Part of #301.
* Rename TorClient::set_stream_prefsIan Jackson2022-01-211-2/+2
| | | | | | | In line with the rest of the renaming. As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/256#note_2771617
* StreamPrefs: rename from ConnectPrefsIan Jackson2022-01-211-11/+11
| | | | | | | | | | | | | The docs even say this is about stream. As @nickm writes in https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/252#note_2771289 we generally call end-to-end connections that are tunneled over Tor "Streams" to distinguish them from everything else in the Tor protocols that could possibly be called a "Connection". That seems to apply here too.
* Merge branch 'always-isolate' into 'main'Ian Jackson2022-01-201-4/+58
|\ | | | | | | | | | | | | Provide isolate-all-streams function Closes #279 See merge request tpo/core/arti!252
| * isolation: Rename isolate_every_stream from ..._connectionIan Jackson2022-01-201-1/+1
| | | | | | | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/252#note_2771291
| * isolation: Rename (internal) EveryStream enum variantIan Jackson2022-01-201-3/+3
| | | | | | | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/252#note_2771289
| * isolation: Much better wording for always isolate settingNick Mathewson2022-01-201-1/+6
| |
| * isolation: Provide isolate-every-connection optionIan Jackson2022-01-201-0/+16
| |
| * isolation: Provide new_isolation_group methodIan Jackson2022-01-201-0/+14
| | | | | | | | | | | | | | In the usual case, set_isolation_group is awkward. This is perhaps slightly duplicative with TorClient::isolated_client(). If so then perhaps the *latter* should be abolished.
| * isolation: Refactor to introduce a bespoke enumIan Jackson2022-01-201-4/+23
| | | | | | | | | | | | No functional change. This will grow a new variant shortly.
* | connection preferences: Make `set_default_prefs` private for nowIan Jackson2022-01-201-1/+4
| |
* | connection preferences: Make `clone_with_prefs` must_useIan Jackson2022-01-201-0/+1
|/ | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/250#note_2771239
* connection preferences: Provide `clone_with_prefs` methodIan Jackson2022-01-191-0/+10
|
* connection preferences: Provide `set_connect_prefs` methodIan Jackson2022-01-191-6/+22
|
* connection preferences: Take ConnectPrefs by referenceIan Jackson2022-01-191-9/+9
| | | | | This may save quite a bit of copying. The callees don't need to copy the whole struct; they copy the bits they need.
* connection preferences: Rename variable and docs to not say "flags"Ian Jackson2022-01-191-12/+12
| | | | These aren't flags. Eg, there's an isolation token in there.
* isolation: Document orthogonality of isolated_client and isolation_groupIan Jackson2022-01-191-0/+11
|
* Integrate status information at arti-clientNick Mathewson2022-01-181-9/+11
| | | | | | | | | | | | | | | | | This commit combines status update information from tor-dirmgr and tor-chanmgr in the arti-client crate, so that the user can get to it; it represents a high-level view of the client's ability to reach the network and route traffic. I have omitted the tor-circmgr support for now; it's mostly not needed. At present it's not so useful, since there's no way for a client to get a TorClient that _isn't_ completely bootstrapped, and therefore there's no way to actually watch these events until they're no longer interesting. That should change with arti#293. This is part of #96.
* Implement the basics of a bootstrap-status API.Nick Mathewson2022-01-131-1/+44
| | | | | | | | | | | | The purpose of a this API is to tell the user how far along Arti is in getting bootstrapped, and if it's stuck, what it's stuck on. This API doesn't yet expose any useful information: by the time it's observable to a client, it's always "100% bootstrapped." But I'm putting it in a MR now so that we can review the basic idea, and to avoid conflicts with later work on tickets like #293 and #278. This is part of #96.
* Improve the layout of crate exports; add runtime convenience functionseta2022-01-111-2/+45
| | | | | | | | | | | | | | | | | | | | This commit addresses multiple problems highlighted by arti#182: - `arti-client` had some types in its public API that weren't accessible without importing another crate (`CfgPath`, `DataReader`, `DataWriter`). This has been fixed. - In addition, the doc comments for `DataReader` and `DataWriter` were cleaned up to be of better quality, now that they're public. - It was impossible to use `arti-client` without also importing `tor-rtcompat`. This is now fixed by the addition of two convenience methods: `TorClient::bootstrap_with_tokio` and `TorClient::bootstrap_with_async_std`. - Potentially controversially: `tor-rtcompat` now returns *concrete* types from methods like `current_runtime`, instead of `impl Runtime`. - This was needed in order to actually be able to name the `TorClient` type that results from using these methods. - This does mean we lose API flexibility, but on balance I think this is a good thing, because the API we *do* have is actually usable...
* Expose and rename stream timeout config.Nick Mathewson2022-01-101-2/+2
| | | | | | | | | | | Previously we kept this in an ambiguously named type, `ClientTimeoutConfig`. But everything we do right now is client related! So `StreamTimeoutConfig` is a better name. Also, we'd previously neglected to expose the builder for this type from `TorClientConfigBuilder`. Now we do. Closes #281.