summaryrefslogtreecommitdiff
path: root/examples/cli.rs
blob: 18a77474005ed7f3e2b7a91f19b450d54939c2a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use std::sync::Arc;

fn main() {
    let s = Arc::new( torctl::spawn("/usr/bin/tor", "tor-data", "").unwrap() );

    let slisten = s.clone();
    std::thread::spawn(move || {
        loop {
            match slisten.read_event() {
                Ok(ev) => println!("Event: {:?}", ev),
                Err(e) => {
                    println!("Error reading event: {}", e);
                    break;
                },
            }
        }
    });
    s.setevents( torctl::EventList::default().log(torctl::Severity::Notice).bootstrap() ).unwrap();

    s.setconf(&[("SocksPort", Some("10245"))]).unwrap();
    dbg!(s.getconf(&["ContactInfo", "DataDirectory", "HiddenServiceOptions"]).unwrap());
    dbg!(s.getinfo(&["version", "config-text"]).unwrap());

    std::thread::sleep(std::time::Duration::from_secs(5));
    s.quit().unwrap();

    std::thread::sleep(std::time::Duration::from_secs(500));
}