How to use libtor in a Rust app

Overview

libtor example

Uses libtor crate to run a Tor daemon in process.

This example spawns the Tor daemon using Tokio's spawn_blocking, and then spawns other work tasks to print dots, and to make a web request to check.torproject.org via the exposed socks proxy.

How to run

You'll need Rust and cargo

cargo run

Hit ctrl+C twice to quit

Source

src/main.rs

Example Output

Running `target/debug/tor`
---poll
.Nov 26 12:29:19.077 [notice] Tor 0.4.6.7 running on Darwin with Libevent 2.1.12-stable, OpenSSL 1.1.1l, Zlib 1.2.11, Liblzma N/A, Libzstd N/A and Unknown N/A as libc.
Nov 26 12:29:19.077 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
Nov 26 12:29:19.078 [notice] Configuration file "/Users/byron/.torrc" not present, using reasonable defaults.
Nov 26 12:29:19.080 [notice] Opening Socks listener on 127.0.0.1:19050
Nov 26 12:29:19.080 [notice] Opened Socks listener connection (ready) on 127.0.0.1:19050
Nov 26 12:29:19.000 [notice] Parsing GEOIP IPv4 file /Users/byron/code/tor/target/debug/build/libtor-sys-188d233741242f4c/out/share/tor/geoip.
.Nov 26 12:29:19.000 [notice] Parsing GEOIP IPv6 file /Users/byron/code/tor/target/debug/build/libtor-sys-188d233741242f4c/out/share/tor/geoip6.
.Nov 26 12:29:19.000 [notice] Bootstrapped 0% (starting): Starting
..---request
........Nov 26 12:29:20.000 [notice] Starting with guard context "default"
Nov 26 12:29:20.000 [notice] Bootstrapped 5% (conn): Connecting to a relay
..Nov 26 12:29:20.000 [notice] Bootstrapped 10% (conn_done): Connected to a relay
...Nov 26 12:29:20.000 [notice] Bootstrapped 14% (handshake): Handshaking with a relay
........Nov 26 12:29:21.000 [notice] Bootstrapped 15% (handshake_done): Handshake with a relay done
Nov 26 12:29:21.000 [notice] Bootstrapped 75% (enough_dirinfo): Loaded enough directory info to build circuits
Nov 26 12:29:21.000 [notice] Bootstrapped 90% (ap_handshake_done): Handshake finished with a relay to build circuits
Nov 26 12:29:21.000 [notice] Bootstrapped 95% (circuit_create): Establishing a Tor circuit
.........Nov 26 12:29:22.000 [notice] Bootstrapped 100% (done): Done
...................Tor is online!
..........................^CNov 26 12:29:27.000 [notice] Interrupt: exiting cleanly.
.tor exit result: 0
........^Creceived Ctrl+C!
received shutdown signal
You might also like...
A Raycast/Spotlight like app shell using tauri
A Raycast/Spotlight like app shell using tauri

Tauri Shell This repo can be used as reference for building alfred/raycast/spotlight apps using Tauri. Usage This reference repository is using Svelte

This repo is a sample video search app using AWS services.
This repo is a sample video search app using AWS services.

Video Search This repo is a sample video search app using AWS services. You can check the demo on this link. Features Transcribing Video and generate

A special web app to render fancy UTF-8 sequences. :hindu_temple: :scroll:

