At the ooni/tor/embedding meeting, we mentioned the idea of having a way for programs that want to call tor_main to pass a control socket to tor_main, so that they don't need to have tor listening on a control port at all.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items ...
Show closed items
Linked items 0
Link issues together to show that they're related.
Learn more.
5bcd8dc5c482da4da71402cd06b0ecc709f05493, 4eb5753bd29b24fd5a523499add35a6214293cd9, f0daaf8d60be8bfcfaa99e3a878cd90967a84bb0, and f1bf9bf8198fcfaf078fdc12eb2ad5adf1901d29 All looks good to me.
One thing to be careful about though is that when the socket is closed (as per TAKEOWNERSHIP behavior), when you "shut down" Tor, you must not call exit().
This may be differ from how OwningControllerProcess behaves.
Moreover lack of windows support may be an issue for us (as that is also a target platform for Measurement Kit), but I guess for the time being we can avoid using this option there.
One thing to be careful about though is that when the socket is closed (as per TAKEOWNERSHIP behavior), when you "shut down" Tor, you must not call exit().
This may be differ from how OwningControllerProcess behaves.
Right! All of the exit handling is in a different ticket, #23848 (moved).
Moreover lack of windows support may be an issue for us (as that is also a target platform for Measurement Kit), but I guess for the time being we can avoid using this option there.
So, this actually will work on windows, but not from the command line. You have to construct a socketpair instead, and you can't pass those around between processes as fd's... but in-process, it will work fine.
I'm waiting for the #23845 (moved) merge for that. I think, as a followup, it would make sense to actually have a C API to set this up without having to use the command line. Fortunately, tor_run_main() is extensible.
assuming that tor_socket_t is similar to evutil_socket_t, whether we can pass a socket on Windows to obtain the same effect
They're similar, but it's going to be a little hacking to get this working on windows: Sockets aren't treated as fds in a nice inheritable way on Windows. But in-process, it should work fine, if we make a fake socketpair with the usual tricks.
if this function to set an owning socket is thread safe (I don't know enough on Tor internals to say whether it's obviously thread safe or not)
It should only ever be called from the Tor main thread, so it should be safe.