summaryrefslogtreecommitdiff
path: root/crates/tor-linkspec/src/traits.rs
Commit message (Collapse)AuthorAgeFilesLines
* Change CircTarget::linkspecs() to return an encoded list.Nick Mathewson2023-05-101-4/+10
| | | | | | | | If we didn't do this, we would need to transfrom `EncodedLinkSpec`s into a `LinkSpec::Unrecognized`, which is not semantically right. What's more, every user of this API wants to consume encoded link specifiers, so encoding them early saves a little effort.
* test_linkspecs: tidy order of linkspecsNick Mathewson2023-05-101-11/+11
| | | | This is pure code movement.
* Move responsibility for linkspec sorting to CircTarget.Nick Mathewson2023-05-101-2/+13
| | | | | | This change is necessary so that we can build Extend2 messages that have their LinkSpecs appear in a verbatim order as provided in an INTRODUCE2 message or in a HS descriptor.
* Allow clippy::unchecked_duration_subtraction in testsNick Mathewson2023-01-271-0/+1
| | | | | This panics on error, and we're fine with a panic on misbehavior in tests.
* Merge branch 'ya-lint' into 'main'eta2023-01-061-1/+4
|\ | | | | | | | | tor-linkspec: Fix an unused lint See merge request tpo/core/arti!935
| * tor-linkspec: Fix an unused lintIan Jackson2022-12-121-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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}; | ^^^^^^^^^^^^
* | test lint blocks: Add many many automaticallyIan Jackson2022-12-121-0/+8
|/ | | | | This is precisely the result of running the rune in maint/adhoc-add-lint-blocks.
* Separate BridgeAddr and PtTargetAddrIan Jackson2022-11-301-2/+2
| | | | | | | | | 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.
* Merge branch 'more-linkspec-tests' into 'main'Nick Mathewson2022-11-291-0/+7
|\ | | | | | | | | Add tests for a bunch of code in tor-linkspec See merge request tpo/core/arti!867
| * linkspec: Add tests for has_any_identity.Nick Mathewson2022-11-281-0/+7
| |
* | Remove deprecated aliases in tor-linkspec.Nick Mathewson2022-11-291-2/+2
| |
* | linkspec: Give a Redacted form for chantarget.Nick Mathewson2022-11-281-6/+28
|/
* TransportId: Fix test case for no pt-targetIan Jackson2022-11-221-16/+19
| | | | | | | | | | | 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`
* Fix a missing import in tests.Nick Mathewson2022-11-181-1/+1
| | | | I'm not sure why the CI didn't reject this the first time around.
* Merge branch 'refactor_into_ownedchantarget' into 'main'Nick Mathewson2022-11-181-7/+1
|\ | | | | | | | | CircMgr: Refactor DirSpecificTarget constructor See merge request tpo/core/arti!866
| * CircMgr: Refactor DirSpecificTarget constructorNick Mathewson2022-11-181-7/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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)
* | ChanTarget: Add a display function, with better output.Nick Mathewson2022-11-171-2/+79
|/ | | | | | | | | | 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
* linkspec: Rename "maybe rename this?" TODOs in favor of #623Nick Mathewson2022-11-071-3/+0
|
* Downgrade TODO on chan_methodNick Mathewson2022-11-071-1/+1
| | | | | This is not something we need to solve for 1.1.0 (and it might not need to be solved ever).
* linkspec: add HasRelayIds::has_any_identity.Nick Mathewson2022-10-251-1/+6
|
* linkspec: specify sort order for HasRelayIds.Nick Mathewson2022-10-241-2/+13
|
* linkspec: Add compare-by-relay-ids function to HasRelayIdsNick Mathewson2022-10-211-1/+68
|
* Merge branch 'bridge-internal-apis' into 'main'Ian Jackson2022-10-201-1/+7
|\ | | | | | | | | Use BridgeConfig to identify bridges in two places See merge request tpo/core/arti!781
| * tor-linkspec: impl From<&ChanTarget> for OwnedChanTargetIan Jackson2022-10-201-1/+7
| | | | | | | | | | | | 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.
* | HasAddrs: Make it clear that the set of addresses can be emptyIan Jackson2022-10-201-1/+4
|/ | | | Eg, a PT bridge may not have an address.
* Fix some rustdoc errors.Nick Mathewson2022-10-131-1/+1
| | | | | | 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>`.
* Fix a warning that I reintroduced.Nick Mathewson2022-10-111-0/+1
| | | | | It looks like this got fixed, but my branch for !759 reintroduced it by refactoring.
* Change multiplicity of ChannelMethod and addressesNick Mathewson2022-10-111-17/+11
| | | | | | | Now each `ChanTarget` has at most one `ChannelMethod`, and only `Direct` `ChannelMethods` can have multiple addresses. Closes #600.
* Allow two useless pattern matches that are going to be not uselessIan Jackson2022-10-111-0/+1
|
* Move two users of HasAddrs to HasChannelMethodsNick Mathewson2022-10-061-2/+4
| | | | All the other users of HasAddrs are correct.
* Begin revising HasAddr and its relationship to ChanTargetNick Mathewson2022-10-061-10/+26
| | | | | | | | | | | | | | | | | | | 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.
* Add a HasChanMethods trait, with a bunch of open TODO questions.Nick Mathewson2022-09-231-1/+20
| | | | We'll need to sort these out as we implement pluggable transports.
* Final (?) API revisions for tor-linkspecNick Mathewson2022-08-101-14/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Remove get_ed_identity_key as unused.Nick Mathewson2022-08-101-23/+0
|
* Teach guard restrictions about RelayId.Nick Mathewson2022-08-101-0/+11
| | | | | This implementation is (sadly) too copy-heavy or now, because HashSet<RelayId> can't be indexed with RelayIdRef.
* Add a set of Identity-related types and accessors.Nick Mathewson2022-08-101-2/+47
| | | | | | | I wonder if these types are correct. I think it makes sense to have a Ref type like this, rather than just using `&RelayId`, but it doesn't seems that I can make `RelayId` and `RelayIdRef` implement Borrow and ToOwned for one another, so maybe I've messed up.
* Introduce HasRelayIds::same_relay_ids.Nick Mathewson2022-08-021-0/+10
| | | | | This method tells if two HasRelayIds contain exactly the same set of Relay identities, and is generally useful for debugging.
* tor-linkspec: Refactor out traits to represent a relay's ID set.Nick Mathewson2022-08-021-14/+24
| | | | | | | | | | | | | | 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.
* squash! Bump every crate's edition to 2021.Nick Mathewson2022-04-251-2/+0
| | | | | Remove all `use` statements for `TryFrom` and `TryInto`. These are now redundant in Rust 2021.
* tor-linkspec: Remove redundant method; add more tests.Nick Mathewson2021-12-041-10/+25
| | | | | | | The redundant method was a `to_owned` that probably shouldn't have been called that. It was only used in one place. The tests should get tor-linkspec's line coverage up above 90%.
* Improve some documentation linksNick Mathewson2021-10-291-2/+2
| | | | | | | | | Instead of putting a fully qualified name in the text, in most cases we should just use the short name of the type or function we're referring to. In other words, instead of saying [`crate::module::Foo`], we should typically say [`Foo`](crate::module::Foo).
* fix/silence clippy lints in test modulesDaniel Eades2021-09-081-0/+1
|
* Move all crates into a `crates` subdirectory.Nick Mathewson2021-08-271-0/+149
This will cause some pain for now, but now is really the best time to do this kind of thing.