Commit Graph

1350 Commits

Author SHA1 Message Date
Ian Jackson 409c5dd6d2 Use new upstream humantime_serde_option feature
Replace all uses of our copy of this code.
2022-03-14 10:33:59 +00:00
Ian Jackson 8b8c2a426e humantime: Update to humantime-serde 1.1.1
This has the humantime_serde::option module, which we have upstreamed
and are about to switch to.

The remaining dependency with  version = "1"  is going to be removed
in a moment.
2022-03-14 10:33:59 +00:00
Nick Mathewson a98ae2a1f0 Canonicalize and intern protover lines on descriptors
This should save around 1MB per consensus, since every relay has a
'protocols' lines, but there are only a few distinct possibilities
for such a line.

Closes #385.
2022-03-11 16:56:12 -05:00
Nick Mathewson 16f1bda324 Canonicalize and intern family representations to save memory.
This should save 1-3 MB of ram on each running arti client.

Closes #384. See also tor#27359 and proposal 298.
2022-03-11 16:54:33 -05:00
Ian Jackson 927594c3a6 Merge branch 'arti-lib' into 'main'
arti: Move all code from binary crate to library crate

See merge request tpo/core/arti!403
2022-03-11 19:57:53 +00:00
Nick Mathewson b835a48528 Merge branch 'smaller_routerstatus' into 'main'
tor-netdoc: Save allocation space in GenericRouterstatus

Closes #387

See merge request tpo/core/arti!400
2022-03-11 19:55:22 +00:00
Nick Mathewson 718a1ee340 Add a more generic implementation of intern-by-ref 2022-03-11 14:03:29 -05:00
Nick Mathewson 6f42c79654 netdoc: Call shrink_to_fit() when we're done parsing rs sections
(Once we're done parsing these, the vector will never get any
longer.)
2022-03-11 14:03:29 -05:00
Nick Mathewson 1c6c05fac3 netdoc: allocate no extra space for RouterStatus addresses.
This should save around 181K of heap on a current directory.
2022-03-11 14:03:29 -05:00
Nick Mathewson e7c584f1b3 netdoc: Make versions smaller in GenericRouterStatus
When the version is a Tor version, we can just parse it; otherwise,
we can intern it.  This shrinks GenericRouterStatus and avoids a lot
of extra help allocations.
2022-03-11 14:03:29 -05:00
Nick Mathewson 3c9093f294 tor-netdoc: reformat cargo.toml.
This is the default vscode format, and seems popular elsewhere.
This commit does nothing but reformat.
2022-03-11 14:03:29 -05:00
Nick Mathewson da82c76399 tor-netdoc: Remove unused or_port field from RS.
Part of #387
2022-03-11 14:03:29 -05:00
Ian Jackson 888eea47b3 tor-netdoc: Actually, make TokVal be a Vec
This enum was otiose: its set of valid values is precisely those of a
Vec.  (Indeed what would TokVal::Multi(vec![]) have meant?)
2022-03-11 18:42:01 +00:00
Ian Jackson 8226a68f7c arti library crate: Add another note about panicking 2022-03-11 18:28:37 +00:00
Ian Jackson 3b7d37e218 arti library crate: re-add clippy lints
I ought to have c&p these.

As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/403#note_2786099
2022-03-11 18:28:37 +00:00
Ian Jackson 4a9c660ce2 arti library crate: Add note about panicking 2022-03-11 18:28:37 +00:00
Ian Jackson 32fe5cdd5b arti: Make main module entrypoints pub
This does not constitute any kind of stable API promise.
But it might allow people to use our arti client code in novel ways.
2022-03-11 18:28:15 +00:00
Ian Jackson 4ae5f11c20 arti: Provide some rubric docs. 2022-03-11 18:28:15 +00:00
Ian Jackson e680960619 arti: Move all code from binary crate to library crate
This is just code motion and the minimal fixups.
2022-03-11 18:28:15 +00:00
Ian Jackson 9a7783a230 Remove a pointless slice
std::slice::from_ref exists.  Spotted while reviewing !400
2022-03-11 18:24:03 +00:00
Ian Jackson d320413912 Merge branch 'config-flatten' into 'main'
Make ArtiConfigBuilder contain a TorClientConfigBuilder

See merge request tpo/core/arti!401
2022-03-11 18:22:23 +00:00
Ian Jackson f914eee6bc rustfmt 2022-03-11 16:41:59 +00:00
Nick Mathewson 837c7d717b Follow-up from arti!318
Make update_config only conditionally exported; add semver-status update.
2022-03-11 11:34:51 -05:00
Nick Mathewson d95dce7c70 Merge branch 'add-flatfile-dirmgr' into 'main'
Add flatfile DirMgr

See merge request tpo/core/arti!318
2022-03-11 16:34:26 +00:00
Ian Jackson 1d281abaf8 Make ArtiConfigBuilder contain a TorClientConfigBuilder
This is an API break: now one must use `.tor()` to access the Tor
configuration parts.

