#tor #daemon #compile #openssl #platform #libevent #ios

sys libtor-sys

Rust crate that internally compiles Tor and its dependencies

26 stable releases (6 major)

Uses old Rust 2015

47.13.0+0.4.7.x Feb 10, 2023
47.10.0+0.4.7.x Sep 5, 2022
47.8.0+0.4.7.x Jun 28, 2022
46.9.1+0.4.6.9 Jan 18, 2022
4.2.6-5+0.4.2.6 Mar 8, 2020

#6 in #libevent

Download history 834/week @ 2024-07-22 625/week @ 2024-07-29 679/week @ 2024-08-05 580/week @ 2024-08-12 690/week @ 2024-08-19 652/week @ 2024-08-26 815/week @ 2024-09-02 742/week @ 2024-09-09 617/week @ 2024-09-16 780/week @ 2024-09-23 631/week @ 2024-09-30 852/week @ 2024-10-07 840/week @ 2024-10-14 644/week @ 2024-10-21 588/week @ 2024-10-28 765/week @ 2024-11-04

2,906 downloads per month
Used in 5 crates (via libtor)

MIT license

1.5MB
37K SLoC

C 33K SLoC // 0.2% comments Shell 1K SLoC // 0.2% comments M4 1K SLoC // 0.2% comments Python 596 SLoC // 0.3% comments Bitbake 512 SLoC // 0.1% comments Automake 370 SLoC // 0.1% comments Rust 289 SLoC // 0.1% comments Perl 40 SLoC // 0.1% comments Q 30 SLoC PHP 11 SLoC Lua 7 SLoC

libtor-sys Continuous integration

This library compiles Tor and a few dependencies (zlib, libevent and openssl) into a single Rust library that can be imported like any other Rust crate into existing projects. This provides a way to use Tor without having to ship/download extra binaries - on platforms that allows running them - while for some other platforms like iOS and newer Android versions this is the only way to run Tor since the OS straight up doesn't allow exec'ing binaries.

Keep in mind that the interface exposed here is very very "low-level" (literally just what's in tor_api.h). Another crate wrapping all of these parts with a nice Rust interface will be released separately.

By default this library only compiles with the minimal set of libraries needed to run Tor, namely OpenSSL, Libevent and Zlib. The with-lzma and with-zstd features can be used to enable the respective compression algorithms, and the vendored-lzma and vendored-zstd features can be used to compile and like those libraries statically instead of using the one provided by your system.

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)

Build gotchas

Command examples to cross-compile for multiple platforms are available in CROSS_COMPILING.md.

Linux/macOS

Building on a UNIX-like os shouldn't be too hard, a cargo build should normally work. Keep in mind that you will need all the "usual" build tools, like a compiler, automake, autoconf, make, in your PATH. On macOS you can install those tools using brew.

If you get an aclocal-1.15 not found or something similar, try to cd into libevent-src and run autoreconf --force --install. Repeat in tor-src if you get the same issue there, and then re-cargo build.

Android

Cross-compiling for Android is fairly straightforward, just make sure that you have the NDK toolchain in your PATH. If you do so, cargo build will use the right compiler targeting the minimum supported sdk version of the NDK you are using (generally 16 for armv7 and 21 for everything else).

iOS

Cross-compiling for iOS on a Mac that has the Xcode Command Line Tools installed should work out of the box.

Windows (MingW)

Cross-compiling for Windows using MingW should also work out of the box, as long as you have the right compiler and the required libraries installed. To link the library into binaries it's generally required to also install the static version of libwinpthreads.

Dependencies

~1.1–3MB
~64K SLoC