aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-linkspec/src/owned.rs
Commit message (Collapse)AuthorAgeFilesLines
* maint: Run maint/add_warning to deny string slicesClara Engler2026-06-091-0/+1
| | | | | | | | | | | | This commit executes maint/add_warning with the just added change to deny string slices except in tests. I recommend auditing this by checking out the previous commit followed by running the script yourself and then verifying that the diff is identical to this commit. This commit makes cargo clippy fail. We will add exceptions in the next commit.
* linkspec: Add serde(default) to fields in RelayIds.Nick Mathewson2026-04-281-2/+6
| | | | | | | | With this change, we will accept serialized RelayId representations that omit one or more keys. This will eventually allow us to omit absent keys when we serialize these. This is the first stage of #2477.
* linkspec: Implement a RelayIdsBuilder::from_relay_ids()David Goulet2026-03-031-0/+18
| | | | | | | | | This is used when we build an OwnedChanTarget using the builder. Instead of going identities by identities at the callsite, we can use this helper to get us a RelayIds builder and set it in the OwnedChanTargetBuilder. Signed-off-by: David Goulet <[email protected]>
* linkspec: Remove comment about expense of cloning protocols.Nick Mathewson2025-12-031-2/+0
|
* Fix name of clippy lint to unchecked_time_subtraction (2)Ian Jackson2025-11-061-1/+1
| | | | Run maint/add_warning
* tor-linkspec: Change HasAddrs::addrs to return an IteratorIan Jackson2025-10-061-6/+7
| | | | | | | | This will let us model the actual structure of routerstatus entries in netdocs more closely. They don't have the addresses in a single list. When this code was written this would have been much more awkward, but now we have RPITIT.
* circmgr: Don't count channel negotiation towards circuit built time.Nick Mathewson2025-08-071-0/+5
| | | | | | | | | | This is important, since some circuits require us to negotiate a new channel, and some don't: by adding this variability, we can easily learn a timeout based on pre-existing channels to our guards, but then later time out if it takes a while to open a TLS connection. This is a possible solution to part of #2079, a bug where we "learn" a circuit timeout that is too low for us to satisfy.
* Switch Cargo.toml files to edition 2024.Nick Mathewson2025-08-071-1/+4
| | | | | | | | | | | | | | First, run ``` git grep -l "^edition =" | xargs perl -i -pe 's/^edition *=.*/edition = "2024"/;' ``` Second, manually verify that all Cargo.toml files have changed, and nothing else has changed. Third, run cargo fmt again.
* tor-chanmgr: don't allow pending channels with no relay idsSteven Engler2024-10-011-1/+1
|
* Run maint/add_warning.Nick Mathewson2024-03-131-0/+1
|
* Run maint/add_warning to add lint block everywhereIan Jackson2023-08-231-0/+1
|
* Run maint/add_warning to actually apply new lint allowsIan Jackson2023-07-101-0/+1
|
* RelayId: Display the ID type on redacted identities.Nick Mathewson2023-06-091-1/+1
| | | | | Formerly we would display just the first characters of the identity, without telling you what kind of ID it was.
* linkspec: implement Display/Redacted on RelayIdsNick Mathewson2023-06-091-0/+22
|
* 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.
* 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.
* linkspec: Give a Redacted form for chantarget.Nick Mathewson2022-11-281-0/+11
|
* tor-linkspec: Provide LoggedChanTarget type alias and utility methodIan Jackson2022-11-231-0/+11
| | | | | This makes it easy to talk about, and construct, a BoxSensitive<OwnedChanTarget>, which is what we'll use in errors.
* Merge branch 'refactor_into_ownedchantarget' into 'main'Nick Mathewson2022-11-181-0/+18
|\ | | | | | | | | CircMgr: Refactor DirSpecificTarget constructor See merge request tpo/core/arti!866
| * CircMgr: Refactor DirSpecificTarget constructorNick Mathewson2022-11-181-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | 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)
* | Remove impl Display for OwnedCircTargetNick Mathewson2022-11-171-7/+0
| | | | | | | | | | Nothing used this; if anything wants it, it would be better off calling `.display_chan_target()`.
* | ChanTarget: Add a display function, with better output.Nick Mathewson2022-11-171-11/+1
|/ | | | | | | | | | 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
* guardmgr: Refactor the interior of FirstHop.Nick Mathewson2022-10-241-15/+8
| | | | | | | | | | | | | 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".
* Change multiplicity of ChannelMethod and addressesNick Mathewson2022-10-111-11/+16
| | | | | | | Now each `ChanTarget` has at most one `ChannelMethod`, and only `Direct` `ChannelMethods` can have multiple addresses. Closes #600.
* tor-linkspec: Remove the old OwnedFoo::new() functionsNick Mathewson2022-10-061-56/+21
| | | | These are now builders.
* Add builders for OwnedChanTarget/OwnedCircTargetNick Mathewson2022-10-061-12/+60
| | | | | This will become the preferred way to make one of these objects, and insulate us against future API changes.
* Begin revising HasAddr and its relationship to ChanTargetNick Mathewson2022-10-061-4/+32
| | | | | | | | | | | | | | | | | | | 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-0/+1
| | | | We'll need to sort these out as we implement pluggable transports.
* Final (?) API revisions for tor-linkspecNick Mathewson2022-08-101-27/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Introduce HasRelayIds::same_relay_ids.Nick Mathewson2022-08-021-4/+2
| | | | | This method tells if two HasRelayIds contain exactly the same set of Relay identities, and is generally useful for debugging.
* Implement serde traits on RelayIds.Nick Mathewson2022-08-021-2/+5
| | | | | This will allow RelayIds to replace IdPair in tor-guardmgr. (The fields are named accordingly with `serde(rename)`.)
* tor-linkspec: Refactor out traits to represent a relay's ID set.Nick Mathewson2022-08-021-15/+60
| | | | | | | | | | | | | | 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.
* ChanMgr: errors: attribute errors to correct address.Nick Mathewson2022-07-061-0/+14
| | | | | | Even when keys are relevant, we still don't want to attribute errors to a set of addresses when we have a single address that we're connected with.
* tor-linkspec: impl Display for OwnedChanTarget and OwnedCircTargetIan Jackson2022-02-041-0/+23
|
* tor-linkspec: Remove redundant method; add more tests.Nick Mathewson2021-12-041-1/+26
| | | | | | | 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%.
* fix/silence clippy lints in test modulesDaniel Eades2021-09-081-0/+1
|
* Move all crates into a `crates` subdirectory.Nick Mathewson2021-08-271-0/+139
This will cause some pain for now, but now is really the best time to do this kind of thing.