Commit Graph

81 Commits

Author SHA1 Message Date
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
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
Nick Mathewson 13d4ee888f Replace tor-decompress with async-compression crate.
This lets us simplify tor-dirclient a fair bit.  Closes #79.
2021-04-13 16:27:52 -04:00
Nick Mathewson edbd54f2fd tor-dirclient: Use AsyncBufRead to simplify code a bit.
Previously we read too much data from our input, and then used the
unused portion as an initial state of a buffer for handling
subsequent data.  Yuck!  Instead we can just use an AsyncBufRead and
only read the parts we want.

This code takes some pains to never read too much data: I'd rather
just "read until the first CRLF" or have some kind of pushback
mechanism.  But for now it's probably fine.
2021-04-13 15:45:27 -04:00
Nick Mathewson bec5fa3e9c Major revision on DirMgr logic -- almost a complete rewrite.
The big idea of this revision is to separate the code that knows
about doing downloads from the code that decides what to download.
Later, we can make a similar change for database access.  With these
changes together, we can make our code much more testable, and
eventually enable more download types in parallel.
2021-04-13 10:48:52 -04:00
Nick Mathewson b2d43507b0 Start moving responsibility for building requests into dirmgr
This will help with my planned "directory state" refactoring.
2021-04-09 08:03:09 -04:00
Nick Mathewson 9f44408bb9 Upgrade rsa, zstd, httpdate. Remove redundant pin-project. 2021-04-05 08:26:29 -04:00
Nick Mathewson 51584f1a87 Make ConsensusRequest take a flavor. 2021-04-01 13:20:29 -04:00
Nick Mathewson 8e9abe425a Add accessors for members of different directory requests
This will let us use these types both as client and server-side
implementations.

Making this change required me to change the download code to take
requests by reference.  (Sorry, David)
2021-04-01 12:31:34 -04:00
Nick Mathewson 1e462848da Rename ClientRequest to Requestable. 2021-04-01 11:54:23 -04:00
Nick Mathewson 69fa6c744d Rename ServerDescriptorRequest to RouterDescRequest
Rationale: the name of the request should match the name of the type
that you parse from it.
2021-03-30 14:32:10 -04:00
Nick Mathewson c17d834b77 ServerDescriptorRequest: handle "all.z" case differently
Having "no descriptors" mean "all of them" is kind of an accident
waiting to happen, and had wrong behavior for partial_docs_ok() and
max_response_len().
2021-03-30 14:29:45 -04:00
Nick Mathewson 3465cc979b fix clippy warnings in request.rs 2021-03-30 14:22:36 -04:00
Nick Mathewson 8efe0f7553 Move RdDigest to routerdesc.rs 2021-03-30 14:20:35 -04:00
David Goulet e685ddee84 dir: Add server descriptor directory request
Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-03-30 14:15:51 -04:00
Nick Mathewson 3ad503866d Fix Rust-1.51 clippy warnings about acronyms in camel case.
This is painful, but we shouldn't have to do it again.
2021-03-29 16:33:48 -04:00
Nick Mathewson 3800c459f6 Rename Rsa{Identity,Signature} to fix clippy warning. 2021-03-29 16:14:43 -04:00
Nick Mathewson 570840c7e1 Refactor errors in tor-decompress and tor-dirclient.
This lets us reinstate the code in dirclient that retired circuits
depending on the error type.
2021-03-24 15:14:44 -04:00
Nick Mathewson d235971ef7 dirclient: add a function to download over a stream.
Also, remove references to DataStream, and comment on the future of
the module.
2021-03-24 13:55:12 -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 988dababf9 Use AsyncRead and AsyncWrite in tor-dirclient 2021-03-10 14:26:01 -05:00
Nick Mathewson 302653977d Bump dependencies with "cargo upgrade" 2021-03-06 08:55:13 -05:00
Nick Mathewson 29311b72f6 Remove an unwrap in dirclient. 2021-03-04 14:20:54 -05:00
Nick Mathewson 57682f5ec1 Move content-encoding handling to decompress
This way tor-dirclient doesn't need to link to the compression crates.
2021-03-04 13:59:12 -05:00
Kushal Das bfb652e73d
Moves decompress related code into tor-decompress crate
The related data structures are marked as public in the
tor-decompress crate so that tor-dirclient can access them.
2021-03-04 22:01:42 +05:30
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 e1c3f550d8 upgrade a few dependencies 2021-02-10 18:23:38 -05:00
Nick Mathewson 243880473f bump serde and log 2021-02-01 16:39:07 -05:00
Nick Mathewson 50da094373 Merge remote-tracking branch 'origin/mr/12' into main 2021-01-27 07:39:36 -05:00
Nick Mathewson a36fadefae A few more tests in request.rs 2021-01-26 12:45:09 -05:00
hiro d363ae0f73 Add an error type check in test_get_decompressor_err in tor-dirclient 2021-01-25 18:59:04 +01:00
hiro 5cd977c752 Add a test for consensus requests in tor-dirclient. 2021-01-22 21:46:18 +01:00
Nick Mathewson 789640ed53 Fix a test in tor-dirclient 2021-01-21 12:10:17 -05:00
Nick Mathewson 34bf6f0658 Merge remote-tracking branch 'origin/mr/10' into main 2021-01-21 11:59:14 -05:00
Kushal Das e95c88f984
Reformats the code and removes extra return
Based rust nightly cargo fmt.
2021-01-21 22:14:21 +05:30
Kushal Das 63a1ad9655
Adds decompress_in_parts_zstd test
Now we are testing decompression of the input via calling
the process method 3 times. We get the final decompressed output
only after the third call.
2021-01-21 22:04:54 +05:30
Kushal Das d8184e7610
Adds decompression test for zstd
Tests the decompression of the whole input in one go.
2021-01-21 21:52:29 +05:30
Kushal Das 55f5d2aa6a
Adds zstd decompression implementation for dirclient
Adds dependency to zstd crate.
2021-01-21 21:03:45 +05:30
Nick Mathewson 8e2cc78a45 Add a test for encoding authcert requests 2021-01-21 09:42:58 -05:00