summaryrefslogtreecommitdiff
path: root/crates/tor-netdir/src
Commit message (Collapse)AuthorAgeFilesLines
* netdir: remove duplicate code in param calculationNick Mathewson2023-01-281-23/+31
|
* netdir: remove the vestigial smallvec implementation I addedNick Mathewson2023-01-281-1/+1
| | | | | It's cute, but I don't think it will help performance, and I'm undecided about whether the semantic implications are true.
* Turn compute_ring_params into a method.Nick Mathewson2023-01-282-55/+61
|
* Several suggestions on gitlab.Ian Jackson2023-01-281-0/+2
|
* netdir: Implement ring-param constructors and time period accessorsNick Mathewson2023-01-284-18/+520
| | | | | | | | | | | | | | 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-274-0/+4
| | | | | 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.
* Merge branch 'onion-netdir-apis' into 'main'Nick Mathewson2023-01-113-0/+289
|\ | | | | | | | | Add onion service APIs to tor-netdir See merge request tpo/core/arti!966
| * Adjust onion service ring APIs in light of prop#342Nick Mathewson2023-01-113-36/+95
| | | | | | | | | | | | | | | | | | | | * 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-112-0/+230
| | | | | | | | | | | | | | | | | | 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.
* | netdir: add network parameters related to onion servicesNick Mathewson2023-01-111-1/+80
|/ | | | | | | These are available unconditionally, since they represent comparatively little storage and processing effort. See param-spec.txt section 8 for the original information here.
* test lint blocks: Add many many automaticallyIan Jackson2022-12-123-0/+26
| | | | | This is precisely the result of running the rune in maint/adhoc-add-lint-blocks.
* 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-082-0/+61
| | | | | 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.
* fix clippy::needless_borrowtrinity-1686a2022-09-101-1/+1
|
* enable doc_auto_cfg feature on every crate when documenting for docs.rstrinity-1686a2022-08-241-0/+1
|
* tor-netdoc: if_ito: Add expansion of acronymIan Jackson2022-08-171-0/+2
|
* tor-netdir: testnet: construct_custom_netdir_with_params: Fix docIan Jackson2022-08-171-1/+2
| | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/657#note_2826168
* tor-netdir, testnet: Provide construct_custom_netdir_with_paramsIan Jackson2022-08-161-2/+16
| | | | | We're going to want this for testing netdirs with padding parameters that diff ere from the spec's default.
* tor-congestion: implement the RTT estimation algorithm from prop#324eta2022-08-111-0/+21
| | | | | | | | | | | This commit implements the round-trip-time estimation algorithm from Tor proposal 324, validating the implementation against the test vectors found in C tor. (Note that at the time of writing, the new test vectors may not be committed to C tor yet, but they will be soon.) This also adds the necessary consensus parameters to `NetParameters`. Some of them have been renamed in order to (hopefully) make them more understandable.
* Merge branch 'main' into 'linkspec_refactor_v3'Nick Mathewson2022-08-102-0/+23
|\ | | | | | | # Conflicts: # crates/tor-netdir/semver.md
| * Finish implementation of params() for DirMgr.Nick Mathewson2022-08-022-0/+23
| | | | | | | | | | | | | | 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.
* Fix a rustdoc link in tor-netdir.Nick Mathewson2022-07-261-1/+1
|
* tor-netdir: Remove latest_netdir method.Nick Mathewson2022-07-261-10/+0
|
* Add new APIs to NetDirProvider to better support timeliness.Nick Mathewson2022-07-262-3/+78
| | | | | | | | | | | | | | | | | Over the years we've found that most callers who want a netdir want what C Tor calls a "reasonably live" network directory: One that is not expired by too much, or too far in the future. But a few want a _strictly_ live directory: one that says it is valid now, with no tolerances. And a few want _any_ directory, no matter how expired it is. This commit adds net methods to NetDirProvider to provide these directories. I think that most use cases will want to explicitly think about what kind of directory they want, so I've made `netdir` the simplest method. I might remove `timely_netdir` by the end of this branch; see TODO comments. Part of #518.
* netdir: Make pick() functions take FnMut closures.Nick Mathewson2022-07-121-2/+2
| | | | | | There's no reason to enforce their being Fn closures, and allowing them to be FnMut allows us to count which filters make us rejected given relays.
* Run maint/add_warning crates/*/src/{lib,main}.rsIan Jackson2022-06-231-0/+3
| | | | Update all lint blocks
* channel padding: Use IntegerMilliseconds in netdirIan Jackson2022-06-211-8/+8
|
* tor-netdir: Make CHANNEL_PADDING_TIMEOUT_UPPER_BOUND pubIan Jackson2022-06-211-1/+1
| | | | We need this because it is a type parameter for the types of nf_ito_*.
* channel padding: Change timeout to match C TorIan Jackson2022-06-211-1/+6
| | | | Pending an official value from the spec.
* channel padding: Add the parameters from the spec to NetDirIan Jackson2022-06-211-0/+28
|
* Remove some outdated comments.Nick Mathewson2022-06-171-1/+1
| | | | | These all say, in one form or another, "there is no guard filtering; there is only one selection". That's now false.
* tor-netdir: testnet: Make construct_netdir infallibleIan Jackson2022-06-132-5/+5
| | | | | This is a *lot* of unwraps. The function takes no parameters and is used only for testing. It ought to be infallible.
* Merge branch 'use-testing-rng'Nick Mathewson2022-06-073-75/+37
|\