22 stable releases (5 major)

Uses old Rust 2015

47.13.0+0.4.7.x Feb 10, 2023
47.8.0+0.4.7.x Jun 28, 2022
47.7.0+0.4.7.x May 27, 2022
46.9.0+0.4.6.x Jan 11, 2022
42.7.0+0.4.2.7 Mar 21, 2020

#1200 in Network programming

Download history 290/week @ 2023-12-17 218/week @ 2023-12-24 158/week @ 2023-12-31 257/week @ 2024-01-07 541/week @ 2024-01-14 361/week @ 2024-01-21 620/week @ 2024-01-28 781/week @ 2024-02-04 494/week @ 2024-02-11 572/week @ 2024-02-18 703/week @ 2024-02-25 747/week @ 2024-03-03 1100/week @ 2024-03-10 909/week @ 2024-03-17 652/week @ 2024-03-24 1163/week @ 2024-03-31

3,879 downloads per month
Used in 4 crates

MIT license

26KB
580 lines

libtor

libtor is a Rust crate for bundling inside your project a fully-running Tor daemon. It exposes a nicer interface to operate it compared to the bare-bones version, libtor-sys. If you need further instructions on how to build or cross-compile the project, you should refer to the libtor-sys README.md.

libtor makes it easier for projects on multiple platforms to use Tor without depending on the user to configure complex proxy settings from other external software.

Example

use libtor::{Tor, TorFlag, TorAddress, HiddenServiceVersion};

Tor::new()
    .flag(TorFlag::DataDirectory("/tmp/tor-rust".into()))
    .flag(TorFlag::SocksPort(19050))
    .flag(TorFlag::HiddenServiceDir("/tmp/tor-rust/hs-dir".into()))
    .flag(TorFlag::HiddenServiceVersion(HiddenServiceVersion::V3))
    .flag(TorFlag::HiddenServicePort(TorAddress::Port(8000), None.into()))
    .start()?;

Since Tor uses internally some static variables to keep its state, keep in mind that you can't start more than one Tor instance per process.

Supported platforms

The currently supported platforms are:

  • Linux (tested on Fedora 30 and Ubuntu Xenial)
  • Android through the NDK
  • MacOS
  • iOS
  • Windows cross-compiled from Linux with mingw

Coming Soon ™️:

  • Windows (natively built)

Dependencies

The following dependencies are needed:

  • openssl
  • pkg-config
  • file
  • the "usual" C build tools: a compiler, automake, autoconf

Dependencies

~5.5–9MB
~169K SLoC