Crates.io | bridge_updater_lib |
lib.rs | bridge_updater_lib |
version | 0.1.0 |
source | src |
created_at | 2024-07-26 06:30:29.338674 |
updated_at | 2024-07-26 06:30:29.338674 |
description | A helper library to get Tor bridges with ease. |
homepage | https://codeberg.org/quisgor/bridge_updater/src/branch/main/bridge_updater_lib |
repository | https://codeberg.org/quisgor/bridge_updater |
max_upload_size | |
id | 1315857 |
size | 126,216 |
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();
}
}
}
}