Commit Graph

141 Commits

Author SHA1 Message Date
Nick Mathewson 2102d2e2b5 Add noop_method_call warning.
This would have saved ahf and me a lot of confusion in debugging a
situation where we were cloning a reference of a type that didn't
implement Clone.
2021-05-27 14:32:29 -04:00
Nick Mathewson 745c90e92c Enable cargo_common_metadata warning. 2021-05-25 15:42:47 -04:00
Nick Mathewson cf59e9be77 Add automatically generated README.md files to each crate. 2021-05-25 15:41:23 -04:00
Nick Mathewson 61c62548a5 Module docs for remaining crates 2021-05-25 15:40:02 -04:00
Nick Mathewson e8214d1df1 Use macros and types to improve handling of Netdir parameters.
(Squashed from typed-netdir-params)
2021-05-25 09:16:59 -04:00
Nick Mathewson f4d2f6980a Broaden type of from_target_ports 2021-05-20 14:12:45 -04:00
Alexander Færøy 00222dbe07 Refactor TorPath code to have explicit constructors.
This patch refactors the internal representation of the TorPath type to
use an enum for representing its state. We add explicit constructor
methods to create the different types of path's, such that client users
can write code that uses different paths based on their need.

This work was done together with Nick as part of the Arti hackathon.
2021-05-20 14:10:11 -04:00
Nick Mathewson ce6702a147 Give every Cargo.toml a repository field 2021-05-19 14:56:09 -04:00
Nick Mathewson 712e6ec23c Fill in "package.categories" on all Cargo.toml 2021-05-19 14:50:39 -04:00
Nick Mathewson 411e1b35e0 Add the "unreachable_pub" lint.
This is a somewhat obnoxious change in its scope and requirements,
but it makes it easier to understand what the real public and
private parts of our APIs are.
2021-05-18 13:45:39 -04:00
Nick Mathewson 9e7de1a692 Prefer "relay" over "node" in most circumstances. 2021-05-18 11:04:44 -04:00
Nick Mathewson e01f227191 Resolve clippy warnings from Rust 1.52.
Rust 1.52 just came out, and there are new clippy lints to deal
with:

   * It spots more cases when we could use Option::map
   * It spots more cases when we could use Iterator::flatten
   * When we build a struct instance, it wants us to list the fields
     in the same order that the struct declares them.
2021-05-07 15:53:17 -04:00
Nick Mathewson 8eb36cbfff Add trait_duplication_in_bounds warning. 2021-05-03 16:30:27 -04:00
Nick Mathewson d516298b47 Add unseparated_literal_suffix lint, and fix it. 2021-05-03 16:19:01 -04:00
Nick Mathewson 9737580402 Add a few more clippy warnings 2021-05-03 16:10:39 -04:00
David Goulet 9c96a0bb3d Fix experimental-api feature after refactoring
Important refactoring happened recently which broke the
"experimental-api" feature.

Fixes are quite simple.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-05-03 09:48:34 -04:00
Nick Mathewson 94c93c9121 Add some more clippy warnings to our list. 2021-04-27 14:51:04 -04:00
Nick Mathewson 2e3780affb Enforce (and obey) clippy lints about exhaustive enums, structs.
These lints force us to declare our exported enums and
exhaustive-looking structs as non-exhaustive (so that we can add to
them in the future without breaking our API) or to explicitly
disable the warning for a given enum/struct (to say that we _intend_
for additions to be a breaking change).
2021-04-27 14:17:49 -04:00
Nick Mathewson 92de7c58f0 Move timer functions into an extension trait. 2021-04-17 09:37:46 -04:00
Nick Mathewson 6878fe8336 Move around the public modules in tor_rtcompat. 2021-04-17 09:21:09 -04:00
Nick Mathewson 1d07132787 Remove all non-runtime methods in tor_rtcompat. 2021-04-16 17:15:55 -04:00
Nick Mathewson 8532cef9aa Add a "Runtime" parameter to all the manager types.
This is a big change, but it is a step towards our goal of removing
tor_rtcompat:: calls directly.
2021-04-16 16:12:08 -04:00
David Goulet 8bd09067cf circmgr: Add missing rng trait to build_path()
Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-04-09 08:45:09 -04:00
David Goulet 48cbae0bc7 circmgr: Add a function to build a circuit by path
Public function so an application can use to build a circuit using a
custom path.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-04-07 08:36:07 -04:00
Nick Mathewson d52ff18b46 Fix a bunch more new clippy lints in Rust 1.51
The major types are:
  * You implemented Into when you should have implemented From.
  * You sliced a slice when you didn't have to.
  * You said Ok(x?) when you could have said x.
  * You said Vec::new(); push(); push(); when you could have said vec![].
