Commit Graph

2548 Commits

Author SHA1 Message Date
Nick Mathewson c06bee8a11 Merge branch 'issue-320' into 'main'
Move persistent state flush from client to circmgr

See merge request tpo/core/arti!321
2022-02-16 13:56:34 +00:00
Yuan Lyu 98b1a5a279 Move persistent state flush from client to circmgr 2022-02-15 20:04:45 -05:00
Nick Mathewson c6c4531652 arti: create TorClient first, then bootstrap.
This change is possible now that #293 is done.

As an immediate benefit, it allows us to start monitoring the
configuration files immediately, and not only after we're done
bootstrapping the client.

Closes #336.
2022-02-15 17:32:08 -05:00
Nick Mathewson 058e4d7705 tor-netdir: Split testnet errors into a new type
There's no reason to have the test-network-construction code share an
error enum with the main netdir code.
2022-02-15 14:43:36 -05:00
Nick Mathewson ceb8e8c1e2 tor-netdir: remove unused error variants
This turns out to have been most of them, which
simplifies matters a lot.
2022-02-15 14:36:15 -05:00
Nick Mathewson 7c7bf2bd03 Fix a rustdoc error. 2022-02-15 13:46:58 -05:00
Nick Mathewson 6bd21d4372 Refactor tor-netdoc a bit more, to use Bug right. 2022-02-15 10:22:38 -05:00
Nick Mathewson 13f39ed896 Minimal compilation fix: InternalError=>Bug
This is a followup for !314 and !310 to fix compilation on main.
2022-02-15 10:13:08 -05:00
Nick Mathewson 7b6a7a57d3 Merge branch 'doc-errors' into 'main'
Refactor errors in tor-netdoc

See merge request tpo/core/arti!314
2022-02-15 15:09:48 +00:00
Nick Mathewson 6b611d6dea Update tor-proto errors to latest API. 2022-02-15 09:57:03 -05:00
Nick Mathewson 8b9b42514a Update tor-cell errors to latest API 2022-02-15 09:56:53 -05:00
Nick Mathewson 4af279b173 Make tor-proto::Error implement HasKind.
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.
2022-02-15 09:41:47 -05:00
Nick Mathewson f23f375e42 tor-proto: use InternalError for internal errors. 2022-02-15 09:41:11 -05:00
Nick Mathewson da0e9e456c tor-cell: provide HasKind.
Additionally, refactor the IoError out of tor_cell::Error:
nothing in TorCell created this; it was only used by tor_proto.

This required refactoring in tor_proto to use a new error type. Here I
decided to use a new CodecError for now, though we may refactor that
away soon too.
2022-02-15 09:41:10 -05:00
eta cb7f068c3b Typo fix from@eta 2022-02-15 14:34:59 +00:00
Ian Jackson e6e4ea25c0 Merge branch 'error-kind-badargument' into 'main'
New name and semantics for Bug (was BadArgument)

See merge request tpo/core/arti!310
2022-02-15 14:21:28 +00:00
Ian Jackson 8688069add tor_error::Bug: change Display impl to use kind
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/310#note_2777626

The message from the kind is precisely right.
2022-02-15 13:58:54 +00:00
Ian Jackson ad6cb60d8a BadApiUsage: change Display impl capitalisation
Now it maches the others
2022-02-15 13:58:52 +00:00
Ian Jackson 5d636738eb Rename BadApiUsage from BadAPIUsage
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/310#note_2777519
mutatis mutandi.

And, fix a leftover instance with an old idea of what this was called.
2022-02-15 11:46:54 +00:00
Ian Jackson 97a0a7359b tor-socksproto: Use bad_api_usage! rather than ad-hoc Invalid error 2022-02-15 11:40:24 +00:00
Ian Jackson b8f928e4f5 Make Bug from InternalError, add bad_api_usage! and into_bad_api_usage!
Including supporting machinery, new kind field, etc.
2022-02-15 11:40:24 +00:00
Ian Jackson 5d87ca8ad7 New name and semantics for BadAPIUsage (was BadArgument) 2022-02-15 11:32:19 +00:00
Nick Mathewson e80d472beb Merge branch 'error-socksproto-autoconvert' into 'main'
Provide, and use From impl for InternalError

See merge request tpo/core/arti!315
2022-02-14 20:57:24 +00:00
Nick Mathewson 72221b0b77 Merge branch 'explain_into_tor_addr' into 'main'
More docs for IntoTorAddr

Closes #253

See merge request tpo/core/arti!305
2022-02-14 20:34:50 +00:00
Nick Mathewson a44b13c93a More docs for IntoTorAddr 2022-02-14 20:34:50 +00:00
Nick Mathewson 31075e8046 Run rustfmt. 2022-02-14 14:47:42 -05:00
eta d7478e2675 Merge branch 'ticket_337' into 'main'
Simplify wait_for_bootstrap to use a Mutex.