But it is not a config file format break, because `#[serde(flatten)]`.
2022-03-11 16:18:27 +00:00
Ian Jackson 0bbee1e477 Make TorClientConfigBuilder Deserialize
As per #371
2022-03-11 16:18:22 +00:00
Christian Grigis 65486b185a
Expose APIs for external DirProvider 2022-03-11 13:44:48 +01:00
Nick Mathewson d9c1555229 dirmgr: Call shrink_to_fit on missing-microdesc hashtable
This hashtable starts out pretty large, but it can spend most of our
runtime (when we aren't downloading) being small.  To avoid doing
too much work, I've made it so we only call shrink_to_fit twice per
consensus: once when we're no longer pending, and once when we're
complete.

Closes #388.
2022-03-10 11:48:58 -05:00
Ian Jackson 6761cf2b69 Merge branch 'config-no-retcon' into 'main'
Drop config back-conversion from FooConfig to FooConfigBuilder

See merge request tpo/core/arti!391
2022-03-10 14:47:01 +00:00
Nick Mathewson 98c5c5b824 Merge branch 'arti-testing-part2' into 'main'
arti-testing: support for simulated TCP breakage

See merge request tpo/core/arti!392
2022-03-10 14:08:44 +00:00
Nick Mathewson d1b151436e arti-testing: Make Action implement Copy 2022-03-10 08:45:56 -05:00
Christian Grigis 335af4ac30
Add methods to `UnverifiedConsensus` 2022-03-10 11:29:58 +01:00
eta 4f34f7cea8 Merge branch 'ticket_391' into 'main'
arti-bench: don't allocate a separate receive-buffer for each job

Closes #391

See merge request tpo/core/arti!395
2022-03-09 13:26:44 +00:00
Ian Jackson 3425a6cbcd Merge branch 'ticket_383' into 'main'
tor-chanmgr: Do not allocate an Internal error unless we mean it.

Closes #383

See merge request tpo/core/arti!394
2022-03-09 11:30:08 +00:00
Nick Mathewson 26bdbc4b61 arti-bench: don't allocate a separate receive-buffer for each job
This makes heap profiling more viable.

Closes #391.
2022-03-08 16:41:06 -05:00
Nick Mathewson a110755193 tor-chanmgr: Do not allocate an Internal error unless we mean it.
Previously we'd allocate an error as a place-holder here, but it's
not a great idea to do that with a `Bug`: each `Bug` stores a whole
stack trace, which uses a whole pile of allocations to construct.

Now we keep an `Option<Error>` instead.

Found while heap profiling.

Closes #383.
2022-03-08 14:04:25 -05:00
Nick Mathewson a460de6e75 arti-testing: reverse two more attrs in attempt to fix min-versions 2022-03-07 15:29:44 -05:00
Nick Mathewson 84536a9c1e arti-testing: reverse two attrs in attempt to fix min-versions 2022-03-07 14:34:02 -05:00
Nick Mathewson de0cf90a32 arti-testing: todo comment cleanup 2022-03-07 11:47:25 -05:00
Nick Mathewson a86f00c222 arti-testing: support for conditional TCP failure. 2022-03-07 11:44:43 -05:00
Ian Jackson 56c2153b9e Merge branch 'fix-expand-tilde-on-windows' into 'main'
Fix expand tilde and invalid path chars on windows

See merge request tpo/core/arti!274
2022-03-07 16:35:15 +00:00
Nick Mathewson 3aed633559 arti-testing: add support for black-holing TCP connections. 2022-03-07 11:26:13 -05:00
Ian Jackson 1b1ce8cc82 Drop remaining conversion from FooConfig to FooConfigBuilder 2022-03-07 15:58:53 +00:00
Ian Jackson 56cb1cef4e Have ArtiConfig contain a TorClientConfig, and drop builder retcon
Replace the recapitulation of TorClientConfig fields in ArtiConfig and
instead just have it contain one.  This is part of #374.

The conversions from ArtiConfig back to ArtiConfigBuilder and
TorClientConfigBuilder would need to change, but, since we don't want
them anyway,

No longer impl Deserialize for ArtiConfig.  (As per #371 this will
want to become a private type.)

No longer impl From<ArtiConfig> for ArtiConfigBuilder and
TorClientConfigBuilder.  And abolish tests of that code.

(This all has to be in one commit, because previously
ArtiConfig::tor_client_config used the validated-to-builder config
retcon.)
2022-03-07 15:58:53 +00:00
Ian Jackson 92d1855b0e Provide way to get TorConfigBuilder from ArtiConfigBuilder
This is needed according to #372, where we observe that builders ought
not to be generated from validated structs.  So we need this
conversion.
2022-03-07 15:58:53 +00:00
Ian Jackson 56bd15b671 Derive Deserialize for handwritten ArtiConfigBuilder 2022-03-07 15:58:53 +00:00
Ian Jackson 5203311a97 Derive Deserialize for derive-builder-generated config builders
I used
  git-grep -P '\#\[serde\((?!default|deny_unknown)'
to find places where I needed to add additional attributes on the
builder method fields.

This is currently a bit duplicative, but when #371 is completely done,
the validated (non-builder) configs won't need to be Deserialize any
more.

This is part of #371 and #372.
2022-03-07 15:58:53 +00:00
Ian Jackson 416b56d852 Use git source for derive_builder for now, for attrs feature
We are going to want to specify custom attributes on fields of the
builder struct.  This feature was missing from derive_builder.

This commitid is the current head of my MR branch
  https://github.com/colin-kiegel/rust-derive-builder/pull/237
  https://github.com/ijackson/rust-derive-builder/tree/builder-field-attrs
Using the commitid prevents surprises if that branch is updated.

We will require this newer version of derive_builder.  The version
will need to be bumped again later, assuming the upstream MR is merged
and upstream do a release containing the needed changes.
2022-03-07 15:56:57 +00:00
Nick Mathewson 5d91fa7f5a arti-testing: CLI for making TCP connections break. 2022-03-07 10:52:04 -05:00
eta c27dde59b6 Merge branch 'moderately-enthused-eyeballs' into 'main'
Implement a basic form of RFC 8305 ("happy eyeballs") for channels

See merge request tpo/core/arti!382
2022-03-07 15:26:37 +00:00
Nick Mathewson ca6070b962 arti-testing: Initial support for broken TCP.
This commit adds support for a BrokenTcp provider that can make
connection attempts fail or time out.  It doesn't yet have a way to
turn on the failure.
2022-03-07 10:12:48 -05:00
eta c98d9dc5fe Implement a basic form of RFC 8305 ("happy eyeballs") for channels
This makes Arti usable in IPv6-only environments (arti#92) by letting us
attempt multiple connections to a given relay using all of its
addresses instead of just using the first (probably IPv4) one, using the
strategy from RFC 8305 § 5.

This isn't a complete implementation of Happy Eyeballs; ideally, we'd
sort the address list before doing concurrent connections. However, it
works (and has been tested inside an IPv6-only container inside eta's
network :p)
2022-03-07 14:56:51 +00:00
Nick Mathewson cc6ba72dc3 Merge branch 'bench_multicirc' into 'main'
arti-bench: support multiple streams per circuit, multiple circuits per sample.

Closes #380

See merge request tpo/core/arti!384
2022-03-07 14:11:53 +00:00
Nick Mathewson 49216a5202 arti-bench: documentation fixes 2022-03-07 08:42:20 -05:00
Nick Mathewson 22ee7671f8 arti-bench: record streams_per_circ and circs_per_sample. 2022-03-07 08:38:02 -05:00
Ian Jackson 6193c9d974 humantime_serde_option: New module in tor-basic-utils
This will be used to allow our config *builder* structs to be
Deserialize.
2022-03-07 12:38:30 +00:00
Michael 206714f2e4 Test shell variable expansion on windows 2022-03-05 01:40:42 +00:00
Lennart Kloock ef21559df1
Add config paths table in `arti` docs 2022-03-04 22:43:14 +01:00
Nick Mathewson cb846de367 Merge branch 'reproducible-build-fix-summary-git' into 'main'
fix reproducible build summary giving invalid branch and commit id

Closes #378

See merge request tpo/core/arti!383
2022-03-04 19:52:19 +00:00
Nick Mathewson 994a8f7cfa Merge branch 'errors-for-dirprovider' into 'main'
Errors for dirprovider

Closes #370

See merge request tpo/core/arti!385
2022-03-04 19:51:23 +00:00
trinity-1686a 5e5864802d fix reproducible build summary giving invalid branch and commit id
fix #378
also fix unrelated error in nightly rustdoc CI
2022-03-04 19:25:40 +01:00
Ian Jackson b095265257 Merge branch 'educe-traits' into 'main'
Replace many manual trait impls with use of educe

See merge request tpo/core/arti!375
2022-03-04 18:00:17 +00:00
Nick Mathewson e4ed8241ba Fix an unwrap() error. 2022-03-04 12:37:22 -05:00
Ian Jackson 055b7399f2 Provide ErrorKind::Other 2022-03-04 17:35:34 +00:00
Ian Jackson 4bff33c397 Provide an error variant for external directory providers 2022-03-04 17:35:34 +00:00
Ian Jackson 952aef1be3 Merge branch 'hex_decode' into 'main'
Speed up RsaIdentity decoding

Closes #377

See merge request tpo/core/arti!381
2022-03-04 17:22:52 +00:00
Nick Mathewson 8c34896651 arti-bench: use isolation to support multiple circuits per run. 2022-03-04 12:22:43 -05:00
Ian Jackson 0cfb6a0e0f tor-basic-utils: copy the README into lib.rs
The doc include rune does not work with our MSRV; it needs 1.54.

The alternative would be some kind of cfg() but that would
  - not provide the crate-level doc on Rust 1.53
  - involve the use of cfg_attr

Instead, just do it the old way.
2022-03-04 16:54:54 +00:00
Nick Mathewson 42245de9f5 arti-bench: simplify future-creation code slightly 2022-03-04 11:45:45 -05:00
Nick Mathewson c978a0d78b arti-bench: refactor stream construction to connect in parallel
Previously we tried to do each connection in a run, and only then did we
start transferring data over them.  Now we collect a bunch of the
futures that return an open stream, and run them all in parallel
with using them.  This change includes connect-time in our
benchmarks, and allows us to test contention in our connect code.

Instead of using a Stream, I've changed the connection-generation
code to call a future-returning function directly, so we have a way
to explicitly pass which run we're in.
2022-03-04 11:41:51 -05:00
eta 8d26726fdf Merge branch 'arti-testing-part1' into 'main'
arti-testing: Initial implementation

See merge request tpo/core/arti!378
2022-03-04 16:29:41 +00:00
Nick Mathewson c23dad8c2d Use RsaIdentity::from_hex() and hex::decode_to_slice in more places
These aren't critical-path, but they do make the code a little nicer.
2022-03-04 09:23:26 -05:00
Nick Mathewson caf372ac0f tor-netdoc: Use RsaIdentity::from_hex() in critical path.
This commit changes the main parsing code for RsaIdentity in
tor-netdoc, and .

Previously, parse_hex_ident was something like 10% of our startup
CPU time; now it's only like ~2%.  (Still not perfect, but way
better.)

Closes #377.
2022-03-04 09:05:04 -05:00
Nick Mathewson b6452b4812 Add a from_hex method for RsaIdentity.
We perform this operation in a bunch of places, and most of them
use hex::decode().  That's not great, since hex::decode() has to do
heap allocation.  This implementation uses hex::decode_to_slice(),
which should be faster.

(In the future we might choose to use one of the faster hex
implementations, but I'm hoping that this change will be sufficient
to get hex decoding out of our profiles.)

Part of #377.
2022-03-04 08:55:34 -05:00
Ian Jackson 6e1da0145b Remove now-obsolete note about location of skip_fmt
Now the diff from the merge base does not contain any hits for ^\+.*bytes
2022-03-04 11:45:24 +00:00
Ian Jackson ebfd734956 Move skip_fmt into tor-basic-utils
Code motion and the minimal mechanical changes.

As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/375#note_2783078
2022-03-04 11:45:24 +00:00
Ian Jackson aba68088d1 Introduce tor-basic-utils
Empty crate right now
2022-03-04 11:45:24 +00:00
Ian Jackson eb66d0af6f Merge branch 'derive-traits' into 'main'
Tidy up many open-coded trait impls

See merge request tpo/core/arti!374
2022-03-04 11:25:57 +00:00
Ian Jackson 64cc5b8537 Move educe to dev-dependencies of tor-bytes
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/375#note_2783080

This is going to move to a new crate, but doing this now makes
things slightly clearer for me.
2022-03-04 11:03:04 +00:00
eta e9f8ddfb9c Fix introduced junk in doc comment. 2022-03-04 10:56:40 +00:00
Ian Jackson 2a7915e6f6 Merge branch 'return_ref_arc' into 'main'
arti-client: Make dirmgr() and circmgr() return &Arc<..>

Closes #369

See merge request tpo/core/arti!379
2022-03-04 10:55:21 +00:00
Nick Mathewson a4914b990b arti-client: Make dirmgr() and circmgr() return &Arc<..>
Previously they returned an Arc, which wasn't necessary unless the
client actually _wanted_ a new Arc.

This would be an API break, except that these functions are marked
'experimental-api', so semver does not apply; nonetheless I've noted
the break in semver_status.md, just in case we care.

Closes #369
2022-03-03 14:08:27 -05:00
Nick Mathewson 06f0339b97 Allow println in arti-testing. 2022-03-03 14:01:44 -05:00
Nick Mathewson 9329c7b878 arti-testing: Initial implementation
This commit adds a new program to try to implement the ideas behind
experimentation in arti#329.  In particular, it tries to implement
basic client "can I bootstrap and connect" functionality testing,
with a lot of instrumentation, and support for breaking things.

So far, the instrumentation is limited to counting TCP bytes and
connections, and counting events.  Still, this is enough to measure
behavior on some of the incorrect-clock tests.

NOTE:

For now, you are _required_ to pass in an explicit configuration, in
hopes that this will lead you to override your storage directories
for doing specific experiments.
2022-03-03 13:05:30 -05:00
eta 64c8ee0d1f Merge branch 'shellexpand' into 'main'
Switch to shellexpand-fork version of shellexpand

See merge request tpo/core/arti!373
2022-03-03 14:31:52 +00:00
Ian Jackson b27ffe14fb Merge branch 'dir-provider-redux' into 'main'
Alternative DirProvider setup

See merge request tpo/core/arti!347
2022-03-02 18:41:50 +00:00
Ian Jackson daa44df221 Replace manual Default impls with educe in tor-guardmgr 2022-03-02 18:06:37 +00:00
Ian Jackson 738f7efa3d Replace manual Default impl with educe in tor-dirmgr 2022-03-02 18:06:37 +00:00
Ian Jackson 4fbb088907 Replace manual Default impl with educe+std in tor-dirmgr 2022-03-02 18:06:37 +00:00
Ian Jackson bb1d59e073 Replace manual Default impl with educe in tor-cell 2022-03-02 18:06:37 +00:00
Ian Jackson ac0ed6ab65 Replace manual Default impls on enums with educe in arti-client 2022-03-02 18:06:37 +00:00
Ian Jackson 2a782a71c0 Refrain from replacing manual with educe Debug impl in caret
Instead, leave a comment saying we have left it this way deliberately.
2022-03-02 18:06:37 +00:00
Ian Jackson 1b8a8f933a Replace manual Debug impl with educe in arti-client 2022-03-02 18:06:37 +00:00
Ian Jackson decdd05ec5 Replace manual Clone impl with educe in arti-hyper 2022-03-02 18:06:37 +00:00
Ian Jackson ea03cc4084 Replace manual Clone impl with educe in tor-rtcompat 2022-03-02 18:06:37 +00:00
Ian Jackson 9dca756e23 Replace manual Debug impls with educe in tor-proto
We now print slighly more information.
2022-03-02 18:06:37 +00:00
Ian Jackson 210b9b70a8 Replace manual Debug impl with educe in tor-dirmgr 2022-03-02 18:06:37 +00:00
Ian Jackson f467f4666e Replace manual Debug impl with educe in tor-chanmgr 2022-03-02 18:06:37 +00:00
Ian Jackson 1c44dfa595 Replace manual Debug impl with educe in tor-cell 2022-03-02 18:03:00 +00:00
Ian Jackson b2d8c14c90 Replace manual Debug impl with educe in tor-guardmgr 2022-03-02 18:03:00 +00:00
Ian Jackson f474a583f1 Replace manual Debug impl with educe in tor-circmgr 2022-03-02 18:03:00 +00:00
Ian Jackson c1b80d6503 Import educe into tor-bytes and provide skip_fmt
Preparatory work for getting rid of some manual Debug impls
2022-03-02 18:03:00 +00:00
Ian Jackson 42f9b3c186 Replace manual Default, and abolish new, in tor-rtcompat
The Default impl was the only call site for new()
2022-03-02 18:01:18 +00:00
Ian Jackson 89074a1326 Replace manual Default and new with std derive in tor-proto 2022-03-02 18:01:08 +00:00
Ian Jackson 535e4ff118 Replace manual Default and new with std derive in tor-netdoc 2022-03-02 18:01:08 +00:00
Ian Jackson 4dfd1ef9cd Replace manual Default and new with std derive in tor-dirclient 2022-03-02 18:01:08 +00:00
Ian Jackson e45a95f65a Replace manual Default impl with std derive in tor-config 2022-03-02 18:01:08 +00:00
Ian Jackson 2becfcf894 Replace manual Default impl with std derive in tor-cell 2022-03-02 18:01:08 +00:00
Ian Jackson 486c73b6b7 Replace manual Clone impl with std derive in retry-error
This just clones the fields.  It is not clear to me why it was
written this way in be86df631d
   Remove anyhow dependency from tor-retry, and rename it to retry-error

Previously, I think, RetryError wasn't Clone.
2022-03-02 17:04:07 +00:00
Ian Jackson 90f86b47e4 Replace manual Debug impl with std derive in tor-circmgr
When I wrote this, I arranged to skip dumping the field `pending`.
This must have been because I thought that either

(a) PendingEntry couldn't `#[derive(Debug)]` (but it can)

and/or

(b) Some of the fields of PendingEntry ought not to be dumped because
they might contain (eg) packet data.  But I think they don't: there's
just the spec, and the Result which is (basically) a Circ.

I tried preseving something closer to the original using educe, but
educe gets somehow tangled up with the generics, and the result fails
to compile.  I haven't investigated this further.
2022-03-02 17:04:07 +00:00
Ian Jackson d1e8aa1dbd tor-llcrypto: Replace a tiny bit of code duplication with a call
No functional change.
2022-03-02 17:04:07 +00:00
Nick Mathewson 241fbd8746 Have caller of dirmgr_builder() provide Arc. 2022-03-02 12:01:26 -05:00
Ian Jackson 7a4369e240 tor-llcrypto: Add test case for RsaIdentity formatting
I'm going to change the code that does this, so add a test first
to check the output doesn't change.

At some point we should have more RSA tests.
2022-03-02 16:25:01 +00:00
Ian Jackson 72bb8e7f28 Switch to shellexpand-fork version of shellexpand
Apropos discussion in
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/274
2022-03-02 12:14:51 +00:00
Nick Mathewson 83c8b11c2c Merge branch 'clippy-allow-arc-clone' into 'main'
Disable clippy::clone_on_ref_ptr

See merge request tpo/core/arti!352
2022-03-01 20:38:05 +00:00
Nick Mathewson e8e9791a97 Bump all crates to 0.1.0 2022-03-01 08:59:34 -05:00
Nick Mathewson 5735222691 Update README.md files from rustdoc. 2022-03-01 08:30:53 -05:00
Nick Mathewson 57a8fe5f55 Fix rustdoc errors. 2022-03-01 08:16:02 -05:00
Nick Mathewson 224252f082 Run rustfmt. 2022-03-01 08:13:05 -05:00
Nick Mathewson f4a0aefae5 Merge remote-tracking branch 'origin/mr/371' 2022-03-01 08:12:51 -05:00
Nick Mathewson 132416275d Merge branch '010_docs' 2022-03-01 08:08:56 -05:00
Ian Jackson 4fa78e3f44 arti-hyper: Upgrade from an example to an "adaptation layer" 2022-03-01 11:53:15 +00:00
Ian Jackson b083ae661e arti-hyper: Expand docs 2022-03-01 11:53:13 +00:00
Ian Jackson 5533fef4f3 arti-hyper: Drop obsolete comment about not doing TLS 2022-03-01 11:53:12 +00:00
Ian Jackson d80f3198ea arti-client: Add stability warning to config module 2022-03-01 11:34:07 +00:00
Ian Jackson 5610cec095 Merge branch 'main' into hyper-docs 2022-03-01 11:02:46 +00:00
Ian Jackson 66f53b6a9a Merge branch 'main' into 364
Conflicts:
	crates/arti-hyper/examples/hyper.rs

Trivially resolved.  Hyper example still works.
2022-03-01 10:36:02 +00:00
Ian Jackson bda9f82c55 Merge branch 'main'
Fixed conflict in crates/arti-client/src/lib.rs as per tree
from
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/364/#note_2782166
ie 13e55b8d7c22c26e55ba75823409b477f1bce66b
2022-03-01 10:28:06 +00:00
Nick Mathewson 7d826e6da1 Merge branch 'tls' into 'main'
Implement TLS in arti-hyper

See merge request tpo/core/arti!355
2022-02-28 20:02:41 +00:00
Nick Mathewson d2eb2ede81 Merge branch 'retry-err-circmgr' into 'main'
add some error to retry_error instead of dropping it

See merge request tpo/core/arti!368
2022-02-28 19:47:01 +00:00
trinity-1686a dcd32f4d00 typo 2022-02-28 20:31:22 +01:00
Nick Mathewson 9bf69f551e Update our stability warning on arti-client. 2022-02-28 14:29:50 -05:00
Nick Mathewson dd8cd08691 Add warnings about configuration stability. 2022-02-28 14:25:24 -05:00
trinity-1686a 0fc7f40575 resolve comment 2022-02-28 20:05:17 +01:00
trinity-1686a 2d430ea69e add some error to retry_error instead of dropping it 2022-02-28 19:30:40 +01:00
trinity-1686a 55a1433499 remove usage of dbg!(..)
it's making rust-nightly job fail
2022-02-28 18:20:34 +01:00
eta 13ba0ea005 arti-client: use PreferredRuntime by default, doc cleanups
This makes using the `PreferredRuntime` the first-class option inside
`arti-client`, freeing users who don't want to think about runtimes from
having to do so.

`TorClient::create_unbootstrapped` and `builder` now automatically
use this runtime, leaving only `builder_custom` for users who wish to
manually specify a runtime.

This lets us clean up the docs a lot: mentions of using custom runtimes
are now relegated to nearer the end of the crate-level documentation,
and we mostly just link to `tor_rtcompat`'s docs to explain more there.
Instead, we take some more time to explain how you use the builder API
to create clients synchronously.

Other doc cleanups included getting rid of the explanation of `TorAddr`
in the main crate-level doc; this is already well-documented elsewhere,
and is something users should discover organically later.

fixes arti#326
2022-02-28 16:41:13 +00:00
Nick Mathewson be288399ec Merge branch 'teardown' into 'main'
tor-circmgr: take_action: Handle Cancelled from the oneshot

Closes #365

See merge request tpo/core/arti!363
2022-02-28 15:16:03 +00:00
Nick Mathewson ec25f68b9b Fix typo in message 2022-02-28 14:47:25 +00:00
Ian Jackson cdbb904664 arti-hyper: Add vacuous doc comments as required by clippy 2022-02-28 14:39:43 +00:00
eta d3d34c6c2e Merge branch 'split-static' into 'main'
Split "static" into sqlite and native-tls features.

Closes #302

See merge request tpo/core/arti!362
2022-02-28 13:41:27 +00:00
eta 1276f71e9a Merge branch 'always-coarsetime' into 'main'
Make coarsetime dependency and traffic-timestamping non-optional.

See merge request tpo/core/arti!358
2022-02-28 13:39:10 +00:00
Ian Jackson 8898bbb421 EK::RemoteProtocolFailed replaces OtherRemote
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/355#note_2781816
2022-02-28 13:27:44 +00:00
Ian Jackson 4425171245 Fix rustfmt
I disagree with all these.  Whatever.
2022-02-28 13:17:41 +00:00
Nick Mathewson 12a83e9661 Merge branch 'fix/210' into 'main'
don't return already errored pending circuit when searching new circuit matching spec

Closes #210

See merge request tpo/core/arti!366
2022-02-28 13:16:31 +00:00
Ian Jackson 551bc69045 arti-hyper: Abolish a bool in favour of a custom private enum
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/355#note_2781820
2022-02-28 13:16:25 +00:00
Ian Jackson adfabe6cd1 arti-hyper: Box the http variant (bare DataStream)
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/355#note_2781819
2022-02-28 13:12:20 +00:00
Ian Jackson 4705234a49 arti-hyper: Fix duplicative doc comment not to be wrong 2022-02-28 13:07:44 +00:00
Ian Jackson 85e7d4b088 arti-hyper: Drop description of nonexistent error-detail feature 2022-02-28 13:07:44 +00:00
Ian Jackson 51c9cec1f1 arti-hyper: Clarify what the TLS features do. 2022-02-28 13:07:44 +00:00
Ian Jackson c24c3af81b arti-hyper: Actually support TLS 2022-02-28 13:07:44 +00:00
Ian Jackson c397c772e6 arti-hyper: Provide TLS connector and make space for TLS stream
Add tls_conn field to ArtiHttpConnector (and argument to constructor).
Introduce MaybeHttpsStream and use it in ArtiHttpConnection.
Have the example program pass the native TLS connector.

Currently the TLS connector and the HTTPS variant are not used, but
this commit is very noisy and fomrulaic, so I have split out the code
to use them into a separate commit for easier preparation and review.
2022-02-28 13:07:44 +00:00
Ian Jackson 148cd61f2b Manually implement Clone for ArtiHttpConnector
This will be needed in a moment and doing it now makes the next patch
smaller and hence easier to read.
2022-02-28 13:07:44 +00:00
Ian Jackson c08a317093 Introduce ErrorKind::OtherRemote
arti-hyper wants to be able to have a kind for TLS failure.

Given that arti-hyper is above arti-client, this shows that callers
above arti-client might need to invent kinds for their own errors.

Possibly this means we need other Other errors for other locations.
If we have pluggable components we might even want OtherTorError.
2022-02-28 13:07:44 +00:00
Ian Jackson 9a729aa2f8 arti-hyper: Disable clippy::clone_on_ref_ptr
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/355#note_2781816
disable this here for now, pending a decision on !352
2022-02-28 13:07:08 +00:00
Ian Jackson 23f8d33d4d Add a debug! log message for source cancellation 2022-02-28 12:52:38 +00:00
Ian Jackson 6d01c60925 Fix rustfmt 2022-02-28 12:36:48 +00:00
Nick Mathewson 76d8338640 Fix two typos 2022-02-28 11:21:52 +00:00
trinity-1686a 5323825964 don't return already errored pending circuit when searching new circuit matching spec 2022-02-27 13:16:03 +01:00
trinity-1686a f06b256010 use wallclock where possible in tests 2022-02-26 00:33:44 +01:00
trinity-1686a 96daba7747 fix tests 2022-02-25 20:45:16 +01:00
trinity-1686a f9a4f23e83 remove most usage of SystemTime::now 2022-02-25 20:34:27 +01:00
Ian Jackson dbf019e426 tor-circmgr: take_action: Handle Cancelled from the oneshot
Fixes #365

Inspection of the code and logs shows that:
 * One of the plan futures' oneshots must be returning Cancelled
 * This means that the corresponding sender must have been dropped
 * The sender is owned by the task spawned by spawn_launch
Presumably that entire task gets dropped as part of executor shutdown,
or something.

The correct response in this situation is to declare that we are
shutting down, and stop trying to do stuff.

Unfortunately, despite trying quite hard by putting sleeps in various
strategic places, I have not been able to reproduce the problem.  So I
can't be 100% sure that the new behaviour is correct.

But I am reasonably confident that this ought not to be able to occur
unless either 1. the task from spawn_launch is dropped, or 2. that
task somehow panics despite its attempts to trap panics and report
them as errors through the oneshot.

So this "burn it all down" action ought only to occur in actually
serious situations.

I observe that
  3ff9b187ea
  Handle panics from circuit construction.
changed the EK for PendingCanceled to EK::ReactorShuttingDown,
and there's From impl.  I think, therefore, that it is right
to reuse this Error variant.

I don't quite understand why when take_action gets an actual error it
doesn't push it, but just logs it.  But I am not changing that for
now.

Arguably the two instances of retry_error.push are a sign of an
inferior flow control pattern - maybe the loop body including the code
I am adding ought to be an IEFE returning
`Result<Option<circ>, crate::Error>`.
2022-02-25 18:10:36 +00:00
Nick Mathewson 489da37fe4 Split "static" into sqlite and native-tls features.
Otherwise, it's impossible to get a static sqlite linkage without
also getting native-tls, even if you wanted rustls.

Closes #302.
2022-02-25 13:05:25 -05:00
Ian Jackson 6b615b4766 impl Debug for various internal types
I wanted this while debugging something.

The ad-hoc impl Debug with f.debug_struct is getting repetitive
and I've already perpetrated one copy-paste mistake.
We should consider using something like the `educe` crate's Clone.
2022-02-25 17:37:10 +00:00
eta 387ebda740 tor-rtcompat: refactor PreferredRuntime, clean up docs
`PreferredRuntime` is now an opaque wrapper struct that contains the
"actual" preferred runtime as a type alias. The `current_user_runtime`
and `create_runtime` functions become `PreferredRuntime::current` and
`PreferredRuntime::create`, respectively.

This removes the dependence on `impl Trait`, meaning we can now name the
returned runtime (yay!).

In addition, the documentation was cleaned up a bit to make it
(hopefully) flow better. Items that don't make sense to publicize, like
testing implementation details, have been marked #[doc(hidden)] and
semver warnings added.
2022-02-25 17:34:05 +00:00
Nick Mathewson 6755648f6b Merge branch 'upgrade-dependencies' into 'main'
Upgrade a few dependencies to newer versions

See merge request tpo/core/arti!357
2022-02-25 16:30:00 +00:00
Nick Mathewson 326e77c66c Update minimum backtrace version to 0.3.39
This is needed to make the backtrace test pass on Rust 1.53 with
minimum-version libraries.
2022-02-25 11:09:24 -05:00
Nick Mathewson 4becaa01b9 Bump minimum tokio to 1.7, since tokio-util now needs that. 2022-02-25 11:09:24 -05:00
Nick Mathewson 3d7d609922 Make coarsetime dependency and traffic-timestamping non-optional.
Previously coarsetime and the traffic-timestamp feature were
enabled, since they were only required for a small corner of the
guardmgr algorithm.

But in 1.0 and beyond we'll be adding a bunch of other features (eg,
netflow padding, DoS prevention) that will need coarsetime all over
the place.

