Commit Graph

7591 Commits

Author SHA1 Message Date
Ian Jackson 09f0ecaa71 rng ranges: Introduce gen_range_infallible
There are a number of places where we generate random Durations
in a range which starts at zero.

These call sites currently (i) have to write out Duration::ZERO
or equivalent, and (ii) would have to use gen_range_checked and expect
the result, even though it can be statically proven to be OK.

To make this slightly smoother, provide `GenRangeInfallible` and
`gen_range_infallible`.
2023-07-10 16:07:18 +01:00
Ian Jackson 8ae759ef95 rng ranges: Use gen_range_checked().unwrap() in test case
Ideally we would be allowed to use vanilla gen_range() here, but there
doesn't seem to be a way to allow a specific clippy-forbidden method
using #[allow] and we probably don't want to make a blanket allow.
2023-07-10 16:07:18 +01:00
Ian Jackson 332285015f rng ranges: Use gen_range_checked().expect() in obvious cases (fmt) 2023-07-10 16:07:18 +01:00
Ian Jackson 5e10805ede rng ranges: Use gen_range_checked().expect() in obvious cases
In each of these, it is locally obvious that the range is nonempty.
2023-07-10 16:07:18 +01:00
Ian Jackson 36f998b690 tor-basic-utils: retry: Use and justify gen_range_checked
delay_bounds's implementation ensures the postcondition, so the
potential p[anic in next_delay_msec cannot happen.
2023-07-10 16:07:18 +01:00
Ian Jackson 58da20b708 rng ranges: Introduce RngExt and gen_range_checked
We will use this in many places instead of gen_range.
2023-07-10 16:07:18 +01:00
gabi-250 1510cf42b7 Merge branch 'keymgr-erased-key' into 'main'
keymgr: Use Box<dyn EncodableKey> instead of Box<dyn Any>.

Closes #937

See merge request tpo/core/arti!1398
2023-07-10 15:06:34 +00:00
gabi-250 47f7e8a6dd Merge branch 's101-q2' into 'main'
Update s101 stats.

See merge request tpo/core/arti!1397
2023-07-10 14:41:02 +00:00
Gabriela Moldovan bd4955f9ed keymgr: Add semver.md. 2023-07-10 15:38:58 +01:00
Gabriela Moldovan 9cde64c2c8 keymgr: Use Box<dyn EncodableKey> instead of Box<dyn Any>.
Prompted by https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1337#note_2917701

This will make it harder to accidentally return the wrong value from
`Keystore::get` (the returned value is now at least guaranteed to
implement `EncodableKey`).

Closes #937
2023-07-10 14:41:30 +01:00
Alexander Færøy 6be6352b98 Merge branch 'conversation' into 'main'
Overhaul send_control_message

See merge request tpo/core/arti!1367
2023-07-10 13:14:11 +00:00
Alexander Færøy 943c12739d Merge branch 'recurse' into 'main'
tor-hsclient: Mock traits: Work around an async boobytrap

See merge request tpo/core/arti!1365
2023-07-10 13:13:31 +00:00
Ian Jackson fd2e4979be clippy: tor-error: Use convert::identity for into_internal!
This launders the closure so that clippy's
clippy::redundant_closure_call can't see it.

We can't have a local #[allow] because it would be on an expression,
which isn't allowed on stable.

This avoids having to use more clumsy idioms at call sites.
2023-07-10 13:49:51 +01:00
Ian Jackson 1a8395cd11 tor-llcrypto: Add a missing instance of the standard lint block
This fixes a needless_vec lint on nightly.
2023-07-10 13:49:51 +01:00
Ian Jackson 473447a82e Run maint/add_warning to actually apply new lint allows 2023-07-10 13:49:51 +01:00
Ian Jackson 01cb7ee0a1 clippy: in tests, allow clippy::useless_vec
This is a perf issue, only.  If tests are too slow, we will notice and
ca speed them up.  We should optimise for clarity and convenience,
rather than speed.

Forbidding this can result in churn between vec![] and [] as tests are
updated and changed.
2023-07-10 13:49:51 +01:00
Ian Jackson 43bf89d540 clippy: globally allow clippy::needless_raw_string_hashes
Rationale: no-one writes these by default without thinkinh.  If they
are unnecessary, then either the string must have had " in it
before (in which case it might do again), or it is near other strings
which *do* need it.

And having it does no harm; indeed IMO it can increase clarity.

Alternative to !1388's
  Fix new "needless_raw_string_hashes" lint from clippy +nightly
2023-07-10 13:49:51 +01:00
Alexander Færøy 590c72eb03 Update s101 stats. 2023-07-10 14:35:27 +02:00
Nick Mathewson 9f3619d5c9 Merge branch 'clippy-vec' into 'main'
Fix new "useless_vec" warning from clippy +nightly

See merge request tpo/core/arti!1395
2023-07-10 12:07:31 +00:00
Ian Jackson 25b7573f58 Merge branch 'clippy-common' into 'main'
clippy +nightly: Uncontroversial adjustments from Nick

See merge request tpo/core/arti!1394
2023-07-10 12:01:02 +00:00
Nick Mathewson c2601ec896 Explain the code for the #952 fix.
Let's explain what Trinity did in its fix for #952, so that we know
why this code is here the next time we find it.
2023-07-10 08:00:08 -04:00
Ian Jackson 501454370f Fix new "useless_vec" warning from clippy +nightly
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.
2023-07-10 12:35:21 +01:00
Nick Mathewson 22f55b7cf8 Remove some needless into_iter() calls.
Clippy nightly now detects when you're calling into_iter() and
passing the result into something that accepts an
`impl IntoIterator`.
2023-07-10 12:33:21 +01:00
Nick Mathewson 0b6cc7ba5e Add exceptions for some cases of diverging_sub_expression
See here for documentation on the lint:
https://rust-lang.github.io/rust-clippy/master/index.html#/diverging_sub_expression

The issue here, from what I can tell, is that the lint triggers
whenever you use a diverging expression as a function body within an
2023-07-10 12:33:21 +01:00
Nick Mathewson 7e78224460 Add an exception for clippy::arc_with_non_send_sync.
We're doing this deliberately, I believe.
2023-07-10 12:33:21 +01:00
gabi-250 2db3e73434 Merge branch 'da-task' into 'main'
RFC: tor-rtmock: Use derive-adhoc for composite runtimes

See merge request tpo/core/arti!1381
2023-07-10 10:53:23 +00:00
Ian Jackson ca32680ba6 Merge branch 'onion-service-client-docs' into 'main'
Update documentation regarding the `onion-service-client` feature

See merge request tpo/core/arti!1392
2023-07-10 09:41:04 +00:00
trinity-1686a c98894cebc fix chutney in CI 2023-07-08 12:31:20 +02:00
Kunal Mehta 7acd7de369 Update documentation regarding the `onion-service-client` feature
It is no longer experimental, but still not rated for security-sensitive
usage per <https://blog.torproject.org/arti_116_released/>.
2023-07-07 22:01:51 -04:00
Ian Jackson 77b0dc2edc Merge branch 'raw_event_report' into 'main'
Fix warn_report and error_report macros.

See merge request tpo/core/arti!1390
2023-07-07 20:07:45 +00:00
Nick Mathewson 53c599d50f Fix warn_report and error_report macros.
Originally they didn't check err.kind(), since err.kind() can never
increase their severity.  We lost that behavior with !1386, and we
became dependent on it with arti!1383.  Since they both merged at
the same time, CI broke.

This patch restores their original behavior.
2023-07-07 15:46:41 -04:00
Nick Mathewson ba3876b22a Merge branch 'feat' into 'main'
arti: Build with HS client support by default

Closes #948

See merge request tpo/core/arti!1382
2023-07-07 19:28:05 +00:00
Nick Mathewson b6b7edad59 Merge branch 'event_report_everywhere' into 'main'
Throughout: Use event_report!() macros for reporting Errors.

Closes #949

See merge request tpo/core/arti!1383
2023-07-07 19:27:20 +00:00
Nick Mathewson b251784041 Merge branch 'fix-os-onionbalance' into 'main'
be more lenient while parsing inner hs desc

Closes #952

See merge request tpo/core/arti!1389
2023-07-07 19:26:27 +00:00
trinity-1686a 2d170425c0 be more lenient while parsing inner hs desc 2023-07-07 21:06:05 +02:00
Ian Jackson 778244c3af Merge branch 'report' into 'main'
tor-error: tracing module: Use macro to generate macros

See merge request tpo/core/arti!1386
2023-07-07 18:09:46 +00:00
Ian Jackson 08632739eb Document (retrospectively) the behaviour of 1.1.6 re HS client 2023-07-07 19:04:16 +01:00
Ian Jackson 696adc3c94 tor-error: tracing module: Use macro to generate macros
This abolishes some quintuplication.

The output is identical except that:
 * The syntax display in the rustdoc output for the resulting macros
   seems to have somewhat less whitepsace.
 * The whimsical error messages in the examples are all identical.
   Ah well.
2023-07-07 18:38:24 +01:00
Nick Mathewson 7d1c8dfde0 Merge branch 'inclusive' into 'main'
rng ranges: Use inclusive Duration ranges in several places

See merge request tpo/core/arti!1385
2023-07-07 17:07:58 +00:00
Nick Mathewson 25c6fe61e4 Throughout: Use *_report!() macros for reporting Errors.
I identified the cases to replace by searching for the string
`.report()`.  There are a few that I didn't change:

  * A couple of cases that used anyhow::Error,
  * One case that reported two Errors.
  * Two cases in `tor_hsclient::err` that just did
    `error!("Bug: {}")`.

I have also not audited the cases in `tor-hsclient` where we're using
`tor_error::Report` manually.

Nonetheless, closes #949.
2023-07-07 13:00:21 -04:00
Ian Jackson 220900a852 tor-error: tracing module: Fix link to tracing macro 2023-07-07 17:48:05 +01:00
Ian Jackson bcc3e6fef8 rng ranges: Use inclusive Duration ranges in several places
Many of these call sites would panic if, somehow, the upper bound was
zero.  In most cases it is very complicated to see if whether this
could happen.

However, there is a better answer:

Durations are (conceptually) dense, so picking the closed set (which
includes its boundary) rather than the open one (which doesn't) will
make little practical difference.

So change four call sites to use `..=` instead of just `..`.
2023-07-07 16:13:52 +01:00
Nick Mathewson 70f0fe634f Merge branch 'report-bugs-v2' into 'main'
Optional tracing support in tor-error for error reporting

See merge request tpo/core/arti!1379
2023-07-07 13:49:59 +00:00
Nick Mathewson 023d288ba2 event_report: assert correctness of format ending
(Also, document that this static assertion is the reason why you are
seeing a confusing error message.)
2023-07-07 09:00:31 -04:00
Nick Mathewson a441b4e9d3 circmgr: Use event_report!() and similar macros
This simplifies our logging a little, and implements part of
2023-07-07 09:00:31 -04:00
Nick Mathewson 7168feefdd tor-error: Add optional tracing support
The main contribution here is a set of convenience macros for
logging error `Report`s.  Notably, this macros always logs
`Internal` and `BadAspiUsage` errors at `WARN`, unless they
are already at `ERROR` or more.

This is a little tricky because `tracing::event!()` requires
its Level argument to be a constant.
2023-07-07 09:00:31 -04:00
Ian Jackson 80f397fb0b Merge branch 'allow_missing_panics' into 'main'
add_warning: Tolerate clippy::missing_panics_doc

Closes #950

See merge request tpo/core/arti!1380
2023-07-07 12:53:46 +00:00
Saksham Mittal 9de4f38b38
Make CompoundFactory private for external code 2023-07-07 18:18:44 +05:30
Nick Mathewson 2b3d4150e3 Merge branch 'clippy-nightly-20230703' into 'main'
Fix various warnings from clippy nightly

Closes #943

See merge request tpo/core/arti!1369
2023-07-07 12:26:45 +00:00
Ian Jackson 4c0935e13a arti: Build with HS client support by default
Fixes #948
2023-07-07 12:54:08 +01:00