2021-03-29 16:45:45 -04:00
Nick Mathewson 6e5c056c6c Use Arc::clone() explicitly with port policies 2021-03-29 09:43:28 -04:00
George Kadianakis 508f4c4f39 Don't copy exit policies around; instead use Arc. 2021-03-29 09:41:18 -04:00
Nick Mathewson 603b0436e0 Add a compatibility layer so we can upgrade rand_core.
dalek-crypto is stuck on rand_core 0.5.1, so we've been stuck too.
This commit introduces a compatibility module so that we can wrap
new rand_core instances to make them backward compatible.
2021-03-18 13:16:32 -04:00
Nick Mathewson 6daf57957d Add the tor project as an author. 2021-03-17 14:43:40 -04:00
Nick Mathewson ba14d43be4 Add keywords to each Cargo.toml 2021-03-17 14:41:02 -04:00
Nick Mathewson c8481a9354 Add a description field to all our Cargo.toml files 2021-03-17 14:31:59 -04:00
Nick Mathewson 58d8472ea0 Give it a homepage everyplace. 2021-03-17 14:13:26 -04:00
Nick Mathewson 695268019e upgrade async-trait 2021-03-09 09:43:00 -05:00
Nick Mathewson 302653977d Bump dependencies with "cargo upgrade" 2021-03-06 08:55:13 -05:00
Nick Mathewson b87b3e978b Use expect() instead of unwrap() in tor-circmgr 2021-03-04 11:33:29 -05:00
Nick Mathewson 8c31418500 Port to work with tokio or async-std.
This is fairly ugly and I think I'll need to mess around with the
feature configuration a while until we get something that's pleasant
to develop with.  This still seems like a good idea, though, since
we _will_ need to be executor-agnostic in the end, or we'll have no
way to handle wasm or embedded environments.

Later down the road, we'll probably want to use futures::Executor or
futures::Spawn more than having global entry points in
tor_rtcompat.  That would probably make our feature story simpler.

Tokio is the default now, since tokio seems to be more heavily used
for performance-critical stuff.

This patch breaks tests; the next one will fix them, albeit
questionably.
2021-03-02 11:55:09 -05:00
Nick Mathewson 568567c5e0 Update to latest futures, once_cell 2021-02-23 15:54:29 -05:00
Nick Mathewson ab9d4a2229 Update some dependencies. 2021-02-19 09:39:23 -05:00
Nick Mathewson aeb410b915 Make authorities and fallbacks configurable.
This commit adds configuration options for these values, with the
right defaults, and uses those options instead of built-in functions
to set them.

We also remove the function to extract information from chutney
directories: now that arti is configurable, it can be chutney's job
to make its own network configurations.
2021-02-11 13:08:46 -05:00
Nick Mathewson 243880473f bump serde and log 2021-02-01 16:39:07 -05:00
Nick Mathewson 680efe169c More logging in circmgr. 2021-01-26 09:13:27 -05:00
Nick Mathewson 3f455e6f30 require latest futures crate 2021-01-15 17:05:05 -05:00
Nick Mathewson fa57fb4995 Upgrade a few more dependencies. 2021-01-13 08:17:14 -05:00
Nick Mathewson 7e843de2c8 Upgrade a few dependencies. 2021-01-13 08:14:28 -05:00
Nick Mathewson f01d641ec8 cargo upgrade. 2020-12-30 15:59:33 -05:00
Nick Mathewson 2e5f694503 Cleanup on DirInfo::circ_params. 2020-12-22 16:17:35 -05:00
Nick Mathewson dd0c866090 Implement the "circwindow" and "ExtendByEd25519ID" parameters
These necessitated a little complexity for our circuit
creation/extension API; we might want to refactor that down the
road.
2020-12-22 16:02:49 -05:00
Nick Mathewson df4524d936 Check ipv6 exit policies when trying to connect to an ipv6 port specifically 2020-12-22 09:28:26 -05:00
Nick Mathewson ccd6cbf627 upgrade to latest anyhow 2020-12-21 10:21:24 -05:00
Nick Mathewson 42db4210ab Simplification: Every relay is in the same family as itself. 2020-12-17 15:32:09 -05:00
Lunar 42f0d294de Make sure that a circuit doesn't use relays in the same family
We implement `Relay::in_same_family` which is in turn used by
`ExitPathBuilder::pick_path` to avoid picking relays in the
same family.

