summaryrefslogtreecommitdiff
path: root/crates/tor-rtcompat/src
Commit message (Collapse)AuthorAgeFilesLines
* AF_UNIX terminology: Rename two error structsIan Jackson2025-03-244-10/+14
| | | | | | 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-242-4/+4
|
* Merge branch 'x509-signature-yeet' into 'main'Nick Mathewson2025-03-054-117/+97
|\ | | | | | | | | | | | | Switch from x509-signature to rustls-webpki when using rustls. Closes #1824 and #1854 See merge request tpo/core/arti!2816
| * rustls: move provider-installer to its own function.Nick Mathewson2025-03-041-13/+21
| | | | | | | | | | We do this so that we can make sure there's a provider installed when we run the tests.
| * rustls.rs: Replace x509-signature with rustls-webpkiNick Mathewson2025-03-044-101/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The x509-signature crate is archived, and won't see any more releases. Using it is tying us to ring 0.16 internally, which means we depend on two ring versions. Fortunately, rustls-webpki relaxes some of the earlier restrictions from the vanilla webpki crate, which means that its certificate parser now accepts C tor's oddball x509 certificates as valid. With this change, we can delegate to rustls's built-in signature-checking code, and we only have to override its certificate validation. (We still override it with a pile of comments about how we don't validate link certificates much.) I've had to include a few certificates: two are for tests, but one is needed as a placeholder, since we can't construct a rustls certificate validator without a root cert, even if we'll never use it. Closes #1824. Closes #1854.
| * rtcompat: Un-rename CertificateDer type.Nick Mathewson2025-03-041-6/+8
| | | | | | | | (We had added this rename when rustls renamed it originally.)
* | tor-rtcompat: Fix grammar in docIan Jackson2025-03-041-1/+1
| | | | | | | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2810#note_3168425
* | tor-rtcompat: Rename spawn_thread to spawn_blockingIan Jackson2025-03-045-34/+33
| | | | | | | | Let's use Tokio terminology here.
* | tor-rtcompat: Give a reason in blocking_io for not using for cpu workIan Jackson2025-03-041-1/+4
| | | | | | | | | | As requested https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2810#note_3167979
* | tor-rtcompat: Fix docs typoIan Jackson2025-03-041-1/+1
| | | | | | | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2810#note_3167978
* | tor-rtcompat: Change the title of RuntimeIan Jackson2025-03-041-1/+1
| | | | | | | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2810#note_3167977
* | tor-rtcompat: Clarify reentrancy restrictions on `block_on`Ian Jackson2025-03-041-2/+5
| | | | | | | | | | Prompted by https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2810#note_3167976
* | tor-rtcompat: Explain Sendness of reenter_block_on futureIan Jackson2025-03-041-0/+6
| | | | | | | | | | | | | | Prompted by https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2810#note_3167975 Also allow ourselves the option of changing this in the future.
* | tor-rtcompat: Clarify distinction between Runtime and ToplevelIan Jackson2025-03-041-2/+8
| | | | | | | | | | Prompted by and partially taken from https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2810#note_3167973
* | tor-rtcompat: Linkify a mention of spawn_threadIan Jackson2025-03-041-1/+1
| | | | | | | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2810#note_3167972
* | tor-rtcompat: Clarify docs (3)Ian Jackson2025-03-041-1/+1
| | | | | | | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2810#note_3167970
* | tor-rtcompat: Make a precise example for mpsc::channelIan Jackson2025-03-041-1/+1
| | | | | | | | | | See https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2810#note_3167969
* | tor-rtcompat: Blocking::spawn_thread semantics correctionIan Jackson2025-03-041-2/+11
| | | | | | | | | | | | | | | | | | The: table entry for `spawn_thread` was wrong. We use AsyncExecutors' spawn_blocking which uses tokio::task::spawn_blocking. This has implications for the semantics, as per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2810#note_3167967 https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2810#note_3167968
* | tor-rtcompat: Clarify docs (2)Ian Jackson2025-03-041-1/+1
| | | | | | | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2810#note_3167966
* | tor-rtcompat: Clarify docsIan Jackson2025-03-041-1/+1
| | | | | | | | | | As suggested https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2810#note_3167965
* | tor-rtmocK; Detect wrong-context blocking_io and spawn_threadIan Jackson2025-03-041-2/+0
| |
* | tor-rtmocK; Detect re-entry into MockExecutorIan Jackson2025-03-041-1/+0
| |
* | tor-rt*: Apply deferred formatting churnIan Jackson2025-03-043-5/+5
| | | | | | | | rustfmt.
* | tor-rtcompat: CompoundRuntime: Rename TaskR member from SpawnRIan Jackson2025-03-041-40/+39
| | | | | | | | | | | | This member is the principal one which implemnets Spawn, Blocking and perhaps ToplevelBlockOn. It doesn't appear that we actually need to split this into multiple members.
* | tor-rtcompat: Remove ToplevelBlockon from RuntimeIan Jackson2025-03-042-12/+12
| | | | | | | | | | | | | | | | Introduce ToplevelRuntime as an alias, and use it in the top-level programs. Now none of the principal protocol implementation code has access to the executor's toplevel entrypoint, and can't call it by mistake.
* | tor-rtcompat: Provide Blocking::blocking_ioIan Jackson2025-03-043-2/+70
| | | | | | | | | | | | | | | | | | 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-046-5/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-046-32/+125
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-048-14/+14
|/ | | | | | | | | | 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..)
* Upgrade to derive_more 2Nick Mathewson2025-02-261-0/+1
| | | | | This took a little refactoring, since derive_more::Foo no longer re-exports std::ops::Foo.
* tor-rtcompat: Rename UnsupportedStreamOps to NoOpStreamOpsHandle (fmt).Gabriela Moldovan2025-01-151-3/+3
|
* tor-rtcompat: Rename UnsupportedStreamOps to NoOpStreamOpsHandle.Gabriela Moldovan2025-01-152-4/+4
| | | | | This renames UnsupportedStreamOpsHandle to NoOpStreamOpsHandle for clarity (the old name kind of sounded like the name of an error type).
* tor-rtcompat: Fix doc warning.Gabriela Moldovan2025-01-151-1/+1
|
* tor-rtcompat: Big invasive change adding StreamOps bound everywhere.Gabriela Moldovan2025-01-155-7/+8
| | | | | | This is unfortunately necessary, because after the channel handshake, we need to give the channel reactor a `StreamOps` handle to the underlying stream.
* tor-rtcompat: Implement StreamOps for TLS stream types.Gabriela Moldovan2025-01-152-1/+22
|
* tor-rtcompat: Implement StreamOps for Framed.Gabriela Moldovan2025-01-151-0/+13
|
* tor-rtcompat: Implement new_handle() using TcpSockFd.Gabriela Moldovan2025-01-153-2/+8
|
* tor-rtcompat: Add the ability to get a StreamOps handle.Gabriela Moldovan2025-01-155-1/+69
| | | | | | | | | | | | | | | | | | | | | | | Needed for cases where we wrap an object that implements `StreamOps` in an external type, thereby losing access to the `StreamOps` functionality. For example, during the channel handshake, we `.split()` the stream that implements `StreamOps`, which leaves us with a `SplitSink` and a `SplitStream`, neither of which implement `StreamOps`. Getting a handle to the underlying object that implements `StreamOps` (for example, a file handle) *before* the stream is `.split()` enables us to use `StreamOps` to manipulate the underlying split stream. This commit also introduces a special `UnsupportedStreamOpsHandle`, which is a type that implements `StreamOps`, but always returns an error. This type is meant to simplify error handling and usage, and is meant to be used in cases where `StreamOps` is not supported. TODO: the name of this type is pretty confusing (it's very similar to `UnsupportedStreamOp`, which is an error type), and should probably be renamed to something else (`NoOpStreamOpsHandle`, `BrokenStreamOpsHandle`, `DummyStreamOpsHandle` come to mind...). Note: this changes the `StreamOps` trait to be slightly different from what I originally envisioned in !2660 and #1769
* tor-rtcompat: Note that SpawnBlocking isn't for CPU-bound tasks.Wesley Aptekar-Cassels2025-01-071-1/+1
|
* tor-rtcompat: Use GAT instead of RPIT in SpawnBlocking trait.Wesley Aptekar-Cassels2025-01-075-5/+16
| | | | Due to the limitations on RPIT, it's better to use a GAT for now.
* tor-rtcompat: Add note about what to use spawn_blocking for.Wesley Aptekar-Cassels2025-01-071-1/+5
|
* tor-rtcompat: Link to spawn_blocking docs.Wesley Aptekar-Cassels2025-01-071-0/+6
|
* tor-rtcompat: Add spawn_blocking to Runtime trait.Wesley Aptekar-Cassels2025-01-076-1/+67
| | | | | This adds a new SpawnBlocking trait, which exposes the spawn_blocking function that tokio, async-std, and other runtimes have.
* Merge branch 'mod-module-files' into 'main'Nick Mathewson2025-01-071-0/+1
|\ | | | | | | | | clippy: deny `mod_module_files` See merge request tpo/core/arti!2689
| * clippy: deny `mod_module_files`Steven Engler2025-01-061-0/+1
| | | | | | | | | | | | Denies 'mod.rs' files for consistency. https://rust-lang.github.io/rust-clippy/master/index.html#mod_module_files
* | fix: fix typosDimitris Apostolou2025-01-061-1/+1
|/
* rtcompat: re-export items from tor_general_addr::generalNick Mathewson2024-12-191-0/+2
|
* streamops: Resolve unused-variable warnings.Nick Mathewson2024-12-121-1/+1
|
* tor-rtcompat: Replace bad_api_usage with UnsupportedStreamOp (fmt).Gabriela Moldovan2024-12-103-5/+17
|
* tor-rtcompat: Replace bad_api_usage with UnsupportedStreamOp.Gabriela Moldovan2024-12-104-23/+12
|