And since we're going to be doing coarsetime all over the place, the
previous justification for making traffic-timestamping optional (the
tiny performance hit) is no longer relevant.
2022-02-25 10:31:01 -05:00
Nick Mathewson 2f2ba8db5f DirProvider: Fix infinite recursion bug 2022-02-25 09:41:45 -05:00
Nick Mathewson a3bc59918d Upgrade to newer version of config crate. 2022-02-25 09:20:48 -05:00
eta 3d623f5a1f Merge branch 'tcp-hook-new-tls' into 'main'
use runtime TlsProvider in tcp-hook example

See merge request tpo/core/arti!356
2022-02-25 14:15:59 +00:00
eta d549844c1a Merge branch 'debug-datastream' into 'main'
tor-proto datastream: Fix typo in Debug impl

See merge request tpo/core/arti!354
2022-02-25 14:15:45 +00:00
Nick Mathewson 55416937cc Upgrade dependency to new version of tokio-util. 2022-02-25 08:48:00 -05:00
Nick Mathewson c627f50544 Upgrade dependency to new version of rlimit. 2022-02-25 08:45:24 -05:00
Ian Jackson 0ebab3df0b Merge branch 'get-runtime' into 'main'
TorClient: Add get_runtime() convenience method

See merge request tpo/core/arti!350
2022-02-25 13:36:34 +00:00
trinity-1686a f633276a91 use runtime TlsProvider in tcp-hook example 2022-02-25 13:42:14 +01:00
Ian Jackson 3903900461 tor-proto datastream: Fix typo in Debug impl
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/353#note_2781632
2022-02-25 12:23:49 +00:00
Ian Jackson 0ad45d437c Merge branch 'tls-trait' into 'main'
tor-rtcompat: Provide TLS wrapping for all streams

