aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-rtcompat
Commit message (Collapse)AuthorAgeFilesLines
* tor-rtcompat: Debug dump type of contained inner runtimederive-traitsIan Jackson2022-03-021-1/+3
|
* Replace manual Default, and abolish new, in tor-rtcompatIan Jackson2022-03-021-13/+1
| | | | The Default impl was the only call site for new()
* Merge branch 'clippy-allow-arc-clone' into 'main'Nick Mathewson2022-03-011-1/+0
|\ | | | | | | | | Disable clippy::clone_on_ref_ptr See merge request tpo/core/arti!352
| * Disable clippy::clone_on_ref_ptrIan Jackson2022-02-241-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This lint is IMO inherently ill-conceived. I have looked for the reasons why this might be thought to be a good idea and there were basically two (and they are sort of contradictory): I. "Calling ‘.clone()` on an Rc, Arc, or Weak can obscure the fact that only the pointer is being cloned, not the underlying data." This is the wording from https://rust-lang.github.io/rust-clippy/v0.0.212/#clone_on_ref_ptr It is a bit terse; we are left to infer why it is a bad idea to obscure this fact. It seems to me that if it is bad to obscure some fact, that must be because the fact is a hazard. But why would it be a hazard to not copy the underlying data ? In other languages, faliing to copy the underlying data is a serious correctness hazard. There is a whose class of bugs where things were not copied, and then mutated and/or reused in multiple places in ways that were not what the programmer intended. In my experience, this is a very common bug when writing Python and Javascript. I'm told it's common in golang too. But in Rust this bug is much much harder to write. The data inside an Arc is immutable. To have this bug you'd have use interior mutability - ie mess around with Mutex or RefCell. That provides a good barrier to these kind of accidents. II. "The reason for writing Rc::clone and Arc::clone [is] to make it clear that only the pointer is being cloned, as opposed to the underlying data. The former is always fast, while the latter can be very expensive depending on what is being cloned." This is the reasoning found here https://github.com/rust-lang/rust-clippy/issues/2048 This is saying that *not* using Arc::clone is hazardous. Specifically, that a deep clone is a performance hazard. But for this argument, the lint is precisely backwards. It's linting the "good" case and asking for it to be written in a more explicit way; while the supposedly bad case can be written conveniently. Also, many objects (in our codebase, and in all the libraries we use) that are Clone are in fact simply handles. They contain Arc(s) (or similar) and are cheap to clone. Indeed, that is the usual case. It does not make sense to distinguish in the syntax we use to clone such a handle, whether the handle is a transparent Arc, or an opaque struct containing one or more other handles. Forcing Arc::clone to be written as such makes for code churn when a type is changed from Arc<Something> to Something: Clone, or vice versa.
* | Bump all crates to 0.1.0arti-v0.1.0Nick Mathewson2022-03-011-1/+1
| |
* | Update README.md files from rustdoc.Nick Mathewson2022-03-011-10/+33
| |
* | Fix rustdoc errors.Nick Mathewson2022-03-011-1/+1
| |
* | arti-client: use PreferredRuntime by default, doc cleanupseta2022-02-281-6/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | tor-rtcompat: refactor PreferredRuntime, clean up docseta2022-02-253-55/+142
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `PreferredRuntime` is now an opaque wrapper struct that contains the "actual" preferred runtime as a type alias. The `current_user_runtime` and `create_runtime` functions become `PreferredRuntime::current` and `PreferredRuntime::create`, respectively. This removes the dependence on `impl Trait`, meaning we can now name the returned runtime (yay!). In addition, the documentation was cleaned up a bit to make it (hopefully) flow better. Items that don't make sense to publicize, like testing implementation details, have been marked #[doc(hidden)] and semver warnings added.
* | Bump minimum tokio to 1.7, since tokio-util now needs that.Nick Mathewson2022-02-251-1/+1
| |
* | Upgrade dependency to new version of tokio-util.Nick Mathewson2022-02-251-1/+1
| |
* | Merge branch 'tls-trait' into 'main'Ian Jackson2022-02-257-29/+38
|\ \ | | | | | | | | | | | | tor-rtcompat: Provide TLS wrapping for all streams See merge request tpo/core/arti!349
| * | Fix rustdoc "skip this" markupIan Jackson2022-02-241-1/+1
| | |
| * | tor-rtcompat: Provide TLS wrapping for all streamsIan Jackson2022-02-247-29/+38
| | | | | | | | | | | | | | | | | | | | | | | | Now all of the runtime types we provide all impl<S> TlsProvider<S> where S: ... rather than merely TlsProvider<Self::TcpStream>. And we document and intent to perhaps require this in the future.
* | | Merge branch 'http-layer' into 'main'eta2022-02-241-0/+2
|\ \ \ | |_|/ |/| | | | | | | | Initial cut of hyper bindings as a library crate See merge request tpo/core/arti!342
| * | Add missing documentation for TLS features to two readmesIan Jackson2022-02-231-0/+2
| |/
* / add example of tcp hooktrinity-1686a2022-02-231-0/+5
|/ | | | this required to make additional types public
* rename *.py scripts to bare nameIan Jackson2022-02-181-0/+0
| | | | | | Update all references. There are three remaining hits for git-grep '\.py\b' all of which are scripts in "little-t-tor", not here in arti.
* Change deny(clippy::all) to warn(clippy::all).Nick Mathewson2022-02-141-1/+1
| | | | Closes #338.
* Upgrade required version of futures crate to 0.3.14Nick Mathewson2022-02-011-1/+1
| | | | | Earlier versions have a bug in UnboundedReceiver that make our new dirclient tests fail.
* Bump the patch version of every crate that changed since 0.0.3Nick Mathewson2022-01-311-1/+1
|
* Use script to update README.md files.Nick Mathewson2022-01-281-6/+8
|
* tor-rtcompat: remove some unused code.Nick Mathewson2022-01-271-16/+0
| | | | | Nothing actually used these accessor functions, and it's not clear what would. We can add them later if they're needed.
* tor-rtcompat: Add some miscellaneous testsNick Mathewson2022-01-274-0/+91
| | | | | These probably aren't for things that will fail IRL, but it's nice to have coverage on the code, just in case.
* tor-rtcompat: Simplify test-declaration macros.Nick Mathewson2022-01-271-60/+35
| | | | Now there's much less copy-and-paste.
* Move tor-rtcompat tests to lib.rsNick Mathewson2022-01-272-311/+312
| | | | | | | | | | | This makes our layout more similar to our other crates, and successfully informs our grcov exclusion pattern that these tests are indeed tests. Doing this knocks down the reported coverage for the tor-rtcompat crate, but that's okay: we hadn't earned it. I hereby promise that this commit is only code-movement.
* Document why {current,create}_runtime are type-erasedNick Mathewson2022-01-271-9/+19
|
* Apply @eta's suggestions from review on !263eta2022-01-272-2/+2
| | | Comment-only.
* Fix documentation references for tor-rtcompat refactoring.Nick Mathewson2022-01-262-9/+11
|
* Rename `SpawnBlocking` trait to `BlockOn`.Nick Mathewson2022-01-268-16/+16
| | | | | This avoids a future confusion with the new `SpawnBlocking` trait in async_executors v0.5, and better describes what the trait provides.
* Make test_with_all_runtimes cover _all_ the runtimes.Nick Mathewson2022-01-264-74/+126
| | | | | | | | | | | This took some refactoring, so that I wouldn't need to define 9 different versions of the function. It also required that we change the behavior of test_with_all_runtimes slightly, so that it asserts on _any_ failure rather than asserting on most but returning Err() for others. That in turn required changes to a few of its callers. There's probably a better way to do all of this macro business, but this is the best I could find.
* Make the native-tls crate optional.Nick Mathewson2022-01-269-20/+118
| | | | | | | | | | | 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
* Define aliases for "the best enabled runtime".Nick Mathewson2022-01-264-23/+45
| | | | | This helps us simplify our code in a few ways, and will help even more once native_tls is optional.
* Make current/create functions into runtime member functions.Nick Mathewson2022-01-264-95/+116
| | | | | This should help avoid some amount of temptation towards API proliferation.
* Rename FooRuntime to FooNativeTlsRuntime for consistency.Nick Mathewson2022-01-262-14/+14
|
* Limit the inner types in tor-rtcompat that have to implement CloneNick Mathewson2022-01-263-33/+10
| | | | | If we implement our own clone on CompoundRuntime, we no longer need Clone implementations on our TlsProvider implementations.
* Remove no-longer-needed tokio runtime helper macroNick Mathewson2022-01-261-27/+18
|
* Unify TokioRuntime and TokioRuntimeHandleNick Mathewson2022-01-262-59/+49
| | | | | | | | | 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.
* Remove misspellings of "rusttls".Nick Mathewson2022-01-261-2/+2
|
* More comments on the limitations of tor-rtcompat's TLS APINick Mathewson2022-01-252-3/+29
| | | | | Also, more comments on why these limitations are safe within the context of Tor, but you wouldn't want to use them elsewhere.
* Comment-only: document sni_hostname more.Nick Mathewson2022-01-251-3/+5
| | | | | Previously we expected the reader to automatically know why it was called "SNI", which really isn't fair.
* Refactor native_tls usage into its own moduleNick Mathewson2022-01-257-230/+130
| | | | | This change uses the async-native-tls crate for everything, and deletes some duplicated code.
* tor-rtcompat: Add support for rustls.Nick Mathewson2022-01-258-9/+461
| | | | | | | | | | | | | | | | | | | This is based on @janimo's approach in !74, but diverges in a few important ways. 1. It assumes that something like !251 will merge, so that we can have separate implementations for native_tls and rustls compiled at the same time. 2. It assumes that we can implement this for the futures::io traits only with no real penalty. 3. It uses the `x509-signature` crate to work around the pickiness of the `webpki` crate. If webpki eventually solves their [bug 219](https://github.com/briansmith/webpki/issues/219), we can remove a lot of that workaround. Closes #86.
* Add a C program to make Tor-style X509 link certificatesNick Mathewson2022-01-241-0/+159
| | | | | We should never use this for anything but making the testing certificates we use for making sure our TLS implementation works.
* Refactor Runtimes to use separate TLS implementations internally.Nick Mathewson2022-01-196-43/+134
| | | | | This will make it easier to implement them using some other TLS provider as well, without having to duplicate all of our code.
* Add a macro to help with opaque Runtime wrappers.Nick Mathewson2022-01-192-0/+70
| | | | | | | We're soon going to have our different Runtime types be built as CompoundRuntime instances. We don't want to expose that detail, though, so we'll use this macro to make them implement the right traits.
* Add a CompoundRuntime type for runtime construction.Nick Mathewson2022-01-192-0/+134
| | | | | | | | | | | | | This type can solve two problems at once. First, it lets users replace parts of an existing runtime implementation without replacing the whole thing. For example, you can use it to override your TcpProvider implementation to solve problems like #235. Second, we can use it internally to tor-rtcompat to define Runtimes piece-by-piece. Mostly we'll use this to separate our Tls implementations from our implementations of the rest of the Runtime.
* Merge branch 'eta/182' into 'main'Nick Mathewson2022-01-112-7/+10
|\ | | | | | | | | Improve the layout of crate exports; add runtime convenience functions See merge request tpo/core/arti!235
| * Improve the layout of crate exports; add runtime convenience functionseta2022-01-112-7/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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...
* | Bump all crate versions to 0.0.3.Nick Mathewson2022-01-111-1/+1
|/