Commit Graph

2355 Commits

Author SHA1 Message Date
Nick Mathewson 2689d810bf Make TorClient reconfigurable.
This covers ClientAddrConfig and ClientTimeoutConfig.
2021-12-07 16:58:41 -05:00
Nick Mathewson cac4ce759e Minor circuit predictor tweaks and comments.
Most notably, make min_exit_circs_for_port actually get used.

Also add a couple of comments.
2021-12-07 16:48:09 -05:00
Nick Mathewson 0f8d620757 Make preemptive circuits reconfigurable.
This required re-centralizing the configuration object for preemptive
circuits, since previously the settings from it were a bit spread out
over the crate.
2021-12-07 16:42:58 -05:00
Nick Mathewson 8fed1524fa MutCfg: Add map_and_replace.
This will help in the case when a configuration can only partially
change.
2021-12-07 16:40:49 -05:00
Nick Mathewson a406e8e449 Make circuit_timing reconfigurable. 2021-12-07 16:08:52 -05:00
Nick Mathewson 99fb41218d Add new configuration objects to reconfigure.
(These weren't in the codebase when I started the first version of
this branch.)
2021-12-07 15:47:25 -05:00
Nick Mathewson 11210124da Allow on-the-fly changing of path_rules
And now the complexity begins: when the user changes the path_rules,
they not only want new circuits to obey those rules: they want
_all new requests_ to be put onto circuits that obey those rules.

That means that when the path rules become more restrictive, we need
to retire all the circuits, and make sure that currently pending
circuits aren't used for any requests.

If it's any comfort, doing this was even more complicated in C tor. ;)
2021-12-07 15:42:14 -05:00
Nick Mathewson f06d5ae48f MutCfg facility to help with reconfiguration.
It's useful to keep configuration objects inside a RwLock<Arc<>>, so we
can have slightly-stale pointers to the existing configuration structure
without holding locks too long.

This code adds a MutCfg type with basic support for this pattern,
and functions to make it a bit more ergonomic.
2021-12-07 15:42:14 -05:00
Nick Mathewson 606d64eac5 Sketch API for reconfiguration.
This patch doesn't actually make anything reconfigurable, but it
does create an API that will tell you "you can't change the value of
that!"  If the API looks reasonable, I can start making it possible
to change the values of individual items.
2021-12-07 15:42:14 -05:00
eta 333d85a0d8 Merge branch 'dns_config_cleanups' into 'main'
Small cleanups to stream timeout configurations

See merge request tpo/core/arti!179
2021-12-07 20:00:31 +00:00
Nick Mathewson 2337d14ecf Make ClientTimeoutConfig members crate-private.
We shouldn't have pub members in these config objects.
2021-12-07 14:05:41 -05:00
Nick Mathewson 46c917d127 Rename timeout_rules to stream_timeouts.
(There are other timeout rules, after all.)

Also, rename stream_timeout to connect_timeout, to make it more clear
when it applies.
2021-12-07 14:03:14 -05:00
eta 2614fb736e Merge branch 'revised_preemptive_config' into 'main'
Usability: renaming and documentation in preemptive circuit config

See merge request tpo/core/arti!176
2021-12-07 17:51:42 +00:00
eta aec99469c7 Merge branch 'tlsconnector-wrapping' into 'main'
Make TlsConnector wrap TCP connections, not create its own

See merge request tpo/core/arti!166
2021-12-07 17:38:04 +00:00
eta 47c3163ce5 Merge branch 'bug252' into 'main'
Make DNS fields in arti-client/src/client.rs configurable

Closes #252

See merge request tpo/core/arti!171
2021-12-07 17:27:38 +00:00
Nick Mathewson 48f77a93c0 Clarify names and docs for predictive circuits.
Also, use humantime_serde, rather than a number of seconds, to indicate
configuration time.
2021-12-07 12:09:05 -05:00
Nick Mathewson c2e20a242a Rename circuits_preemptive to preemptive_circuits
This obeys a few conventions:
  * adjective before noun
  * config objects end with "config"
2021-12-07 12:06:53 -05:00
eta b14c5f370e Make TlsConnector wrap TCP connections, not create its own
`tor-rtcompat`'s `TlsConnector` trait previously included a method to
create a TLS-over-TCP connection, which implied creating a TCP stream
inside that method. This commit changes that, and makes the function
wrap a TCP stream, as returned from the runtime's `TcpProvider` trait
implementation, instead.

