Commit Graph

43 Commits

Author SHA1 Message Date
Nick Mathewson 4717bb270f Tests for tor-dirmgr::bootstrap 2021-11-11 08:58:48 -05:00
Nick Mathewson 83d9f2299e Replace all println/eprintln calls outside of arti CLI with trace. 2021-11-04 11:04:59 -04:00
eta e8e9699c3c Get rid of tor-proto's ChannelImpl, and use the reactor more instead
Instead of awkwardly sharing the internals of a `tor-proto` `Channel`
between the reactor task and any other tasks, move most of the internals
into the reactor and have other tasks communicate with the reactor via
message-passing to allocate circuits and send cells.

This makes a lot of things simple, and has convenient properties like
not needing to wrap the `Channel` in an `Arc` (though some places in the
code still do this for now).

A lot of test code required tweaking in order to deal with the refactor;
in fact, fixing the tests probably took longer than writing the mainline
code (!). Importantly, we now use `tokio`'s `tokio::test` annotation
instead of `async_test`, so that we can run things in the background
(which is required to have reactors running for the circuit tests).

This is an instance of #205, and also kind of #217.
2021-11-03 13:19:45 +00:00
Nick Mathewson dddf67a902 Use coarsetime to build an incoming traffic timestamp.
We need this for the circuit timeout estimator (#57).  It needs to
know "how recently have we got some incoming traffic", so that it
can tell whether a circuit has truly timed out, or whether the
entire network is down.

I'm implementing this with coarsetime, since we need to update these
in response to every single incoming cell, and we need the timestamp
operation to be _fast_.

(This reinstates an earlier commit, f30b2280, which I reverted
because we didn't need it at the time.)

Closes #179.
2021-11-02 12:17:11 -04:00
Nick Mathewson d272afb341 Cargo.lock: v0.0.1 is now published. 2021-10-29 11:58:28 -04:00
Nick Mathewson f7a72d7f62 Update Cargo.lock in preparation for Arti 0.0.1 release. 2021-10-29 09:40:35 -04:00
Nick Mathewson 2fae63b5ae Upgrade to fslock version 0.2
This version makes all locks per-handle rather than per-process, by
moving from lockf() to flock() on unix.
2021-10-27 14:52:09 -04:00
eta 4fa0122dde Improve and future-proof the `arti` CLI
This switches out `arti`'s argument-parsing library with `clap`, which
is a lot more featureful (and very widely used within the Rust
ecosystem). We also now use a lot of `clap`'s features to improve the
CLI experience:

- The CLI now expects a subcommand (currently, either "help", or "proxy"
  for the existing SOCKS proxy behaviour). This should let us add
  additional non-SOCKS-proxy features to arti in future.
- `clap` supports default values determined at runtime, so the way the
  default config file is loaded was changed: now, we determine the
  OS-specific path for said file before invoking `clap`, so the help
  command can show it properly.
  - The behaviour of `tor_config` was also changed; now, one simply
    specifies a list of configuration files to load, together with
    whether they're required.
  - That function also way overused generics; this has been fixed.
- Instead of using the ARTI_LOG environment variable to configure
  logging, one now uses the `-l, --log-level` CLI option.
  (The intent is for this option to be more discoverable by users.)
- The `proxy` subcommand allows the user to override the SOCKS port used
  on the CLI without editing the config file.
2021-10-27 19:11:48 +01:00
Nick Mathewson 968ffa3d6c Migrate tor-dirmgr from chrono to time 0.3
(This appears to be the emerging consensus of how to handle
RUSTSEC-2020-0159.)
2021-10-24 11:12:06 -04:00
Nick Mathewson 4893e9a15f Migrate tor-netdoc from chrono to time 0.3
(This appears to be the emerging consensus of how to handle
RUSTSEC-2020-0159.)
2021-10-24 10:50:21 -04:00
Nick Mathewson 89de07686d Upgrade to latest tracing-{subscriber,journald} 2021-10-23 22:23:26 -04:00
Nick Mathewson fa266c5644 Upgrade to new version of simple_asn1. 2021-10-22 15:44:37 -04:00
Nick Mathewson 7c7a388e28 Rename tor_client/arti_tor_client to arti_client.
Solves a name conflict with the existing tor_client create.

Closes #130.
2021-10-21 14:22:11 -04:00
eta e4a3ae492a tor-client/examples: add `hyper` example
The new `hyper` tor-client example demonstrates integrating arti with the
popular Rust `hyper` HTTP library by implementing a custom Hyper "connector"
(a type that can initiate connections to HTTP servers) that proxies said
connections via the Tor network.
2021-10-19 15:59:02 -04:00
eta ccd1d36e90 tor-proto: implement tokio Async{Read, Write} traits conditionally
futures::io::AsyncRead (and Write) isn't the same thing as tokio::io::AsyncRead,
which is a somewhat annoying misfeature of the Rust async ecosystem (!).

To mitigate this somewhat for people trying to use the `DataStream` struct with
tokio, implement the tokio versions of the above traits using `tokio-util`'s
compat layer, if a crate feature (`tokio`) is enabled.
2021-10-19 19:59:29 +01:00
eta b42a6712c9 tor-client: refactor TorClient::bootstrap's args into a config object
The three arguments TorClient::bootstrap requires by way of configuration
have been factored into a new TorClientConfig object.

This object gains two associated functions: one which uses `tor_config`'s
`CfgPath` machinery to generate sane defaults for the state and cache
directories, and one that accepts said directories in order to create a
config object with those inserted.

(this commit was inspired by trying to use arti as a library and being somewhat
overwhelmed by the amount of config stuff there was to do :p)
2021-10-19 19:59:25 +01:00
Nick Mathewson 5b6a862096 Upgrade to latest chrono; update cargo_audit.sh
Thanks to the chrono update, we no longer include an
obsolete/vulnerable version of the `time` crate.  Unfortunately, it
turns out that chrono has the same trouble as `time`: it, too, looks
at the environment via localtime_r, and the environment isn't
threadsafe.

One step forward, one step back.  At least the underlying issue is
one that lots of people seem to care about; let's hope they come up
with a solution.
2021-10-19 08:03:41 -04:00
Nick Mathewson a91884389d Merge branch 'reject_bad_hostnames' 2021-10-18 12:19:12 -04:00
Nick Mathewson d8a06159cc Commit change to cargo.lock. 2021-10-18 10:18:09 -04:00
Jani Monoses 8d39a6e96e Update Cargo.lock. 2021-10-18 13:22:53 +03:00
Nick Mathewson f4475c3006 Update const-oid: the previous version has been yanked. 2021-10-15 07:56:02 -04:00
Nick Mathewson 81a5675c1b arti: On startup, increase the NOFILE resource limit.
The default soft limit is typically enough for process usage on most
Unixes, but OSX has a pretty low default (256), which you can run
into easily under heavy usage.

With this patch, we're going to aim for as much as 16384, if we're
allowed.

Fixes part of #188.
2021-10-14 13:25:19 -04:00
Nick Mathewson 0cb7231649 proxy: Mark ENFILES and EMFILES as survivable.
I don't love this approach, but those errors aren't distinguished by
ErrorKind, so we have to use libc or winapi, apparently.  At least
nothing here is unsafe.

Addresses part of #188.
2021-10-14 13:12:58 -04:00
Nick Mathewson 5b06b3c64a Pass the guard manager down to the path selection functions. 2021-10-11 15:59:45 -04:00
Nick Mathewson c41dd01a14 Add a GuardMgr member to CircuitBuilder 2021-10-10 12:24:48 -04:00
Nick Mathewson 58355d7d54 Re-export configuration types from tor-client. 2021-10-09 17:30:06 -04:00
Nick Mathewson 00acc5c5b8 Tests for top-level GuardMgr.
Also, refactor our message handling to be more like the tor_proto
reactors.  The previous code had a bug where, once the stream of
events was exhausted, we wouldn't actually get any more
notifications.
2021-10-07 12:09:29 -04:00
Nick Mathewson 6cdce3dee6 Implement persistent state for guard mgr 2021-10-07 10:45:42 -04:00
Nick Mathewson 0779923d64 Initial backend implementation for guard node manager.
There are some missing parts here (like persistence and tests)
and some incorrect parts (I am 90% sure that the "exploratory
circuit" flag is bogus).  Also it is not integrated with the circuit
manager code.
2021-10-07 10:45:42 -04:00
Nick Mathewson 7e68883a27 Change tor-persist to use json instead of toml.
The limitations with toml seemed to be reaching a head, and I wasn't
able to refactor the guardmgr code enough to actually have its state
be serializable as toml.  Json's limitations are much narrower.
2021-10-07 09:30:08 -04:00
Trinity Pointard 9c275a04ee update ctrlc and der
ctrlc had rustsec issues, der was yanked
2021-10-06 23:55:08 +02:00
Neel Chauhan e76988738a Introduce ClientConfig for is_localhost config parameter 2021-10-06 12:32:17 -07:00
Nick Mathewson 150270f904 Update cargo.lock again. 2021-10-05 08:21:34 -04:00
Nick Mathewson 7bdb6e7633 Update cargo.lock; upgrade to newer rusqlite. 2021-10-05 08:10:04 -04:00
Nick Mathewson 932924b733 tor-netdir: Add RelayWeight type and accessors.
I'm not thrilled with this code, but I think it's needed to
implement guards correctly.
2021-09-29 13:49:07 -04:00
Nick Mathewson 5e196f7f3f Run cargo update on other dependencies. 2021-09-25 15:46:32 -04:00
Trinity Pointard 954395573a update fslock to compile android 2021-09-25 12:01:45 +02:00
Nick Mathewson 34ad08c1db Run cargo upate. 2021-09-23 08:27:48 -04:00
Nick Mathewson b51e2ff5b3 Upgrade memmap2, directories, and dirs dependencies. 2021-09-23 08:26:29 -04:00
Nick Mathewson 8bf394b0d5 Move version-controlled Cargo.lock to /.
Previously I'd hoped to have it only apply to reproducible builds,
but the work of keeping it up-to-date and checking it for drift
seems to have been tripping us up.  Let's try doing it the other way
for now, and we'll see how that goes.
2021-09-20 11:37:11 -04:00
Trinity Pointard 46f30aad4d address review comments
sha256: 7f190568fa05f71ad356dc56a7a9725a4be18e5e40d6880f469e22981a18edd7
2021-08-26 08:38:45 +02:00
Trinity Pointard eb0522fe63 fix segfault on static bin
see https://github.com/rusqlite/rusqlite/issues/914

sha256: 684ebc4b8c270fc63beba185f6c54ceeb98734f13aa7aeca9b64acb33432a21c
2021-08-25 20:37:58 +02:00
Trinity Pointard 540302851e make arti availlable as build artifact
and make builds reproducible
sha256sum: f141c54929a43a31b9ed6b529f6f863aace87f7406818b2f8ffe2b7a5e2803fb
2021-08-25 18:16:45 +02:00