Commit Graph

934 Commits

Author SHA1 Message Date
Nick Mathewson 9e28e4e7a9 Resolve unwrap() instances in tor-netdir.
This includes revising the pick_weighted() function to not panic
if its inputs are above 2^64 in total.
2021-03-16 15:00:14 -04:00
Nick Mathewson ec6ef97fc6 Change an unwrap() in llcrypto to an expect(). 2021-03-16 14:15:44 -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 442d3d7f89 Allow spaces in command-line arguments again 2021-03-12 13:21:44 -05:00
Nick Mathewson e2ed031dfe Improve implementation of copy_interactive
Previously we'd flush after every write.  Now we only flush when the
reader has nothing more to tell us.  This way we can be sure that we're
sending out the data as soon as we can, without leaving any cells
partially filled unnecessarily.
2021-03-12 13:15:52 -05:00
Nick Mathewson a1036b01cd Remove a couple of unused deps from tor-llcrypto. 2021-03-10 16:10:56 -05:00
Nick Mathewson 49b508e5cc Avoid most regex features. 2021-03-10 16:05:33 -05:00
Nick Mathewson 9d07f4160f Only enable the `config` features we are using.
This saves us from a lot of extra backends, including an entire
extra version of serde (!).
2021-03-10 15:46:06 -05:00
Nick Mathewson 7dd92e3808 Cut down on tokio features. 2021-03-10 15:42:26 -05: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 988dababf9 Use AsyncRead and AsyncWrite in tor-dirclient 2021-03-10 14:26:01 -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 695268019e upgrade async-trait 2021-03-09 09:43:00 -05:00
Nick Mathewson 302653977d Bump dependencies with "cargo upgrade" 2021-03-06 08:55:13 -05:00
Nick Mathewson fb4f3d0029 Avoid unwrap() in llcrypto. 2021-03-04 14:32:07 -05:00
Nick Mathewson d7c1d4166a Avoid unwrap() in dirmgr. 2021-03-04 14:31:28 -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
Nick Mathewson a444f6c3dc Add tor-decompress to top-level Cargo.toml 2021-03-04 13:31:48 -05:00
Nick Mathewson a2ac0f724e Merge remote-tracking branch 'origin/mr/18' into main 2021-03-04 13:30:46 -05:00
Nick Mathewson 8bbf093e34 Avoid unwrap() in dirmgr 2021-03-04 13:24:00 -05:00
Nick Mathewson 9b97197762 Avoid unwrap() in tor-consdiff. 2021-03-04 12:59:15 -05:00
Nick Mathewson 59bfa4d517 Avoid unwrap() in tor-config 2021-03-04 12:51:11 -05:00
Nick Mathewson 95c71aff91 clippy warning on msg.rs 2021-03-04 11:54:14 -05:00
Nick Mathewson 2f81e8dd34 Remove use of unwrap() in tor-client. 2021-03-04 11:37:14 -05:00
Nick Mathewson b87b3e978b Use expect() instead of unwrap() in tor-circmgr 2021-03-04 11:33:29 -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 7feab6d85d tor-cert: use expect() instead of unwrap() 2021-03-04 11:23:13 -05:00
Nick Mathewson 564bf104d5 Change how we sort link specifiers in extend cells
Instead of implementing a dubious PartialOrd for link spec, add a
sorting function and call that explicitly.
2021-03-04 11:13:22 -05:00