Closes #337

See merge request tpo/core/arti!308
2022-02-14 19:46:23 +00:00
eta 29daf5a74a Merge branch 'warn_not_deny' into 'main'
Change deny(clippy::all) to warn(clippy::all).

Closes #338

See merge request tpo/core/arti!306
2022-02-14 19:45:18 +00:00
Nick Mathewson e4321bbae2 Merge remote-tracking branch 'origin/mr/313' 2022-02-14 14:25:28 -05:00
Ian Jackson 8db7ab8148 Merge branch 'error-kind-protocol' into 'main'
Split up ErrorKind::ProtocolViolation

See merge request tpo/core/arti!312
2022-02-14 19:07:00 +00:00
Ian Jackson 4774cbd18d Provide, and use From impl for InternalError
Adding this autoconversion is quite safe since every error generation
site is explicit and has its own context, and we don't really need to
add more.

This simplifies the code and will simplify future work.
2022-02-14 18:48:35 +00:00
Ian Jackson 65e2deaf29 Merge branch 'error-kind-notimp' into 'main'
Split up ErrorKind::NoSupport

See merge request tpo/core/arti!311
2022-02-14 18:31:56 +00:00
Nick Mathewson b6d23c36be Refactor tor_netdoc::Error
This error type doesn't impement HasKind, since the kind will depend
on context.

However, the existing implementation was pretty messy and inconsistent:
Some errors had positions, some didn't.
Some took messages as str, some as String.
Some had internal errors that were somewhat orthogonal to their actual
types.

This commit refactors tor_netdoc::Error to use a ParseErrorKind, and
adds a set of convenience functions to add positions and
messages to the errors that need them.
2022-02-14 13:08:28 -05:00
Ian Jackson 4d14398fe1 Split up ErrorKind::ProtocolViolation 2022-02-14 17:55:56 +00:00
Ian Jackson b74f3a3c10 ErrorKind::NotImplemented: fix two tests 2022-02-14 17:54:05 +00:00
Ian Jackson 02959576bb tor_socksproto::Error HasKind fix two delegations
We should not generally explicitly specify a kind for errors which
contain a more detailed error which itself has a kind.  Stating the
kind literally is a latent bug, which becomes a real bug if the
contained type's kind changes or starts to vary.

(There may be exceptions to this principle but this isn't one of
them.)
2022-02-14 17:46:19 +00:00
Nick Mathewson 9e88f279d9 Merge branch 'error-kind-config-transition' into 'main'
Clarify ErrorKind::InvalidConfigTransition

See merge request tpo/core/arti!309
2022-02-14 16:51:32 +00:00
Ian Jackson 30ebb1358a Split up ErrorKind::NoSupport 2022-02-14 16:06:45 +00:00
Nick Mathewson b27c51d3a2 netdoc: Make doc-build errors a separate type
Every other case of tor_netdoc::Error means a parse failure.  This one,
though, means a failure to construct  a document.
2022-02-14 10:46:04 -05:00
Nick Mathewson eeab17f811 Merge branch 'useless_qm' into 'main'
dirmgr: Remove a useless Ok(x?)

See merge request tpo/core/arti!307
2022-02-14 15:42:51 +00:00
Ian Jackson 3a9a4b6532 Clarify ErrorKind::InvalidConfigTransition 2022-02-14 15:41:40 +00:00
Nick Mathewson 61867613a2 netdoc: remove Error::Untimely.
Nothing creates this.
2022-02-14 10:28:58 -05:00
Nick Mathewson 9e3d0bc817 Merge branch 'update_if_zero' into 'main'
Use atomic set-and-check to update OptTimestamps if none.

See merge request tpo/core/arti!297
2022-02-14 15:18:28 +00:00
Nick Mathewson 8ea95aee7a Simplify wait_for_bootstrap to use a Mutex.
Since the only purpose of this function is to make sure that no
bootstrapping task is running, a simple futures:🔒:Mutex
should do the job just fine.

Closes #337.
2022-02-14 09:59:37 -05:00
Nick Mathewson 2cd4f0c872 dirmgr: Remove a useless Ok(x?)
Found by nightly clippy.
2022-02-14 09:30:18 -05:00
Nick Mathewson 1cecc7e45a Change deny(clippy::all) to warn(clippy::all).
Closes #338.
2022-02-14 09:24:06 -05:00
Nick Mathewson 7da5d557bf Rename bootstrap_existing to bootstrap.
(Looks like this one got missed.)
2022-02-11 12:58:25 -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
eta 5981fa7932 Merge branch 'connect_examples' into 'main'
Write some examples for TorClient::connect()

See merge request tpo/core/arti!303
2022-02-11 16:40:02 +00:00