Skip to content
Snippets Groups Projects

onion-tunnel: Stricter bootstrap recognition

Merged Clara Engler requested to merge cve/onionmasq:dev/cve/censorship into main
3 unresolved threads

This commit makes the onion-tunnel bootstrapping more conservative in when to be considered bootstrapped.

Previously, there has been a tokio timeout task that gave the TorClient::bootstrap method a 30 second chance to complete, before indicating an error.

This works well in a censored environment where the user has never been able to download any sort of consensus, because in that case, arti will obviously be unable to fetch one, so the bootstrap method will time out.

However, when the user happens to have a valid consensus in their cache, the bootstrap call will succeed immediately, even though arti may in fact not be usable.

To mitigate this issue, we add a loop after the bootstrap call, which will terminate only if it receives at least one bootstrap status indicating a usability of the Tor network.

See #110

Merge request reports

Pipeline #221535 passed

Pipeline passed for e71cadb4 on cve:dev/cve/censorship

Approved by

Merged by Clara EnglerClara Engler 5 months ago (Nov 7, 2024 11:57am UTC)

Merge details

  • Changes merged into main with 75071fd4.
  • Deleted the source branch.
  • Auto-merge enabled

Pipeline #221537 passed

Pipeline passed for 75071fd4 on main

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
421 //
422 // We considere arti to be bootstrapped iff the bootstrap() method succeeds *and* there has been
423 // at least one `ConnStatus` implying usability.
424 //
425 // TODO(cve): Keep in mind that ConnStatus may theoretically get unbootstrapped and work in a
426 // non monotone fashion, this approach sort of ignores this.
421 427 let mut bootstrap_task = Box::pin(
422 428 tokio::time::timeout(
423 429 // TODO: Might worth adding this as a config parameter?
424 430 std::time::Duration::new(30, 0),
425 tokio::spawn(async move { tc.bootstrap().await }),
431 tokio::spawn(async move {
432 tc.bootstrap().await?;
433 let mut events = tc.chanmgr().bootstrap_events();
434 while let Some(status) = events.next().await {
435 if status.usable() {
  • I think it looks good, and I assume we later on hook it up with some callback to the java code to emit what state we are in (trying to connect (since some epoch), connected (since some epoch), idle) ?

  • Alexander Hansen Færøy approved this merge request

    approved this merge request

  • 418 418 // We'll give arti 30 seconds to bootstrap. The following is some Rust ninjitstu for the
    419 419 // timeout task to be used in the select below and fused so once completed, it is basically
    420 420 // ignored while still being polled.
    421 //
    422 // We considere arti to be bootstrapped iff the bootstrap() method succeeds *and* there has been
    • Sorry for asking maybe sth. obvious, but - what effect does this change have on the caching mechanism in general? What is caching still used for? Does the early failure allow the user to configure bridges and reconnect with the help of the cached consensus?

      Edited by cyberta
    • Author Maintainer

      It doesn't change the caching mechanism in general really. This is mostly because its a low-level arti internal. (I think it is part of the tor-dirmgr crate).

      IIRC caching is used to not overload the directory authorities and the mirrors. They already need to spend a high amount of bandwidth for offering this information.

      The torrc even mentions this:

      ## Uncomment this to mirror directory information for others. Please do
      ## if you have enough bandwidth.
      #DirPort 9030 # what port to advertise for directory connections
      Edited by Clara Engler
    • Please register or sign in to reply
  • Clara Engler added 1 commit

    added 1 commit

    • e71cadb4 - onion-tunnel: Stricter bootstrap recognition

    Compare with previous version

  • Clara Engler enabled an automatic merge when all merge checks for e71cadb4 pass

    enabled an automatic merge when all merge checks for e71cadb4 pass

  • merged

  • Clara Engler mentioned in commit 75071fd4

    mentioned in commit 75071fd4

  • Please register or sign in to reply
    Loading