aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-proto/src/util/err.rs
Commit message (Collapse)AuthorAgeFilesLines
* proto: Rework error handling in `HopMgr::get_or_spawn_reactor()`Gabriela Moldovan2026-06-231-1/+20
| | | | | | | | | | This reworks `get_or_spawn_reactor()` to return `Error` instead of `ReactorError`. The main change here is that we now have a dedicated `Error::Spawn` variant for `SpawnError`s, instead of mapping these to `ReactorError` (which actually triggers a clean shutdown, which is not quite what we want here).
* proto: Check the AUTHENTICATE auth type that we support itDavid Goulet2026-03-191-0/+9
| | | | | | | | As a responder, we should check the AUTHENTICATE auth type and make sure we support it. We were not doing that, we were simply putting in our max version. Signed-off-by: David Goulet <[email protected]>
* proto: Add new LinkspecDecodeErr kindGabriela Moldovan2026-02-051-0/+15
| | | | | | This will be needed by relays, for wrapping tor_linkspec decode errors (which can happen if the link specifiers in the EXTEND2 cell can't be converted to a channel target).
* proto: Add docs for ExcessPaddingGabriela Moldovan2025-12-011-0/+1
|
* proto: Add new error type for cells received on non-existent streams.Gabriela Moldovan2025-09-221-0/+17
| | | | | Prompted by https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/3267#note_3261239
* proto: Use a new error type for excess padding.Nick Mathewson2025-09-151-1/+20
|
* proto: Make the OutboundClientHandshake use new cell handlerDavid Goulet2025-08-201-9/+0
| | | | | | | | | | | | | | | | | Use the ChannelFrame<> for the entirety of the outbound client handshake that is the ClientInitiator channel type. With this change, the codec.rs code is not needed anymore along its CodecError as well which has been normalized onto the crate::Error instead in order to simplify error handling and avoid duplication of error types. Unit tests have been modified to reflect this change of what can be done with a channel frame. Also renamed to focus on client behavior. Part of #1597 Signed-off-by: David Goulet <[email protected]>
* proto: Implement a From<std::io::Error> for ErrorDavid Goulet2025-08-201-0/+6
| | | | | | | | | To be able to return a crate::Error from the Decoded/Encoder trait, it needs to implement this conversion. Part of #1597 Signed-off-by: David Goulet <[email protected]>
* Switch Cargo.toml files to edition 2024.Nick Mathewson2025-08-071-3/+3
| | | | | | | | | | | | | | First, run ``` git grep -l "^edition =" | xargs perl -i -pe 's/^edition *=.*/edition = "2024"/;' ``` Second, manually verify that all Cargo.toml files have changed, and nothing else has changed. Third, run cargo fmt again.
* proto: Add the ability to enforce a maximum number of cells per hopNick Mathewson2025-07-101-1/+12
|
* tor-proto: Add error and channel types for conflux handshake outcome.Gabriela Moldovan2025-05-061-0/+13
| | | | | These will be used for sending the conflux handshake outcome to the reactor user.
* tor-proto: Add line breaks between impl blocks.Gabriela Moldovan2025-02-251-0/+4
| | | | For readability
* tor-proto: Implement From<Bug> for ReactorError.Gabriela Moldovan2025-02-251-1/+6
| | | | | | | | | | We will soon have a `ConfluxSet` type. Some of its operations will return `Bug` (for example, the method for getting the *only* leg of the conflux set will return a `Bug` if the set has no legs, or more than 1 leg). This conversion function will make it easier these errors to `ReactorError`.
* tor-proto: Provide a variant for memquota errorsIan Jackson2024-10-031-0/+6
|
* 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).
* 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
|
* chanmgr: bubble ClockSkew up through the Error object.Nick Mathewson2022-04-071-2/+0
| | | | | | | | Fortunately, we don't need a separate type here: authenticated clock skew can only come attached to a `tor_proto::Error`. We also remove skew from `tor_proto::Error::HandshakeCertsExpired`, since it would now be redundant.
* tor-proto: better errors when handshake fails due to untimely certsNick Mathewson2022-03-231-5/+23
| | | | | | | | | | | | | | | | | | We now check the handshake certificates unconditionally, and only report them as _expired_ as a last resort. (Rationale: if somebody is presenting the wrong identity from a year ago, it is more interesting that they are presenting the wrong ID than it is that they are doing so with an expired cert. We also now report a different error if the certificate is expired, but its expiration is within the range of reported clock skew. (Rationale: it's helpful to distinguish this case, so that we can blame the failure on possible clock skew rather than definitely attributing it to a misbehaving relay.) Part of #405.
* Merge branch 'proto_handshake_err' into 'main'Nick Mathewson2022-02-241-16/+23
|\ | | | | | | | | | | | | tor-proto: Split up a couple of handshake-based errors Closes #359 and #358 See merge request tpo/core/arti!344
| * tor-proto: refactor handshake protocol errors to a different typeNick Mathewson2022-02-231-3/+11
| | | | | | | | | | | | | | | | This helps the user distinguish between protocol violations that happen when connecting to the tor network from those that happen while connected. Closes #358.
| * tor-proto: Rename BadHandshake to BadCircHandshakeNick Mathewson2022-02-231-4/+4
| | | | | | | | (We'll have a BadChanHandshake soon.)
| * tor-proto: Split IoErr based on when it occursNick Mathewson2022-02-231-11/+10
| | | | | | | | | | | | | | We want to distinguish handshake failures from errors later on in the channel's lifetime. Closes #359.
* | Give specific error kinds to different END reasonsNick Mathewson2022-02-231-3/+1
|/ | | | Closes #360.
* Eliminate RequestedResourceAbsent kind.Nick Mathewson2022-02-221-6/+2
| | | | | | | | There was only one use of this, and it was in as-yet-unused relay-only code. Removing this type required refactoring the relay onion handshake code to use its own error type, which is probably clever anyway.
* Fold NamespaceFull into BadApiUsage.Nick Mathewson2022-02-221-1/+1
|
* Rename RemoteNameError to RemoteHostNotFoundNick Mathewson2022-02-221-2/+2
| | | | | This is a bit ugly but we need it to work around the problem where exits aren't always clear about _why_ a hostname lookup failed.
* Replace RemoteRefused with CircuitRefused.Nick Mathewson2022-02-221-1/+1
| | | | Also document that it's a lower-level error kind.
* Rename RemoteIdMismatch to RelayIdMismatch.Nick Mathewson2022-02-221-1/+1
|
* Fold AlreadyClosed into BadApiUsageNick Mathewson2022-02-221-1/+1
|
* tor_proto::Error: Fix an incomplete sentence.Nick Mathewson2022-02-161-1/+2
|
* Update tor-proto errors to latest API.Nick Mathewson2022-02-151-21/+17
|
* Make tor-proto::Error implement HasKind.Nick Mathewson2022-02-151-16/+42
| | | | | | This took some refactoring, and gave an opportunity to notice a few error variants that weren't being used, or didn't mean what they said on the tin.
* tor-proto: use InternalError for internal errors.Nick Mathewson2022-02-151-2/+3
|
* Get rid of unbounded stream sender, and RawCellStreameta2021-11-121-1/+6
| | | | | | | | | | | | | | | | | | | | | Previously, the reactor would use an `UnboundedSender` to send things to the `RawCellStream`, in order that the reactor wouldn't block if you failed to read from the latter. This is bad, though, since it means people can just run us out of memory by sending lots of things. To fix this, we make the new `StreamReader` type (which does the reading parts from `RawCellStream`) keep track of the stream's receive window and issue SENDMEs once *it* has consumed enough data to require it, thus meaning that we shouldn't get sent enough data to fill the channel between reactor and `StreamReader` (and, if we do, that's someone trying to flood us, and we abort the circuit). As hinted to above, the `RawCellStream` was removed and its reading functionalities replaced by `StreamReader`; its writing functionalities are handled by `StreamTarget` anyway, so we just give out one of those for the write end. This now means we don't need any mutexes! note: this commit introduces a known issue, arti#230
* Move all crates into a `crates` subdirectory.Nick Mathewson2021-08-271-0/+154
This will cause some pain for now, but now is really the best time to do this kind of thing.