See merge request tpo/core/arti!349
2022-02-25 11:13:34 +00:00
Ian Jackson 310779c39d TorClient:runtime(): rename from get_runtime
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/350#note_2781368
2022-02-25 10:45:30 +00:00
eta 3e37d7e105 Merge branch 'debug-datastream' into 'main'
tor-proto datastream: Do not dump packet data in DataWriterImpl

See merge request tpo/core/arti!353
2022-02-24 21:30:52 +00:00
eta 3ac6ee71c8 Merge branch 'eta/335' into 'main'
arti-client: Unlock the state manager on failure to bootstrap

Closes #335

See merge request tpo/core/arti!334
2022-02-24 21:00:33 +00:00
eta 8f9831b219 Merge branch 'socks-version-is-http' into 'main'
make arti return a web page when receiving http request on socks port

See merge request tpo/core/arti!348
2022-02-24 20:48:28 +00:00
eta c6fdd7c003 arti-client: Unlock the state manager on failure to bootstrap
`StateMgr` got a new `unlock()` method that does what it says on the
tin. We now call it from `bootstrap()` using the new
`util::StateMgrUnlockGuard`, which works in a manner similar to the
`BoolResetter` from `tor_dirmgr`.

(A decent small little task in future might be to unify these types in
some sort of general arti utility crate?)

