Commit Graph

127 Commits

Author SHA1 Message Date
Jani Monoses 44d1271c86 Switch all uses of the log crate to the tracing.
Issue #74
2021-08-20 21:10:50 +03:00
Nick Mathewson fe5d826942 Merge remote-tracking branch 'origin/mr/60' 2021-08-18 08:53:11 -04:00
S0AndS0 484cc24856 Add the "implicit_clone" lint.
> Check `implicit_clone` section of Clippy documentation for details;
>
>   https://rust-lang.github.io/rust-clippy/master/index.html#implicit_clone

This adds, and addresses, the following Clippy configuration to crates;

    #![deny(clippy::implicit_clone)]

And moves related line within `maint/add_warning.py` file. My intent is to
mitigate extra edits after merging, so please let me know if I need to do this
last bit differently.
2021-08-17 11:49:39 -07:00
S0AndS0 b5a58f5871 Add the "missing_panics_doc" lint.
> Check `missing_panics_doc` section of Clippy documentation for details;
>
>   https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc

This adds the following Clippy configuration to crates;

    #![deny(clippy::missing_panics_doc)]

And adds necessary doc-comments to methods that may panic.
2021-08-13 15:11:04 -07:00
Nick Mathewson 9c6dd27ca1 Use add_warnings.py for clippy::cast_lossless 2021-08-13 11:36:14 -04:00
S0AndS0 657e7b2246 Add the "cast_lossless" lint.
> Check `cast_lossless` section of Clippy documentation for details;
>
>   https://rust-lang.github.io/rust-clippy/master/index.html#cast_lossless

This adds the following Clippy configuration to crates;

    #![deny(clippy::cast_lossless)]

And applies suggested Clippy and `cargo fmt` fixes.
2021-08-12 17:25:15 -07:00
Nick Mathewson d2172b518d Merge commit 'origin/mr/46^' 2021-08-12 15:29:55 -04:00
Nick Mathewson de00b5f512 Merge remote-tracking branch 'origin/mr/51' 2021-08-09 16:00:53 -04:00
Nick Mathewson 79d9eac58c Add unnecessary_wraps to the big warning list. 2021-08-06 16:20:37 -04:00
Felipe Lema bf3c422555 shrink result to actual number of bytes read once on return 2021-08-05 20:08:18 -04:00
Felipe Lema 161d5312bd fix clippy::redundant_slicing 2021-08-05 01:21:48 -04:00
Felipe Lema 49cf119e18 use loop + `read` + slice-of-result
Loop into several reads because we want to short-circuit if case we're
reading too many bytes.

Added handling of allocation of `result` so we can use the "next window
buffer" for `read`. This way we can read on steps and short-circuit when
needed.
2021-08-05 00:34:40 -04:00
Felipe Lema 5277c747d5 read from stream in a single go (not looping) 2021-08-03 16:08:53 -04:00
Felipe Lema dcfcf09956 don't use intermediate buffer, but read directly into `result` 2021-08-03 16:08:53 -04:00
rls 51d91508f7 Fix typos and other spelling mistakes 2021-07-31 18:02:35 +02:00
rls 0587e97c7b Change output type in DirResponse to Vec<u8>
Previously the DirResponse contained a String for the output.
By changing it to a Vec<u8> the caller has to parse the Vec<u8> and deal with potential failures.

With this change `fetch_multiple`'s
`useful_responses` should also contain non-UTF-8 responses.
This will case an Err to be returned in the `download_attempt` function if the
DirResponse does not contain valid UTF-8.
2021-07-30 22:41:33 +02:00
Nick Mathewson b0167eec44 Allow tor-rtcompat to build with no runtimes.
Thanks to cargo's version-2 feature resolver, we can require a
runtime for tests only.

I'm also making it so that the functions that create or fetch
Runtimes only exist when one of the runtime features is enabled.
For now that seems like a better solution than having those
functions exist but panic.

Closes #129.
2021-07-01 09:47:55 -04:00
Nick Mathewson 1c21295d19 Merge remote-tracking branch 'origin/mr/34' 2021-06-27 14:30:49 -04:00
Nick Mathewson 8947e54d7e Remove "default-features=false" thing on tor-rtcompat for now. 2021-06-24 10:53:11 -04:00
Nick Mathewson 2df9b0e921 Bump version dependencies to 0.0.0 2021-06-24 09:27:17 -04:00
Nick Mathewson b774360755 Remove "publish = false" 2021-06-24 07:04:26 -04:00
YUAN LYU 92dbf20a76 Add clippy warn needless pass by value 2021-06-21 23:27:19 -04:00
YUAN LYU b830e81b7f Add clippy warn needless borrow 2021-06-21 21:34:40 -04:00
Nick Mathewson e6faeaa1f8 Fix some warnings about needless & from nightly clippy 2021-06-18 07:19:24 -04:00
Nick Mathewson 9310273448 Remove some (but not all) needless dependencies. 2021-06-17 09:09:43 -04:00
Nick Mathewson 83b1150c81 Enormous tor-circmgr rewrite.
As with the tor-chanmgr code, the circuit manager is now implemented
using an AbstractCircMgr type that uses traits to abstract the
particular behavior of other types that it uses.  (Specifically:
circuits, building circuits, and telling whether one circuit usage
is compatible with another.)  Abstracting out the dependencies in
this ways makes it possible to test the circuit manager without
having to actually build real circuits.

This commit also introduces new behavior for handling pending
circuit requests.  Upon getting a new request, first we check to see
if there's an existing circuit we can use.  If there isn't, we look
for pending circuits and wait for them.  If there aren't any pending
circuits we can use, we launch one or more, and wait for them.

So far, that's the same as the old behavior.  But here's a change:
if, while we are waiting for some pending circuits, a different
circuit is completed, and it's one we could use, then the task that
was building _that_ circuit will tell us: "please look at this
circuit".  This gives us better changes of getting a usable circuit
fast.

Minor changes:

* The Error type in CircMgr no longer uses anyhow; several errors
  have been simplified.

* We've gotten more formal about the relationship between circuit
  usage and target usage.
2021-06-14 12:12:31 -04:00
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 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 90e96b32c8 Prefer "relay" to "server" when appropriate. 2021-05-18 10:34:15 -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
Nick Mathewson b254158354 Bump regex and memchr versions 2021-05-03 09:19:19 -04:00
Nick Mathewson 615e2ed31a Split mocking parts of rtcompat into new rtmock crate.
Since these parts are testing-only, let's take steps to make sure we
don't ship them in production by accident.
2021-05-03 09:10:33 -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 adefe60f60 upgrade httparse and zeroize 2021-04-25 12:39:35 -04:00
Nick Mathewson 951ea280c8 Only list the supported encodings in the `Accept-Encoding` header
Closes #113
2021-04-21 10:04:22 -04:00
Nick Mathewson 03f25bd2bc Use stream_pair() to write a test for tor_dirclient::download 2021-04-21 09:04:27 -04:00
Nick Mathewson b00ff9f110 Make zstd and xz compression optional, but on-by-default. 2021-04-21 08:37:53 -04:00
Nick Mathewson 572565bce2 Test for tor_dirclient::read_headers 2021-04-20 14:52:58 -04:00
Nick Mathewson 68ce1da4b0 Tests for tor_dirclient::read_and_decompress 2021-04-20 14:33:09 -04:00
Nick Mathewson 8007d719d9 Test for tor_dirclient::read_until_limited() 2021-04-20 13:51:47 -04:00
Nick Mathewson 50978dc7d2 tor-dirclient: more requests.rs tests 2021-04-20 13:32:20 -04:00