private void stderr__tor(object sender, DataReceivedEventArgs pipe) { if (InpuClientMessage != null) { InpuClientMessage.Invoke("[Erroe]: " + pipe.Data); } }
internal void tor_stop() { if (InpuClientMessage != null) { InpuClientMessage.Invoke("Attempting to open another Tor process."); } Process[] processes = Process.GetProcessesByName("tor"); if (processes.Length > 0) { processes[0].Kill(); } }
private void stdout__tor(object sender, DataReceivedEventArgs pipe) { try { if (pipe.Data.Contains("Bootstrapped 100%: Done.")) { if (InpuClientMessage != null) { InpuClientMessage.Invoke("Tor had been initialized."); } } if (InpuClientMessage != null) { InpuClientMessage.Invoke(pipe.Data); } } catch { tor_restart(); } }
internal void tor_start() { if (IsProcessOpen("tor")) { if (InpuClientMessage != null) { InpuClientMessage.Invoke("A Tor process already exists."); } tor_stop(); } else { if (InpuClientMessage != null) { InpuClientMessage.Invoke("Tor init..."); } this.tor = new Process(); this.tor.StartInfo.FileName = Directory.GetCurrentDirectory() + "\\tor.exe"; if (InpuClientMessage != null) { InpuClientMessage.Invoke("Loaded file " + Directory.GetCurrentDirectory()); } this.tor.StartInfo.CreateNoWindow = false; this.tor.StartInfo.UseShellExecute = false; this.tor.StartInfo.RedirectStandardOutput = true; this.tor.StartInfo.RedirectStandardInput = true; this.tor.StartInfo.RedirectStandardError = true; this.tor.OutputDataReceived += new DataReceivedEventHandler((sender, args) => { stdout__tor(sender, args); }); this.tor.ErrorDataReceived += new DataReceivedEventHandler((sender, args) => { stderr__tor(sender, args); }); this.tor.Start(); Console.WriteLine("Strapping input..."); this.tor.BeginOutputReadLine(); this.tor.BeginErrorReadLine(); } }