summaryrefslogtreecommitdiff
path: root/crates/tor-linkspec/src/ids.rs
Commit message (Collapse)AuthorAgeFilesLines
* Upgrade to derive_more version 1.0.0Nick Mathewson2024-09-251-7/+7
| | | | | | The `derive_more` crate broke backward compatibility with this version, so this change involved quite a few manual fixups. With luck, they'll keep compatibility for some while in the future.
* tor-linkspec: Use derive-deftly rather than strum for same_relay_idsIan Jackson2024-04-031-0/+3
|
* 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
|
* Fix new "useless_vec" warning from clippy +nightlyIan Jackson2023-07-101-1/+1
| | | | | | | | | | | Explanation at https://rust-lang.github.io/rust-clippy/master/index.html#/useless_vec This is the non-tests subset of the same-named commmit in !1388, (recreated by hand by me, and then checked against that commit; I stole the commit message from Nick's.) This should be uncontroversial I think.
* RelayId: Display the ID type on redacted identities.Nick Mathewson2023-06-091-3/+2
| | | | | Formerly we would display just the first characters of the identity, without telling you what kind of ID it was.
* RelayId: implement id_type and as_bytes in terms of RelayIdRefIan Jackson2023-04-271-8/+2
| | | | This eliminates some duplicated code.
* RelayIdRef: as_bytes: Doesn't borrow from selfIan Jackson2023-04-271-1/+1
| | | | | | | This borrows from the contained key, but not from self. This will allow us to implement RelayId::as_bytes in terms of RelayIdRef::as_bytes.
* RelayId: impl Display in terms of RelayIdRefIan Jackson2023-04-271-3/+9
| | | | This removes a duplicated copy of the format strings.
* 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/+29
|
* linkspec: Add compare-by-relay-ids function to HasRelayIdsNick Mathewson2022-10-211-2/+4
|
* Write more tests for RelayId and RelayIdRef.Nick Mathewson2022-10-151-0/+138
|
* Fix deserialize impl for RelayId.Nick Mathewson2022-10-151-1/+1
| | | | | | | 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.
* linkspec: impl Hash for RelayIdRefNick Mathewson2022-10-151-1/+1
|
* tor-linkspec: ByRelayIds<> type to hold a set of HasRelayIdsNick Mathewson2022-10-041-0/+1
| | | | | This is based on the type generated with n_key_set, with a couple of extra methods to take advantage of RelayId and RelayIdRef.
* tor-netdir: Add a static assertion about RelayIdType::COUNTNick Mathewson2022-08-101-1/+16
| | | | | | | Doing this will make sure that we fix a correctness issue in netdir that will be caused if we add more IDs. (Also add RelayIdType::COUNT in tor-linkspec.)
* Implement `Into<RelayIdRef>` for `&RelayId`.Nick Mathewson2022-08-101-0/+6
| | | | | This will let us use `&RelayId` in all the places that take `Into<RelayIdRef>`.
* Final (?) API revisions for tor-linkspecNick Mathewson2022-08-101-24/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* linkspec: Add more accessors (some internal) for ids.Nick Mathewson2022-08-101-0/+68
| | | | These will all be used shortly.
* Introduce a RelayIdSet and use it in place of HashSet<RelayId>.Nick Mathewson2022-08-101-0/+13
| | | | | 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.
* Teach guard restrictions about RelayId.Nick Mathewson2022-08-101-0/+16
| | | | | This implementation is (sadly) too copy-heavy or now, because HashSet<RelayId> can't be indexed with RelayIdRef.
* Parsing, encoding, and serde for RelayId.Nick Mathewson2022-08-101-4/+191
| | | | | | | | | | | | | | | The formats used here are backward-compatible with those used by C tor and those used elsewhere in our code. We need a way to encode _both_ current kinds of identities as a string that tells you what kind of ID they are. Traditionally we have used hexadecimal, sometimes with a $, for RSA ids, and we have used base64 for Ed25519 IDs. We also introduce a new forward-compatible format for new identity keys in the future. (The new format is the key identity type, a colon, and the id encoded as base64.) We will use this new format _only_ when we need to encode identities in a way where it would be otherwise unclear what kind of key we are dealing with.
* Add a set of Identity-related types and accessors.Nick Mathewson2022-08-101-0/+105
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.