aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-rtcompat/src/impls/tokio.rs
Commit message (Collapse)AuthorAgeFilesLines
* tor-rtcompat: manually create and connect() socketSteven Engler2026-06-081-5/+21
| | | | | | | | | This will allow us in the future to set custom sockopts on the socket before calling connect(). I tested an arti proxy with tokio and async-std manually. Arti doesn't yet support smol so I was not able to test it, but it's using the same code as async-std so I would expect it to work.
* tor-rtcompat+misc: add `NetStreamProvider::ConnectOptions`Steven Engler2026-06-081-4/+20
| | | | | | | | | This adds the trait type `ConnectOptions` to `NetStreamProvider` and adds this `ConnectOptions` as an argument to `NetStreamProvider::connect()`. You probably want to look at the changes in tor-rtcompat first, then the rest of this commit is updating the various places we use `NetStreamProvider`.
* tor-rtcompat+misc: add `NetStreamProvider::ListenOptions`Steven Engler2026-05-071-3/+19
| | | | | | | | | This adds the trait type `ListenOptions` to `NetStreamProvider` and adds this `ListenOptions` as an argument to `NetStreamProvider::listen()`. You probably want to look at the changes in tor-rtcompat first, then the rest of this commit is updating the various places we use `NetStreamProvider`.
* opentelemetry: Instrument a bunch of functions.Wesley Aptekar-Cassels2025-11-241-0/+3
| | | | | These are all aimed at figuring out in more detail what's going on in #2079 and related issues.
* tor-rtcompat: use a consistent `listen()` implementationSteven Engler2025-11-101-1/+3
| | | | | | This gives us a consistent `listen()` implementation across runtimes, and gives us flexibility to customize the bind/listen process for TCP sockets.
* Fix Windows compile warningsTobias Stoeckmann2025-08-051-0/+2
| | | | | Use unix-specific crates only if needed and suppress clippy warnings of unused variables if their usage is unix-specific.
* *: use std::io::Error::other in many placesNick Mathewson2025-05-151-2/+1
| | | | | | | The `IoError::other` function is an easier way to say `IoError::new(IoErrorKind::Other, ...)`. It's been around since 1.74, but clippy started warning about the more verbose version in 1.87.
* AF_UNIX terminology: Rename two error structsIan Jackson2025-03-241-3/+3
| | | | | | We change `NoUnixAddressSupport` to `NoAfUnixSocketSupport` because it doesn't make much sense to talk about support for the addresses separately from support for the sockets.
* Fix AF_UNIX terminology in docs, comments, and error messagesIan Jackson2025-03-241-1/+1
|
* tor-rtcompat: Rename spawn_thread to spawn_blockingIan Jackson2025-03-041-1/+1
| | | | Let's use Tokio terminology here.
* tor-rtcompat: Provide Blocking::blocking_ioIan Jackson2025-03-041-0/+10
| | | | | | | | | This was referenced and explained from the docs, but didn't exist yet. Here it is. Everyone except the Tokio glue, and the CompoundRuntime, just use the default implementation in terms of spawn_thread. spawn_thread has a more relaxed contract, so this is correct.
* tor-rtcompat: Provide a new function for executor re-entryIan Jackson2025-03-041-0/+5
| | | | | | | | | | | | | | | Forbid re-entering the executor using ToplevelBlockOn::block_on. This was always forbidden in the case of MockExecutor, but that meant that tests using MockExecutor would malfunction if the code under test needed to re-enter the executor from sync code (since the code under test would have to use block_on, which wrong). See #1835. Provide a function which *can* do this, reenter_block_on. The MockExecutor needs to know the difference, and other runtimes may too. They are conceptually quite different operations. Introduce ToplevelRuntime as a convenience alias.
* tor-rtcompat: New plan for blocking interaction, Blocking traitIan Jackson2025-03-041-3/+3
| | | | | | | | | | | | | | | * Document the new plan for blocking interaction in the trait-level docs for the Blocking trait (used to be SpawnBlocking). Add cross-references (in some cases to not-yet-existing pieces). * Rename: spawn_blocking to spawn_thread. We're going to distinguish thread-creation (relatively expensive) from brief entry to sync code (relatively cheap, but more restricted). * Rename the SpawnBlocking trait to Blocking, and its ThreadHandle to ThreadHandle. This trait is going to gain more functionality. * Add the missing mention of `Blocking` to the docs for `Runtime`.
* tor-rtcompat: Rename BlockOn to ToplevelBlockOnIan Jackson2025-03-041-1/+1
| | | | | | | | | | We're going to distinguish top-level runtime entry, from *re*-entry to an existing executor. It is most convenient to rename this trait first. Documentation of the distinction will come later. (We're going to retain the function name `block_on`, but we want the trait to be more obviously a top-level only thing, though, so we give it a name that will hopefully avoid it peroulating throughout the codebase..)
* tor-rtcompat: Implement new_handle() using TcpSockFd.Gabriela Moldovan2025-01-151-0/+5
|
* tor-rtcompat: Use GAT instead of RPIT in SpawnBlocking trait.Wesley Aptekar-Cassels2025-01-071-1/+3
| | | | Due to the limitations on RPIT, it's better to use a GAT for now.
* tor-rtcompat: Add spawn_blocking to Runtime trait.Wesley Aptekar-Cassels2025-01-071-0/+11
| | | | | This adds a new SpawnBlocking trait, which exposes the spawn_blocking function that tokio, async-std, and other runtimes have.
* tor-rtcompat: Replace bad_api_usage with UnsupportedStreamOp (fmt).Gabriela Moldovan2024-12-101-2/+6
|
* tor-rtcompat: Replace bad_api_usage with UnsupportedStreamOp.Gabriela Moldovan2024-12-101-6/+2
|
* tor-rtcompat: Implement StreamOps for all the stream types.Gabriela Moldovan2024-12-101-2/+19
| | | | Part of #1769
* Remove re-export of "unix" from tor_rtcompat.Nick Mathewson2024-10-291-6/+8
|
* rtcompat: remove async_trait from NetStreamListener.Nick Mathewson2024-09-241-1/+0
| | | | (The trait no longer has any async methods.)
* rtcompat: NetStreamProvider<unix::SocketAddr> for non-unix platformsNick Mathewson2024-09-241-0/+3
| | | | | | | Since there is no way to construct a unix::SocketAddr on these platforms, it's harmless to provide an implementation for NetStreamProvider. What's more, doing so greatly simplifies our AbstractAddr implementation.
* rtcompat: Implement NetStreamProvider<Unix> for tokio.Nick Mathewson2024-09-241-4/+60
|
* tokio: Perpare macro for use with Unix streams.Nick Mathewson2024-09-241-24/+31
|
* tokio: start a macro to implement wrappers for stream typeNick Mathewson2024-09-241-67/+74
| | | | | This commit does nothing interesting yet: it's a separate commit because it reindents a lot of code.
* rtcompat: Rename TcpProvider to NetStreamProvider.Nick Mathewson2024-09-241-7/+7
| | | | | | | | | | | | | | (And similarly rename TcpListener to NetStreamListener, along with their TcpStream/TcpListener associated types.) These types are about to become generic over addresses, and therefore shouldn't be named after TCP. Renaming was done mostly with Rust Analyzer, except for some macros that needed to be hand-edited. (I'll revise the comments in the next commit; this one is all about renaming.)
* rtcompat: Remove accept() from TcpListenerNick Mathewson2024-09-241-4/+0
| | | | | | | | | | It's redundant with the incoming() method (which turns the TcpListener into a Stream of connections), and nothing actually used it outside of tests. Removing this method allows us to simplify our TcpListener code a good deal, as can be seen by some of the implementations we removed from our example and testing code.
* tor-rtcompat: use track-caller for thin wrappersJim Newsome2023-12-181-0/+2
| | | | | | | | | | | | | | In particular, when the (unstable) tokio tracing feature is enabled, every tracing line includes the name of where the current task was created. Without this change, that ends up being the name of intermediate trait methods like TokioRuntimeHandle::block_on, which is not very helpful. Adding the `track_caller` attribute causes the name of the caller of these methods to be used instead, which is typically more helpful. IIUC this change is not breaking in terms of semver https://rustc-dev-guide.rust-lang.org/backend/implicit-caller-location.html.
* Upgrade async_executors dependency to 0.7.0Nick Mathewson2023-09-281-4/+3
|
* UdpSocket: remove support for connect().Nick Mathewson2022-03-181-20/+3
| | | | | | | | Currently, Arti doesn't need this. But once it does, it will be way better to have a separate type for connected sockets, rather than having to error-check every time somebody gives us a socket. Part of #410
* add simple unit test on UDPtrinity-1686a2022-03-141-0/+4
|
* add skeleton for DNS handlingtrinity-1686a2022-03-141-2/+2
|
* add udp to runtimetrinity-1686a2022-03-141-1/+53
|
* 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.
* Rename `SpawnBlocking` trait to `BlockOn`.Nick Mathewson2022-01-261-1/+1
| | | | | This avoids a future confusion with the new `SpawnBlocking` trait in async_executors v0.5, and better describes what the trait provides.
* Remove no-longer-needed tokio runtime helper macroNick Mathewson2022-01-261-27/+18
|
* Unify TokioRuntime and TokioRuntimeHandleNick Mathewson2022-01-261-7/+25
| | | | | | | | | 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.
* Refactor native_tls usage into its own moduleNick Mathewson2022-01-251-124/+0
| | | | | This change uses the async-native-tls crate for everything, and deletes some duplicated code.
* tor-rtcompat: Add support for rustls.Nick Mathewson2022-01-251-1/+1
| | | | | | | | | | | | | | | | | | | 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.
* Refactor Runtimes to use separate TLS implementations internally.Nick Mathewson2022-01-191-23/+33
| | | | | This will make it easier to implement them using some other TLS provider as well, without having to duplicate all of our code.
* Make TlsConnector wrap TCP connections, not create its owneta2021-12-071-7/+22
| | | | | | | | | | | | | | | | | | | | `tor-rtcompat`'s `TlsConnector` trait previously included a method to create a TLS-over-TCP connection, which implied creating a TCP stream inside that method. This commit changes that, and makes the function wrap a TCP stream, as returned from the runtime's `TcpProvider` trait implementation, instead. This means you can actually override `TcpProvider` and have it apply to *all* connections Arti makes, which is useful for issues like arti#235 and other cases where you want to have a custom TCP stream implementation. This required updating the mock TCP/TLS types in `tor-rtmock` slightly; due to the change in API, we now store whether a `LocalStream` should actually be a TLS stream inside the stream itself, and check this property on reads/writes in order to detect misuse. The fake TLS wrapper checks this property and removes it in order to "wrap" the stream, making reads and writes work again.
* Document every macro.Nick Mathewson2021-09-071-0/+3
| | | | | (The nightly version of clippy now includes macros for its missing_docs_in_private_items lint.)
* Move all crates into a `crates` subdirectory.Nick Mathewson2021-08-271-0/+320
This will cause some pain for now, but now is really the best time to do this kind of thing.