Commit Graph

234 Commits

Author SHA1 Message Date
Nick Mathewson 886faa96b3 Remove semver.md files now that 1.1.2 is out. 2023-02-28 10:06:41 -05:00
Nick Mathewson f41449d0bd Patchlevel bumps for remaining changed crates.
These crates have had small code changes, but no API additions:

tor-config
tor-socksproto
tor-cert
tor-chanmgr
tor-ptmgr
tor-guardmgr
tor-circmgr
tor-dirclient
tor-dirmgr
arti
tor-hsservice
tor-congestion

These crates have had API extensions:

fs-mistrust
tor-llcrypto
tor-bytes
tor-checkable
tor-linkspec
tor-netdoc
tor-persist
arti-client
2023-02-28 07:13:27 -05:00
Nick Mathewson bc68974212 tor-linkspec: New UnparsedLinkspec type.
Unlike linkspec, this doesn't validate the actual contents of the
specifiers. We'll use this so we can handle the linkspec list for an
introduction point in an HsDesc, and just pass it on when
constructing our circuits.

I haven't added any accessor or constructor functions, because I
don't expect to need them.
2023-02-17 15:26:23 -05:00
Ian Jackson a0a740ffc1 tor-linkspec: LinkSpec parsing: use read_nested_u8len (fmt) 2023-02-06 16:08:32 +00:00
Ian Jackson 5997d99a7a tor-linkspec: LinkSpec parsing: use read_nested_u8len
This eliminates hardcoded length values.
2023-02-06 16:08:21 +00:00
Nick Mathewson 7c1b6a5a81 Bump the patch version of every crate that had API additions
These crates had API or behavior changes that may affect downstream
crates. Fortunately, they're all version 0.x, and don't need minor
bumps for this.
2023-02-01 10:36:29 -05:00
Nick Mathewson 66f594a4b6 Bump the patch-level version of crates with _minor_ changes.
These changes influence behavior, but not effect compatibility.
(If I messed up, and any crate except for `arti` has non-breaking
API changes, that's still fine, since they are all version
0.x.)
2023-02-01 10:23:58 -05:00
Nick Mathewson 592d6bf8a3 Bump the patch version of each crate with _trivial_ changes.
These crates have not had changes to their behavior; as such it is
not necessary to bump their dependencies to require the new versions.
2023-02-01 10:10:36 -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
eta b525fccfb0 Merge branch 'ya-lint' into 'main'
tor-linkspec: Fix an unused lint

See merge request tpo/core/arti!935
2023-01-06 17:16:27 +00: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 05ca80950e tor-linkspec: Fix an unused lint
Otherwise:

  cargo +stable clippy -p tor-proto --all-features --all-targets

Produces:

  warning: unused import: `PtTargetAddr`
   --> crates/tor-linkspec/src/traits.rs:9:28
    |
  9 | use crate::{ChannelMethod, PtTargetAddr, RelayIdRef, RelayIdType, RelayIdTypeIter};
    |                            ^^^^^^^^^^^^
2022-12-12 15:08:31 +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 429d2c7cb7 bridge config: Rename accessors
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/904#note_2858480
2022-11-30 15:49:34 +00:00
Ian Jackson bb6c98bdc1 BridgeAddr tests: dedupe slightly 2022-11-30 15:49:34 +00:00
Ian Jackson 199a6e0754 Separate BridgeAddr and PtTargetAddr
As per
  https://gitlab.torproject.org/tpo/core/arti/-/issues/668#note_2858220

This commit is difficult to split up.

The innards of BridgeAddr and PtTargetAddr are still a bit entangled.
2022-11-30 15:49:34 +00:00
Nick Mathewson bdddb78828 Merge branch 'more-linkspec-tests' into 'main'
Add tests for a bunch of code in tor-linkspec