UTF RENDER πŸ›• πŸ“œ A special web app to render fancy UTF-8 sequences. πŸ›• πŸ“œ ABOUT πŸ“š Emojis and fancy symbols are part of the UTF-8 character standard (

Web-wrapped Supabase desktop app for macOS, Windows & Linux powered by Tauri
Web-wrapped Supabase desktop app for macOS, Windows & Linux powered by Tauri

Supabase Desktop App What is it? It's a cross-platform web-wrapped Supabase desktop app powered by Tauri. You can install it on your macOS, Windows (u

Scaffold that provides a basic setup for a Yew app with DaisyUI for styling.

Yew and Tailwind CSS Scaffold This scaffold provides a basic setup for a Yew app with Tailwind CSS for styling. It also includes DaisyUI, a Tailwind C

OpenAI chat client desktop app (Windows, MacOS, Linux)
OpenAI chat client desktop app (Windows, MacOS, Linux)

ChatWizard OpenAI chat client Desktop Application (Windows, MacOS, Linux) Declaration This project is currently undergoing active development and has

Desktop app for UpVPN - Pay as you go VPN

upvpn A Modern Serverless VPN upvpn upvpn (pronounced Up VPN) lets you connect to the internet from a location of your choice. For more information pl

Easy to use Rust i18n library based on code generation

rosetta-i18n rosetta-i18n is an easy-to-use and opinionated Rust internationalization (i18n) library powered by code generation. rosetta_i18n::include

Proof of Concept / Experiment: Use IDF-HAL-LL from bare metal Rust
Proof of Concept / Experiment: Use IDF-HAL-LL from bare metal Rust

Proof of Concept / Experiment: Use IDF-HAL-LL from BM Rust idf-ll-compile pre-compiles a static library for ESP32C3 and ESP32 esp-ll a simple crate th

Owner
Byron Hambly
yak shaving simulator
Byron Hambly
Fusion is a cross-platform App Dev ToolKit build on Rust . Fusion lets you create Beautiful and Fast apps for mobile and desktop platform.

Fusion is a cross-platform App Dev ToolKit build on Rust . Fusion lets you create Beautiful and Fast apps for mobile and desktop platform.

Fusion 1 Oct 19, 2021
Reload Rust code without app restarts. For faster feedback cycles.

hot-lib-reloader hot-lib-reloader is a development tool that allows you to reload functions of a running Rust program. This allows to do "live program

Robert Krahn 274 Jan 1, 2023
A Rust library that implements the main lightning logic of the lipa wallet app.

lipa-lightning-lib (3L) Warning This library is not production ready yet. Build Test Start Nigiri Bitcoin: nigiri start --ln The --ln flag is not stri

lipa 9 Dec 15, 2022
An example app in Rust for CircleCI's Dynamic Config demo

circleci-dynamic-config-example An example app in Rust for CircleCI's dynamic config demo. Dynamic config allows you to dynamically generate CircleCI'

yujiosaka 2 Oct 6, 2022
OpenAI ChatGPT desktop app for Mac, Windows, & Linux menubar using Tauri & Rust

ChatGPT Desktop App Unofficial open source OpenAI ChatGPT desktop app for mac, windows, and linux menubar using tauri & rust. Downloads Windows (2.7 M

Sonny Lazuardi 732 Jan 5, 2023
Simple comparison app for iRacing car setups.

CarTunes Simple comparison app for iRacing car setups. About Export a setup in the iRacing garage and CarTunes will let you compare it with other setu

Jay Oster 31 Jan 7, 2023
A VtubeStudio plugin that allows iFacialMocap to stream data to the app, enabling full apple ARkit facial tracking to be used for 2D Vtuber models.

facelink_rs A VtubeStudio plugin that allows iFacialMocap to stream data to the app, enabling full apple ARkit facial tracking to be used for 2D Vtube

Slashscreen 2 May 6, 2022
Easily sync your clipboard between devices. This is a work in progress app.

Clipboard Sync Description Easily sync your clipboard between devices. This is a work in progress app. Stack Frontend: React Tauri isomorphic-ws TSX,

Steveplays 2 Mar 2, 2022
Extracting react native app source code from apk file.

extract-myreact Extracting React Native app source code from apk file.

Aan 3 Oct 5, 2022
A simple web-app allowing you to batch archive groups of repositories from a given organization

ice-repos My goal here is to build a simple web-app allowing you to batch archive groups of repositories from a given organization, using Rust+Yew. As

Nic McPhee 6 Nov 5, 2022