summaryrefslogtreecommitdiff
path: root/crates/arti-client/src/client.rs
Commit message (Collapse)AuthorAgeFilesLines
* Apply `sensitive` in some info-level log messages.Nick Mathewson2022-05-061-1/+2
| | | | | This specifically applies the `sensitive` wrapper in the places where we're logging target addresses at level "info" or higher.
* Fix spacingSamanta Navarro2022-04-271-1/+1
|
* squash! Bump every crate's edition to 2021.Nick Mathewson2022-04-251-1/+0
| | | | | Remove all `use` statements for `TryFrom` and `TryInto`. These are now redundant in Rust 2021.
* arti-client: Report clock skew when it is noteworthyNick Mathewson2022-04-121-0/+2
| | | | | (Also, blame clock skew when it is an explanation of why we cannot finish a connection.)
* Make daemon tasks self-contained; introduce NetDirProvidereta2022-03-301-261/+14
| | | | | | | | | | | | | | | The various background daemon tasks that `arti-client` used to spawn are now handled inside their respective crates instead, with functions provided to spawn them that return `TaskHandle`s. This required introducing a new trait, `NetDirProvider`, which steals some functionality from the `DirProvider` trait to enable `tor-circmgr` to depend on it (`tor-circmgr` is a dependency of `tor-dirmgr`, so it can't depend on `DirProvider` directly). While we're at it, we also make some of the tasks wait for events from the `NetDirProvider` instead of sleeping, slightly increasing efficiency.
* Merge branch 'isolation-followup' into 'main'Nick Mathewson2022-03-281-12/+12
|\ | | | | | | | | implement IsolationHelper for StreamIsolation See merge request tpo/core/arti!434
| * remove usage of 'token' where it's no longer a tokentrinity-1686a2022-03-271-3/+3
| |
| * move StreamIsolation to isolation moduletrinity-1686a2022-03-241-1/+1
| |
| * rename *_isolation_group to *_isolationtrinity-1686a2022-03-241-8/+8
| |
* | Merge branch 'dir-filter' into 'main'Ian Jackson2022-03-251-1/+6
|\ \ | | | | | | | | | | | | arti-client, dirmgr: Initial DirFilter code See merge request tpo/core/arti!431
| * | Expose DirFilter from arti-client.Nick Mathewson2022-03-241-1/+6
| |/ | | | | | | | | This will make it possible to implement a directory-munging mechanism in arti-testing for #397.
* / Implement a periodic task scheduler, and a basic dormant modeeta2022-03-231-35/+111
|/ | | | | | | | | | | This is a revised version of !397; it implements a scheduling system for periodic tasks that can be externally controlled, and then uses the external control aspect to implement a basic dormant mode (#90). More technically, the scheduling system consists of a `Stream` that periodic tasks are expected to embed in a `while` loop or similar, a way for tasks themselves to choose how long to wait until the stream next yields a result, and a handle to control this outside of the task.
* Alternative API for set_isolation_group().Nick Mathewson2022-03-171-2/+5
| | | | | | | | | | | | Instead of requiring a `Box<dyn Isolation>`, it now takes either a `Box<dyn Isolation>`, or an arbitrary `T` that implements `Isolation`. This API still allows the user to pass in a `Box<dyn Isolation>` if that's what they have, but it doesn't require them to Box the isolation on their own. Part of #414.
* Merge branch 'test-isolation' into 'main'Nick Mathewson2022-03-171-17/+18
|\ | | | | | | | | new api for isolation See merge request tpo/core/arti!377
| * replace TODOs with documentationtrinity-1686a2022-03-161-2/+1
| |
| * accept boxed isolation in StreamPref::set_isolation_grouptrinity-1686a2022-03-161-2/+2
| |
| * add tests on Isolation and fix conditional compilation issuestrinity-1686a2022-03-161-1/+0
| | | | | | | | | | | | it seems I added conditional compilation without noticing it?? and there was some errors when choosing a prefered runtime depending on feature flags
| * replace Arc with Box and use dyn-clonetrinity-1686a2022-03-161-52/+37
| | | | | | | | this also removes JoinResult
| * replace result with eithertrinity-1686a2022-03-161-5/+6
| |
| * testing new api for isolationTrinity Pointard2022-03-161-36/+53
| |
* | DirMgrConfig: abolish builder; make it transparent and exhaustiveIan Jackson2022-03-161-2/+2
| | | | | | | | See rationale in the comment.
* | Make CircMgrConfig transparent (and make it a trait)Ian Jackson2022-03-161-5/+5
|/ | | | See commentary for the rationale.
* actually add DNS supporttrinity-1686a2022-03-141-1/+1
|
* Merge branch 'educe-traits' into 'main'Ian Jackson2022-03-041-14/+7
|\ | | | | | | | | Replace many manual trait impls with use of educe See merge request tpo/core/arti!375
| * Replace manual Default impls on enums with educe in arti-clientIan Jackson2022-03-021-14/+7
| |
* | arti-client: Make dirmgr() and circmgr() return &Arc<..>Nick Mathewson2022-03-031-4/+4
| | | | | | | | | | | | | | | | | | | | | | Previously they returned an Arc, which wasn't necessary unless the client actually _wanted_ a new Arc. This would be an API break, except that these functions are marked 'experimental-api', so semver does not apply; nonetheless I've noted the break in semver_status.md, just in case we care. Closes #369
* | Merge branch 'dir-provider-redux' into 'main'Ian Jackson2022-03-021-17/+21
|\ \ | |/ |/| | | | | Alternative DirProvider setup See merge request tpo/core/arti!347
| * Add a builder function for replacing a DirProvider.Nick Mathewson2022-02-231-12/+12
| | | | | | | | Put it behind experimental_api.
| * Un-parameterize DirProvider.Nick Mathewson2022-02-231-5/+3
| | | | | | | | | | | | | | | | | | | | This patch removes the EventStream associated type and the Runtime parameter. The Runtime parameter wasn't actually used for anything, and the EventStream was easy enough to replace with a BoxStream in this case. Also replaced DirBootstrapEvents with a BoxStream to avoid tying anything to our backend.
| * Add basic DirProvider trait, use it in clientChristian Grigis2022-02-231-6/+12
| |
* | 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`.