See merge request tpo/core/arti!867
2022-11-29 18:41:54 +00:00
Nick Mathewson 69744ef8f3 Remove deprecated aliases in tor-linkspec. 2022-11-29 10:56:59 -05:00
Nick Mathewson 45c4beff7a Fix up compatibility issues between linkspec tests and other patches 2022-11-28 08:29:33 -05:00
Nick Mathewson 777b6bee3d linkspec: Add some tests for ChannelMethod 2022-11-28 08:20:57 -05:00
Nick Mathewson 60bc179019 linkspec: Tests for PtTargetSettings 2022-11-28 08:19:47 -05:00
Nick Mathewson 119e5f6f75 PtTransportName: Remove unused accessors. 2022-11-28 08:19:47 -05:00
Nick Mathewson d990a23948 linkspec: Add tests for has_any_identity. 2022-11-28 08:19:45 -05:00
Nick Mathewson 145ab3c49b linkspec: Add test for lookup on no-ids. 2022-11-28 08:19:08 -05:00
Nick Mathewson aa72f3d8c8 Add a test for ByRelayIds::remove_by_all_ids 2022-11-28 08:19:08 -05:00
Nick Mathewson c62958c76f Add a default debug_redacted impl to save space. 2022-11-28 08:01:53 -05:00
Nick Mathewson 2aa0ae4016 linkspec: Give a Redacted form for chantarget. 2022-11-28 08:01:50 -05:00
Ian Jackson 1a39a0c7e9 Make ChannelMethod non-exhaustive
Enums with variants conditional on cargo features must be
non-exhaustive, because cargo features are supposed to be additive,
meaning that enabling a feature (which might happen due to some random
distant thing) ought not to break things using that enum.

There were surprisingly few places to fix this.
2022-11-24 17:17:36 +00:00
Ian Jackson 45a79bf725 tor-linkspec: Provide LoggedChanTarget type alias and utility method
This makes it easy to talk about, and construct, a
BoxSensitive<OwnedChanTarget>, which is what we'll use in errors.
2022-11-23 18:28:38 +00:00
Ian Jackson 822a6ce32b TransportId: Fix test case for no pt-target
Fixes

  cargo +stable clippy --manifest-path=/home/ian/Rustup/Arti/arti/Cargo.toml --locked --target-dir=target --offline -p tor-linkspec --no-default-features --all-targets