Compared to the original C implementation, we are missing
support for options EnforceDistinctSubnets and NodeFamilySets.

This has only been very lightly tested so far.

Closes: #43
2020-12-16 16:34:59 +01:00
Nick Mathewson 635cdc06d8 Write a few misc unit tests 2020-12-15 15:34:08 -05:00
Nick Mathewson cae16665cb Basic support for IPv6 and begin flags.
We now have a way to tell a circuitmgr whether we require ipv4/ipv6
support for a target address in an exit policy, and we use similar
logic to set begin flags.
2020-12-15 14:41:03 -05:00
Nick Mathewson d408cf0f4b Implement a notion of "circuit dirtiness", as in Tor. 2020-12-15 11:37:17 -05:00
Nick Mathewson 6a42ba718f Fix some clippy warnings. 2020-12-15 08:37:23 -05:00
Nick Mathewson a7a3ef5135 circmgr: refactor and bugfix a bit.
Notably, turn the hashmap into its own type.  This will help with
other refactoring and fixes in the future.

Also notably, fix the code we use when a pending circuit is
complete.  There's still a design flaw there though.
2020-12-14 14:57:29 -05:00
Nick Mathewson c4d3f34e47 tor-circmgr: update documentation 2020-12-14 14:33:21 -05:00
Nick Mathewson 20751f9993 Give more information if we fail to create a pending circuit. 2020-12-14 14:18:36 -05:00
Nick Mathewson 07c08cdf6c Remove now-unused busted From<TargetCircUsage> for CircUsage 2020-12-14 14:08:58 -05:00
Nick Mathewson 6f800ad271 tor-circmgr: always remove closed circuits from the list. 2020-12-14 14:07:58 -05:00
Nick Mathewson 57499d5cf5 tor-circmgr: Use a better key type for our circuit map.
We now use the unique id of each non-pending circuit as its key in
the map.  I wish I could do this without copying, but I don't see a
great way to do that while keeping the pending entries in the same
map for now.
2020-12-14 14:00:53 -05:00
Nick Mathewson d92c1aac04 Remember the actual usable ports for an exit after we've built a circuit
Previously we'd just remember the port that we _wanted_ a circuit
for, and forget all the ports that it _could_ support.

This is part of a bigger circmgr revision/refactoring pass; there
should be cleanups before I merge this.
2020-12-14 12:29:51 -05:00
Nick Mathewson 17c84fd59e upgrade to require latest anyhow. 2020-12-08 17:26:19 -05:00
Nick Mathewson 8d6087426e De-parameterize ChanMgr and everything that wraps it.
This makes a whole lot of our code simpler, and makes it so that
CircMgr and DirMgr no longer need to have anything parameterized
over transports, either.

Instead of boxing Transport inside of ChanMgr, I've made a new
Connection trait that goes from a ChanTarget* straight to a Channel.
This lets us avoid having to box the intermediate TLS object.

