Commit Graph

225 Commits

Author SHA1 Message Date
Ian Jackson 4d14398fe1 Split up ErrorKind::ProtocolViolation 2022-02-14 17:55:56 +00:00
Ian Jackson 30ebb1358a Split up ErrorKind::NoSupport 2022-02-14 16:06:45 +00:00
Ian Jackson 3a9a4b6532 Clarify ErrorKind::InvalidConfigTransition 2022-02-14 15:41:40 +00:00
Nick Mathewson 1cecc7e45a Change deny(clippy::all) to warn(clippy::all).
Closes #338.
2022-02-14 09:24:06 -05:00
Nick Mathewson 7885db406a Merge branch 'eta/unbootstrapped-clients' into 'main'
Allow creating unbootstrapped `TorClient`s (and `DirMgr`s)

Closes #293

See merge request tpo/core/arti!298
2022-02-11 17:43:46 +00:00
eta 882e75cd28 Allow creating unbootstrapped `TorClient`s (and `DirMgr`s)
This commit changes how the `TorClient` type works, enabling it to be
constructed synchronously without initiating the bootstrapping process.
Daemon tasks are still started on construction (although some of them
won't do anything if the client isn't bootstrapped).

The old bootstrap() methods are now reimplemented in terms of the new
create_unbootstrapped() and bootstrap_existing() methods.

This required refactoring how the `DirMgr` works to enable the same sort
of thing there.

closes #293
2022-02-11 16:42:19 +00:00
Nick Mathewson 4e8db2b836 socksproto: Simplify Truncated handling
Refactor the Error type to remove the yucky internal hidden Truncated
variant.  Instead, there's now an embedded tor_bytes::Error value.

If that tor_bytes::Error is Truncated, we bubble it up when we convert our
handshake result to the nested error struct.

Thus there is still (sadly) a variant of tor_socksproto::Error
that shouldn't be exposed to user code.  But refactoring every
inner method under handshake.rs seemed like a bad idea: once we're using
Result<Result<..>>, the ? operator no longer helps us much.
2022-02-11 09:36:57 -05:00
Nick Mathewson f62b2600c7 Move the Truncated error into tor-errors. 2022-02-11 09:36:57 -05:00
Nick Mathewson f6189e174b tor-socksproto: Implement HasKind
(This error isn't yet wrapped in TorError, but it will be eventually
when we implement socks proxy and PT support.)
2022-02-11 09:36:57 -05:00
Nick Mathewson cb6de69ef6 tor-config: Add HasKind support.
This required a few new ErrorKinds.
2022-02-09 12:30:20 -05:00
Nick Mathewson c43f494b44 tests for tor-error::internal
These tests turned up a need for using the #[track_caller]
annotation in order to get accurate locations, which is fortunately
stable since Rust 1.46.0.
2022-02-04 16:33:43 -05:00
Nick Mathewson 1166977975 Docs and clarification for a bunch of Error stuff 2022-02-04 16:06:11 -05:00
Nick Mathewson 9bd7419c20 Make the Error detail type non-exported from arti-client
At least by default, we should have Error be private, and not expose
it as part of our APIs.

To keep functionality in `arti`, I had to add an `ExitTimeout` error
kind.

For interface consistency, I also re-exported ErrorKind and HasError
from `arti_client`.
2022-02-04 16:06:11 -05:00
Nick Mathewson f973fe5060 Require backtrace 0.3.8.
This is the first version that builds correctly on our CI.  It's
from back in 2018, so requiring it shouldn't cause any major
problems.
2022-02-04 13:52:46 -05:00
Ian Jackson 87270415f0 errors: ErrorKind::TODO: Fix typo in message
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/262#note_2772816
2022-02-04 14:46:35 +00:00
Ian Jackson ca960df6b1 errors: Change docs for ErrorKind to refer to Arti
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/262#note_2772810
2022-02-04 14:43:58 +00:00
Ian Jackson f5e874cf91 errors: Drop "Error" and "Failed" from various enum variants 2022-02-04 14:42:37 +00:00
Ian Jackson 0a1cda6886 tor-chanmgr::Error: impl HasKind 2022-02-04 14:42:37 +00:00
Ian Jackson 14f67609f7 errors: Initial impl HasKind in arti-client, ErrorKind::TODO
This involves making a temporary ErrorKind::TODO.  That will continue
to exist until all errors (at least, the ones that make it out to
here) can be properly categorised.

Introducing this will let us work from the top and bottom towards the
middle.
2022-02-04 14:42:37 +00:00
Ian Jackson 68d0ec437f spawn errors: impl HasKind for futures::SpawnError
This needs two kinds.  We have decided to treat a non-shutdown
SpawnError as "unexplained" rather than as an InternalError.

There are many crates whose
  From<futures::task::SpawnError> for Error
erroneously treat it as an internal error.  We will fix them in a moment.
2022-02-04 14:42:37 +00:00
Ian Jackson a623982197 tor_persist::Error: impl HasKind and adjust comments
And change the comments to slightly reinterpret these errors, to
relate to the circumstances rather than error generation site.
2022-02-04 14:42:37 +00:00
Ian Jackson 89b0c108d7 tor-error: provide into_internal! 2022-02-04 14:42:37 +00:00
Ian Jackson 776270fee2 tor-error: Allow making an `InternalError` from some other error
This can be used in call sites where an error is thought not to be
possible.

The `source` will be used only for formatting messages.
2022-02-04 14:42:37 +00:00
Ian Jackson c963bd648b tor-error: Introduce InternalError as a type and a kind
This can contain a backtrace, which will be printed.
2022-02-04 14:42:37 +00:00
Ian Jackson 9e5b6fa820 tor-error: Skeleton for new crate
As per doc/Errors.md.

Currently there are no error kinds.  Some will be added as we go along.
2022-02-04 14:33:09 +00:00