giving

  446 |             .method(ChannelMethod::Pluggable(PtTarget::new(
      |                                    ^^^^^^^^^ variant or associated item not found in `transport::ChannelMethod`
2022-11-22 14:59:25 +00:00
Ian Jackson 28ca346297 TransportId: Parse "bridge" as builtin transport
This will allow  transport="bridge"  in bridge configurations, etc.
Doing it at this layer means it will be recognised everywhere.
2022-11-22 14:59:25 +00:00
Ian Jackson 813f0a71c9 TransportId: Provide new_builtin and new_pluggable
I think normal Rustic practice is to provide a real constructor as
well as just `Default`.
2022-11-22 14:59:25 +00:00
Ian Jackson 331aa673ea TransportId: Provide name accessor and deconstructor
We are maintaining the notion that at some point this thing might
grow additional variants.
2022-11-22 14:59:25 +00:00
Ian Jackson 4b8010782a TransportId: Document and change string repr for builtin
* Change the Display of builtin to "-"
 * Parse "" and "-" as builtin, as well as "<none>"
 * Document this
2022-11-22 14:59:21 +00:00
Ian Jackson fe0970e28e TransportId: Add test case for builtin Display repr 2022-11-22 14:59:21 +00:00
Ian Jackson fec66077de BridgeAddr rename from PtTargetAddr: Update in tor-linkspec
And the error too.

We need this for the API for BridgeConfigBuilder, where the user can
specify any kind of target "address", even a hostname.

It's already non-conditional, it's just that the name is too limiting.

In this commit:
 * Change in tor-linkspec
 * Export transitional aliases
 * Add TODOs to remove the transitional aliases
2022-11-21 14:54:39 +00:00
Ian Jackson 224f4905e4 tor-linkspec: Provide deconstructors for PtTargetSettings and PtTarget 2022-11-21 14:54:39 +00:00
Nick Mathewson de9f3177b0 Fix a missing import in tests.
I'm not sure why the CI didn't reject this the first time around.
2022-11-18 10:34:19 -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 c666133be4 Merge branch 'mark-bridges-not-experimental' into 'main'
Mark bridge and PT-related APIs as non-experimental.

Closes #643

See merge request tpo/core/arti!865
2022-11-18 14:22:31 +00:00
Nick Mathewson 95081198e5 Remove impl Display for OwnedCircTarget
Nothing used this; if anything wants it, it would be better off
calling `.display_chan_target()`.
2022-11-17 09:12:57 -05:00
Nick Mathewson 25702ccd9e ChanTarget: Add a display function, with better output.
This change lets us display a ChanTarget's members without first
cloning them into an OwnedChanTarget.

It also resolves a reliability issue by outputting better info when
talking about connections via pluggable transports.

Closes #647
2022-11-17 09:06:08 -05:00
Nick Mathewson cf152c5ed6 linkspec: Make "pt-client" non-experimental. 2022-11-16 12:26:31 -05:00
Nick Mathewson d78cde7dea Allow a subset-only ChanMethod match when looking up a BridgeConfig
If we have a bridge guard that is using Direct connection and it
knows multiple addresses, our code to match it with a BridgeConfig
is wrong, because the BridgeConfig has only one address, and our
code looks for an exact match.

Fixes #642.
2022-11-15 13:53:14 -05:00
Nick Mathewson 06e4e91614 Remove allow() for a false-positive warn on Rust 1.56. 2022-11-10 11:04:20 -05:00
Nick Mathewson 34ae02e75f Upgrade to serde_with 2, phf 0.11. Closes #526. 2022-11-10 11:04:18 -05:00
Nick Mathewson 936920b26e bump rust-version to 1.60 in every crate. 2022-11-10 10:57:33 -05:00
Nick Mathewson 897bac680f linkspec: Rename "maybe rename this?" TODOs in favor of #623 2022-11-07 12:27:50 -05:00
Nick Mathewson f5364065f3 PtTargetSettings: Enforce correctness at lower level.
This resolves a number of TODOs.
2022-11-07 12:21:22 -05:00
Nick Mathewson 06972f171d Remove a blank line 2022-11-07 12:19:02 -05:00
Nick Mathewson bc28793166 Downgrade TODO on chan_method
This is not something we need to solve for 1.1.0 (and it might not
need to be solved ever).
2022-11-07 11:49:49 -05:00
Nick Mathewson b423a40478 Remove TODO about third ChannelMethod variant.
We didn't find a use for this.
2022-11-07 10:39:13 -05:00
Nick Mathewson e832a90c4b Remove TODO about inlining PtTargetSettings.
Since there are (or soon will be) parsing restrictions on this type,
we don't want to inline it as a simple Vec.
2022-11-07 10:36:20 -05:00
Nick Mathewson 932fe48eaf Run add_warnings. 2022-11-03 11:06:02 -04:00
Ian Jackson 48f48841e1 Require derive_more 0.99.3
0.99.[012] have a bug https://github.com/JelteF/derive_more/issues/114
which makes the Deref derive for bridgedesc::StateGuard not work
and therefore breaks minimal-versions CI.

It seems simpler to require the newer version everywhere.
2022-11-03 11:37:23 +00:00
Nick Mathewson 29c46d08b5 Merge branch 'guards_as_bridges_part2' into 'main'
Use ByRelayIds to hold guards in GuardSet

See merge request tpo/core/arti!808
2022-10-27 21:09:47 +00:00
Ian Jackson a56efbfdf0 impl Hash for BridgeConfig and various PT information
The bridge descriptor manager wants to index data structures by the
BridgeConfig.
2022-10-27 15:57:54 +01:00
Nick Mathewson 7d313a12bc ByRelayIds: Add additional accessor functions.
These are the ones that turned out to be necessary while converting
guard samples to use ByRelayIds.
2022-10-25 09:23:28 -04:00
Nick Mathewson ac71bb0ef1 linkspec: add HasRelayIds::has_any_identity. 2022-10-25 09:23:28 -04:00
Nick Mathewson d7672a13d5 linkspec: specify sort order for HasRelayIds. 2022-10-24 08:59:12 -04:00
Nick Mathewson 1195c40a99 linkspec: Remove now-useless declared_peer_addr
The singleton variation here is almost never what we want.
2022-10-24 08:59:12 -04:00
Nick Mathewson bb117a4bd4 guardmgr: Refactor the interior of FirstHop.
Now it contains either an `OwnedChanTarget` or an `OwnedCircTarget`,
which will let `GuardMgr` return bridges that can be used to make
circuits.

As part of this change, it was necessary to revise some
address-modification functions that applied to filters and
`OwnedChanTarget`.  Now they do the smart thing, and remove only the
address that are in the `ChanMethod`.  This means that the addresses
from HasAddrs are still accurate about which addresses the relay
"has".
2022-10-24 08:59:12 -04:00
Nick Mathewson 00f887db70 linkspec: Add compare-by-relay-ids function to HasRelayIds 2022-10-21 09:21:43 -04:00
Nick Mathewson f23adcd4c8 Merge branch 'pt-serde' into 'main'
serde support for PtTarget

See merge request tpo/core/arti!780
2022-10-20 17:13:19 +00:00
Nick Mathewson 34aa352d16 Implement serde for PtTarget and its members.
This will let us remember bridges that use pluggable transports.
2022-10-20 12:37:41 -04:00
Nick Mathewson bc09a3fe65 Inline now-needless variant constructors for PtTargetAddr 2022-10-20 12:37:41 -04:00
Nick Mathewson 95b03dc96f Remove a now-needless `allow(dead_code)` 2022-10-20 12:37:41 -04:00
Nick Mathewson d8f9a79c4f linkspec: Always expose PT-related types.
The `PtTarget` type and its contents (`TransportName`,
`PtTargetAddr`, `PtSettings`) are now unconditionally compiled and
exposed.  This will allow us to serialize and deserialize them in
our guard-state files even when we have been built without explicit
PT support.

The `pt-client` feature controls whether `TransportName` is a
variant of `TransportId`, and whether `PtTarget` is a variant of
`ChanMethod`: this in turn means that we'll still have simpler
binary code and smaller structures when we're building without PT
support (which is what we wanted when we initially made these types
conditional).
2022-10-20 12:37:40 -04:00
Ian Jackson 803131c1ea Merge branch 'bridge-internal-apis' into 'main'
Use BridgeConfig to identify bridges in two places

See merge request tpo/core/arti!781
2022-10-20 16:14:14 +00:00
Ian Jackson 6193bed788 impl HasAddrs for PtChannelAddr and ChannelMethod 2022-10-20 14:16:34 +01:00
Ian Jackson c93500e14c tor-linkspec: impl From<&ChanTarget> for OwnedChanTarget
This lets us write functions which can either take an existing
owned OwnedChanTarget, or copy out of some other kind of ChanTarget
passed by reference.
2022-10-20 13:29:07 +01:00
Ian Jackson a5eba71edd HasAddrs: Make it clear that the set of addresses can be empty
Eg, a PT bridge may not have an address.
2022-10-20 12:47:50 +01:00
Nick Mathewson 3975d0db7e linkspec: Fix typo in error messages. 2022-10-18 15:01:54 -04:00
Nick Mathewson a46e8af605 linkspec: Add ByRelayIds::remove_exact.
We need a function to remove an entry if it appears with _exactly_
the same relay Ids, but not otherwise.  This method will do that.
2022-10-18 11:49:21 -04:00
Nick Mathewson 0c8a5a1fa4 linkspec: Add an "all_overlapping" accessor to ByRelayIds.
Also, add a few tests for this and the other accessors.

We'll need this accessor to find whether we have any channels to
_any_ of the identities that we're trying to connect to.
2022-10-18 11:49:21 -04:00
Nick Mathewson 522907ac9a Write more tests for RelayId and RelayIdRef. 2022-10-15 10:38:08 -04:00
Nick Mathewson 8e2ce9de1d Write tests for RelayIdSet. 2022-10-15 10:06:02 -04:00
Nick Mathewson ae07909a02 Fix deserialize impl for RelayId.
We need to handle String, not just str, since some deserializers
have to handle escapes and generate new strings.

Found while writing tests; fixes #605.
2022-10-15 10:04:37 -04:00
Nick Mathewson ddc5b63a19 linkspec: impl Hash for RelayIdRef 2022-10-15 09:57:45 -04:00
Nick Mathewson 8f267ba166 Fix some rustdoc errors.
In addition to the usual "You named that method wrong!" errors, we
have a new rustdoc error that complains about bogus "HTML tags" that
are actually unquoted usage of types like `Result<Foo>`.
2022-10-13 09:08:46 -04:00
Nick Mathewson 85284ef847 Merge branch 'factory_redux' into 'main'
chanmgr: Build and use chanmgr factory APIs

See merge request tpo/core/arti!769
2022-10-13 12:58:28 +00: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
Nick Mathewson 5da9596a04 Add several accessors to ChannelMethod.
* Get `TransportId`
 * Get the target address (of any type)
 * Ask, "is this a direct connection"?
2022-10-12 10:15:00 -04:00
Nick Mathewson 0cb7b030b3 Fix a warning that I reintroduced.
It looks like this got fixed, but my branch for !759 reintroduced it
by refactoring.
2022-10-11 09:38:04 -04:00
Nick Mathewson 74d4c73d09 Change multiplicity of ChannelMethod and addresses
Now each `ChanTarget` has at most one `ChannelMethod`, and only
`Direct` `ChannelMethods` can have multiple addresses.

Closes #600.
2022-10-11 08:53:31 -04:00
Ian Jackson 32126f2089 Allow two useless pattern matches that are going to be not useless 2022-10-11 12:22:46 +01:00
Nick Mathewson 22b14066f0 Clarify limits on socket address from ChannelMethod 2022-10-06 15:13:05 -04:00
Nick Mathewson 95a5393cd8 Move two users of HasAddrs to HasChannelMethods
All the other users of HasAddrs are correct.
2022-10-06 15:13:05 -04: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 f8dc4f8b06 ChannelMethod: Add method to access the (optional) SocketAddr 2022-10-06 15:13:05 -04:00
Nick Mathewson b84224feb4 Add builders for OwnedChanTarget/OwnedCircTarget
This will become the preferred way to make one of these objects, and
insulate us against future API changes.
2022-10-06 15:13:05 -04:00
Nick Mathewson ce09b7c96f Begin revising HasAddr and its relationship to ChanTarget
HasAddr used to mean "Here are addresses that I have, at which I can
be contacted."  But "Where (and how) can I be contacted?" is now a
question for HasChannelMethod to answer.

(We still need to have "HasAddr", though, so we can answer things
like "what country is this relay in" and "are these relays in the
same /8?")

So this commit introduces:
  * A new trait for adding an implementation of HasChannelMethod in
    terms of HasAddr.
  * A requirement on ChanTarget that it needs to implement
    HasChannelMethod.

There is some temporary breakage here, marked with "TODO pt-client",
that I'll fix later in this branch.
2022-10-06 15:13:05 -04:00
Nick Mathewson 11caa46525 tor-linkspec: ByRelayIds<> type to hold a set of HasRelayIds
This is based on the type generated with n_key_set, with a
couple of extra methods to take advantage of RelayId and RelayIdRef.
2022-10-04 16:05:40 -04:00
Ian Jackson 9705ef3fea Merge branch 'bridge-parse' into 'main'
Parse (and format) bridge lines

See merge request tpo/core/arti!745
2022-10-03 20:13:02 +00:00