This means you can actually override `TcpProvider` and have it apply to
*all* connections Arti makes, which is useful for issues like arti#235
and other cases where you want to have a custom TCP stream
implementation.

This required updating the mock TCP/TLS types in `tor-rtmock` slightly;
due to the change in API, we now store whether a `LocalStream` should
actually be a TLS stream inside the stream itself, and check this
property on reads/writes in order to detect misuse. The fake TLS wrapper
checks this property and removes it in order to "wrap" the stream,
making reads and writes work again.
2021-12-07 17:00:40 +00:00
eta 926d9a2d5d Merge branch 'real_chutney_v2' into 'main'
Detect and use CHUTNEY_PATH in test scripts.

See merge request tpo/core/arti!168
2021-12-07 16:56:47 +00:00
Neel Chauhan 9c66b68c5a Rename ClientDNSConfig -> ClientTimeoutConfig 2021-12-07 08:43:58 -08:00
Nick Mathewson 36f6a61f05 Remove some XXXs about zeroizing from tor-proto.
There is now a ticket about this issue in general, at arti#254.
2021-12-07 11:21:48 -05:00
eta a3f2e32485 Merge branch 'bug183a_redux' into 'main'
Squash, refactor, and test !139 (Don't use same family as exit when picking a guard)

Closes #183

See merge request tpo/core/arti!173
2021-12-07 16:01:30 +00:00
eta 85bb40a002 Merge branch 'safe_mul_dur_f64' into 'main'
Use a panic-free function to multiply timeouts.

See merge request tpo/core/arti!175
2021-12-07 15:47:18 +00:00
eta 45b96579b8 Merge branch 'preemptive-config' into 'main'
Allow configurability on preemptive circuits

Closes #245

See merge request tpo/core/arti!164
2021-12-07 15:04:42 +00:00
Neel Chauhan 0e9c2d274e Allow configurability on preemptive circuits 2021-12-07 15:04:41 +00:00
Nick Mathewson d6f628c6b7 Use a panic-free function to multiply timeouts.
Previously we used Duration::mul_f64, which panics if its output is
out-of-range.  That shouldn't actually be possible for the values
we're giving it, but probably it's better to just multiply in a safe
way.

This resolves a couple of XXXXs and therefore relates to #231.
2021-12-06 16:00:17 -05:00
Nick Mathewson d33d7f7fdd tor-netdir: Use reproducible RNG in tests.
The rand crate's documentation says it's not okay to rely on StdRng
having reproducible output.  So instead, let's switch to ChaCha12Rng
instead (which is what StrRng currently uses).
2021-12-06 15:11:03 -05:00
Nick Mathewson 31b385c5b2 Resolve roughly half of the XXXXs.
We want to only use TODO in the codebase for non-blockers, and open
tickets for anything that is a bigger blocker than a TODO.  These
XXXXs seem like definite non-blockers to me.

Part of arti#231.
2021-12-06 15:11:03 -05:00
Nick Mathewson 2909f8f077 Tests for new family-related functions. 2021-12-06 11:26:30 -05:00
Nick Mathewson 2c2f774bd1 Move the "real families" code into tor-netdir.
Just as `in_same_family` is a member of Relay, so the function for
getting all the real family members of a relay should belong in the
same crate.

This change also removes the `family()` accessor: it gives the _claimed_ family rather
 than the _acknlowedged_ family, and is therefore a bit dangerous.

 There's still a hole in this logic; I've noted it in the Limitations
section.  If we get a microdescriptor for a relay in between creating
and using  the guard restriction, it might be omitted from the family
list.
2021-12-06 10:48:27 -05:00
Nick Mathewson cfc31dadd4 Use hashset _inside_ GuardRestriction.
This approach saves us from a linear search when picking guards.
2021-12-06 09:44:56 -05:00
Nick Mathewson e25c2d991e Start a TROUBLESHOOTING.md with known compilation issues. 2021-12-06 09:35:06 -05:00
Nick Mathewson 54971e3c9a Change GuardUsage to have Vec of restrictions.
There's not much reason to use a HashSet here, since we're just
going over the whole list.

This reverts commit 16e8489abb and does a little more
refactoring.
2021-12-06 09:26:32 -05:00
Neel Chauhan b0016682c3 Implement guard family restriction code 2021-12-06 09:05:48 -05:00
Nick Mathewson 9f9bb3e4c1 chutney: Make $target relative to ${CHUTNEY_PATH}
This is per a suggestion from @trinity-1686a.
2021-12-05 16:04:46 -05:00
Nick Mathewson 66d5f73b9c tor-linkspec: Remove redundant method; add more tests.
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%.
2021-12-04 15:42:53 -05:00
Nick Mathewson 214c251e41 Remove the unused "Error" type from caret.
This was a relic of the old, now-unused "caret_enum!" macro.
Removing it gets caret's coverage to 100%.

Yes, technically this is a semver breaker on caret.
2021-12-04 15:13:43 -05:00
Neel Chauhan ac1afe92cc Improve ClientDNSConfig field comments 2021-12-03 10:34:24 -08:00
Neel Chauhan f32a10865e Make DNS fields in arti-client/src/client.rs configurable 2021-12-03 10:28:42 -08:00
Nick Mathewson 68d4070038 Idle hacking: Get 90% coverage in tor-llcrypto
For this one I just wrote some "are things completely broken" tests
for the rand_compat wrappers. These won't detect subtle biases in
the RNGs! They'll only let you know if the wrappers have screwed up
in some way that always sets a given bit to 1 or 0.
2021-12-02 18:58:35 -05:00
Nick Mathewson 04d99ff1d0 Idle hacking to get 90% coverage in arti-config
This is just a matter of writing a few tests for some very easy
functions.
2021-12-02 18:55:30 -05:00
Nick Mathewson 2ee620ec46 Idle hacking to get tor-socksproto line coverage over 90%
This was just a matter of adding a call to one function.
2021-12-02 18:52:58 -05:00
Nick Mathewson d582b1c439 Python does not have quadruple-quote.
Fix a bug in postprocess_coverage.py that stuck a big row of '
characters in its output.
2021-12-02 17:38:27 -05:00
Nick Mathewson 99a046da46 Get tor-units grcov line coverage to 100%
This is mostly a finger exercise, and an experiment in "what does
grcov consider to be coverage".  Here's what I've found out...

* In grcov's eyes, most #[derive(Foo)] lines count as containing code;
  but calling any one derived function counts as calling those lines.

* Unlike with tarpaulin, it is actually possible to reach 100% grcov
  line coverage.  (Tarpaulin likes to pick "}" lines and tell you that
  you never reached them; or sometimes it picks expression
  statements that have the effect of a return, and tells you that
  they're unreached.  Even with these tests, tarpaulin claims that
  the line coverage of tor-units is only 97.3%.)

* In rust, it may be a bit hopeless trying to get high function
  coverage. Even though we've hit every line of the tor-units crate,
  the function coverage from its own tests is only 9.38% (55.41%
  from other crates).  I think this is probably due to derived
  functions, or maybe due to generics getting instantiated?
  I've got no idea; the denominator for the function coverage
  lines fluctuates oddly.
2021-12-02 17:08:22 -05:00
Nick Mathewson 47614ee737 Implement Eq,PartialEq for BoundedInt32. 2021-12-02 16:40:22 -05:00
Nick Mathewson 047f0fb571 Merge remote-tracking branch 'origin/mr/165' 2021-12-02 15:29:04 -05:00
Nick Mathewson b009e31410 When tearing down test net, always tear down test net :)
Previously, if the arti process had died or been killed, we wouldn't
reach the point where we called "chutney stop".
2021-12-02 09:25:28 -05:00
Nick Mathewson ec2245164f Detect and use CHUTNEY_PATH in test scripts.
If the user has CHUTNEY_PATH set, respect that value, rather than
cloning a local chutney.

Also, if we have a local chutney, then update it in case there have
been changes.
2021-12-02 09:22:52 -05:00
eta dbc801f256 Merge branch 'postprocess_coverage' into 'main'
Postprocess coverage index.html with python instead

Closes #249

See merge request tpo/core/arti!163
2021-12-02 10:46:02 +00:00
Neel Chauhan f5362028b4 Remove dir_port from RouterStatusBuilder 2021-12-01 21:51:49 -08:00