diff options
Diffstat (limited to 'examples/cli.rs')
-rw-r--r-- | examples/cli.rs | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/examples/cli.rs b/examples/cli.rs index 39c4b0f..2995bac 100644 --- a/examples/cli.rs +++ b/examples/cli.rs @@ -1,8 +1,27 @@ +use std::sync::Arc; + fn main() { - let s = torctl::spawn("/usr/bin/tor", "tor-data", "").unwrap(); + 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(&["NOTICE", "INFO", "WARN", "ERR"]).unwrap(); + s.setconf(&[("SocksPort", Some("10245"))]).unwrap(); dbg!(s.getconf(&["ContactInfo", "DataDirectory", "HiddenServiceOptions"]).unwrap()); - dbg!(s.getinfo(&["version", "config-text", "md/all"]).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)); |