Commit Graph

1544 Commits

Author SHA1 Message Date
Nick Mathewson 36353aacd8 Fix some typos in comments.
Also, tell the "typos" tool to ignore Cargo.lock.
2021-10-19 10:40:32 -04:00
Nick Mathewson 457e7f064c Reverse two swapped log messages 2021-10-19 10:24:19 -04:00
Nick Mathewson 26e1b6fb72 Improve logging when trying to get the lock on the directory cache.
Previously we'd say that we were "waiting for the other process to
bootstrap" even if it was already bootstrapped: and we wouldn't
actually declare success when it was done.
2021-10-19 10:18:02 -04:00
Nick Mathewson 193148c12d Remove Guard::get_relay(); use Guard::guard_id().get_relay().
The `get_relay` function was confusing, since it would return None if
the relay was present, but wasn't actually a guard.  We only used it
in one place, and in that one place we used it wrong, leading to a
panic bug.

Fixes #193.
2021-10-19 08:33:55 -04: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 45fb7022df Remove special-case for ipv6 in is_valid_hostname 2021-10-18 14:56:12 -04:00
Nick Mathewson b63fee25b2 Use a proper RFC5737 address in tests. 2021-10-18 14:53:01 -04:00
Nick Mathewson 539982bf8e Add the "clock" feature to chrono in netdoc.
This seems to fix a bug when running cargo check on netdoc individually.

Reported by @janimo
2021-10-18 14:40:02 -04:00
Nick Mathewson 0750199a8c Move hostname enforcement into TorAddr. 2021-10-18 14:32:05 -04:00
Nick Mathewson 5ae433c747 Change how we connect to target addresses.
Now we all both address:port, (address, port), and more.

We also allow SocketAddr and IpAddr, but only via a trait
labeled as "Dangerous".
2021-10-18 14:03:38 -04:00
Nick Mathewson 26aa0f8e25 Remove "internal" address checking to its own function. 2021-10-18 12:28:50 -04:00
Nick Mathewson a91884389d Merge branch 'reject_bad_hostnames' 2021-10-18 12:19:12 -04:00
Nick Mathewson 36febf7c14 Rename is_localhost to allow_local_addrs, and apply it to IPs too. 2021-10-18 12:07:18 -04:00
Nick Mathewson d8a06159cc Commit change to cargo.lock. 2021-10-18 10:18:09 -04:00
Jani Monoses 7fb88307b5 Do not use downcast_ref, use tor-client error. 2021-10-18 13:43:06 +03:00
Jani Monoses 12da3f0771 Remove anyhow usage in tor-client. 2021-10-18 13:43:01 +03:00
Jani Monoses f683d4f3cd Remove useless into() conversions caught by clippy. 2021-10-18 13:22:53 +03:00
Jani Monoses 8d39a6e96e Update Cargo.lock. 2021-10-18 13:22:53 +03:00
Jani Monoses 8b8228190d Remove anyhow dependency from tor-dirmgr. 2021-10-18 13:22:53 +03:00
Jani Monoses 6181e623f8 Use unwrap in tests.
For now, this avoids having to separately handle
AuthorityBuilderError, DirMgrConfigBuilderError, DownloadScheduleConfigBuilderError,
NetworkConfigBuilderError and FallbackDirBuilderError when anyhow is not
used.

