aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-proto/src/util
Commit message (Collapse)AuthorAgeFilesLines
...
* tor-proto: Remove the no-longer needed allowsIan Jackson2024-10-031-1/+0
|
* tor-proto: Provide a variant for memquota errorsIan Jackson2024-10-031-0/+6
|
* tor-proto: SometimesUnboundedSink: provide as_inner accessorIan Jackson2024-10-021-0/+10
|
* Fix typosDimitris Apostolou2024-09-031-2/+2
|
* extract tor_async_utils::oneshot into ::oneshot-fused-workaroundJim Newsome2024-08-281-1/+1
| | | | | | | | | | | | | | Having this in the `tor-async-utils` crate prevents us from doing both of the following without introducing a circular dependency: * using it in `tor-rtmock` (which we currently do, particularly in tests). * using `tor-rtmock` to test things in `tor-async-utils`. We don't do this yet, but it is generally sensible to do so. In particular we want to move the `stream_peak` module there, which is currently tested with `tor-rtmock`. Moving this into its own crate avoids this circular dependency.
* StreamPollSet: disallow polling ready streamsJim Newsome2024-08-211-22/+28
|
* tor-proto: Use PeekableStream to get rid of redundant bufferingJim Newsome2024-08-211-180/+217
| | | | | | | | | | | | | | | | | | | | | | | | | * Update `StreamPollSet` to require that its streams implement `PeekableStream`, and to not do its own buffering of values read from the stream. This avoids an extra layer of buffering for streams that already buffer a value, and makes the interior state a little simpler and more robust. It does have a downside of making the API a little less convenient, since the caller must do its own `poll_peek` call if it wants a reference to the item. * Update `StreamMap` to implement `PeekableStream` for `OpenStreamEntStream`, as it must to satisfy the updated `StreamPollSet` API. We have to somewhat constrain the `poll_ready_streams_iter` API to no longer return both a reference to the stream and the message. I don't see a way to return both while satisfying the borrow checker. Luckily we don't really need both anymore. * Update the Circuit reactor to handle the updated `StreamMap::poll_ready_streams_iter` API.
* StreamPollSet: remove redundant type parameter VJim Newsome2024-08-121-23/+20
| | | | | This was required to be the same type as `S::Item`. We can just use `S::Item` directly.
* StreamPollSet: replace nested OptionJim Newsome2024-08-081-10/+28
| | | | | | | | | | | | | | | | | Bullied by clippy. I'm on the fence whether this is actually an improvement, or whether I should add an exception. ``` error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases --> crates/tor-proto/src/util/stream_poll_set.rs:106:56 | 106 | pub fn remove(&mut self, key: &K) -> Option<(K, P, Option<Option<V>>, S)> { | ^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#option_option = note: `-D clippy::option-option` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::option_option)]` ```
* StreamMap: Merge rxs into open_streamsJim Newsome2024-08-081-0/+5
| | | | | | This simplifies the bookkeeping a bit, and clears a path towards updating the Streams in our StreamPollSet to directly respect flow control.
* StreamPollSet: allow access to inner streamsJim Newsome2024-08-081-39/+334
|
* KeyedFuturesUnordered: explicitly document Stream behaviorJim Newsome2024-08-081-0/+13
|
* KeyedFuturesUnordered: return actual referencesJim Newsome2024-08-081-23/+10
| | | | | | We can actually return references here instead of `impl Deref`, simplifying this code a bit and follow-on code to use this in StreamPollSet.
* KeyedFuturesUnordered: additional testingJim Newsome2024-08-081-37/+98
| | | | | | | | | Primarily I wanted to exercise the code path that we get a spurious wakeup due to a future that was removed from the map later becoming ready. I also ended up merging ReadyFut and PendingFut into a more flexible ValueFut to make this a little nicer.
* Add KeyedFuturesUnordered::get and KeyedFuturesUnordered::get_mutJim Newsome2024-08-081-3/+72
|
* KeyedFuturesUnordered::remove: return the future as wellJim Newsome2024-08-082-18/+55
|
* KeyedFuturesUnordered: refactor so that futures are accessibleJim Newsome2024-08-082-100/+100
| | | | | | | | | | | Instead of wrapping `FuturesUnordered`, which doesn't support efficient access to its internal futures, keep the futures themselves in our own HashMap, and use a custom Waker to be notified which futures are ready to be polled. *Almost* a pure refactor in this step - the implementation now requires that keys are `Send + Sync + 'static` so that we can put them inside an `Arc` and send them over a channel.
* Add StreamPollSetJim Newsome2024-08-011-0/+602
|
* Add KeyedFuturesUnorderedJim Newsome2024-08-011-0/+366
|
* Merge branch 'todo-number' into 'main'Alexander Færøy2024-07-071-1/+1
|\ | | | | | | | | Fix two TODO ticket numbers See merge request tpo/core/arti!2224
| * Fix two TODO ticket numbersIan Jackson2024-06-251-1/+1
| | | | | | | | | | I seem to have mistyped this ticket number. We meant #1397 aka "Circuit reactor isn't great", not some release ticket.
* | Rename OptTimestamp to AtomicOptTimestampNeel Chauhan2024-06-241-7/+7
|/
* SometimesUnboundedSink: Add a test case with some manual sequencingIan Jackson2024-05-301-0/+68
|
* SometimesUnboundedSink: Write commentary about WakerIan Jackson2024-05-301-0/+36
|
* SometimesUnboundedSink: Document some error behaviourIan Jackson2024-05-301-0/+4
|
* SometimesUnboundedSink: Fix a copypaste errorIan Jackson2024-05-301-1/+1
| | | | | If only I'd used a macro for these, but that's not entirely straightforward.
* SometimesUnboundedSink: Narrow dead code allowIan Jackson2024-05-301-2/+1
|
* Implmeent SometimesUnboundedSinkIan Jackson2024-05-291-0/+145
|
* Add tor_proto::util::ct::is_zeroJim Newsome2024-03-201-0/+25
|
* Run maint/add_warning.Nick Mathewson2024-03-133-0/+3
|
* Run maint/add_warning to add lint block everywhereIan Jackson2023-08-233-0/+3
|
* tor-proto: Add a helper for adding a stream entry with a specific stream ID.Gabriela Moldovan2023-08-031-2/+12
| | | | | | | | | This adds a new `add_ent_with_id` function for adding a new entry to the `StreamMap`. The existing `add_ent` function auto-generates a new stream ID, which is not good if we're a hidden service, as stream IDs are supposed to be chosen by the OP (client). When accepting a new stream, services, exit relays, and dir auths need to use the stream ID received in the BEGIN cell (instead of generating a new stream ID).
* Run maint/add_warning to actually apply new lint allowsIan Jackson2023-07-103-0/+3
|
* Lower tor-proto::util::ct::lookup to tor-llcryptoNick Mathewson2023-06-161-56/+1
| | | | | | | | This is mostly code movement; you may want to review it with `--color-moved`. I'm doing this so we can also use the function in netdoc for looking up hsdesc authentication.
* Allow clippy::unchecked_duration_subtraction in testsNick Mathewson2023-01-273-0/+3
| | | | | This panics on error, and we're fine with a panic on misbehavior in tests.
* test lint blocks: Add many many automaticallyIan Jackson2022-12-123-0/+25
| | | | | This is precisely the result of running the rune in maint/adhoc-add-lint-blocks.
* Final (?) API revisions for tor-linkspecNick Mathewson2022-08-101-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this change, each individual identity type becomes optional. The functions that expose them unconditionally are now in a "legacy" trait that only some downstream types are expected to implement. There are new convenience APIs in HasRelayIds: * to return Option<&keytype>, * to see if one identity-set contains another. This commit will break several downstream crates! For the reviewer's convenience, I will put the fixes for those crates into a series of squash! commits on this one. tor-netdir ---------- Revise tor-netdir to accept optional identities. This required some caveats and workarounds about the cases where we have to deal with a key type that the tor-netdir code does not currently recognize at all. If we start to add more identity types in the future, we may well want more internal indices in this code. tor-proto --------- In order to make tor-proto support optional identities, there were fewer changes than I thought. Some "check" functions needed to start looking at "all the ids we want" rather than at "the two known IDs"; they also needed to accommodate that case where we don't have an ID that we demand. This change will also help with bridges, since we want to be able to connect to a bridge without knowing all of its IDs up front. The protocol currently _requires_ the two current ID types in some places. To deal with that, I added a new `MissingId` error. I also removed a couple of unconditional identity accessors for chanmgr; code should use `target().identity(...)` instead. tor-chanmgr ----------- This is an incomplete conversion: it does not at all handle channel targets without Ed25519 identities yet. It still uses those identities to index its internal map from identity to channel; but it gives a new `MissingId` error type if it's given a channel target that doesn't have one. We'll want to revise the map type again down the road when we implement bridges, but I'd rather not step on the channel-padding work in progress right now. tor-guardmgr ------------ This change is mostly a matter of constructing owned identity types more sensibly, rather than unwrapping them directly. There are some places marked with TODOs where we still depend on particular identity types, because of how the directory protocol works. This will need revisiting when we add bridge support here. tor-circmgr ----------- These changes are just relatively simple API changes in the tests.
* tor-proto: Stop using write_infallible in handshake code.Nick Mathewson2022-07-111-0/+21
| | | | | | | | This change was a bit annoying, since most of this code _can't_ fail, and so the only reasonable response is to wrap the input in an internal error... except for one case where we're actually encoding a caller-provided message, so we _do_ want to wrap the EncodeError from tor_bytes.
* tor-proto: split and elaborate tor_bytes::Error instancesNick Mathewson2022-06-231-6/+26
| | | | | | | | | Some of these were for decoding particular objects (we now say what kind of objects), and some were unrelated tor_cert errors that for some reason we had shoved into a tor_bytes::Error. There is now a separate tor_cert::CertError type, independent from tor_cert's use of `tor_bytes::Error` for parsing errors.
* tor-proto: Split CellErr based on activity.Nick Mathewson2022-06-231-9/+33
| | | | | | Failing to encode is fundamentally different from failing to decode. We now treat those separately, and describe _what_ we failed to encode or decode.
* tor-proto: clean up error names and messagesNick Mathewson2022-06-231-37/+42
| | | | | This avoids adding additional information for now; that will come on the next commits.
* Merge branch 'display_source_cleanup' into 'main'eta2022-06-211-7/+7
|\ | | | | | | | | Do not include error source() in display() format. See merge request tpo/core/arti!598
| * Do not include error source() in display() format.Nick Mathewson2022-06-211-7/+7
| | | | | | | | | | | | | | | | | | According to doc/Errors.md, and in keeping with current best practices, we should not include display an error's `source()` as part of that error's display method. Instead, we should let the caller decide to call source() and display that error in turn. Part of #323.
* | tor-proto: err: Provide ChannelClosed as a separate unit errorIan Jackson2022-06-211-4/+22
|/
* Change to exhaustive match.Ian Jackson2022-06-081-1/+2
|
* try to differentiate transient from nontransient errortrinity-1686a2022-06-081-2/+18
|
* Use testing_rng() in tests throughout our crates.Nick Mathewson2022-06-021-1/+2
| | | | | | This only affects uses of thread_rng(), and affects them all more or less indiscriminately. One test does not work with ARTI_TEST_PRNG=deterministic; the next commit will fix it.
* More tests for ClockSkew.Nick Mathewson2022-05-251-0/+40
|
* Fix typos (using the typos-cli tool).Nick Mathewson2022-05-041-1/+1
|
* Implement a better clock skew estimator.Nick Mathewson2022-04-111-8/+75
| | | | | | | | This time, our estimator discards outliers, takes the mean of what's left, and uses the standard deviation to try to figure out how seriously to take our report of skew/not-skew. These estimates are still not actually used.