Commit Graph

92 Commits

Author SHA1 Message Date
Ian Jackson c433899948 clippy: Rename a `from_foo` method that doesn't do conversion 2022-01-19 17:26:09 +00:00
Ian Jackson 1d5a480f79 Fix two bugs related to incomplete read/write
Discovered by clippy
2022-01-19 17:17:56 +00:00
eta c003fde04d Merge branch 'channel-arc-rework-5' into 'main'
chanmgr: get rid of Arc around Channel

See merge request tpo/core/arti!236
2022-01-13 13:12:30 +00:00
Ian Jackson 9b723cba53 chanmgr: get rid of Arc around Channel 2022-01-13 13:12:29 +00:00
Nick Mathewson bbf7c59b2d Describe when we will need SendmeAcceptMinVersion
(spoiler: not until we have a relay implementation)

Closes #53.
2022-01-12 15:52:24 -05:00
Nick Mathewson e335f6c75a Change RequireSendmeAuth to an enum.
This is a fine example of why booleans are risky:
it's far to easy to pass "animate:bool" into "inanimate:bool" like
we did here.

This is a followup from our fix to #294.
2022-01-12 15:46:36 -05:00
Nick Mathewson 1e915c3946 Fix a boolean inversion in auth_sendme_optional.
Previously we were requiring authenticated sendme cells exactly when we
should be permitting the old format, and vice versa.

This bug was caused by using a boolean to represent one property, but
with giving that boolean two different senses without inverting at the
right time.

The next commit will prevent a recurrence.

Closes #294
2022-01-12 15:36:55 -05:00
Nick Mathewson d49a490d4a Document SendmeEmitMinVersion status
(We don't need to look at SendmeEmitMinVersion since higher
values are not yet defined.)
2022-01-12 15:13:19 -05:00
Nick Mathewson b4761f8cfd Merge branch 'eta/182' into 'main'
Improve the layout of crate exports; add runtime convenience functions

See merge request tpo/core/arti!235
2022-01-11 18:42:15 +00:00
Ian Jackson cfcd3ea689 Add a blank line between doc and comment. 2022-01-11 18:23:58 +00:00
eta 41e202a3a4 Improve the layout of crate exports; add runtime convenience functions
This commit addresses multiple problems highlighted by arti#182:

- `arti-client` had some types in its public API that weren't accessible
  without importing another crate (`CfgPath`, `DataReader`,
  `DataWriter`). This has been fixed.
  - In addition, the doc comments for `DataReader` and `DataWriter` were
    cleaned up to be of better quality, now that they're public.
- It was impossible to use `arti-client` without also importing
  `tor-rtcompat`. This is now fixed by the addition of two convenience
  methods: `TorClient::bootstrap_with_tokio` and
  `TorClient::bootstrap_with_async_std`.
- Potentially controversially: `tor-rtcompat` now returns *concrete*
  types from methods like `current_runtime`, instead of `impl Runtime`.
  - This was needed in order to actually be able to name the `TorClient`
    type that results from using these methods.
  - This does mean we lose API flexibility, but on balance I think this
    is a good thing, because the API we *do* have is actually usable...
2022-01-11 15:16:03 +00:00
Nick Mathewson 7d3482ca1a Bump all crate versions to 0.0.3. 2022-01-11 09:40:32 -05:00
Nick Mathewson 4841b50c9f Minimize the required version for each dependency.
I found these versions empirically, by using the following process:

First, I used `cargo tree --depth 1 --kind all` to get a list of
every immediate dependency we had.

Then, I used `cargo upgrade --workspace package@version` to change
each dependency to the earliest version with which (in theory) the
current version is semver-compatible.  IOW, if the current version
was 3.2.3, I picked "3".  If the current version was 0.12.8, I
picked "0.12".

Then, I used `cargo +nightly upgrade -Z minimal-versions` to
downgrade Cargo.lock to the minimal listed version for each
dependency.  (I had to override a few packages; see .gitlab-ci.yml
for details).

Finally, I repeatedly increased the version of each of our
dependencies until our code compiled and the tests passed.  Here's
what I found that we need:

anyhow >= 1.0.5: Earlier versions break our hyper example.

async-broadcast >= 0.3.2: Earlier versions fail our tests.

async-compression 0.3.5: Earlier versions handled futures and tokio
    differently.

async-trait >= 0.1.2: Earlier versions are too buggy to compile our
    code.

clap 2.33.0: For Arg::default_value_os().

coarsetime >= 0.1.20: exposed as_ticks() function.

curve25519-dalek >= 3.2: For is_identity().

generic-array 0.14.3: Earlier versions don't implement
    From<&[T; 32]>

httparse >= 1.2: Earlier versions didn't implement Error.

itertools at 0.10.1: For at_most_once.

rusqlite >= 0.26.3: for backward compatibility with older rustc.

serde 1.0.103: Older versions break our code.

serde_json >= 1.0.50: Since we need its Value type to implement Eq.

shellexpand >= 2.1: To avoid a broken dirs crate version.

tokio >= 1.4: For Handle::block_on().

tracing >= 0.1.18: Previously, tracing_core and tracing had separate
    LevelFilter types.

typenum >= 1.12: Compatibility with rust-crypto crates

x25519-dalek >= 1.2.0: For was_contributory().

Closes #275.
2022-01-07 19:08:58 -05:00
Nick Mathewson 0151ceceb0 ClientCirc: change some methods to take &self
Previously they took Arc<Self>, and then Self, but &self is perfectly
fine here.
2022-01-07 13:55:26 -05:00
Ian Jackson d63a251afc tor-circmgr: Remove Arc around ClientCirc
See the new commentary text on `ClientCirc` for the rationale.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2022-01-07 18:19:20 +00:00
eta ea41fa3346 Merge branch 'refactor/unwrap-or-default' into 'main'
prefer 'unwrap_or_default' to manual constructor

See merge request tpo/core/arti!215
2022-01-06 15:36:12 +00:00
Nick Mathewson 5c3300867d Merge remote-tracking branch 'origin/mr/214' 2022-01-06 09:02:09 -05:00
Nick Mathewson c15168be61 Merge remote-tracking branch 'origin/mr/212' 2022-01-06 08:28:13 -05:00
Daniel Eades d68e934716 prefer 'unwrap_or_default' to manual constructor 2022-01-01 19:14:29 +00:00
Daniel Eades 592642a9e6 extend lints to include 'clippy::all' 2021-12-28 20:15:40 +00:00
Neel Chauhan 383843f0d7 tor-circmgr: Don't clone parameters in create_chantarget() 2021-12-25 17:22:38 -08:00
Neel Chauhan 7dba3d8c51 tor-proto: In begin_stream_impl(), if number of hops is zero, don't continue 2021-12-25 16:01:22 -08:00
Nick Mathewson 6303a71d58 tor-proto: Replace XXXs with references to arti#269
These will require thought; should we ignore them, act on them, or
continue to  treat them as internal errors?
2021-12-20 10:56:24 -05:00
Nick Mathewson 64257a10fa tor-proto: Allow one meta-cell handler at a time.
Previously the code would let us try to install a meta-cell handler
before the old one was done, leading to possible confusion.
2021-12-16 16:01:50 -05:00
eta 6a12f388f2 Merge branch 'ct_sendme_tags' into 'main'
tor-proto: use const-time eq on sendme tags.

See merge request tpo/core/arti!201
2021-12-16 20:29:01 +00:00
Nick Mathewson 51c4ca73f2 tor-proto: set HalfStream::connected_ok right.
Previously we'd always set it to true, allowing one CONNECTED per
half-closed stream even if the stream had already received a
CONNECTED  cell.

This resolves an XXXX.
2021-12-16 11:48:39 -05:00
Nick Mathewson a09fbc9f27 tor-proto: replace a streammap XXXX with a ticket. 2021-12-16 11:33:50 -05:00
Nick Mathewson d794355b07 tor-proto: use const-time eq on sendme tags.
There's no known attack here, but it's best practice to always compare
digests using a constant-time comparison operator.

This resolves an XXXX comment.
2021-12-16 11:06:30 -05:00
Nick Mathewson e2dd418c84 tor-proto: document an infelicitous behavior.
This was an XXXX before. Now it explains why the behavior is safe for
now, but maybe not forever.
2021-12-16 10:39:00 -05:00
Nick Mathewson f73840544c Extend trace messages for destroy/truncated reasons.
It makes sense to put the method for human-readable strings onto the
type itself, so that we can format these whenever they occur.

