Commit Graph

141 Commits

Author SHA1 Message Date
Nick Mathewson 37fe255fda Try refactoring build.rs for testability.
I'm adding a local "Buildable" trait here so I can swap out Circuits
for something else.  This also lets me refactor Builder<> to be
parameterized on TimeoutEstimator again, and lets us get rid of the
first_hop() accessor on paths.
2021-07-19 12:25:26 -04:00
Nick Mathewson 1821532dd8 Add a test for double_timeout.
There is something wrong here, though.  I had to rewrite wait_for() a
lot back in the main branch to get this test working right.  See
arti#149 for details on that issue.
2021-07-19 12:25:26 -04:00
Nick Mathewson 61d8e5175c tor-circbuild: use SleepProvider::now() instead of Instant::now()
This should make time mockable for testing purposes.
2021-07-19 12:25:26 -04:00
Nick Mathewson 94db617682 Add the ability to reconfigure a running ParetoEstimator 2021-07-19 12:25:26 -04:00
Nick Mathewson 2bc762a3ca Monomorphize: just use the pareto timeout implementation. 2021-07-19 12:25:26 -04:00
Nick Mathewson f341e493ea Allow the pareto estimator to be disabled. 2021-07-19 12:25:26 -04:00
Nick Mathewson 3e894218aa Connect the timeout estimator code to our circuit builder.
This currently leaves a bit to be desired, since the logic is kind
of gnarly.  I'm not sure I want to be using so many Arc<>s.
2021-07-19 12:25:26 -04:00
Nick Mathewson cd51d8bb8b Implement a circuit timeout estimator backend.
This backend uses the kludged-up^W heuristic-enhanced Pareto
estimator from path-spec.txt section 2.4.  See path-spec.txt for
full details on the algorithm.  I've tried to note with TODO-SPEC
comments all the things that the spec currently leaves out.

Nothing actually uses this code yet.  By the time it's in use, I'd
expect that many of these functions will need to have new
visibilities.
2021-07-19 12:25:26 -04:00
Nick Mathewson 6838e26307 Merge remote-tracking branch 'origin/mr/38' 2021-07-15 12:36:40 -04:00
Nick Mathewson 70bcda78d7 Move wait_for into MockSleepProvider.
This function is generally useful for testing functions where we
want time to advance bit by bit.
2021-07-15 10:15:28 -04:00
Trinity Pointard 93347ec80e remove now invalid doc-comment 2021-07-15 00:08:47 +02:00
Trinity Pointard 402662f09c make isolation_group optional in SupportedCircUsage 2021-07-14 17:45:01 +02:00
Trinity Pointard 52fab4e3c6 move IsolationToken to circmgr
document the behavior of IsolationToken::default
remove From and Into impls between IsolationToken and u64
2021-07-14 16:21:00 +02:00
Trinity Pointard 9e71e2267a fix clippy lints 2021-07-13 17:54:23 +02:00
Trinity Pointard 59434d0ae1 implement stream isolation 2021-07-13 16:47:57 +02:00
Trinity Pointard 676577c184 make ipv[46]_policy take into account BadExit
they now report an empty policy for BadExit relays
2021-07-10 02:38:41 +02:00
Nick Mathewson 7d39ab29db Move responsibility for circuit construction into CircuitBuilder.
Previously this was done in functions associated with Path and
OwnedPath, but this caused their method signatures to get more and
more complicated.

This change will also allow us to make timeout handling part of the
circuit-building process.
2021-07-08 08:23:00 -04:00
Nick Mathewson b0167eec44 Allow tor-rtcompat to build with no runtimes.
Thanks to cargo's version-2 feature resolver, we can require a
runtime for tests only.

I'm also making it so that the functions that create or fetch
Runtimes only exist when one of the runtime features is enabled.
For now that seems like a better solution than having those
functions exist but panic.