Turn off a clippy warning.
2021-10-18 13:22:39 +03:00
Nick Mathewson 9df9706010 Use append in place of extend_from_slice in DataReaderImpl::add_data.
Suggested by @cheako.
2021-10-17 12:31:10 -04:00
Nick Mathewson a1758644a6 Add in first cargo-audit exception, as an example. 2021-10-17 11:11:54 -04:00
Nick Mathewson 342dec3872 Add an ignored cargo-audit warning, with appropriate documentation 2021-10-17 11:02:11 -04:00
Nick Mathewson 290fe83671 Move "cargo audit" invocation into a script. 2021-10-17 10:41:52 -04:00
Nick Mathewson 3b7b43ae5f Turn off default-features in chrono where possible. 2021-10-17 10:37:30 -04:00
Nick Mathewson 37234548e2 Add a cast to correct a type error about WSAEMFILE 2021-10-15 08:08:19 -04: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 02b20edeb3 Add a few tracing directives to tor-dirmgr. 2021-10-13 13:37:18 -04:00
Nick Mathewson e9399ec6c0 tor-dirmgr: report bootstrap success on all successful cases.
Previously we would sometimes fail to report that we had
successfully bootstrapped.
2021-10-13 13:01:55 -04:00
Nick Mathewson 16767fb517 Fix a documentation link error. 2021-10-13 12:56:00 -04:00
Nick Mathewson 13769dbc56 Report errors in logging configuration a bit more usefully 2021-10-13 12:53:17 -04:00
Nick Mathewson 7dd8af55d9 Document trace_filter example in main.rs too. 2021-10-13 12:37:33 -04:00
Nick Mathewson 8113a8ba12 Don't report the bootstrap as completed unless it actually succeeds.
(Previously we'd report it as successful even if the inner download
task was a failure.)
2021-10-13 12:19:40 -04:00
Nick Mathewson f15cde80de Use better reporting for guard status.
The previous code would report all failures to build a circuit as
failures of the guard.  But of course that's not right:  If we
fail to extend to the second or third hop, that might or might not
be the guard's fault.

Now we use the "pending status" feature of the GuardMonitor type so
that an early failure is attributed to the guard, but a later
failure is attributed as "Indeterminate".  Only a complete circuit
is called a success.  We use a new "GuardStatusHandle" type here so
that we can report the status early if there is a timeout.
2021-10-13 11:24:37 -04:00
Nick Mathewson e625b2cff5 Rename GuardStatusMsg, make it public, add an `Indeterminate` case. 2021-10-13 10:55:44 -04:00
Nick Mathewson 733aa3a4e2 Implement guards for multihop paths.
There are some limitations here, as noted in the comments.
2021-10-13 10:27:46 -04:00
Nick Mathewson fd893f750c Actually select guards for directory circuits. 2021-10-13 09:30:50 -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 ad851c43c6 WIP 2021-10-11 15:37:59 -04:00
Nick Mathewson 73669fa05e Make the guard selection function return a more useful type. 2021-10-11 15:23:12 -04:00
Nick Mathewson 19038ae39a Add a function to look up a Relay by ChanTarget. 2021-10-11 15:21:46 -04:00
Nick Mathewson 34b576a815 Integrate GuardUsability and GuardMonitor into CircuitBuilder.
(When we're building a path with a guard, we need to tell the guard
manager whether the path succeeded, and we need to wait to hear
whether the guard is usable.)
2021-10-10 13:48:58 -04:00
Nick Mathewson 33ba697b5d Notify guard manager on network change and state flush. 2021-10-10 12:38:50 -04:00
Nick Mathewson c41dd01a14 Add a GuardMgr member to CircuitBuilder 2021-10-10 12:24:48 -04:00
Nick Mathewson 99effeb532 Merge branch 'sync_guard_api' 2021-10-10 12:15:05 -04:00
Nick Mathewson 91cca2183e Change the GuardMgr APIs to no longer be async. 2021-10-10 12:14:33 -04:00
Nick Mathewson 34c10feae4 Use an mpsc::unbounded() channel in GuardMgr.
The advantage here is that we no longer have to use a futures-aware
Mutex, or a blocking send operation, and therefore can simplify a
bunch of the GuardMgr APIs to no longer be async.  That'll avoid
having to propagate the asyncness up the stack.

The disadvantage is that unbounded channels are just that: nothing
in the channel prevents us from overfilling it.  Fortunately, the
process that consumes from the channel shouldn't block much, and
the channel only gets filled when we're planning a circuit path.
2021-10-10 12:08:31 -04:00
Nick Mathewson dcca0ec366 Require up-to-date x25519-dalek, async_executors, and argh.
I tried using -Z minimal-versions to downgrade all first-level
dependencies to their oldest permitted versions, and found that we
were apparently depending on newer features of all three crates.

I'm kind of surprised there were only three.
2021-10-09 19:37:08 -04:00