closes arti#335
2022-02-24 19:55:59 +00:00
eta d9df4d647d Merge branch 'http-layer' into 'main'
Initial cut of hyper bindings as a library crate

See merge request tpo/core/arti!342
2022-02-24 19:48:35 +00:00
Ian Jackson 78ab634ed9 Fix rustfmt 2022-02-24 19:45:58 +00:00
Nick Mathewson 7f3ea03e58 Merge branch 'proto_handshake_err' into 'main'
tor-proto: Split up a couple of handshake-based errors

Closes #359 and #358

See merge request tpo/core/arti!344
2022-02-24 19:44:34 +00:00
Ian Jackson f3520478b1 tor-proto datastream: Do not dump packet data in DataWriterImpl 2022-02-24 19:39:18 +00:00
Ian Jackson 097c852e58 tor-proto datastream: import std::fmt::Debug trait name 2022-02-24 19:39:18 +00:00
eta 3e4358c5d3 Merge branch 'remote_stream_err' into 'main'
Give specific error kinds to different END reasons

Closes #360

See merge request tpo/core/arti!343
2022-02-24 19:31:41 +00:00
trinity-1686a 65b71a190f use less magic in http check 2022-02-24 20:03:42 +01:00
eta b5cd85b401 Merge branch 'debug-datastream' into 'main'
impl Debug for DataStream (and its components)