Closes #129.
2021-07-01 09:47:55 -04:00
Nick Mathewson 1c21295d19 Merge remote-tracking branch 'origin/mr/34' 2021-06-27 14:30:49 -04:00
Nick Mathewson 8947e54d7e Remove "default-features=false" thing on tor-rtcompat for now. 2021-06-24 10:53:11 -04:00
Nick Mathewson 2df9b0e921 Bump version dependencies to 0.0.0 2021-06-24 09:27:17 -04:00
Nick Mathewson b774360755 Remove "publish = false" 2021-06-24 07:04:26 -04:00
YUAN LYU 92dbf20a76 Add clippy warn needless pass by value 2021-06-21 23:27:19 -04:00
YUAN LYU b830e81b7f Add clippy warn needless borrow 2021-06-21 21:34:40 -04:00
Nick Mathewson 4ca629dff7 Remove unused import. 2021-06-21 11:21:42 -04:00
Nick Mathewson bf251402d4 More tests and a little code-golf for coverage on tor-circmgr 2021-06-20 11:35:09 -04:00
Nick Mathewson 133d000c34 tor_circmgr: simplify build_circuit a bit. 2021-06-20 11:02:26 -04:00
Nick Mathewson 36b0a666cb A few tests for circparameters generation. 2021-06-19 17:21:58 -04:00
Nick Mathewson e4499fbfd3 More/better tests on tor_circmgr::mgr 2021-06-19 16:05:11 -04:00
Nick Mathewson 89de6227b8 A little testing and refactgoring in tor-circmgr. 2021-06-19 13:08:46 -04:00
Nick Mathewson 8f8a2cf4ab Misc tests in tor-proto. 2021-06-19 13:01:35 -04:00
Nick Mathewson e6faeaa1f8 Fix some warnings about needless & from nightly clippy 2021-06-18 07:19:24 -04:00
Nick Mathewson a36626d9de Run "typos" to fix a few more typos. 2021-06-17 18:45:05 -04:00
Nick Mathewson 458bc44ca9 Use retry-error in tor-circmgr. 2021-06-17 18:34:39 -04:00
Nick Mathewson be86df631d Remove anyhow dependency from tor-retry, and rename it to retry-error
Now RetryError is parameterized on an underlying error type.
2021-06-17 16:09:43 -04:00
Nick Mathewson 9310273448 Remove some (but not all) needless dependencies. 2021-06-17 09:09:43 -04:00
Nick Mathewson 8424ec700b Suppress a clippy warning. 2021-06-17 08:26:34 -04:00
Nick Mathewson 4517e6eaa2 more improvements to circmgr tests. 2021-06-16 15:22:40 -04:00
Nick Mathewson 321fd79632 Notes about badexit flag and opportunities for error 2021-06-16 15:10:26 -04:00
Nick Mathewson 1b6cf24087 More tests on circmgr::path. 2021-06-16 15:08:52 -04:00
Nick Mathewson 4e3e1982be circmgr: tests for path/dirpath.rs 2021-06-16 13:24:11 -04:00
Nick Mathewson d3f27716d9 Tests for circmgr::usage 2021-06-16 11:36:50 -04:00
Nick Mathewson c67f2b2a67 tor_circmgr: even more tests 2021-06-16 10:02:51 -04:00
Nick Mathewson 66fad93f31 More tests in tor-cirmgr::mgr 2021-06-16 09:16:54 -04:00
Nick Mathewson 834d3c1855 remove now-unused imports 2021-06-14 20:20:24 -04:00
Nick Mathewson 7a8b2344a1 Comment out build_path for now.
It just duplicates TorPath::build_circuit, which is all you actually
need.
2021-06-14 16:32:16 -04:00
Nick Mathewson 83b1150c81 Enormous tor-circmgr rewrite.
As with the tor-chanmgr code, the circuit manager is now implemented
using an AbstractCircMgr type that uses traits to abstract the
particular behavior of other types that it uses.  (Specifically:
circuits, building circuits, and telling whether one circuit usage
is compatible with another.)  Abstracting out the dependencies in
this ways makes it possible to test the circuit manager without
having to actually build real circuits.

This commit also introduces new behavior for handling pending
circuit requests.  Upon getting a new request, first we check to see
if there's an existing circuit we can use.  If there isn't, we look
for pending circuits and wait for them.  If there aren't any pending
circuits we can use, we launch one or more, and wait for them.

So far, that's the same as the old behavior.  But here's a change:
if, while we are waiting for some pending circuits, a different
circuit is completed, and it's one we could use, then the task that
was building _that_ circuit will tell us: "please look at this
circuit".  This gives us better changes of getting a usable circuit
fast.

Minor changes:

* The Error type in CircMgr no longer uses anyhow; several errors
  have been simplified.

* We've gotten more formal about the relationship between circuit
  usage and target usage.
2021-06-14 12:12:31 -04:00
Nick Mathewson 0b0b00baf9 Add an XXXX to path.rs 2021-06-04 08:50:56 -04:00
Nick Mathewson bddf2ba580 Missing experimental-api imports. 2021-06-03 10:10:25 -04:00
Nick Mathewson 0b2c3ee285 cirmgr: Move usage-related code into a submodule, and refactor. 2021-06-02 20:01:09 -04:00