#bridge #tor #censorship

bridge_updater_lib

A helper library to get Tor bridges with ease

1 unstable release

0.1.0 Jul 26, 2024

#8 in #censorship


Used in bridge_updater

Unlicense

76KB
1.5K SLoC

Bridge Updater Lib

Get Tor bridges with ease

A helper library made to retrieve bridge contents from The Tor Project's website. Designed to be integrated with GUI or terminal interfaces.

Example code:

use bridge_updater_lib::updater::Updater;
use std::{io::Write, fs::OpenOptions};

#[tokio::main]
async fn main() {
    if let Ok(mut upd) = Updater::new() {

        /* Retrieve captcha */
        if upd.retrieve_captcha().await.is_ok() {
            if let Some((_captcha_id, captcha_image)) = upd.captcha.clone() {
                let mut captcha_file = OpenOptions::new().write(true).create(true).truncate(true).open("captcha_image.jpg").unwrap();
                captcha_file.write_all(&captcha_image).unwrap();
                captcha_file.sync_all().unwrap();
            }
        }

        /* Retrieve bridges */
        let input_captcha = "ekGbudf";

        if upd.retrieve_bridges(&input_captcha).await.is_ok() {
            if let Some((bridges_text, bridges_qr)) = upd.bridges.clone() {
                println!("Bridges: {}", bridges_text);
                let mut qrcode_file = OpenOptions::new().write(true).create(true).truncate(true).open("bridges_qrcode.jpg").unwrap();
                qrcode_file.write_all(&bridges_qr).unwrap();
                qrcode_file.sync_all().unwrap();
            }
        }
    }
}

Dependencies

~13–28MB
~448K SLoC