[−][src]Function torut::utils::run_tor
pub fn run_tor<A, T, P>(path: P, args: A) -> Result<Child, Error> where
A: AsRef<[T]>,
T: AsRef<str>,
P: AsRef<str>,
run_tor runs new tor from specified path with specified args. It should not be used when control port is disabled.
Parameters
path
- path to run tor binary. Note: if not found rust will query $PATH see docs forstd::process::Command::new
args
- cli args provided to tor binary in raw form - array of strings. Format should be like: ["--DisableNetwork", "1"]
For arguments reference take a look at: https://www.torproject.org/docs/tor-manual.html.en
Common parameters
- CookieAuthentication 1 - enables cookie authentication, since null may not be safe in some contexts
- ControlPort PORT - sets control port which should be used by tor controller, like torut, to controll this instance of tor.
Result detection note
It exists after finding "Opened Control listener" in the stdout. Tor may not print such text to stdout. In that case this function will never exit(unless tor process dies).
Stdout note
This function uses std::io::BufReader
to read data from stdout in order to decide if tor is running or not.
Dropping buf_reader drops it's internal buffer with data, which may cause partial data loss.
For most cases it's fine, so it probably won't be fixed. Alternative to this is char-by-char reading which is slower but should be also fine here.