Commit Graph

522 Commits

Author SHA1 Message Date
Ian Jackson 37edcd688a Use ErrorReport - run rustfmt
Split off for ease of review and possible rebase.
2023-01-30 18:52:32 +00:00
Ian Jackson 3a8c36e9c6 Use ErrorReport for remaining errors in error! in tor-circmgr 2023-01-30 18:52:32 +00:00
Ian Jackson 25c41977ac Use ErrorReport for errors in warn! in tor-circmgr 2023-01-30 18:52:32 +00:00
Ian Jackson f657ef5b6c Use ErrorReport for errors in info! in tor-circmgr 2023-01-30 17:59:09 +00:00
Nick Mathewson b7c8646d7b circmgr: drop a receiver more explicitly.
Clippy now complains about `let _ = (expr_producing_a_future);`,
which is probably smart, since maybe you wanted to await that future
and ignore the result.  So it seems that the right way to get rid of
an unwanted Receiver is now to drop it explicitly.

Closes #749
2023-01-27 09:16:51 -05:00
Nick Mathewson a6dd92843e Allow clippy::unchecked_duration_subtraction in tests
This panics on error, and we're fine with a panic on misbehavior in
tests.
2023-01-27 08:28:02 -05:00
Nick Mathewson bf04641c68 Disable clippy::unlinlined-format-args
This warning kind of snuck up on us! (See #748)  For now, let's
disable it.  (I've cleaned it up in a couple of examples, since
those are meant to be more idiomatic and user-facing.)

Closes #748.
2023-01-27 08:27:47 -05:00
Nick Mathewson 8ce05dc725 CircMgr: Draft API to construct targeted multihop circuits.
Onion services and onion clients need these to make connections to
HsDirs, Introduction points, and Rendezvous points.
2023-01-24 12:32:21 -05:00
Nick Mathewson 190f24e66d CircMgr: Draft APIs used to implement onion service clients. 2023-01-24 12:32:21 -05:00
eta 118050e54c Merge branch 'test-lints' into 'main'
Add test lint blocks to all "mod test"

See merge request tpo/core/arti!937
2023-01-06 17:16:09 +00:00
Emil Engler 8579bc66a8
doc: consistent summary line for the READMEs
This commit introduces a consistency to the summary line of all
README.md files in each and every crate.
2022-12-20 14:31:47 +01:00
Ian Jackson 125a455bdc test lint blocks: Add many many automatically
This is precisely the result of running the rune in
maint/adhoc-add-lint-blocks.
2022-12-12 18:00:30 +00:00
Ian Jackson 4181ccb8cc tor-circmgr: Use ErrorReport on a logged error
To demonstrate what the use looks like.
2022-12-12 16:40:51 +00:00
Nick Mathewson e0aeda3071 Remove semver.md files now that 1.1.0 is released. 2022-11-30 17:10:29 -05:00
Nick Mathewson 38bef96b99 Bump the minor version of every crate.
We made this job easy this time around: by incrementing our MSRV, we
have forced ourselves to do at least a minor bump everywhere.
2022-11-30 15:10:16 -05:00
Ian Jackson b822e2ebe9 tor-cirmgr: Replace OwnedChanTarget with LoggedChanTarget in errors
This
 1. Makes the errors smaller
 2. Redacts (currently, scrubs) the chantarget when safe logging is enabled

The other error variants in tor-circmgr::Error don't seem to contain
information that should become sensitive as part of bridge support.
2022-11-23 18:28:38 +00:00
Nick Mathewson f2121101d1 Even more comments explaining circuit cancellation. 2022-11-22 12:53:32 -05:00
Nick Mathewson e7c942c918 Improve notes surrounding circuit cancellation.
It turns out that bug #656 is not a real bug, but it was easy to
overlook the code that prevented it.

Closes #656.
2022-11-22 12:53:32 -05:00
Nick Mathewson c0aa10d409 CircMgr: retire all circuits if bridge configuration changes.
Closes #650.
2022-11-22 12:53:32 -05:00
Nick Mathewson 47041bd4ce Merge branch 'refactor_into_ownedchantarget' into 'main'
CircMgr: Refactor DirSpecificTarget constructor

See merge request tpo/core/arti!866
2022-11-18 15:21:46 +00:00
Nick Mathewson ec148a63cb CircMgr: Refactor DirSpecificTarget constructor
This commit replaces the
`impl From<&T> for OwnedChanTarget where T:ChanTarget`
with a new `IntoOwnedChanTarget` trait. This lets us be explicit
that we're constructing an owned object, and not just converting
something.

No semver change needed, since these APIs haven't been released.

----------- (new description)
2022-11-18 09:55:46 -05:00
Nick Mathewson 76e41b8bf6 circmgr: make some imports conditional
This resolves an "unused import" warning when bridges are not
enabled.
2022-11-18 08:53:47 -05:00
Nick Mathewson 1928fd0b72 circmgr: Make "specific-relay" non-experimental. 2022-11-18 08:53:47 -05:00
Nick Mathewson db9440464b Remove a spurious log that I committed by mistake. Whoops. 2022-11-15 13:15:32 -05:00
Nick Mathewson 050eab9bba Implement more cases for `DirSpecificTarget`.
Without this fix, any attempt to actually use a circuit for a
`DirSpecificTarget` will fail, since supports() will say false, and
`restrict_mut()` will say `NotSupported`.
2022-11-15 11:42:54 -05:00
Ian Jackson b41becec56 Merge branch 'guardmgr' into 'main'
Move guardmgr creation to arti-client, rather than within circmgr

See merge request tpo/core/arti!850
2022-11-14 17:01:31 +00:00
Ian Jackson 525c452e77 Move GuardMgr::new call to arti_client::TorClient
Having this done within circmgr was irregular - most of our other key
buildup functions are done in TorClient::create_inner.

It is also inconvenient, as it buries the guardmgr within the circmgr.
2022-11-14 15:50:07 +00:00
Ian Jackson 9ecda958a4 Document Clone semantics of GuardMgr and DirMgr 2022-11-11 16:55:56 +00:00
Nick Mathewson 936920b26e bump rust-version to 1.60 in every crate. 2022-11-10 10:57:33 -05:00
Ian Jackson 8efcfb64af Merge branch 'misc-todo-ptclient' into 'main'
Downgrade and/or remove a few misc "TODO pt-client" comments

See merge request tpo/core/arti!838
2022-11-08 16:21:30 +00:00
Nick Mathewson 6b422b1c4d circmgr: downgrade TODO pt-client comments
These are structure-internal things we can solve later, if ever.
2022-11-08 08:31:59 -05:00
Nick Mathewson 95a95076a7 Refactor external guardmgr APIs: Stop taking NetDir arguments.
These arguments were used only for legacy (testing) purposes; the
tests now use `TestNetDirProvider`.  This lets us simplify our
internal logic for passing a `NetDir` to our samples, and prepare
for having a `BridgeSet` to pass there instead.

This is a breaking change to `guardmgr` and `circmgr`.
2022-11-08 08:10:15 -05:00
Ian Jackson 6c64be06a6 guardmgr config: Introduce and require new GuardMgrConfig trait
It doesn't seem to me like it makes sense to provide the backward
compatibility here.
2022-11-03 15:43:41 +00:00
Ian Jackson 2bfce54959 guardmgr config: Pass fallback list from config by reference
This does involve additional cloning.  However, soon it will mean that
we can pass the whole `TorClientConfig` by reference.
2022-11-03 15:43:41 +00:00
Nick Mathewson 932fe48eaf Run add_warnings. 2022-11-03 11:06:02 -04:00
Nick Mathewson 40ec12b0cb Merge branch 'guards_as_bridges_part1' into 'main'
Allow GuardMgr to expose bridges as guards (part 1)

See merge request tpo/core/arti!785
2022-10-24 13:30:02 +00:00
Nick Mathewson c4263543d4 circmgr: More NOTEs and TODO pt-clients. 2022-10-24 08:59:12 -04:00
Nick Mathewson 103c88dd95 Circmgr: construct paths using either Relay or OwnedCircTarget
Previously we could only use Relay for this case, which won't work
any more: a Bridge is not a `tor_netdir::Relay`.  Instead we allow
the GuardMgr to give us something that knows how to convert itself
into an OwnedCircTarget.

This change required a far amount of follow-on revisions and
refactoring, but it should all be internal to the path-building
logic.
2022-10-24 08:59:12 -04:00
Ian Jackson a30e42a740 tor-circmgr: Make get_or_launch_dir_specific feature-specific 2022-10-21 15:19:18 +01:00
Ian Jackson 6806180ce1 tor-circmgr: Rename get_or_launch_dir_specific from _bridge
DirSpecificTarget in the usage was renamed apropos an MR comment but
this function name was overlooked.
2022-10-21 15:19:18 +01:00
Ian Jackson aa3cd7a97c tor-circmgr README: Add experimental features boilerplate 2022-10-21 15:18:41 +01:00
Ian Jackson ea7f31b357 tor-circmgr README: Remove "Limitations"
This doesn't make sense now we've released Arti 1.0.  The version
number is enough I think.
2022-10-21 15:18:41 +01:00
Ian Jackson ef5e60c879 circmgr: Plumbing for direct to target directory circuits
The target is identified by Into<OwnedChanTarget>.
We introduce corresponding TargetCircUsage and SupportedCircUsage.
2022-10-20 13:28:30 +01:00
Ian Jackson f84d8777db cargo fmt to remove blank lines
Apparently cargo fmt doesn't like these, which my perl rune didn't
delete.

This commit is precisely the result of `cargo fmt`.
2022-10-12 15:29:04 +01:00
Ian Jackson d9910dba08 Replace all README copies in src/lib.rs with includes
The feature we want is `#[doc = include_str!("README.md")]`, which is
stable since 1.54 and our MSRV is now 1.56.

This commit is precisely the result of the following Perl rune:
  perl -i~ -0777 -pe 's{(^//!(?!.*\@\@).*\n)+}{#![doc = include_str!("../README.md")]\n}m' crates/*/src/lib.rs
2022-10-12 15:29:03 +01:00
Ian Jackson 82ad9eea5f Allow "clippy::single_char_pattern" in tests.
This lint exists for perf reasons, and this is rarely relevant in
tests.

Using double quoted str is generally cognitively less burdensome.
2022-10-12 13:50:29 +01:00
Nick Mathewson 299ebd729d tor-linkspec: Remove the old OwnedFoo::new() functions
These are now builders.
2022-10-06 15:13:05 -04:00
Nick Mathewson 102e3c221d Bump minor version of tor-rtcompat and most of its dependents
(Since the APIs for the `Schedule::sleep*` functions changed, this
is a breaking change in tor-rtcompat.  Therefore, the Runtime trait
in tor-rtcompat is now a different trait.  Therefore, anything that
uses the Runtime trait in its APIs has also broken.)
2022-10-03 10:01:46 -04:00
Nick Mathewson 388e0cbab5 Bump crates that have had backward compatible API changes. 2022-10-03 09:52:34 -04:00
Nick Mathewson 3272c6fb04 Add the necessary APIs for bridge-based circuit construction. 2022-09-26 11:23:21 -04:00
Nick Mathewson 67b88547c5 CircMgr: Add an accessor for the CircuitBuilder.
Without this, actually building circuits manually is a pain.

This API is behind the `experimental-api` feature, and so it does
not require a semver.md entry.
2022-09-22 08:57:34 -04:00
Nick Mathewson a5f704f443 Remove semver.md from arti-1.0.0 2022-09-07 09:17:00 -04:00
Nick Mathewson 96875ea208 Bump crate versions in preparation for Arti 1.0.0 release.
Because we want to work more on ensuring that our semver stability
story is solid, we are _not_ bumping arti-client to 1.0.0 right now.

Here are the bumps we _are_ doing.  Crates with "minor" bumps have
had API breaks; crates with "patch" bumps have had new APIs added.

Note that `tor-congestion` is not bumped here: it's a new crate, and
hasn't been published before.

```
tor-basic-utils         minor
fs-mistrust             minor
tor-config              minor
tor-rtcompat            minor
tor-rtmock              minor
tor-llcrypto            patch
tor-bytes               patch
tor-linkspec            minor
tor-cell                minor
tor-proto               minor
tor-netdoc              patch
tor-netdir              minor
tor-persist             patch
tor-chanmgr             minor
tor-guardmgr            minor
tor-circmgr             minor
tor-dirmgr              minor
arti-client             minor
arti-hyper              minor
arti                    major
arti-bench              minor
arti-testing            minor
```
2022-09-01 08:59:49 -04:00
Alexander Færøy 3e3a68683c Shorten the duration needed in preemptive::test::does_not_predict_old_ports.
This patch shortens the duration of the `does_not_predict_old_ports`
test in the preemptive module. AppVeyor spawns its VMs/containers per
build, so the `Instant::now()` call returns a value smaller than `60 *
60 + 1` which causes the subtraction to overflow and thus panic.

Thanks to @trinity-1686a for the help here.

See: tpo/core/arti#563.
2022-08-31 14:52:40 +02:00
Nick Mathewson 0510224820 circmgr: treat usage as sensitive. 2022-08-25 11:02:06 -04:00
trinity-1686a 7f939fa480 enable doc_auto_cfg feature on every crate when documenting for docs.rs 2022-08-24 18:22:41 +02:00
Ian Jackson 46d9dadd02 Merge branch 'channel' into 'main'
Channel padding

See merge request tpo/core/arti!657
2022-08-17 10:26:25 +00:00
Ian Jackson 3aed28acd4 channel usage: Rename CU::UserTraffic from CU::Exit
As suggested in
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/657#note_2827246
2022-08-17 10:54:41 +01:00
Ian Jackson d9338293c8 Add semver notes 2022-08-17 10:54:41 +01:00
Ian Jackson 5db974ef72 Move ChannelUsage from tor_proto to tor_chanmgr
Replace Channel::note_usage with Channel::engage_padding_activities,
which unconditionally causes the channel to (start to) do netflow
padding things.

The condition now lives in chanmgr.

Addresses
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/657#note_2826094
2022-08-17 10:54:41 +01:00
Ian Jackson 48fc5d3c39 chanmgr: Use NetDirProvider::params and Arc<dyn..Netparameters>
This gets rid of many Result().  Many parameters are renamed.
Test cases of the now-impossible branch are removed.

Deleting the match from padding_parameters will come in a moment.
I've split off that commit since it has much whitespace noise.
for now, change the error type to Void.
2022-08-17 10:54:41 +01:00
Nick Mathewson 8862eb1e34 Additionally, mark the LostUsablityRace error as a "reset". 2022-08-16 14:03:43 -04:00
Nick Mathewson 4c9bf4803c Mark some circuit-building errors as "transient".
A "transient" error is one that does not indicate a true failure,
but rather an _expected_ need to retry.  When we hit one of these,
we do not count it against the total number of permitted failures.

(We do impose a higher limit on "real failures plus transient
failures", though, to prevent infinite loops in the event of a
programming error.

Closes #517.
2022-08-16 14:03:43 -04:00
Ian Jackson 76a1c45202 Introduce ChannelConfig
This commit is just the necessary plumbing.  The config is currently
empty.  We'll add something to it, for padding control, later.
2022-08-16 18:39:57 +01:00
Ian Jackson 8d44ef05dc Provide ChannelUsage and plumb it all the way down
Channel padding depends on what the channel is being used for.  We
therefore need to let the channel code know this information.

The implementation of the per-channel padding control logic will be in
the new note_usage function, which for now is simply a stub.

A future commit will introduce a `PaddingControlState` which lives in
the channel frontend; consult the doc comment for that type to see why
the plumbing through the channel manager terminates in the channel
frontend.
2022-08-16 18:37:06 +01:00
Ian Jackson 4f44ef755a dormancy: Plumb through to chanmgr reconfigure_general
The chanmgr remembers the last dormancy state it was told.

We invent a chanmgr-specific Dormancy which the arti-client code knows
how to convert from the richer top-level dormant status.  This avoids
having to have everyone know all the variants of the top-level state.

To call reconfigure_general, we must also obtain and plumb through a
netdir.  Right now we must return an internal error if there is in
fact no netdir, because reconfigure_general does not yet cope with a
missing netdir.

Nothing actually *uses* the dormancy yet.
2022-08-16 18:37:06 +01:00
Nick Mathewson 37b3daa11d tor-netdir: Collapse by_id and by_relay_id into a single fn.
There are some downstream changes required for this to work, but
they are all just unit tests that could no longer infer the type of
an Ed25519 key.
2022-08-10 10:39:46 -04:00
Nick Mathewson 2d4507ff35 Final (?) API revisions for tor-linkspec
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.
2022-08-10 10:39:37 -04:00
Nick Mathewson b56e1bf119 Introduce a RelayIdSet and use it in place of HashSet<RelayId>.
This makes lookups a little more efficient.  I do with that HashSet
just supported this use-case, but for now this seems our best option.
2022-08-10 10:39:36 -04:00
Nick Mathewson deaf8b657d Teach guard restrictions about RelayId.
This implementation is (sadly) too copy-heavy or now, because
HashSet<RelayId> can't be indexed with RelayIdRef.
2022-08-10 10:39:36 -04:00
Nick Mathewson 8af41bd65f Use accessors in two places where tests look at specific keys.
(It's safe to require these specific keys, since we constructed the
objects for testing, and we know for certain that they contain given
keys.)
2022-08-10 10:39:36 -04:00
Nick Mathewson c291d86311 Avoid a simple usage of ed_identity() in circmgr tests 2022-08-02 14:27:47 -04:00
Nick Mathewson fdfc5f29e3 Introduce HasRelayIds::same_relay_ids.
This method tells if two HasRelayIds contain exactly the same set of
Relay identities, and is generally useful for debugging.
2022-08-02 14:19:00 -04:00
Nick Mathewson 0e41913a4c guardmgr: Change APIs that used to take IDs.
These are the other inspiration for #428.
2022-08-02 12:40:57 -04:00
Nick Mathewson b68a3ed5e5 tor-linkspec: Refactor out traits to represent a relay's ID set.
We want the set of identities supported by a relay to be extensible
in the future with minimal fuss; we'd also like to make working
with these ID sets more convenient.  To handle that, this commit
adds a new trait for "Something that has the same IDs as a relay"
and a new object for "an owned representation of a relay's IDs."

This commit introduces a similar trait for "Something with a list of
SocketAddr, like a relay has."  There's no owned equivelent for
that, since Vec<SocketAddr> is already a thing.

Closes #428.
2022-08-02 12:40:23 -04:00
Nick Mathewson b16c042004 Now that versions have bumped, remove semver.md files. 2022-08-01 10:07:12 -04:00
Nick Mathewson 859ae4acd0 Bump patch versions on crates that have new APIs.
Do _not_ bump the dependency versions on crates that have had no
changes since arti 0.0.5, since those crates do not depend on the
new APIs.

```
cargo set-version -p tor-basic-utils   --bump patch
cargo set-version -p tor-llcrypto      --bump patch
git restore crates/tor-checkable
git restore crates/tor-consdiff
git restore crates/tor-rtmock
```
2022-08-01 09:56:29 -04:00
Nick Mathewson 511cb46997 Bump minor version on crates with deps with breaking changes.
This performs the transitive closure of the last operation:
everything that depends on a crate with a breaking change gets the
version which it depends on bumped.

```
cargo set-version -p tor-proto         --bump minor
cargo set-version -p tor-netdoc        --bump minor
cargo set-version -p arti-hyper        --bump minor
cargo set-version -p arti-bench        --bump minor
cargo set-version -p arti-testing      --bump minor
cargo set-version -p tor-config        --bump minor
```
2022-08-01 09:49:13 -04:00
Nick Mathewson f5dcb98f06 Bump minor versions on all crates that have had breaking changes.
Done with these commands:

```
cargo set-version -p fs-mistrust       --bump minor
cargo set-version -p tor-bytes         --bump minor
cargo set-version -p tor-socksproto    --bump minor
cargo set-version -p tor-cert          --bump minor
cargo set-version -p tor-linkspec      --bump minor
cargo set-version -p tor-cell          --bump minor
cargo set-version -p tor-netdir        --bump minor
cargo set-version -p tor-persist       --bump minor
cargo set-version -p tor-chanmgr       --bump minor
cargo set-version -p tor-guardmgr      --bump minor
cargo set-version -p tor-circmgr       --bump minor
cargo set-version -p tor-dirclient     --bump minor
cargo set-version -p tor-dirmgr        --bump minor
cargo set-version -p arti-client       --bump minor
cargo set-version -p arti              --bump minor
```
2022-08-01 09:43:09 -04:00
trinity-1686a 19a71534ec fix runtime issues on ios 2022-07-30 15:42:37 +02:00
Nick Mathewson 8d9e0eb334 CircMgr: Remove directory liveness testing. 2022-07-26 10:41:38 +01:00
Nick Mathewson a0c48caa46 CircMgr: Update to new NetDirProvider API
Everything here wants a timely directory, except that it is okay
to build timeout-testing circuits with a stale one.
2022-07-26 10:41:06 +01:00
Ian Jackson 87801dd4c0 Apply 1 suggestion(s) to 1 file(s) 2022-07-13 13:13:13 +00:00
Nick Mathewson ef76b273a9 circmgr: Refactor DirPathBuilder::pick_path.
We no longer needs to have a "return" at the end of each match
block.
2022-07-12 12:05:35 -04:00
Nick Mathewson c59d6a9211 circmgr: Use FilterCounts to explain why we couldn't build paths 2022-07-12 12:02:12 -04:00
Nick Mathewson 2deb03eb61 circmgr: Use FilterCounts to explain why we couldn't find an exit. 2022-07-12 11:51:05 -04:00
Nick Mathewson 51f4779f75 tor-circmgr: Clarify and improve Protocol error. 2022-07-12 10:01:56 -04:00
Nick Mathewson 4db7f4b9db tor-circmgr: minor error message edits. 2022-07-12 09:39:20 -04:00
Nick Mathewson d7a626aaa8 Add more information to failed-to-select fallback errors.
Also re-order the filters to be a little more logical.
2022-07-07 13:16:06 -04:00
Nick Mathewson 20435aea75 Bump crate and dependency versions.
These were done with the following commands:

```
cargo set-version -p tor-basic-utils   --bump patch
cargo set-version -p fs-mistrust       --bump minor
cargo set-version -p tor-error         --bump patch
cargo set-version -p tor-config        --bump patch
cargo set-version -p tor-units         --bump patch
cargo set-version -p tor-rtcompat      --bump minor
cargo set-version -p tor-llcrypto      --bump patch
cargo set-version -p tor-bytes         --bump minor
cargo set-version -p tor-socksproto    --bump minor
cargo set-version -p tor-cert          --bump minor
cargo set-version -p tor-cell          --bump minor
cargo set-version -p tor-proto         --bump minor
cargo set-version -p tor-netdoc        --bump patch
cargo set-version -p tor-netdir        --bump minor
cargo set-version -p tor-persist       --bump patch
cargo set-version -p tor-chanmgr       --bump minor
cargo set-version -p tor-guardmgr      --bump minor
cargo set-version -p tor-circmgr       --bump patch
cargo set-version -p tor-dirclient     --bump patch
cargo set-version -p tor-dirmgr        --bump minor
cargo set-version -p arti-client       --bump patch
cargo set-version -p arti              --bump minor
cargo set-version -p arti-bench        --bump minor
cargo set-version -p arti-testing      --bump minor
```
2022-06-24 12:00:22 -04:00
Ian Jackson 23c352b96b clippy: Consolidate many lints in maint/add_warning
Found these by disabling the nightly dbg macro special case.  Now, we
have a mechanism for globally adding suppressions to tests, we can use
that instead.
2022-06-24 14:23:38 +01:00
Ian Jackson 589c6e52bb Run maint/add_warning crates/*/src/{lib,main}.rs
Update all lint blocks
2022-06-23 19:15:42 +01:00
Nick Mathewson 08d9bbf33b Do not include error source() in display() format.
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.
2022-06-21 14:14:14 -04:00
Nick Mathewson 34e8e208cc CircMgr: Enable reachable_addrs filter. 2022-06-17 08:47:57 -04:00
Nick Mathewson 1c5f540dc8 Add a configuration option for reachable_addrs
(This doesn't do anything yet.)
2022-06-17 08:47:57 -04:00
Nick Mathewson 0223c91b26 Merge branch 'high-level-features' into 'main'
Add "full" and "experimental" features to arti, arti-client, and below.

Closes #499

See merge request tpo/core/arti!584
2022-06-16 12:24:47 +00:00
Ian Jackson 3e035927f2 tor-netdir: testnet: Make construct_netdir infallible (rustfmt)
Run rustfmt.  Separate commit to make review of the substantive commit
easier.
2022-06-13 14:26:32 +01:00
Ian Jackson 7d223ac9e6 tor-netdir: testnet: Make construct_netdir infallible
This is a *lot* of unwraps.  The function takes no parameters and
is used only for testing.  It ought to be infallible.
2022-06-13 14:25:45 +01:00
Nick Mathewson 8a586a40fa Add "full" and "experimental" features to arti-client and below.
The "full" feature is a catch-all for all features, _except_:

   * Those that select a particular implementation (like
     tor-llcrypto/with-openssl) or build flag (like "static")
   * Those that are experimental or unstable (like "experimental-api")
   * Those that are testing-only.
2022-06-10 15:32:21 -04:00
Nick Mathewson 5854e4bbd9 Merge branch 'use-testing-rng' 2022-06-07 19:02:12 -04:00
Nick Mathewson dc0a4e3c3d Move responsibility for GuardMgr NetDir updates to GuardMgr.
Previously it was the job of a task in CircMgr to do this; but we're
going to want to give GuardMgr full access to the latest NetDir for
this, and for other code-simplification reasons.

With this change I'm deprecating a couple of functions in
tor-circmgr.  It's no longer necessary for us to have an artificial
external way for you to feed new NetDirs to a circmgr.  (I could
just remove them, but I want practice deprecating.)
2022-06-07 11:44:51 -04:00
Nick Mathewson 957eb929a0 Remove now-redundant Send+Sync constraints alongside NetDirProvider 2022-06-07 11:44:51 -04:00
Nick Mathewson 967ea67b7d Use testing_rng() in tests throughout our crates.
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.
2022-06-02 14:56:42 -04:00
Ian Jackson 4f42101554 lints: Add let_unit_value allow to all crates
From running add_warning, with manual picking of the right
hunks/lines.
2022-05-31 15:23:52 +01:00
Ian Jackson ba0843da4a lints: Add lint block delimiters to every crate
This was the result of:
  maint/add_warning crates/*/src/{lib,main}.rs
and then manually curating the results.
2022-05-31 13:00:31 +01:00
Orhun Parmaksız bfd41ddb5f
Lexically sort Cargo.toml dependencies
Utilize cargo-sort: https://github.com/DevinR528/cargo-sort

Signed-off-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
2022-05-28 20:05:51 +03:00
Nick Mathewson 4326aa1de9 Regenerate version bump from previous commit.
This commit was made by reverting the previous commit, then
re-running the script I used to generate it.  In theory there should
be no semantic changes: only changes due to improved formatting from
cargo edit.
2022-05-27 10:18:52 -04:00
Nick Mathewson b232365a75 Semantic version changes for Arti 0.4.0 release
I followed the following procedure to make these changes:

* I used maint/changed_crates to find out which crates had changed
  since 0.3.0.
* I used grep and maint/list_crates to sort those crates in
  topological (dependency) order.
* I looked through semver_status to find which crates were listed as
  having semver-relevant changes (new APIs and breaking changes).
* I scanned through the git logs of the crates with no
  semver-relevant changes listed to confirm that, indeed, they had
  no changes.  For those crates, I incremented their patch-level
  version _without_ changing the version that other crates depend on.
* I scanned through the git logs of the crates with no
  semver-relevant changes listed to confirm that, indeed, they had
  no obvious breaking changes.
* I treated all crates that depend on `arti` and/or `arti-client` as
  having breaking changes.
* I identified crates that depend on crates that have changed, even
  if they have not changed themselves, and identified them as having
  a non-breaking change.
* For all of the crates, I used `cargo set-version -p $CRATE --bump
  $STATUS` (where `STATUS` is `patch` or `minor`) to update the
  versions, and the depended-upon versions.
2022-05-27 09:01:20 -04:00
Nick Mathewson 546ae3000e Resolve the new `derive_partial_eq_without_eq` lint.
It's a little overzealous sometimes, but it's mostly to the good.
2022-05-23 12:55:37 -04:00
Ian Jackson be5bc04c02 impl_standard_builder: Have it generate FooConfig::builder
This deletes many handcoded impls.  It also generates lots of impls
that we previously didn't have.
2022-05-12 18:50:26 +01:00
eta 2255778afa Merge branch 'builder-default-bis' into 'main'
impl_standard_builder followup

See merge request tpo/core/arti!505
2022-05-12 15:57:56 +00:00
Ian Jackson c1c6f2b376 Rename impl_standard_builder from impl_default_via_builder
I have Plans for this macro.  In particular:

 * I have a wip branch which tests that the Builder can be
   deserialised from an empty config (ie, that config reading
   of a config with a blank section for this item works).

 * I think we should autogenerate $Config::builder(),
   and promote that, rather than $ConfigBuilder::default().
   This macro could do that.
2022-05-12 15:59:13 +01:00
Ian Jackson 888d6e0511 config: Replace more handwritten impl Default 2022-05-12 15:59:10 +01:00
Nick Mathewson 2a5ee2c8c9 Merge branch 'ticket_412_467' into 'main'
Teach DirMgr to use slightly untimely directories

Closes #467 and #412

See merge request tpo/core/arti!500
2022-05-12 14:42:51 +00:00
Ian Jackson 04b8729d6b Add correct serde(default) attrs for humantime_serde::option
Discovered by a test case in my local tree.  The test case was
macro-generated by an extension of impl_standard_builder (which
macro istself currently awaiting review, arti!499)

Have also sent an MR to update the upstream docs
  https://github.com/jean-airoldie/humantime-serde/pull/8
2022-05-12 11:34:53 +01:00
Nick Mathewson dd20ac45ab Note a TODO in exitpath construction. 2022-05-11 12:42:38 -04:00
Nick Mathewson 7b93091f57 Bump the version of every* crate to 0.3.0
* Except for safelog and fs-mistrust, which are new.
2022-05-06 10:03:15 -04:00
Nick Mathewson 89b38b16c7 Change safelog version to 0.1.0.
(This is okay because we haven't published it yet, or any crate that
uses it.)
2022-05-06 09:59:13 -04:00
Nick Mathewson 013bb26040 Merge branch 'derive-builder-fork' into 'main'
Switch to derive_builder_arti_fork

Closes #446

See merge request tpo/core/arti!490
2022-05-06 13:07:51 +00:00
Ian Jackson 030289481f Switch to derive_builder_arti_fork
For reference, the git source for this crate (and the others in its
workspace) currently lives in my personal github account (ijackson).
If this fork turns out to be long-lived and gains features and/or
users, it would be good to move it to a gitlab somewhere.

I have granted Nick crate ownership on the crates.io system.
2022-05-06 13:36:40 +01:00
Nick Mathewson 4679023c39 Apply `sensitive` in some info-level log messages.
This specifically applies the `sensitive` wrapper in the places
where we're logging target addresses at level "info" or higher.
2022-05-06 07:36:50 -04:00
Ian Jackson d47e94b459 config derive attrs: Make builders serde, and validated structs not
* Builders additionally derive: Debug, Serialize, Deserialize.

 * Validated structs no longer derive: Serialize, Deserialize
   and all related attributes deleted.

 * As a consequence, all the `#[serde(deny_unknown_fields)]`
   are gone.  That means that right now unknown fields are totally
   ignored.  This is good for compatibility but poor for useability.
   Doing something better here is arti#417, in progress.

 * As a consequence, delete tor_dirmgr::retry::default_parallelism.
   (The default value was already duplicated into a builder attr.)
2022-05-05 10:35:52 +01:00
Ian Jackson a334f17262 Merge branch 'socket-addr-list-builder' into 'main'
FallbackDir: orports: Introduce and use VecBuilder

See merge request tpo/core/arti!474
2022-05-04 18:13:45 +00:00
Ian Jackson 4ad4cae418 FallbackDir: Use VecBuilder for orports
And drop the ad-hoc orport() method.  This brings FallbackDir's
orports field in line with our list builder API.

The general semver note in "configuation" seems to cover most of this.
2022-05-04 17:18:55 +01:00
Ian Jackson 015db3d78d GuardUsage: restrictions: Use list builder
Although these do not appear in the config, it does have a builder.
It seems sensible to get rid of this ad-hoc list manipulation site,
and replace it with our standard list builder API.

define_list_builder_helper requires that the builder element type be
Deserialize.  Currently GuardUsageRestriction is a transparent, public
enum, so we aren't really exposing anything.

We could introduce GuardUsageRestrictionBuilder now, but
since it's not in the config and thereofore only in the public API of
the lower crates, we can definitely put that off.
2022-05-04 16:16:38 +01:00
Ian Jackson 4bca912715 Change builder list API
The new API is (roughly) as discussed in
  https://gitlab.torproject.org/tpo/core/arti/-/issues/451

This is quite a large commit and it is not convenient to split it up.
It contains the following changes:

 * Redo the list builder and accessor macros implemnetation,
   including docs and tests.

 * Change uses of define_list_config_builder.  In each case:
   - Move the docs about the default value to the containing field.
   - Remove the other docs (which were just recapitulations, and
     are now not needed since the ListBuilder is no longer public).
   - Rewmove or replace `pub` in the define_list_builder_helper call,
     so that the builder is no longer public.
   - Change the main macro call site to use define_list_builder_helper.
   - Add a call to define_list_builder_accessors.

 * Make the module `list_builder` pub so that we have somewhere to
   put the overview documentation.

 * Consequential changes:
   - Change `outer.inner().replace(X)` to `outer.set_inner(X)`
   - Consequential changes to imports (`use` statements).
2022-05-04 13:50:10 +01:00
eta 6f787e1e77 Merge branch 'derive-builder-git-fixup' into 'main'
derive_builder: Use git dep everywhere, rather than cargo patch

See merge request tpo/core/arti!477
2022-04-27 14:31:08 +00:00
Ian Jackson a97ad69855 derive_builder: Use git dep everywhere, rather than cargo patch
The `[patch]` approach causes the tree not to build when used as a
dependency, unless the `[patch]` is replicated into the depending
project.

Instead, replace our `derive_builer =` dependencies with a reference
to a specific git commit:

  perl -i~ -pe 'next unless m/^derive_builder/; s#"(0\.11\.2)"#{ version = "$1", git = "https://github.com/ijackson/rust-derive-builder", rev = "ba0c1a5311bd9f93ddf5f5b8ec2a5f6f03b22fbe" }#' crates/*/Cargo.toml

Note that the commitid has changed.  This is because derive_builder is
in fact a workspace of 4 crates.  3 of them are of interest to arti
itself (the 4th exists only for testing).  So the same "add git
revision" treatment had to be done to the `derive_builder` and
`derive_builder_macro` crates.  Each dependency edge involves a new
commit in the derive_builder workspace, since we can't create a git
commit containing its own commitid.  (We want to use commits, rather
than a branch, so that what we are depending on is actually properly
defined, and not subject to the whims of my personal github
namespace.)

There are no actual code changes in derive_builder.
2022-04-27 14:57:59 +01:00
Samanta Navarro c53818d496 Fix grammar and typos 2022-04-27 13:52:13 +01:00
Nick Mathewson c1ea419477 Merge branch 'main' into 'msrv_1_56'
# Conflicts:
#   crates/tor-config/Cargo.toml
#   crates/tor-dirmgr/src/state.rs
#   doc/semver_status.md
2022-04-26 12:45:16 +00:00
Ian Jackson ce877e4421 Document defaults for all the config lists
And add an imprecation in define_list_config_builder's doc comment do
do so in future for other invocations of the macro.

Add add the missing full stops.
2022-04-25 18:22:54 +01:00
Ian Jackson 1f215da1a3 Rename ThingListBuilder::replace (from set)
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/471#note_2798024
2022-04-25 18:15:25 +01:00
Nick Mathewson 2f6bc6bdc4 squash! Bump every crate's edition to 2021.
Remove all `use` statements for `TryFrom` and `TryInto`.  These are
now redundant in Rust 2021.
2022-04-25 13:06:26 -04:00
Nick Mathewson b60b0a266a Bump every crate's edition to 2021.
This is an automated change made with a perl one-liner and verified
with grep -L and grep -l.

Some warnings are introduced with this change; they will be removed
in subsequent commits.

See arti#208 for older discussion on this issue.
2022-04-25 13:05:31 -04:00
Nick Mathewson ca05b0904c Add 'rust-version = "1.56"' to every Cargo.toml file.
This change was made automatically with a perl one-liner, and
confirmed with `grep -L`.

The `rust-version` field itself was introduced in 1.56.0.
2022-04-25 13:04:31 -04:00
Nick Mathewson 0069fd2206 Reformat all not-yet-reformatted Cargo.toml files.
There are no semantic changes here; only formatting.  This is in
preparation for other changes (wrt MSRV and edition)
2022-04-25 13:04:31 -04:00
Ian Jackson dca4f3ede1 Use better syntax for doc comment attribute
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/471#note_2798020
2022-04-25 17:05:30 +01:00
Ian Jackson 24518675db Introduce PredictedPortsListBuilder
This means that `NetworkConfig::initial_predicted_ports` is now like
the other list-like things, returning `&mut list_builder` with the same
`set()` and `append()` methods.
2022-04-25 17:05:30 +01:00
trinity-1686a b9dd23de91 fix typo in doc 2022-04-25 00:27:29 +02:00
Ian Jackson 6da7a2e3e2 Use git source for derive_builder for now, for sub_builder feature
This commitid is the current head of my MR branch
  https://github.com/colin-kiegel/rust-derive-builder/pull/253
  https://github.com/ijackson/rust-derive-builder/tree/field-builder
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.

We will need the new version of not only `derive_builder_core` (the
main macro implementation) but also`derive_builder` for a new error
type.
2022-04-21 14:07:28 +01:00
eta 41dd682552 Merge branch 'report-skew' into 'main'
Report skew estimates from arti-client

See merge request tpo/core/arti!455
2022-04-13 12:51:23 +00:00
Nick Mathewson 4582dddca8 circmgr: back off on preemptive circuits if they fail consistently
Rather than running preemptive circuit construction every 10
seconds, we change it to back off when it is "failing".  (We define
"failing" as creating no new circuits, and as giving at least one
error.)

This change means that we'll have one less reason to hammer the
network when our connectivity is failed for some reason.

Closes #437.
Part of #329.
2022-04-12 09:19:10 -04:00
Nick Mathewson 482c022e23 circmgr: Remove now-unused scheduled entry points.
Now that we have TaskSchedule, we don't need to expose these any
longer.
2022-04-12 09:04:10 -04:00
Nick Mathewson 3d5276a9cc circmgr: Report CircProvenance from AbstractCircMgr.
This feature is similar to ChanProvenance from ChanMgr, except that
we don't yet need to report it outside the crate.  I'm going to use
it to distinguish newly created circuits from existing circuits in
the preemptive circuit builder.
2022-04-12 08:41:32 -04:00
Nick Mathewson 72f00daf12 circmgr: re-export clock skew estimates. 2022-04-12 08:03:49 -04:00
Nick Mathewson c3c43b088e Create and use API to report guard/fallback skew.
(The information is not yet recorded.)
2022-04-07 10:47:45 -04:00
Nick Mathewson 0050045867 ChanMgr: Return provenance information from get_or_launch
We need this since we want to report certain conditions only when
they happen on a new channel, not if we observe them on a
preexisting channel.
2022-04-07 10:46:06 -04:00
Nick Mathewson 36440a957c Distinguish UsageMismatch cases by whether a race is possible
This lets us say that the UsageMismatch cases in some parts of the
code reflect a programming error (RetryTime::Never), whereas in
other case it reflects another circuit request getting to the
circuit first (RetryTime::Immediate).
2022-04-04 11:41:00 -04:00
Nick Mathewson 6d8a6b42e7 circmgr: Improve retry-and-or-delay logic.
Use the new RetryTime type and its associates to decide how long to
wait (if at all) between attempts to build a circuit.

Closes #421.

Part of #329.
2022-04-04 11:15:18 -04:00
Nick Mathewson c3b2bcc91e circmgr: implement HasRetryTime. 2022-04-04 11:15:18 -04:00