Commit Graph

291 Commits

Author SHA1 Message Date
Nick Mathewson 9f44408bb9 Upgrade rsa, zstd, httpdate. Remove redundant pin-project. 2021-04-05 08:26:29 -04:00
Nick Mathewson 23c672708a Merge branch 'hs3_ntor_squashed' 2021-04-02 08:34:46 -04:00
Nick Mathewson 89cae112b6 hs_ntor: add a disclaimer and put it behind a feature. 2021-04-02 08:34:03 -04:00
George Kadianakis 81fa7d01ad First draft of HS Ntor implementation. 2021-04-02 08:30:45 -04:00
Nick Mathewson e68c27a324 Fix a rust 1.51 warning: remove a semicolon 2021-04-02 08:00:25 -04:00
Nick Mathewson 7aa876cc0a Resolve rustdoc warnings. 2021-03-29 18:18:25 -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 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 2dce8fda0b Check for channel match in create_firsthop_ntor().
This way we won't even try sending the CREATE2 cell unless the
Ed25519 identity we know for the channel matches the provided
CircTarget.
2021-03-24 15:29:52 -04:00
Nick Mathewson 3a8fccf94f Add a "this crate has no timeouts" comment to tor-proto. 2021-03-24 11:18:27 -04:00
Nick Mathewson 3833ca2665 Move stream timeout logic into tor-client.
This is consistent with the other pieces of tor-proto, which do not
handle timeouts on their own.  It also lets us remove tor-rtcompat
as a dependency from tor-proto, and simplify some of the test cases
to use async_test.

This commit unindents a lot of test code; use git's "-b" flag to
read the parts that matter.
2021-03-24 11:14:07 -04:00
Nick Mathewson 886788860a Add tests for correct incoming sendme handling.
At this point I'm going to pause writing tor-proto tests for a
little while and think about refactoring that could make these tests
simpler.  I'm doing way too much copy-paste here.
2021-03-22 11:50:41 -04:00
Nick Mathewson ffb4723986 Extend the begindir test to exchange data on the stream. 2021-03-19 15:12:50 -04:00
Nick Mathewson 3587809944 Introduce a helper to tor_proto::circuit tests 2021-03-19 14:47:57 -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 a4e0dde4da Add appropriate categories to some Cargo.toml files. 2021-03-17 14:51:18 -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 c51a947d04 circuit: Add a test for a bad crypto handshake. 2021-03-16 14:02:48 -04:00
Nick Mathewson 83c294a90f circuit: tests for different undesired responses to EXTEND. 2021-03-16 11:50:52 -04:00
Nick Mathewson 3fb69e4a01 circuit: improve errors on bad extended2 2021-03-16 11:50:33 -04:00
Nick Mathewson 964274c9b0 Refactor circuit reactor for testing. 2021-03-16 11:49:34 -04:00
Nick Mathewson ed84f938ea Test for Channel::check_match 2021-03-16 10:41:19 -04:00
Nick Mathewson 4818d57ed7 Bump a couple of deps 2021-03-13 17:25:05 -05:00
Nick Mathewson 9f4341bbf9 Merge remote-tracking branch 'origin/mr/21' 2021-03-12 15:21:31 -05:00
George Kadianakis 97f7bc7232 Avoid a slice copy in send_relay_cell().
Convert slice to array in the parent function instead of copying.
2021-03-12 21:32:04 +02:00
Nick Mathewson 7b4ca6d954 Better management for END cells in streams. 2021-03-10 15:02:34 -05:00
Nick Mathewson 310f779e52 Box the buffer in DataWriterImpl. 2021-03-10 14:32:15 -05:00
Nick Mathewson 0e015675c1 Remove now-unused methods from DataStream and its allies. 2021-03-10 14:29:30 -05:00
Nick Mathewson 0c34badb81 Treat StreamClosed as indicating no error.
This is wrong, but less wrong than the other way around.
2021-03-10 14:25:15 -05:00
Nick Mathewson a8b158b2a6 Use AsyncRead and AsyncWrite in our proxy implementation 2021-03-10 14:16:50 -05:00
Nick Mathewson ab4c8a4df0 Make DataStream implement AsyncRead and AsyncWrite. 2021-03-10 13:06:13 -05:00
Nick Mathewson f5279b8ee4 Implement AsyncWrite for DataWriter. 2021-03-10 12:53:32 -05:00
Nick Mathewson 6a97e3ba08 Revise DataReader to implement AsyncRead.
The tricks I needed here turned out to be:

  * I needed to store the future returned by read_cell() while it is
    returning Poll::Pending.

  * Since the type of that future is secret, I needed to put it in a
    Box<dyn Future>.

  * But since that future holds a reference to the DataReader, that
    would create a self-referential structure if we tried to store
    the DataReader and the future at the same time.  So instead, I
    had to make an enum() that either holds a DataReader directly,
    or holds the future that will give us back the DataReader when
    it's done.  (I also had to change the read_cell() function so
    that it takes ownership of the DataReader, and returns it when
    it's finished.)  (Daniel Franke explained how to do this.)

  * Finally, I couldn't figure out how to change the enum's type
    in-place, so I had to wrap it in an Option<>.  (Daniel Franke
    says this isn't actually necessary.)

I've noted a couple of places in the read code where I want to
handle errors and closes more carefully.
2021-03-10 10:39:56 -05:00
Nick Mathewson 25cafff23d Rearrange DataStream code a bit and add an internal layer of indirection 2021-03-10 09:36:53 -05:00
Nick Mathewson 05aaecf2f8 Make note_ended private on RawCellStream. 2021-03-10 09:30:54 -05:00
Nick Mathewson fe94adef4d Move DataStream into its own module. 2021-03-10 09:24:49 -05:00
Nick Mathewson 1b723eec12 Move ResolveStream to its own module. 2021-03-10 09:14:52 -05:00
Nick Mathewson 0cd05e1793 Implement From<tor_proto::Error> for std::io::Error 2021-03-10 09:08:53 -05:00
Nick Mathewson 8ef6919a07 Move RawCellStream into its own module. 2021-03-10 09:07:52 -05:00
Nick Mathewson 2a93266b7b Rename TorStream => RawCellStream 2021-03-10 08:34:54 -05:00
Nick Mathewson 29050c2555 Refactor DataStream constituents a bit.
These new (internal so far) APIs correspond more closely to what
we'll need for AsyncRead and AsyncWrite.

We also make write methods take a mutable reference to self, since
that seems to be (closer to) what the AsyncRead/AsyncWrite code
expects.
2021-03-09 13:11:59 -05:00
Nick Mathewson 302653977d Bump dependencies with "cargo upgrade" 2021-03-06 08:55:13 -05:00
Nick Mathewson bbfbdec733 Make a few async_test tests work correctly again.
For these, we need to call tor_rtcompat::task::block_on() directly,
since they would crash with tokio enabled.  Perhaps down the line we
should look for a better fix here.
2021-03-02 11:59:52 -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 a1c4d5a110 Merge remote-tracking branch 'origin/mr/16' into main 2021-02-26 08:16:10 -05:00
George Kadianakis 8e97237cd1 Refactor StreamMap methods to use HashMap::Entry 2021-02-26 14:16:35 +02:00