Is it possible to start an external proxy binary then run rust comms through it?

Hello All,

I'm working on a Red Team project for work where I need to periodically browse one of our websites. I wrote a program that can do that so far with Reqwest. Now I'm looking to expand that capability by piping those requests through a proxy and I got it working with the Tor via their Arti project. I was able to compile it and when I run it externally, my requests go through just fine.

I want to expand this even further by having my rust program start the external binary but I think I'm going to run into an issue there. Since the proxy never closes, as its purpose is to continuously listen for connections, I don't think that would work with Rust's standard process lib right? Rust waits for the child process to close before proceeding? I've done some research to see if there's a way to spawn a child process in a non-blocking way and most forums I came across say no.

I'm sure this isn't a unique problem. Other than starting Arti manually, external to my Rust app, has anyone gotten a setup working like what I'm looking to do?

There is also an additional project that might be a solution. Tor also has a project called arti_client that is supposed to integrate arti directly into Rust. I think with this approach, this would replace my reqwest infrastructure and instead use arti_client but when I tried to get it to work, I was getting a bunch of errors. Namely things like expecting a Result return but when I tried to implement that, I received another error saying there's a type mismatch.

I'm fairly new to Rust so I'm sure there's probably a straight forward way of getting this working and I just don't know the syntax for it.

So yeah, does anyone have any experience with spawning a child process in a non-blocking way so you can continue the program or any specific experience with arti_client?

std::process::Command::spawn does not block for the spawned process to end.

Maybe I'm misunderstanding...in order to read any output from the child process I have to call output right?

And that says it waits for the child process to finish. I imagine that means it waits for the child process to close?

So, as an alternative, can I just start the child process but not look for output and get a non-blocking spawn?

You don't have to. There's .stdout on the spawned handle that you can take and read from incrementally.

If you're also going to write to child's stdin, do it from another thread while reading stdout, otherwise it can deadlock when I/O buffers are full and the other process is waiting for you to read while your process is waiting to write.

Ahh ok, thank you!

Now just to figure out how to run a binary on disk relative to my current directory.