parent
b38f162a91
commit
904e872ccc
File diff suppressed because it is too large
Load Diff
@ -1,15 +1,83 @@
|
||||
use libtor::{Tor, TorFlag, Error as libtorError};
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn start_tor() -> Result<u8, libtorError> {
|
||||
let t: u8 = Tor::new()
|
||||
use std::{thread, io, fs};
|
||||
|
||||
use libtor::{Tor, TorFlag, Error as libtorError, log as libtorLog};
|
||||
use eframe::egui;
|
||||
|
||||
|
||||
// "wowradiod6mhb4ignjqy5ghf5l42yh2yeumgeq3yi7gn7yqy3efhe5ad.onion"
|
||||
// "wowradiof5wx62w4avdk5fwbvcoea2z4ul2q3awffn5vmfaa3vhlgiid.onion"
|
||||
|
||||
const TOR_LOG: &str = &"/tmp/tor-rust/tor.log";
|
||||
|
||||
fn start_tor() -> thread::JoinHandle<Result<u8, libtorError>> {
|
||||
let t: thread::JoinHandle<_> = Tor::new()
|
||||
.flag(TorFlag::DataDirectory("/tmp/tor-rust".into()))
|
||||
.flag(TorFlag::SocksPort(19050))
|
||||
.start().unwrap();
|
||||
return Ok(t)
|
||||
.flag(TorFlag::LogTo(libtorLog::LogLevel::Info, libtorLog::LogDestination::File(TOR_LOG.to_string())))
|
||||
.start_background();
|
||||
return t
|
||||
}
|
||||
|
||||
fn clear_tor_log() -> io::Result<()> {
|
||||
let r: io::Result<()> = fs::write(TOR_LOG, "");
|
||||
return r
|
||||
}
|
||||
|
||||
struct LzaGUI {
|
||||
tor_started: bool
|
||||
}
|
||||
|
||||
impl Default for LzaGUI {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
tor_started: false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl eframe::App for LzaGUI {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ui.heading("lza gui");
|
||||
let texture: egui::TextureHandle = ui.ctx().load_texture(
|
||||
"rainbow",
|
||||
egui::ColorImage::example(),
|
||||
egui::TextureFilter::Linear
|
||||
);
|
||||
ui.add(egui::Image::new(texture.id(), texture.size_vec2()));
|
||||
ui.label("Made by ya boi, lza_menace");
|
||||
ui.hyperlink("https://lzahq.tech");
|
||||
|
||||
ui.separator();
|
||||
ui.heading("Tor");
|
||||
if self.tor_started {
|
||||
ui.label("Tor started.");
|
||||
if ui.button("Clear Tor logs").clicked() {
|
||||
let _r: io::Result<()> = clear_tor_log();
|
||||
}
|
||||
ui.collapsing("View Tor logs:", |ui| {
|
||||
egui::ScrollArea::vertical().stick_to_bottom(true).show(ui, |ui| {
|
||||
let contents = fs::read_to_string(TOR_LOG.to_string()).unwrap();
|
||||
ui.label(contents);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
if ui.button("Start Tor").clicked() {
|
||||
let _t: thread::JoinHandle<Result<u8, libtorError>> = start_tor();
|
||||
self.tor_started = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// let t: Result<u8, libtorError> = start_tor();
|
||||
println!("Hello, world!");
|
||||
let options = eframe::NativeOptions::default();
|
||||
eframe::run_native(
|
||||
"lza gui",
|
||||
options,
|
||||
Box::new(|_cc| Box::new(LzaGUI::default())),
|
||||
);
|
||||
}
|
||||
|
Reference in new issue