summaryrefslogtreecommitdiff
path: root/crates/tor-netdir/src/lib.rs
Commit message (Collapse)AuthorAgeFilesLines
* Rename onion-* cargo features to hs-* in tor-* cratesIan Jackson2023-02-281-24/+24
| | | | Fixes #756
* Fix minimal-versions (.then_some is too new)Ian Jackson2023-02-091-1/+1
|
* tor-netdir: Make is_hsdir_for_ring crate-localIan Jackson2023-02-091-1/+2
| | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1012#note_2876824
* Fix typosNick Mathewson2023-02-091-2/+2
|
* Fix compilation with various feature combinationsIan Jackson2023-02-091-5/+18
|
* hsdir: rustfmtIan Jackson2023-02-091-6/+5
| | | | | Deferred formatting changes which would have obscured the commits they were prompted by.
* hsdir: Actually compute the hash ringIan Jackson2023-02-091-4/+0
|
* hsdir: Be able to enumerate the hidden service directoriesIan Jackson2023-02-091-0/+25
| | | | | | * Provide an accessor for the HSDIR flag * Provide a function for testing a relay for hsdir inclusion * Provide an iterator on NetDir that returns the hsdirs
* hsdir: Ring calculation plumbingIan Jackson2023-02-091-16/+10
| | | | | | | | | | | * Implement Netdir::compute_rings in terms of a new HsDirRing::compute, that currently does nothing. * Actually call Netdir::compute_rings (since now it doesn't panic). * Make Netdir::compute_rings not be pub. We do this unconditionally, rather than exposing the distinction between a netdir-without-hsdir and a netdir-with-hsdir.
* hsdir representation: Introduce HsDirs generic typeIan Jackson2023-02-091-33/+56
| | | | | This already allows us to get rid of some duplication, and will be useful more widely in a moment.
* hsdir: Rename HsRingParams to HsDirParamsIan Jackson2023-02-091-2/+2
| | | | | | | | | The file which contains this type is called hsdir_params.rs. We have a general problem with slight confusion about when to includen "dir" and when to include "ring". Resolve this in favour of the rule now added to the module-level doc comment.
* hsdir_params: Rename some variables for consistencyIan Jackson2023-02-091-2/+2
| | | | | | | | | | These variables are going to be struct fields, which will sort of enforce consistent naming. The struct fields are going to appear in a moment. We'll call the fields "current" and "secondary" after the naming in the test cases. And import hsdir_params::HsRingParams, which we're going to make more references to.
* hsdir: Replace open-coded params fields and args with HsRingParamsIan Jackson2023-02-091-2/+2
| | | | | | This will enable us to pass these around more conveniently. And make empty_from_params take an owned params, which it would like.
* hsdir: Remove a done TODO - this *is* now a TiSliceIan Jackson2023-02-091-1/+0
|
* tor-netdir: Provide Netdir::md_by_idxIan Jackson2023-02-091-0/+6
| | | | We'll need this shortly.
* tor-netdir: Store previous netdir (if required by features)Ian Jackson2023-02-091-1/+15
|
* tor-netdoc: Change fill_from_previous_netdirIan Jackson2023-02-091-10/+7
| | | | | | | | | | | | | | | | * Remove the return value, which was not used anywhere. Also remove the code to calculate the return value. * Take an Arc<NetDir> rather than a reference. We are going to want this for HS support. This has no overall effect on the lifetime of the4 Arc, which was owned at the one call site and then imediately dropped. * Change the documentation to explain what the function's role is in the netdir API, rather than the fiddly details of what it actually does internally. Relegate the latter to a code comment. (When we have HS, this will do more, or, at least, make further arrangements.)
* tor-hscrypto: Rename key types to correspond to new spec names.Nick Mathewson2023-02-081-2/+2
|
* Tidy up docs about RouterStatusIdxIan Jackson2023-02-011-9/+6
| | | | | | Always use "index" and not "position". Remove wording which is otiose given the type name.
* tor-netdir: Use typed-index-collections for router status indexIan Jackson2023-02-011-16/+29
|
* tor-netdir: Provide ConsensusRelays extension trait (fmt)Ian Jackson2023-02-011-4/+1
|
* tor-netdir: Provide ConsensusRelays extension traitIan Jackson2023-02-011-11/+31
| | | | | Call it everywhere instead of the inherent method on MdConsensus. (Verified by ad-hoc temporarily renaming MdConsensus::relays().)
* Change two in-code references to the wrong feature nameIan Jackson2023-02-011-2/+2
| | | | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/issues/756 I think this is going in the wrong direction, but it is better to fix it so that the names agree for now, pending a decision on the naming.
* Turn compute_ring_params into a method.Nick Mathewson2023-01-281-1/+1
|
* netdir: Implement ring-param constructors and time period accessorsNick Mathewson2023-01-281-18/+37
| | | | | | | | | | | | | | This logic is a bit tricky, so I've tried to document it and add fairly good tests. The silver lining is that the external API for all of this logic will make it invisible and hidden. There are some cases where I added functions that I think might eventually get lowered into MdConsensus: But I don't want to lower too much right now, since the convention for our netdoc accessors is that they are fairly unsophisticated, and they show you the document as it is. Closes #686
* 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.
* Elide a bunch of lifetimes.Nick Mathewson2023-01-271-3/+3
| | | | | Clippy now warns about these; I'm not sure how these warnings snuck up on us.
* Disable clippy::unlinlined-format-argsNick Mathewson2023-01-271-0/+1
| | | | | | | | 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.
* Adjust onion service ring APIs in light of prop#342Nick Mathewson2023-01-111-35/+71
| | | | | | | | | | * It is the NetDir's responsibility to tell the caller what the time period is. * There can be up to two secondary time periods. * Each time period has a single SRV. * Secondary time periods only apply for onion services, when they publish. * When publishing, the correct input is a time period.
* Sketch APIs for the onion service directory ring.Nick Mathewson2023-01-111-0/+114
| | | | | | | | | These are a bit complex internally, but the API they present is pretty simple. I've left some discussion of points where the design isn't totally fleshed out, and where we need to look harder at the spec. Part of #716.
* test lint blocks: Do some semi-manuallyIan Jackson2022-12-121-0/+8
| | | | | | | This is the hunks from running the rune in maint/adhoc-add-lint-blocks but which require some subsequent manual fixup: usually, deleting now-superfluous outer allows, but in some cases manually putting back lints that the adhoc script deleted.
* Mock implementation of a NetDirProvider for testing.Nick Mathewson2022-11-081-0/+2
| | | | | I'm about to remove the old testing APIs from GurdMgr that took in a NetDir in each function: adding this will make that possible.
* Run add_warnings.Nick Mathewson2022-11-031-0/+1
|
* FlagEvent trait: Implement using macrosIan Jackson2022-10-251-1/+6
| | | | | | | | | | | The explicit list of variant names, that needs to be kept in sync, and is a test failure semver break hazard, is now gone. All the necessary code is now generated automatically, and cannot be wrong. I want this because I find myself wanting to add a second implementation of FlagEvent, for another type.
* netdir: Expose addrs-in-same-subnets calculation from SubnetConfigNick Mathewson2022-10-241-8/+18
| | | | | Previously this was a private method only visible from Relay, but now we can use it on any two HasAddrs objects.
* cargo fmt to remove blank linesIan Jackson2022-10-121-1/+0
| | | | | | | Apparently cargo fmt doesn't like these, which my perl rune didn't delete. This commit is precisely the result of `cargo fmt`.
* Replace all README copies in src/lib.rs with includesIan Jackson2022-10-121-26/+1
| | | | | | | | 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
* tor-linkspec: Remove the old OwnedFoo::new() functionsNick Mathewson2022-10-061-3/+15
| | | | These are now builders.
* Begin revising HasAddr and its relationship to ChanTargetNick Mathewson2022-10-061-1/+4
| | | | | | | | | | | | | | | | | | | 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.
* enable doc_auto_cfg feature on every crate when documenting for docs.rstrinity-1686a2022-08-241-0/+1
|
* Merge branch 'main' into 'linkspec_refactor_v3'Nick Mathewson2022-08-101-0/+15
|\ | | | | | | # Conflicts: # crates/tor-netdir/semver.md
| * Finish implementation of params() for DirMgr.Nick Mathewson2022-08-021-0/+15
| | | | | | | | | | | | | | Now it maintains an up-to-date set of default parameters to be handed out if there is no directory. Closes #528.
* | tor-netdir: Add a static assertion about RelayIdType::COUNTNick Mathewson2022-08-101-2/+5
| | | | | | | | | | | | | | 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.)
* | netdir: remove long-unused missing_descriptor_for codeNick Mathewson2022-08-101-23/+0
| |
* | tor-netdir: Remove or hide some no-longer-used accessors.Nick Mathewson2022-08-101-29/+13
| | | | | | | | | | The hidden ones are only used to implement higher-level accessors; the others are not used at all.
* | tor-netdir: Collapse by_id and by_relay_id into a single fn.Nick Mathewson2022-08-101-49/+58
| | | | | | | | | | | | 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.
* | Final (?) API revisions for tor-linkspecNick Mathewson2022-08-101-25/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | netdir: Add and use a new ids_listed() function.Nick Mathewson2022-08-021-0/+9
| |
* | netdir: add an accessor that takes a HasRelayIds.Nick Mathewson2022-08-021-1/+12
| |
* | tor-linkspec: Refactor out traits to represent a relay's ID set.Nick Mathewson2022-08-021-2/+6
|/ | | | | | | | | | | | | | 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.