[*] Actually, a copy of the information from a ChanTarget. Ick, but
I had to make a copy to avoid parameterizing
Connecter::build_channel.
2020-12-08 16:29:18 -05:00
Nick Mathewson a52585d9d6 Mark some XXXX issues as XXXX-A1. 2020-12-07 16:07:59 -05:00
Alexander Færøy 0eedd017ce Fix typo in pick_path().
This patch fixes a minor typo in the error case when looking for a
middle relay for a 3-hop circuit where the error message should say "No
middle relay found" and not "No exit relay found".
2020-12-05 22:45:43 +00:00
Nick Mathewson 412f1763de Implement correct (?) weighting for path selection. 2020-12-02 13:51:19 -05:00
Nick Mathewson 85c287c4e4 When retiring circuits, do it by ID, not by reference. 2020-12-01 16:50:51 -05:00
Nick Mathewson f5f2a648a3 tor-dirclient: add timeouts
This adds two timeouts in total: one for sending begin, and getting
headers, and one for getting the rest of the data.

These timeouts are way too long right now, but at least the code is
there.
2020-12-01 08:56:25 -05:00
Nick Mathewson a3a077419a Fix a couple of new clippy warnings. 2020-11-28 14:20:15 -05:00
Nick Mathewson e18b4e07cb Upgrade a couple of dependencies 2020-11-28 14:17:42 -05:00
Nick Mathewson cc55469307 Add a function to retire circuits. 2020-11-24 12:44:04 -05:00
Nick Mathewson 02bac5f04e Add support for using fallback directories in path construction
This is mainly a refactoring commit, with a little new code.

It also adds #[derive(Copy,Clone)] for a few types.
2020-11-19 10:06:48 -05:00
Nick Mathewson 0945808e9b Add a notion of a one-hop fallback path.
These have a FallbackDirectory as target, rather than a Relay.
2020-11-17 16:58:26 -05:00
Nick Mathewson 5188263429 Refactor first-hop handling types a bit
This lets us have the notion of "get the first hop of a path as some
kind of a chantarget", which will make it easier to write other path
types.
2020-11-17 16:46:23 -05:00
Nick Mathewson 1148b2d79a Note an unpleasantness in the circmgr api. 2020-11-16 15:07:19 -05:00
Nick Mathewson cb59ae3933 Move closed-check for circuits into an atomicbool. 2020-11-13 09:08:15 -05:00
Nick Mathewson 6e5db3a0e7 Make Arc<>-ness of ClientCirc explicit. 2020-11-12 12:58:33 -05:00
Nick Mathewson ac174c7666 Make the Arc-ness of channels more explicit.
Previously every channel was a secret Arc<>, which I think is bad
style, and which stopped us from using weak references in other
places.
2020-11-12 12:34:50 -05:00
Nick Mathewson fabd6840ff tor-circmgr: timeout and retry support. 2020-11-11 17:40:32 -05:00
Nick Mathewson 59e4b5631a Isolate async_std usage in a new tor_rtcompat crate.
Like tor_llcrypto, this crate is meant to expose only the part of
other crates (in this case, a async runtime crate) that we use.
2020-11-11 13:46:39 -05:00
Nick Mathewson dc301094fd Use anyhow in tor-circmgr and tor-chanmgr 2020-11-11 10:23:29 -05:00
Nick Mathewson af16ec18a3 update some dependencies 2020-11-11 09:14:26 -05:00
Nick Mathewson 4d24fff9c0 Upgrade dependencies 2020-11-10 12:27:10 -05:00
Nick Mathewson 9c7ed1fdde upgrade a few packages. 2020-11-05 16:56:29 -05:00
Nick Mathewson 6120a2ceac circmgr: Make sure circmgr can be shared among threads 2020-11-04 11:31:39 -05:00
Nick Mathewson 7128c14f49 Make 'netdir' no longer a field in circmgr. 2020-11-02 14:25:49 -05:00
Nick Mathewson 80b70881af Add a tiny bit of cleanup logic to tor-circmgr 2020-11-02 14:21:14 -05:00
Nick Mathewson 8ab8c52193 Document tor-circmgr 2020-11-02 14:11:31 -05:00
Nick Mathewson 7d2b2391ab Implement rudimentary circuit-manager functionality
This code is meant to "get or launch a circuit as appropriate."
It's super dodgy, but it is probably good enough for a first pass.
2020-11-02 11:54:02 -05:00
Nick Mathewson d9dafa0a28 Add a new circuit-manager crate and move path selection there. 2020-11-02 10:44:31 -05:00