aboutsummaryrefslogtreecommitdiff
path: root/crates/arti/src/main.rs
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'clippy-allow-arc-clone' into 'main'Nick Mathewson2022-03-011-1/+0
|\ | | | | | | | | Disable clippy::clone_on_ref_ptr See merge request tpo/core/arti!352
| * Disable clippy::clone_on_ref_ptrIan Jackson2022-02-241-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Merge branch 'main'Ian Jackson2022-03-011-1/+16
|\ \ | | | | | | | | | | | | | | | | | | Fixed conflict in crates/arti-client/src/lib.rs as per tree from https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/364/#note_2782166 ie 13e55b8d7c22c26e55ba75823409b477f1bce66b
| * | Split "static" into sqlite and native-tls features.Nick Mathewson2022-02-251-1/+16
| | | | | | | | | | | | | | | | | | | | | Otherwise, it's impossible to get a static sqlite linkage without also getting native-tls, even if you wanted rustls. Closes #302.
* | | arti-client: use PreferredRuntime by default, doc cleanupseta2022-02-281-1/+1
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* / Upgrade to newer version of config crate.Nick Mathewson2022-02-251-0/+2
|/
* Merge branch 'client_builder' into 'main'Nick Mathewson2022-02-231-1/+4
|\ | | | | | | | | | | | | Make a TorClientBuilder API. Closes #350 See merge request tpo/core/arti!337
| * Make a TorClientBuilder API.Nick Mathewson2022-02-181-1/+4
| | | | | | | | | | | | | | | | This is a defensive API choice to protect against the possibility that we'll want to add a bunch of other non-config options in the future. Closes #350
* | Merge branch 'error-report' into 'main'Nick Mathewson2022-02-221-2/+7
|\ \ | |/ |/| | | | | Improve error messages from arti cli See merge request tpo/core/arti!331
| * Placate clippyIan Jackson2022-02-181-1/+2
| |
| * Add a missing anyhow context() callIan Jackson2022-02-181-2/+2
| |
| * Provide error reporter and use it in the arti binaryIan Jackson2022-02-181-1/+5
| |
* | arti cli: Add some anyhow context() callsIan Jackson2022-02-181-5/+8
| |
* | arti cli: socks proxy: Start listening immedatelyIan Jackson2022-02-181-4/+7
| | | | | | | | This makes arti less awkward to use.
* | arti cli: Do config watch setup before entering future selectIan Jackson2022-02-181-3/+3
|/ | | | IMO this clarifies things a bit, and makes things more deterministic.
* Fix compilation on mainNick Mathewson2022-02-171-1/+2
|
* arti: create TorClient first, then bootstrap.Nick Mathewson2022-02-151-4/+3
| | | | | | | | | | This change is possible now that #293 is done. As an immediate benefit, it allows us to start monitoring the configuration files immediately, and not only after we're done bootstrapping the client. Closes #336.
* Change deny(clippy::all) to warn(clippy::all).Nick Mathewson2022-02-141-1/+1
| | | | Closes #338.
* Allow creating unbootstrapped `TorClient`s (and `DirMgr`s)eta2022-02-111-1/+1
| | | | | | | | | | | | | | | This commit changes how the `TorClient` type works, enabling it to be constructed synchronously without initiating the bootstrapping process. Daemon tasks are still started on construction (although some of them won't do anything if the client isn't bootstrapped). The old bootstrap() methods are now reimplemented in terms of the new create_unbootstrapped() and bootstrap_existing() methods. This required refactoring how the `DirMgr` works to enable the same sort of thing there. closes #293
* arti: Limit mut-ness of cfg_sources to one block.Nick Mathewson2022-02-021-12/+16
|
* Detect changes in non-client configuration sections tooNick Mathewson2022-02-011-10/+4
| | | | We don't yet do much with these, but we can avoid discarding them.
* Make configuration-watching configurable and off-by-default.Nick Mathewson2022-02-011-2/+11
| | | | | | | | I'm slightly concerned about whether this is behavior people would expect to have on-by-default, so let's make this off-by-default for now. Maybe the `application` and `system` sections should merge?
* Reload configuration when our configuration files change.Nick Mathewson2022-02-011-1/+4
| | | | Closes #270
* Un-Arc<> TorClient in the arti crateNick Mathewson2022-02-011-5/+2
| | | | | TorClient doesn't need to be wrapped in an Arc any longer, thanks to other refactoring.
* arti_config: Refactor configuration sources into a structNick Mathewson2022-02-011-19/+24
| | | | | | | | | | | | | | | | | | | This is by no means our final API, but should represent an improvement. Here instead of having to specify a list of files and their is-this-optional status, along with a list of command-line options, we have a single structure that encapsulates all of that information. Two advantages here: - Callers no longer have to remember what the boolean means. - We can "reload" more easily, by keeping the source object around. This change also implements the correct behavior for our default configuration file in `arti::main`: if the file is absent and the user doesn't list a config file, that's no problem. But if the user lists _that very same config file, we should insist that it be present.
* Make max_file_limit configurableNeel Chauhan2022-01-281-1/+1
|
* arti: be more careful to use the user-selected runtimeNick Mathewson2022-01-261-4/+11
|
* Rename `SpawnBlocking` trait to `BlockOn`.Nick Mathewson2022-01-261-1/+1
| | | | | This avoids a future confusion with the new `SpawnBlocking` trait in async_executors v0.5, and better describes what the trait provides.
* Make the native-tls crate optional.Nick Mathewson2022-01-261-2/+2
| | | | | | | | | | | 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
* Make current/create functions into runtime member functions.Nick Mathewson2022-01-261-3/+5
| | | | | This should help avoid some amount of temptation towards API proliferation.
* Tracing configuration for logfiles, per-target filtersNick Mathewson2022-01-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Previously we could only configure one global tracing filter that applied to stdout and journald. There was no support for log files, either. This patch fixes both issues, by substantially revising the configuration format: There are now separate filters for each log file, for journald, and for the console log. Because we want to allow multiple logfiles, they have to go into an array in the configuration. The configuration logic has grown a bit complicated in its types, since the tracing_subscriber crate would prefer to have the complete structure of tracing Layers known statically. That's fine when you know how many you have, and which kinds there will be, but for the runtime-configuration case we need to mess around with `Box<dyn Layer ...>`. I also had to switch from tracing_subscriber's EnvFilter to its Targets filter. It seems "EnvFilter" can only be applied as a Layer in itself, and won't work as a Filter on an individual Layer. Closes #166. Closes #170.
* Move tracing setup into a separate module.Nick Mathewson2022-01-101-43/+3
| | | | No code changes here yet.
* Move a comment to the right place.Nick Mathewson2022-01-061-4/+2
|
* extend lints to include 'clippy::all'Daniel Eades2021-12-281-2/+4
|
* add semicolons if nothing returnedDaniel Eades2021-11-251-0/+1
|
* Move the socks_port option into a new proxy section.Nick Mathewson2021-11-181-1/+4
| | | | Now there are no options that aren't in a toml section.
* Move top-level configuration downwards from `arti` to `arti-config`.Nick Mathewson2021-11-181-152/+11
| | | | | | | | To do this at all neatly, I had to split out `tor-config` from `arti-config` again, and putting the lower level stuff (paths, builder errors) into tor-config. I also changed our use of derive_builder to always use a common error type, to avoid error type proliferation.
* In rust-nightly CI, forbid debugging prints.Nick Mathewson2021-11-041-0/+3
| | | | | | | | | | | | | | | | | | | | This patch makes the rust-nightly CI task fail if it detects any dbg!(), println!(), or eprintln!() calls in production code. Because of clippy limitations, it may also gripe about calls to these macros in our tests. The preferred workarounds are to either instead. Both are acceptable. We're doing this check in CI rather than unconditionally with clippy directives, since we often want to have these calls in our code temporarily while we're developing. Some day we might want this test to go into a pre-push hook. This patch also adds #![allow()] directives for println!() and eprintln!() in the arti crate. Since that one isn't a library, it's okay for it to speak to stdout/stderr. Closes #218.
* Remove all remaining dbg! instances.Nick Mathewson2021-11-041-3/+0
|
* Improve and future-proof the `arti` CLIeta2021-10-271-68/+135
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* Update our disclaimers and limitations sections.Nick Mathewson2021-10-271-5/+3
|
* Rename tor_client/arti_tor_client to arti_client.Nick Mathewson2021-10-211-5/+5
| | | | | | Solves a name conflict with the existing tor_client create. Closes #130.
* Fix most warnings from nightly.Nick Mathewson2021-10-191-1/+3
| | | | (One represents code that I forgot to write.)
* Make elements of TorClientConfig private.Nick Mathewson2021-10-191-13/+10
|
* tor-client: refactor TorClient::bootstrap's args into a config objecteta2021-10-191-10/+16
| | | | | | | | | | | | | 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)
* Merge branch 'reject_bad_hostnames'Nick Mathewson2021-10-181-2/+10
|\
| * Formatting fixesNeel Chauhan2021-10-061-1/+3
| |
| * Introduce ClientConfig for is_localhost config parameterNeel Chauhan2021-10-061-2/+8
| |
* | arti: On startup, increase the NOFILE resource limit.Nick Mathewson2021-10-141-0/+3
| | | | | | | | | | | | | | | | | | | | | | 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.
* | Report errors in logging configuration a bit more usefullyNick Mathewson2021-10-131-2/+22
| |