See merge request tpo/core/arti!351
2022-02-24 18:36:19 +00:00
Nick Mathewson d8120e1649 proto: Refactor conversion from CodecError to Error
Remove default conversion; instead use a specific conversion in each
of the two modules that need to do it.
2022-02-24 13:23:42 -05:00
Ian Jackson afb50fe735 Disable clippy::clone_on_ref_ptr
This lint is IMO inherently ill-conceived.

I have looked for the reasons why this might be thought to be a good
idea and there were basically two (and they are sort of contradictory):

I. "Calling ‘.clone()` on an Rc, Arc, or Weak can obscure the fact
    that only the pointer is being cloned, not the underlying data."

This is the wording from
  https://rust-lang.github.io/rust-clippy/v0.0.212/#clone_on_ref_ptr

It is a bit terse; we are left to infer why it is a bad idea to
obscure this fact.  It seems to me that if it is bad to obscure some
fact, that must be because the fact is a hazard.  But why would it be
a hazard to not copy the underlying data ?

In other languages, faliing to copy the underlying data is a serious
correctness hazard.  There is a whose class of bugs where things were
not copied, and then mutated and/or reused in multiple places in ways
that were not what the programmer intended.  In my experience, this is
a very common bug when writing Python and Javascript.  I'm told it's
common in golang too.

But in Rust this bug is much much harder to write.  The data inside an
Arc is immutable.  To have this bug you'd have use interior mutability
- ie mess around with Mutex or RefCell.  That provides a good barrier
to these kind of accidents.

II. "The reason for writing Rc::clone and Arc::clone [is] to make it
     clear that only the pointer is being cloned, as opposed to the
     underlying data. The former is always fast, while the latter can
     be very expensive depending on what is being cloned."

This is the reasoning found here
  https://github.com/rust-lang/rust-clippy/issues/2048

This is saying that *not* using Arc::clone is hazardous.
Specifically, that a deep clone is a performance hazard.

But for this argument, the lint is precisely backwards.  It's linting
the "good" case and asking for it to be written in a more explicit
way; while the supposedly bad case can be written conveniently.

Also, many objects (in our codebase, and in all the libraries we use)
that are Clone are in fact simply handles.  They contain Arc(s) (or
similar) and are cheap to clone.  Indeed, that is the usual case.

It does not make sense to distinguish in the syntax we use to clone
such a handle, whether the handle is a transparent Arc, or an opaque
struct containing one or more other handles.

Forcing Arc::clone to be written as such makes for code churn when a
type is changed from Arc<Something> to Something: Clone, or vice
versa.
2022-02-24 18:15:44 +00:00
Ian Jackson b56115a04f impl Debug for DataStream (and its components)
My proximate motivation is that tls-api wants its inner streams to be
Debug.  But in general, I agree with the Rust API Guidelines notion
that almost everything should be Debug.

I have gone for the "dump all the things" approach.  A more nuanced
approach would be possible too.
2022-02-24 17:49:34 +00:00
Ian Jackson 5f83b2b7be Fix rustdoc "skip this" markup 2022-02-24 16:19:28 +00:00
Ian Jackson 82af514926 TorClient: Add get_runtime() convenience method 2022-02-24 14:33:30 +00:00
Ian Jackson 2bbd01b060 tor-rtcompat: Provide TLS wrapping for all streams
Now all of the runtime types we provide all
  impl<S> TlsProvider<S> where S: ...
rather than merely TlsProvider<Self::TcpStream>.

And we document and intent to perhaps require this in the future.
2022-02-24 14:26:38 +00:00
Nick Mathewson 0600613110 Merge branch 'dir-store-redux' into 'main'
Dir store redux

See merge request tpo/core/arti!345
2022-02-24 13:58:54 +00:00
trinity-1686a e9b42938ec make arti return a web page when receiving http request on socks port 2022-02-23 23:03:42 +01:00
Nick Mathewson ed2a5de9b4 Add a builder function for replacing a DirProvider.
Put it behind experimental_api.
2022-02-23 15:23:09 -05:00
Nick Mathewson 9aeb967010 Un-parameterize DirProvider.
This patch removes the EventStream associated type and the Runtime
parameter.  The Runtime parameter wasn't actually used for anything,
and the EventStream was easy enough to replace with a BoxStream in
this case.

Also replaced DirBootstrapEvents with a BoxStream to avoid tying
anything to our backend.
2022-02-23 14:46:17 -05:00
Christian Grigis 279b5978b7 Add basic DirProvider trait, use it in client 2022-02-23 14:11:21 -05:00
Dimitris Apostolou a3c1ba4b1a
Fix typos 2022-02-23 21:07:05 +02:00
tharvik b28803d861 dirmgr::Store.expire_all takes config 2022-02-23 13:56:52 -05:00
tharvik 8658052ce3 dirmgr: add Store trait 2022-02-23 13:50:33 -05:00
eta 8603a90fb2 Merge branch 'custom-tcp-hook' into 'main'
add example of tcp hook

See merge request tpo/core/arti!341
2022-02-23 18:02:08 +00:00
trinity-1686a 078a91c591 add one more comment to hook-tcp 2022-02-23 18:00:35 +01:00
Nick Mathewson 74a5ce8635 tor-proto: refactor handshake protocol errors to a different type
This helps the user distinguish between protocol violations that
happen when connecting to the tor network from those that happen
while connected.

