Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catching stdout/stderr of tor thread #11

Open
Jikstra opened this issue Jan 5, 2021 · 3 comments
Open

Catching stdout/stderr of tor thread #11

Jikstra opened this issue Jan 5, 2021 · 3 comments

Comments

@Jikstra
Copy link
Contributor

Jikstra commented Jan 5, 2021

I think it would be very helpful if it would be possible to catch the stdout/stderr of the tor thread. But as it's only a thread and not a sub/child process, I have no idea how to do it. Maybe it's not even possible?

I think it would be super helpful for things like parsing the log to achieve:

  • knowing the progress of the bootstrapping
  • parsing for errors/warnings

Currently the tor thread is quite a blackbox, of course it would be possible to communicate through the control port, but this would need another socket/lib to interact with. Parsing the log should be a lot more straight forward.

Maybe somebody has an idea how we could implement this?

@afilini
Copy link
Member

afilini commented Jan 12, 2021

I personally think that the best way to interact with Tor would be through its control port. In that regard this library is definitely lacking a few things that could make doing so easier: we could, for instance, automatically add the required flags, read the ControlPort value from file, read the cookie, etc. With some of those utilities it should become trivial to start Tor, get the authentication data and connect to its ControlPort to fetch whatever data one might need.

That said, I agree that it would still be pretty useful to have a way to capture and read logs from code, even just for potentially showing them to the user in a dedicated page or something like that.

I guess on UNIX systems we could create a pipe with mknod, then tell Tor to use that as a "file" for logging and finally start reading it like we would read a normal file using the filesystem APIs provided by Rust.

I'm not very familiar with Windows though, so I'm not sure if something similar can be done. I'll have to do some more research..

@gabidi
Copy link

gabidi commented Feb 6, 2021

@Jikstra Using a mix of the control port and routing logs to a file gives you most of what you need (i think)
A link to what i'm doing, in case it helps
https://github.com/Sifir-io/sifir-rs-sdk/blob/main/tor/src/lib.rs#L282-L315

@mariuszste
Copy link

I'm not very familiar with Windows though, so I'm not sure if something similar can be done. I'll have to do some more research..

On windows we could use named pipes. I think they behave similarly to the unix pipes in that they can be opened with CreateFile. So I think it should work just fine (not tested though).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants