Commit Graph

167 Commits

Author SHA1 Message Date
trinity-1686a 7f939fa480 enable doc_auto_cfg feature on every crate when documenting for docs.rs 2022-08-24 18:22:41 +02:00
Nick Mathewson fb5695570e Add a semver note for TcpStream send conversion. 2022-08-15 09:48:54 -04:00
Ian Jackson 740f306cb0 tor-rtcompat: Require that TcpStream be Send
The lack of this seems to have been an oversight.
2022-08-15 09:47:40 -04:00
eta e0c4e37d2b tor-rtcompat: s/micros/millis inside a flaky test
The other tests wait for 100 milliseconds; this one waits for 100
*microseconds* for some reason, which meant it was understandably flaky
if run on anything less than perfect conditions (arti#515).

This is probably a typo, so just change it.

fixes arti#515
2022-07-26 15:01:03 +01:00
Nick Mathewson 1dda69af2b Remove semver.md files now that 0.5.0 is out 2022-06-24 13:31:38 -04:00
Nick Mathewson 20435aea75 Bump crate and dependency versions.
These were done with the following commands:

```
cargo set-version -p tor-basic-utils   --bump patch
cargo set-version -p fs-mistrust       --bump minor
cargo set-version -p tor-error         --bump patch
cargo set-version -p tor-config        --bump patch
cargo set-version -p tor-units         --bump patch
cargo set-version -p tor-rtcompat      --bump minor
cargo set-version -p tor-llcrypto      --bump patch
cargo set-version -p tor-bytes         --bump minor
cargo set-version -p tor-socksproto    --bump minor
cargo set-version -p tor-cert          --bump minor
cargo set-version -p tor-cell          --bump minor
cargo set-version -p tor-proto         --bump minor
cargo set-version -p tor-netdoc        --bump patch
cargo set-version -p tor-netdir        --bump minor
cargo set-version -p tor-persist       --bump patch
cargo set-version -p tor-chanmgr       --bump minor
cargo set-version -p tor-guardmgr      --bump minor
cargo set-version -p tor-circmgr       --bump patch
cargo set-version -p tor-dirclient     --bump patch
cargo set-version -p tor-dirmgr        --bump minor
cargo set-version -p arti-client       --bump patch
cargo set-version -p arti              --bump minor
cargo set-version -p arti-bench        --bump minor
cargo set-version -p arti-testing      --bump minor
```
2022-06-24 12:00:22 -04:00
Ian Jackson 4831f9d38c Merge branch 'clippy' into 'main'
Fix clippy nightly again

See merge request tpo/core/arti!603
2022-06-24 14:13:58 +00:00
Nick Mathewson ce4d062c09 Update README.md files from rustdoc. 2022-06-24 08:02:56 -04:00
Ian Jackson 589c6e52bb Run maint/add_warning crates/*/src/{lib,main}.rs
Update all lint blocks
2022-06-23 19:15:42 +01:00
Nick Mathewson 19679a6f13 Remove rustls from tor-rtcompat/full
This is another consequence of the `ring` license issue; see #493.
2022-06-16 08:45:10 -04:00
Nick Mathewson 0223c91b26 Merge branch 'high-level-features' into 'main'
Add "full" and "experimental" features to arti, arti-client, and below.

Closes #499

See merge request tpo/core/arti!584
2022-06-16 12:24:47 +00:00
Nick Mathewson d44dd6f44f Merge branch 'dormant_directory' into 'main'
Use TaskSchedule to sleep in directory bootstrapping

Closes #497

See merge request tpo/core/arti!571
2022-06-13 13:59:26 +00:00
Nick Mathewson 8a586a40fa Add "full" and "experimental" features to arti-client and below.
The "full" feature is a catch-all for all features, _except_:

   * Those that select a particular implementation (like
     tor-llcrypto/with-openssl) or build flag (like "static")
   * Those that are experimental or unstable (like "experimental-api")
   * Those that are testing-only.
2022-06-10 15:32:21 -04:00
Nick Mathewson 947bbe6fe7 TaskSchedule: Add a sleep_until_wallclock method too. 2022-06-10 13:59:30 -04:00
Ian Jackson 8eb215bf81 Document semver changes 2022-06-08 11:24:26 +01:00
Ian Jackson 3ba3b26842 rt-compat: Make all the individual runtime traits Clone+Send etc.
This will make it much more convenient for code that only wants one of
these traits (or a subset of them).  This is a good thing to support
because it will allow us to use a ZST in places that do not need an
actual async runtime handle (typically, the runtime handle is needed
only for spawn).
2022-06-08 11:24:26 +01:00
Nick Mathewson 3502a12da2 Add a `sleep` function to TaskSchedule.
Having this alias makes it easier to implement more complex
schedules, like those used in DirMgr.
2022-06-07 10:41:44 -04:00
Nick Mathewson 897a2d5fa0 Add "suspend" and "resume" to TaskSchedule.
Unlike "cancel" and "fire", "suspend" and "resume" don't change any
pending timers or events: they just prevent execution of those
events for a while, and let them resume later on.
2022-06-07 10:11:49 -04:00
Ian Jackson 4f42101554 lints: Add let_unit_value allow to all crates
From running add_warning, with manual picking of the right
hunks/lines.
2022-05-31 15:23:52 +01:00
Ian Jackson ba0843da4a lints: Add lint block delimiters to every crate
This was the result of:
  maint/add_warning crates/*/src/{lib,main}.rs
and then manually curating the results.
2022-05-31 13:00:31 +01:00
Ian Jackson 5824992471 Merge branch 'post-release-fix-20220527' into 'main'
Fix minor issues found while publishing crates for Arti 0.4.0

See merge request tpo/core/arti!547
2022-05-30 14:57:49 +00:00
Orhun Parmaksız bfd41ddb5f
Lexically sort Cargo.toml dependencies
Utilize cargo-sort: https://github.com/DevinR528/cargo-sort

Signed-off-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
2022-05-28 20:05:51 +03:00
Nick Mathewson 5b1622c283 tor-rtcompat: Fix a warning when building with no backends.
Cargo publish (and probably nobody else!) builds this crate with no
features enabled.  When you do that, you get a warning about an
unused `use std::io`.

Fixing that.
2022-05-27 14:07:06 -04:00
Nick Mathewson b232365a75 Semantic version changes for Arti 0.4.0 release
I followed the following procedure to make these changes:

* I used maint/changed_crates to find out which crates had changed
  since 0.3.0.
* I used grep and maint/list_crates to sort those crates in
  topological (dependency) order.
* I looked through semver_status to find which crates were listed as
  having semver-relevant changes (new APIs and breaking changes).
* I scanned through the git logs of the crates with no
  semver-relevant changes listed to confirm that, indeed, they had
  no changes.  For those crates, I incremented their patch-level
  version _without_ changing the version that other crates depend on.
* I scanned through the git logs of the crates with no
  semver-relevant changes listed to confirm that, indeed, they had
  no obvious breaking changes.
* I treated all crates that depend on `arti` and/or `arti-client` as
  having breaking changes.
* I identified crates that depend on crates that have changed, even
  if they have not changed themselves, and identified them as having
  a non-breaking change.
* For all of the crates, I used `cargo set-version -p $CRATE --bump
  $STATUS` (where `STATUS` is `patch` or `minor`) to update the
  versions, and the depended-upon versions.
2022-05-27 09:01:20 -04:00
eta 864fd03917 Improve documentation around Cargo features; make Runtime require Debug
- arti#445 highlighted the lack of good documentation around Arti's
  multiple runtime support, as well as it being difficult to determine
  what runtime was actually in use.
- Improve the documentation to solve the first problem.
- To solve the second problem, make Runtime require Debug (which is
  arguably a good idea anyway, since it makes them easier to embed in
  things), and print out the current runtime's Debug information when
  arti is invoked with `--version`.
- (It also prints out other Cargo features, too!)

fixes arti#445
2022-05-11 13:26:35 +01:00
eta f0739e46aa tor-rtcompat: make CompoundRuntime handle SleepProviders properly
Previously, CompoundRuntime would use the default implementations of
SleepProvider::now() and ::wallclock(), instead of using its wrapped
SleepProvider. This mildly embarrassing omission has been rectified.
2022-05-10 11:42:53 +01:00
Nick Mathewson 7b93091f57 Bump the version of every* crate to 0.3.0
* Except for safelog and fs-mistrust, which are new.
2022-05-06 10:03:15 -04:00
Nick Mathewson 9447e69355 Update README.md files (automated). 2022-05-06 09:51:11 -04:00
Samanta Navarro c53818d496 Fix grammar and typos 2022-04-27 13:52:13 +01:00
Nick Mathewson f8dbad941e Bump async_executors to 0.6 2022-04-26 12:16:22 -04:00
Nick Mathewson b60b0a266a Bump every crate's edition to 2021.
This is an automated change made with a perl one-liner and verified
with grep -L and grep -l.

Some warnings are introduced with this change; they will be removed
in subsequent commits.

See arti#208 for older discussion on this issue.
2022-04-25 13:05:31 -04:00
Nick Mathewson ca05b0904c Add 'rust-version = "1.56"' to every Cargo.toml file.
This change was made automatically with a perl one-liner, and
confirmed with `grep -L`.

The `rust-version` field itself was introduced in 1.56.0.
2022-04-25 13:04:31 -04:00
Nick Mathewson 0069fd2206 Reformat all not-yet-reformatted Cargo.toml files.
There are no semantic changes here; only formatting.  This is in
preparation for other changes (wrt MSRV and edition)
2022-04-25 13:04:31 -04:00
Nick Mathewson 5b2fc118df Bump all arti*, tor* crates to 0.2.0
Not all of these strictly need to be bumped to 0.2.0; many could go
to 0.1.1 instead.  But since everything at the tor-rtcompat and
higher layers has had breaking API changes, it seems not so useful
to distinguish.  (It seems unlikely that anybody at this stage is
depending on e.g. tor-protover but not arti-client.)
2022-04-01 09:15:18 -04:00
eta 5d27710ef1 Merge branch 'disallowed_lint' into 'main'
Remove allow(clippy::disallowed_methods) lint flag.

See merge request tpo/core/arti!437
2022-03-30 14:02:13 +00:00
eta ac64bdea27 Make daemon tasks self-contained; introduce NetDirProvider
The various background daemon tasks that `arti-client` used to spawn are
now handled inside their respective crates instead, with functions
provided to spawn them that return `TaskHandle`s.

This required introducing a new trait, `NetDirProvider`, which steals
some functionality from the `DirProvider` trait to enable `tor-circmgr`
to depend on it (`tor-circmgr` is a dependency of `tor-dirmgr`, so it
can't depend on `DirProvider` directly).

While we're at it, we also make some of the tasks wait for events from
the `NetDirProvider` instead of sleeping, slightly increasing
efficiency.
2022-03-30 14:26:43 +01:00
Nick Mathewson 700e491813 Remove allow(clippy::disallowed_methods) lint. 2022-03-30 08:55:58 -04:00
eta fd081742fa Merge branch 'no-system-time' into 'main'
Don't use SystemTime::now()

Closes #306

See merge request tpo/core/arti!365
2022-03-30 12:44:25 +00:00
eta ee47a16697 tor-rtcompat/scheduler: add unit tests, FireIn -> FireAt
Addressing review comments: added some unit tests for the new scheduler
type, and made FireIn use an Instant instead (making it FireAt).
2022-03-24 14:07:40 +00:00
eta 1ca79ff988 Implement a periodic task scheduler, and a basic dormant mode
This is a revised version of !397; it implements a scheduling system for
periodic tasks that can be externally controlled, and then uses the
external control aspect to implement a basic dormant mode (#90).

More technically, the scheduling system consists of a `Stream` that
periodic tasks are expected to embed in a `while` loop or similar, a
way for tasks themselves to choose how long to wait until the stream
next yields a result, and a handle to control this outside of the task.
2022-03-23 13:43:48 +00:00
Nick Mathewson 2aa5f45bc8 UdpSocket: remove support for connect().
Currently, Arti doesn't need this.  But once it does, it will be
way better to have a separate type for connected sockets, rather
than having to error-check every time somebody gives us a socket.

Part of #410
2022-03-18 15:39:40 -04:00
trinity-1686a f4581ffd04 add simple unit test on UDP 2022-03-14 21:19:20 +01:00
trinity-1686a fa29925689 fix typos and minor issues 2022-03-14 21:16:56 +01:00
trinity-1686a 9b3be0ad47 add skeleton for DNS handling 2022-03-14 20:59:35 +01:00
trinity-1686a 4a44ef56c0 add udp to runtime 2022-03-14 20:59:33 +01:00
Ian Jackson b095265257 Merge branch 'educe-traits' into 'main'
Replace many manual trait impls with use of educe

See merge request tpo/core/arti!375
2022-03-04 18:00:17 +00:00
Ian Jackson ea03cc4084 Replace manual Clone impl with educe in tor-rtcompat 2022-03-02 18:06:37 +00:00
Ian Jackson 42f9b3c186 Replace manual Default, and abolish new, in tor-rtcompat
The Default impl was the only call site for new()
2022-03-02 18:01:18 +00:00
Nick Mathewson 83c8b11c2c Merge branch 'clippy-allow-arc-clone' into 'main'
Disable clippy::clone_on_ref_ptr

See merge request tpo/core/arti!352
2022-03-01 20:38:05 +00:00
Nick Mathewson e8e9791a97 Bump all crates to 0.1.0 2022-03-01 08:59:34 -05:00
Nick Mathewson 5735222691 Update README.md files from rustdoc. 2022-03-01 08:30:53 -05:00
Nick Mathewson 57a8fe5f55 Fix rustdoc errors. 2022-03-01 08:16:02 -05:00
eta 13ba0ea005 arti-client: use PreferredRuntime by default, doc cleanups
This makes using the `PreferredRuntime` the first-class option inside
`arti-client`, freeing users who don't want to think about runtimes from
having to do so.

`TorClient::create_unbootstrapped` and `builder` now automatically
use this runtime, leaving only `builder_custom` for users who wish to
manually specify a runtime.

This lets us clean up the docs a lot: mentions of using custom runtimes
are now relegated to nearer the end of the crate-level documentation,
and we mostly just link to `tor_rtcompat`'s docs to explain more there.
Instead, we take some more time to explain how you use the builder API
to create clients synchronously.

Other doc cleanups included getting rid of the explanation of `TorAddr`
in the main crate-level doc; this is already well-documented elsewhere,
and is something users should discover organically later.

fixes arti#326
2022-02-28 16:41:13 +00:00
trinity-1686a f06b256010 use wallclock where possible in tests 2022-02-26 00:33:44 +01:00
trinity-1686a f9a4f23e83 remove most usage of SystemTime::now 2022-02-25 20:34:27 +01:00
eta 387ebda740 tor-rtcompat: refactor PreferredRuntime, clean up docs
`PreferredRuntime` is now an opaque wrapper struct that contains the
"actual" preferred runtime as a type alias. The `current_user_runtime`
and `create_runtime` functions become `PreferredRuntime::current` and
`PreferredRuntime::create`, respectively.

This removes the dependence on `impl Trait`, meaning we can now name the
returned runtime (yay!).

In addition, the documentation was cleaned up a bit to make it
(hopefully) flow better. Items that don't make sense to publicize, like
testing implementation details, have been marked #[doc(hidden)] and
semver warnings added.
2022-02-25 17:34:05 +00:00
Nick Mathewson 4becaa01b9 Bump minimum tokio to 1.7, since tokio-util now needs that. 2022-02-25 11:09:24 -05:00
Nick Mathewson 55416937cc Upgrade dependency to new version of tokio-util. 2022-02-25 08:48:00 -05:00
Ian Jackson 0ad45d437c Merge branch 'tls-trait' into 'main'
tor-rtcompat: Provide TLS wrapping for all streams

See merge request tpo/core/arti!349
2022-02-25 11:13:34 +00:00
eta d9df4d647d Merge branch 'http-layer' into 'main'
Initial cut of hyper bindings as a library crate

See merge request tpo/core/arti!342
2022-02-24 19:48:35 +00:00
Ian Jackson afb50fe735 Disable clippy::clone_on_ref_ptr
This lint is IMO inherently ill-conceived.

I have looked for the reasons why this might be thought to be a good
idea and there were basically two (and they are sort of contradictory):

I. "Calling ‘.clone()` on an Rc, Arc, or Weak can obscure the fact
    that only the pointer is being cloned, not the underlying data."

This is the wording from
  https://rust-lang.github.io/rust-clippy/v0.0.212/#clone_on_ref_ptr

It is a bit terse; we are left to infer why it is a bad idea to
obscure this fact.  It seems to me that if it is bad to obscure some
fact, that must be because the fact is a hazard.  But why would it be
a hazard to not copy the underlying data ?

In other languages, faliing to copy the underlying data is a serious
correctness hazard.  There is a whose class of bugs where things were
not copied, and then mutated and/or reused in multiple places in ways
that were not what the programmer intended.  In my experience, this is
a very common bug when writing Python and Javascript.  I'm told it's
common in golang too.

But in Rust this bug is much much harder to write.  The data inside an
Arc is immutable.  To have this bug you'd have use interior mutability
- ie mess around with Mutex or RefCell.  That provides a good barrier
to these kind of accidents.

II. "The reason for writing Rc::clone and Arc::clone [is] to make it
     clear that only the pointer is being cloned, as opposed to the
     underlying data. The former is always fast, while the latter can
     be very expensive depending on what is being cloned."

This is the reasoning found here
  https://github.com/rust-lang/rust-clippy/issues/2048

This is saying that *not* using Arc::clone is hazardous.
Specifically, that a deep clone is a performance hazard.

But for this argument, the lint is precisely backwards.  It's linting
the "good" case and asking for it to be written in a more explicit
way; while the supposedly bad case can be written conveniently.

Also, many objects (in our codebase, and in all the libraries we use)
that are Clone are in fact simply handles.  They contain Arc(s) (or
similar) and are cheap to clone.  Indeed, that is the usual case.

It does not make sense to distinguish in the syntax we use to clone
such a handle, whether the handle is a transparent Arc, or an opaque
struct containing one or more other handles.

Forcing Arc::clone to be written as such makes for code churn when a
type is changed from Arc<Something> to Something: Clone, or vice
versa.
2022-02-24 18:15:44 +00:00
Ian Jackson 5f83b2b7be Fix rustdoc "skip this" markup 2022-02-24 16:19:28 +00:00
Ian Jackson 2bbd01b060 tor-rtcompat: Provide TLS wrapping for all streams
Now all of the runtime types we provide all
  impl<S> TlsProvider<S> where S: ...
rather than merely TlsProvider<Self::TcpStream>.

And we document and intent to perhaps require this in the future.
2022-02-24 14:26:38 +00:00
Ian Jackson f8d17bce83 Add missing documentation for TLS features to two readmes 2022-02-23 13:53:45 +00:00
trinity-1686a 81d7747d7b add example of tcp hook
this required to make additional types public
2022-02-23 13:29:37 +00:00
Ian Jackson 1c301230e4 rename *.py scripts to bare name
Update all references.  There are three remaining hits for
  git-grep '\.py\b'
all of which are scripts in "little-t-tor", not here in arti.
2022-02-18 11:46:06 +00:00
Nick Mathewson 1cecc7e45a Change deny(clippy::all) to warn(clippy::all).
Closes #338.
2022-02-14 09:24:06 -05:00
Nick Mathewson c8dd73d55f Upgrade required version of futures crate to 0.3.14
Earlier versions have a bug in UnboundedReceiver that make our new
dirclient tests fail.
2022-02-01 09:54:47 -05:00
Nick Mathewson 01d9937308 Bump the patch version of every crate that changed since 0.0.3 2022-01-31 10:30:52 -05:00
Nick Mathewson 5187b05c19 Use script to update README.md files. 2022-01-28 08:36:34 -05:00
Nick Mathewson 19f878b3aa tor-rtcompat: remove some unused code.
Nothing actually used these accessor functions, and it's not clear
what would.  We can add them later if they're needed.
2022-01-27 15:52:59 -05:00
Nick Mathewson f7373f8b20 tor-rtcompat: Add some miscellaneous tests
These probably aren't for things that will fail IRL, but it's nice
to have coverage on the code, just in case.
2022-01-27 15:48:30 -05:00
Nick Mathewson af85262257 tor-rtcompat: Simplify test-declaration macros.
Now there's much less copy-and-paste.
2022-01-27 15:09:09 -05:00
Nick Mathewson 9435e4b36e Move tor-rtcompat tests to lib.rs
This makes our layout more similar to our other crates, and
successfully informs our grcov exclusion pattern that these tests
are indeed tests.

Doing this knocks down the reported coverage for the tor-rtcompat
crate, but that's okay: we hadn't earned it.

I hereby promise that this commit is only code-movement.
2022-01-27 14:45:00 -05:00
Nick Mathewson 9f3ad85d75 Document why {current,create}_runtime are type-erased 2022-01-27 10:31:45 -05:00
eta c4321289f2 Apply @eta's suggestions from review on !263
Comment-only.
2022-01-27 15:25:57 +00:00
Nick Mathewson 5dcc821146 Fix documentation references for tor-rtcompat refactoring. 2022-01-26 14:58:28 -05:00
Nick Mathewson bf8fa66d36 Rename `SpawnBlocking` trait to `BlockOn`.
This avoids a future confusion with the new `SpawnBlocking` trait in
async_executors v0.5, and better describes what the trait provides.
2022-01-26 14:06:58 -05:00
Nick Mathewson dec2c4ee63 Make test_with_all_runtimes cover _all_ the runtimes.
This took some refactoring, so that I wouldn't need to define 9
different versions of the function.  It also required that we change
the behavior of test_with_all_runtimes slightly, so that it asserts
on _any_ failure rather than asserting on most but returning Err()
for others.  That in turn required changes to a few of its callers.

There's probably a better way to do all of this macro business, but
this is the best I could find.
2022-01-26 14:06:58 -05:00
Nick Mathewson 30b3818a9e Make the native-tls crate optional.
This commit puts the native-tls crate behind a feature.  The feature
is off-by-default in the tor-rtcompat crate, but can be enabled
either from arti or arti-client.

There is an included script that I used to test that tor-rtcompat
could build and run its tests with all subsets of its features.

Closes #300
2022-01-26 14:06:58 -05:00
Nick Mathewson 8af3528cd3 Define aliases for "the best enabled runtime".
This helps us simplify our code in a few ways, and will help even
more once native_tls is optional.
2022-01-26 14:06:58 -05:00
Nick Mathewson 6f29d485e4 Make current/create functions into runtime member functions.
This should help avoid some amount of temptation towards API
proliferation.
2022-01-26 14:06:58 -05:00
Nick Mathewson 2333d0466e Rename FooRuntime to FooNativeTlsRuntime for consistency. 2022-01-26 14:06:58 -05:00
Nick Mathewson 05a04220cc Limit the inner types in tor-rtcompat that have to implement Clone
If we implement our own clone on CompoundRuntime, we no longer need
Clone implementations on our TlsProvider implementations.
2022-01-26 14:06:58 -05:00
Nick Mathewson 99c59a8f2b Remove no-longer-needed tokio runtime helper macro 2022-01-26 14:06:58 -05:00
Nick Mathewson 668364d75d Unify TokioRuntime and TokioRuntimeHandle
Having separate types here doesn't justify the (very limited)
benefit of distinguishing between the case where we have created an
executor that we own and the case where we have a handle to an
already-running tokio executor.

Part of #301.
2022-01-26 14:06:58 -05:00
Nick Mathewson 5af8a1bf28 Remove misspellings of "rusttls". 2022-01-26 14:05:05 -05:00
Nick Mathewson e4e691a790 More comments on the limitations of tor-rtcompat's TLS API
Also, more comments on why these limitations are safe within the
context of Tor, but you wouldn't want to use them elsewhere.
2022-01-25 13:16:39 -05:00
Nick Mathewson 0898b485aa Comment-only: document sni_hostname more.
Previously we expected the reader to automatically know why it was
called "SNI", which really isn't fair.
2022-01-25 13:16:39 -05:00
Nick Mathewson d1d121aac6 Refactor native_tls usage into its own module
This change uses the async-native-tls crate for everything, and
deletes some duplicated code.
2022-01-25 13:16:39 -05:00
Nick Mathewson 8def5a0d89 tor-rtcompat: Add support for rustls.
This is based on @janimo's approach in !74, but diverges in a few
important ways.

1. It assumes that something like !251 will merge, so that we can
   have separate implementations for native_tls and rustls compiled
   at the same time.

2. It assumes that we can implement this for the futures::io traits
   only with no real penalty.

3. It uses the `x509-signature` crate to work around the pickiness of
   the `webpki` crate.  If webpki eventually solves their
   [bug 219](https://github.com/briansmith/webpki/issues/219), we
   can remove a lot of that workaround.

Closes #86.
2022-01-25 13:16:39 -05:00
Nick Mathewson 979cfb46d1 Add a C program to make Tor-style X509 link certificates
We should never use this for anything but making the testing
certificates we use for making sure our TLS implementation works.
2022-01-24 14:22:07 -05:00
Nick Mathewson 17920e43f8 Refactor Runtimes to use separate TLS implementations internally.
This will make it easier to implement them using some other TLS
provider as well, without having to duplicate all of our code.
2022-01-19 15:47:26 -05:00
Nick Mathewson 8d3e4576da Add a macro to help with opaque Runtime wrappers.
We're soon going to have our different Runtime types be built as
CompoundRuntime instances.  We don't want to expose that detail,
though, so we'll use this macro to make them implement the right
traits.
2022-01-19 15:47:26 -05:00
Nick Mathewson dd72607601 Add a CompoundRuntime type for runtime construction.
This type can solve two problems at once.

First, it lets users replace parts of an existing runtime
implementation without replacing the whole thing.  For example, you
can use it to override your TcpProvider implementation to solve
problems like #235.

Second, we can use it internally to tor-rtcompat to define Runtimes
piece-by-piece.  Mostly we'll use this to separate our Tls
implementations from our implementations of the rest of the Runtime.
2022-01-19 15:47:26 -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
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
Daniel Eades 592642a9e6 extend lints to include 'clippy::all' 2021-12-28 20:15:40 +00:00