I'm choosing the "human_str" method name here, since caret-generated
types already have a to_str.  I was thinking about using Display,
but caret types already implement that.

I've also moved the message from "warn!" to "debug!", since these
aren't necessarily a problem condition.
2021-12-15 11:33:48 -05:00
Nick Mathewson 1cf0b87eb7 Merge remote-tracking branch 'origin/mr/191' 2021-12-15 10:46:58 -05:00
eta 2e0ff665bb Merge branch 'check_put_return' into 'main'
Always check whether stream-level SENDMEs are expected.

Closes #261

See merge request tpo/core/arti!192
2021-12-15 15:45:08 +00:00
Neel Chauhan 043b97fecf In reactor, use enums on whether to destroy circuits 2021-12-14 14:36:30 -08:00
Neel Chauhan b601d8b147 Methodize the destroy circuit reason 2021-12-14 14:26:45 -08:00
Nick Mathewson d5c2361d3f Always check whether stream-level SENDMEs are expected.
(It's a protocol violation to get a SENDME when our send window is
already full.)

This patch makes SendWindow::put return a Result, so that it's
easier to do the right thing with it.

Closes #261.
2021-12-14 17:11:48 +00:00
eta 8d660cbcf1 Actually decrement the stream-level SENDME window
arti!126 overhauled the `tor-proto` circuit reactor, but left out one
very important thing: actually decrementing the SENDME window for
streams (not circuits) when we send cells along them.

Since the circuit-level SENDME window would often prevent us from
running into a problem, this wasn't caught until my benchmarking efforts
noticed it (in the form of Tor nodes aborting the circuit for a protocol
violation).

fixes arti#260
2021-12-14 16:37:56 +00:00
Neel Chauhan 2595f3f8c1 Handle TRUNCATED cells 2021-12-13 12:21:25 -08:00
Neel Chauhan b6ef659311 Log on TRUNCATED cell 2021-12-13 12:21:19 -08:00
Trinity Pointard 9753a7ee06 fix nightly clippy errors 2021-12-09 12:16:23 +01:00
Nick Mathewson d0b217d1a5 Beautify some Vec->array code in tor-proto.
[T;N] supports TryFrom<Vec<T>>, and has since Rust 1.48: we can just
use that.

This resolves an XXXX comment.
2021-12-08 14:01:06 -05:00
Nick Mathewson 9a8c91bdf8 Merge remote-tracking branch 'origin/mr/180' 2021-12-08 12:39:02 -05:00
Neel Chauhan 2d915ed684 In CryptInit, return a Result in initialize() 2021-12-08 08:38:56 -08:00
Nick Mathewson 4536c2ac87 Upgrade to digest v0.10.0
We generally try to track the latest rust-crypto traits when we can:
fortunately, this upgrade didn't break much, considering.
2021-12-07 20:33:46 -05:00
Nick Mathewson 36f6a61f05 Remove some XXXs about zeroizing from tor-proto.
There is now a ticket about this issue in general, at arti#254.
2021-12-07 11:21:48 -05:00
Nick Mathewson 31b385c5b2 Resolve roughly half of the XXXXs.
We want to only use TODO in the codebase for non-blockers, and open
tickets for anything that is a bigger blocker than a TODO.  These
XXXXs seem like definite non-blockers to me.

Part of arti#231.
2021-12-06 15:11:03 -05:00
dagon 0c10f4ea0b add constructors 2021-11-30 23:51:03 +10:00
Nick Mathewson eef81d9d57 Bump every crate by one patch version. 2021-11-29 15:21:58 -05:00
Nick Mathewson efe165acf3 Mark a test as #[ignore]
This test seems unreliable on CI: we've got to disable them for now
so that we have a working CI system.  The CI failure is #238; the
ticket to repair them is #244.
2021-11-29 11:10:51 -05:00
Daniel Eades db16d13df4 add semicolons if nothing returned 2021-11-25 13:20:37 +00:00
Nick Mathewson 3e7e599a22 More typo fixes that I forgot to save :( 2021-11-24 18:23:12 -05:00