Closes #358.
2022-02-23 10:39:08 -05:00
Nick Mathewson d42b932ed9 tor-proto: Rename BadHandshake to BadCircHandshake
(We'll have a BadChanHandshake soon.)
2022-02-23 10:39:08 -05:00
Nick Mathewson afa49eac8f tor-proto: Split IoErr based on when it occurs
We want to distinguish handshake failures from errors later on in
the channel's lifetime.

Closes #359.
2022-02-23 10:38:48 -05:00
Ian Jackson fc35ffd6cd arti-hyper: impl HasKind for ConnectionError 2022-02-23 14:35:41 +00:00
Ian Jackson d7d0f52ef6 arti-hyper: Add note about missing https support 2022-02-23 14:35:41 +00:00
Ian Jackson 89146f37fb arti-hyper: Add vacuous doc comments to placate clippy 2022-02-23 14:35:41 +00:00
Ian Jackson 03de9f727c arti-hyper: Move support code into library
Pure code motion.  (Including motion/copying of "use" lines.)
2022-02-23 14:35:40 +00:00
Nick Mathewson 6c615898e4 Give specific error kinds to different END reasons
Closes #360.
2022-02-23 09:35:28 -05:00
Ian Jackson 80d8edc51f arti-hyper: Introduce new ConnectionError type
We need this not to use anyhow because we don't want our libraries to
expose anyhow, and this is about to go into the library.
2022-02-23 14:34:53 +00:00
Ian Jackson fe864c17c6 impl From<TorAddrError> for tor_error::Error
It auto-converts to ErrorDetail but add this for convenience of
callers which don't want to look into that unstable API.
2022-02-23 14:34:53 +00:00
Nick Mathewson 92141c6d72 Merge remote-tracking branch 'origin/mr/340' 2022-02-23 09:29:40 -05:00
Nick Mathewson 6ea0df166a Merge branch 'client_builder' into 'main'
Make a TorClientBuilder API.

Closes #350

See merge request tpo/core/arti!337
2022-02-23 14:14:32 +00:00
eta 9960064720 examples/hook-tcp: add some comments, rework lifetimes a bit
Try to make the `hook-tcp` example a bit easier to read by
adding/changing comments, and renaming the lifetimes for
`async_trait`-generated trait methods.
2022-02-23 13:59:03 +00:00
Ian Jackson 0cf9751d7f arti-hyper: Move hyper example from arti-client
Code motion and consequential dependency adjustments.
2022-02-23 13:55:17 +00:00
Ian Jackson 0f80be6b35 arti-hyper: empty crate skeleton 2022-02-23 13:55:14 +00:00
Ian Jackson f8d17bce83 Add missing documentation for TLS features to two readmes 2022-02-23 13:53:45 +00:00
trinity-1686a ce679ad72a implement correct handling of connection close and add comment explaining goal of the example 2022-02-23 13:29:37 +00:00
trinity-1686a b5707a98e7 add drop on CustomTcpStream to catch disconnection without close 2022-02-23 13:29:37 +00:00
trinity-1686a 81d7747d7b add example of tcp hook
this required to make additional types public
2022-02-23 13:29:37 +00:00
Ian Jackson fd288f90f9 Documentation suggestion from review. 2022-02-23 13:19:10 +00:00
Ian Jackson 05bf12edfa Cleanups on !340 from @diziet 2022-02-23 13:17:27 +00:00
eta 05257da72d Merge branch 'restore_needless_borrow_check' into 'main'
Remove clippy::needless_borrow exception in CI.

Closes #310

See merge request tpo/core/arti!338
2022-02-23 13:15:15 +00:00
Nick Mathewson 784f1531bb Make NoLock into BadApiUsage.
To implement this, we had to refactor the tor_circmgr api for
flushing state changes to disk, so that it checks if it has the lock,
and only then tries to store.
2022-02-22 16:13:37 -05:00
Nick Mathewson a2e2663e90 Eliminate RequestedResourceAbsent kind.
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.
2022-02-22 16:00:25 -05:00
Nick Mathewson 789e6c87b8 Fold NamespaceFull into BadApiUsage. 2022-02-22 15:44:49 -05:00
Nick Mathewson 4cedc1a190 Rename RemoteNameError to RemoteHostNotFound
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.
2022-02-22 15:43:27 -05:00
Nick Mathewson 0ce4a12976 Replace TorNetworkError with TorDirectoryError
This is still not as specific as we want; but there's already a TODO
comment in tor-dirclient::err about fixing that at some point in the
future.
2022-02-22 15:41:01 -05:00
Nick Mathewson 7d4a57d5fa Rename TorConnectionFailed to TorAccessFailed 2022-02-22 15:38:13 -05:00
Nick Mathewson 3f0d50e08f Fold UnexplainedTaskSpawnFailure into Internal. 2022-02-22 15:37:22 -05:00
Nick Mathewson 0e242831b2 Rename TorShuttingDown to ArtiShuttingDown 2022-02-22 15:36:09 -05:00
Nick Mathewson 0d079071fe Replace RemoteRefused with CircuitRefused.
Also document that it's a lower-level error kind.
2022-02-22 15:34:46 -05:00
Nick Mathewson f018d0c74b Rename RemoteIdMismatch to RelayIdMismatch. 2022-02-22 15:32:08 -05:00
Nick Mathewson 04ca1f662f Fold EK::Canceled into TransientFailure
Also add some TODO comments in circmgr for future work.
2022-02-22 15:30:12 -05:00
Nick Mathewson 5351aaa308 Fold AlreadyClosed into BadApiUsage 2022-02-22 15:25:24 -05:00
Nick Mathewson a02737be1c Add TODOs for errorkinds we mean to fix later
Per #348, These are the cases that we meant to fix down the road, but
not in 0.1.0.
2022-02-22 15:22:49 -05:00
Nick Mathewson e62afdf79a Merge remote-tracking branch 'origin/mr/335' 2022-02-22 12:46:51 -05:00
Nick Mathewson 4d4c7f47a7 Merge branch 'error-report' into 'main'
Improve error messages from arti cli

See merge request tpo/core/arti!331
2022-02-22 17:31:18 +00:00
Ian Jackson be2bb0ccfb tor_error::Report: add tests 2022-02-22 14:57:16 +00:00
Ian Jackson 01c5e07087 tor_error::Report: Add bound to struct
This is more typing in the definition but it produces much better
error messages if you try to Report(foo).to_string()
2022-02-22 14:53:17 +00:00
Ian Jackson 06964bbfbb Move program name printing to report_and_exit 2022-02-22 14:52:47 +00:00
Ian Jackson d1f4e9f3c6 Merge branch 'pending_error' into 'main'
Handle panics from circuit construction

Closes #347

See merge request tpo/core/arti!336
2022-02-22 10:58:09 +00:00
Nick Mathewson dd55f5ce2d Remove clippy::needless_borrow exception in CI.
This exception is no longer necessary now that the underlying CI bug
is fixed.
2022-02-20 09:09:38 -05:00
Nick Mathewson c910226b55 Make a TorClientBuilder API.
This is a defensive API choice to protect against the possibility
that we'll want to add a bunch of other non-config options in
the future.

Closes #350
2022-02-18 15:28:31 -05:00
Nick Mathewson 3ff9b187ea Handle panics from circuit construction.
We handle them by reporting them to task that's waiting for the
circuit, then relaying the panic.

Doing so allows the waiting task to distinguish panics
(EK::Internal) from cases where the reactor dropped the task
entirely (EK::ReactorShuttingDown).  And doing _that_ removes one
case of EK::Canceled, which helps us on our goals towards #348.

Closes #347.
2022-02-18 14:22:38 -05:00
Ian Jackson 7d403b42fe Placate clippy on nightly, properly
I c&p this lint suppression but from a cli option printed by clippy,
and I didn't notice the need to change the - to _.
2022-02-18 18:07:43 +00:00
Nick Mathewson 0513a1d8a6 Edit tor-error comment to reflect shared ideas 2022-02-18 12:51:05 -05:00
Ian Jackson 4182c30b63 Placate clippy on nightly 2022-02-18 17:37:21 +00:00
Ian Jackson f9d2ecad27 Bump anyhow minimal version to 1.0.23
This is the first one where anyhow::Error impl AsRef<dyn StdError>

We want this because we want to add error reporting functionality
which works with all kinds of errors, which means we need an
anyhow::Error which can be vieweed as a StdError.

(The alternative would be to deref at the call sites of
report_and_exit, making it less ergonomic.)

anyhow 1.0.23 is from November 2019.
2022-02-18 17:04:57 +00:00
eta b4c0bd6ef3 Merge branch 'proxy-sooner' into 'main'
arti cli: socks proxy: Start listening immedately

See merge request tpo/core/arti!333
2022-02-18 16:06:08 +00:00
Ian Jackson e0630fda7e arti cli: Add some anyhow context() calls 2022-02-18 14:05:40 +00:00
Ian Jackson 3f8d566a7a arti cli: socks proxy: Start listening immedately
This makes arti less awkward to use.
2022-02-18 14:04:42 +00:00
Ian Jackson 460b94ef14 arti cli: Do config watch setup before entering future select
IMO this clarifies things a bit, and makes things more deterministic.
2022-02-18 13:55:12 +00:00
Nick Mathewson e3e3f9934b Move the main body of our circuit-launching task into a new function
This reduces our nesting, and will help us handle panics.
2022-02-18 08:33:50 -05:00
Dimitris Apostolou 5d61c3cf88
Fix typos 2022-02-18 15:29:02 +02:00
eta 74aa16e87a Merge branch 'script-filenames' into 'main'
Remove extension from scripts

See merge request tpo/core/arti!328
2022-02-18 12:50:16 +00:00
Ian Jackson f5a489e28c Placate rustfmt
I think all of this diff is a strict disimprovement, but whatever.
2022-02-18 12:48:17 +00:00
Ian Jackson 4a007beba7 Placate clippy 2022-02-18 12:48:00 +00:00
Ian Jackson 0eba24cb43 Add missing docs for report_and_exit 2022-02-18 12:46:58 +00:00
Ian Jackson 1e811a71d3 Add a missing anyhow context() call 2022-02-18 12:10:31 +00:00
Ian Jackson 8c4726b55e Provide error reporter and use it in the arti binary 2022-02-18 12:10:31 +00:00
Ian Jackson ccb4604237 Merge branch 'no-http-status-err' into 'main'
dirclient: Remove HttpStatus error variant

Closes #349

See merge request tpo/core/arti!329
2022-02-18 12:04:54 +00:00
Ian Jackson 1c301230e4 rename *.py scripts to bare name
Update all references.  There are three remaining hits for
  git-grep '\.py\b'
all of which are scripts in "little-t-tor", not here in arti.
2022-02-18 11:46:06 +00:00
Nick Mathewson 1572fc520e spelling fix 2022-02-17 15:59:56 -05:00
Nick Mathewson 023ff75a64 Add #[display] annotations for remaining ErrorKinds. 2022-02-17 15:18:19 -05:00
Nick Mathewson 64a0d4dce5 dirclient: Remove HttpStatus error variant
Getting a non-200 status is no longer a failure condition; it's just
a different kind of answer.

Closes #349.
2022-02-17 15:12:00 -05:00
Nick Mathewson 83d001d661 Merge branch 'remaining-errors' 2022-02-17 14:22:47 -05:00
Nick Mathewson 2f6160965d Fix compilation on main 2022-02-17 14:19:21 -05:00
Nick Mathewson 80be59497e Merge branch 'clippy-followup' into 'main'
Remove some needless refs and slicing

See merge request tpo/core/arti!327
2022-02-17 18:25:54 +00:00
Ian Jackson 6503d8ce03 Avoid recursive From impls
These (&foo).into() constructions are needed so we use the
implemnetation of `From<&Foo>`, not a recursive call to this very
function.

This is a partial revert of the previous commit.  I'm making this a
separate commit for the benefit of posterity.
2022-02-17 17:42:12 +00:00
Nick Mathewson a5e4e24537 Use TorConnectionFailed for failure to download directory. 2022-02-17 12:37:07 -05:00
Nick Mathewson 4c08141488 Clarify state vs cache in ErrorKind 2022-02-17 12:35:35 -05:00
Nick Mathewson 024ec61a1a Correct ErrorKinds for some tor-dirclient errors. 2022-02-17 12:26:18 -05:00
Nick Mathewson de86ac0b0f Rename CircuitTimeout to TorNetworkTimeout. 2022-02-17 12:22:51 -05:00
Nick Mathewson 034c5ba9f5 Rename ExitTimeout to RemoteNetworkTimeout. 2022-02-17 12:19:33 -05:00
Nick Mathewson 4db586cf00 tor_circmgr::Error: Sort variants by interesting-ness.
We can't use discriminants here now, but maybe we can in the future.
2022-02-17 12:12:04 -05:00
Nick Mathewson 550eb9e61b Tweak documentation on ErrorKind::Transient 2022-02-17 11:50:42 -05:00
eta a772d02578 Merge branch 'issue-325' into 'main'
Make CircMap open_ent_count O(1)

See merge request tpo/core/arti!302
2022-02-17 14:36:19 +00:00
Ian Jackson ce6fbac0d7 Merge branch 'bootstrap_second' into 'main'
arti: create TorClient first, then bootstrap.

Closes #336

See merge request tpo/core/arti!320
2022-02-17 14:21:04 +00:00
Ian Jackson 516a2a3de8 Merge branch 'typos' into 'main'
Fix typos

See merge request tpo/core/arti!326
2022-02-17 14:19:08 +00:00
Ian Jackson c9aa3b9937 tor-dirmgr: Use Bug type for sqlite-detected bugs
So we get a stack trace
2022-02-17 13:32:47 +00:00
Ian Jackson 1a9a209771 tor-dirmgr: Make sqlite_error_kind take rusqlite::Error
We're about to reuse this and we'll want it to take the higher-level
type.  Also it seems more proper like this.
2022-02-17 13:31:36 +00:00
Ian Jackson 9a6518fb81 tor-error: splitting/lumping guidelines 2022-02-17 13:31:11 +00:00
Ian Jackson 9a55290037 tor-dirclient: Error::HttpError: add a TODO saying to abolish 2022-02-17 13:31:11 +00:00
Ian Jackson 079f7fd1b8 ErrorKind::RemoteRefused: Expand on description, narrowing scope 2022-02-17 13:31:11 +00:00
Ian Jackson cca253ff9f ErrorKind::Csnceled: Expand on description 2022-02-17 13:31:11 +00:00
Ian Jackson 48e3ae6b79 ErrorKind::CircuitTimeout: Expand on description 2022-02-17 13:31:11 +00:00
Ian Jackson de70e15f21 ErrorKind::DirectoryExpired: Add possible deprecation notes 2022-02-17 13:31:11 +00:00
Ian Jackson 2d4901ccde tor-circmgr: errors: Use autoconversion for Bug 2022-02-17 13:31:03 +00:00
Ian Jackson bbcc871105 Remove some needless refs and slicing
Prompted by nightly's clippy (which has some false positives, so is
currently disabled).
2022-02-17 11:16:27 +00:00
Ian Jackson 094ddd7cd7 Add a comment about "&mut [&mut ]" 2022-02-17 11:07:52 +00:00
Ian Jackson 95e081ab44 Merge branch 'ptr_arg_fix' into 'main'
Re-enable clippy::ptr_arg where it had been disabled.

See merge request tpo/core/arti!323
2022-02-17 11:07:45 +00:00