libtor icon indicating copy to clipboard operation
libtor copied to clipboard

Cannot run multiple Tor instances

Open Selyatin opened this issue 4 years ago • 7 comments

I'm trying to run multiple tor instances for browser automation and each instance will connect to it's Tor instance so that each one of them will use a different IP, the issue is when I'm trying to launch Tor multiple times I'm getting this error.

** INTERNAL ERROR: Raw assertion failed in Tor 0.4.4.7 at /home/shiro/Documents/Project/target/debug/build/libtor-sys-99c3932bcfc8d9f9/out/tor-src/src/ext/csiphash.c:123: the_siphash_key_is_set **

OS/Distribution: Kubuntu 20.10

Selyatin avatar Mar 05 '21 20:03 Selyatin

I think this is actually by design, unfortunately. Tor uses a lot of global variables to store its internal state, which means that multiple instances running at the same time would conflict with each other because they would share those variables.

Note that this is different if you run multiple processes, because each of them would get its own set of variables. But with libtor everything is running in a single process, which makes it impossible to isolate them.

I'll keep this issue open to see if somehow there's a way to add support for it, but I personally don't really have any idea unfortunately.

afilini avatar Mar 06 '21 08:03 afilini

@Selyatin this might. be the solution for you https://docs.rs/mitosis/0.1.1/mitosis/

somehowchris avatar Oct 26 '21 19:10 somehowchris

it might make sense -- since we can't really do much with the libtor object anyways -- to always run it fork'ed.

Otherwise, I'd recommend making the builder type failable using a library global that only allows one instance to run.

(Hit up on this when writing tests that spawn > 1 tor instance)

JeremyRubin avatar Aug 25 '22 19:08 JeremyRubin

BTW there is arti which is a complete rewrite of tor in pure rust, which has isolated clients

somehowchris avatar Aug 26 '22 06:08 somehowchris

Is any of you aware of a way to load a shared library multiple times at different addresses? If we can figure out how to do that, then we can clean up this commit and use it to load separate sets of global variables at different addreses. At least on unix systems.

afilini avatar Aug 31 '22 09:08 afilini

dlmopen?

On Wed, Aug 31, 2022, 2:58 AM Alekos Filini @.***> wrote:

Is any of you aware of a way to load a shared library multiple times at different addresses? If we can figure out how to do that, then we can clean up this commit https://github.com/afilini/libtor-sys/commit/0fd95beb4771fb8b34e635a4a16fc4903e0396df and use it to load separate sets of global variables at different addreses. At least on unix systems.

— Reply to this email directly, view it on GitHub https://github.com/MagicalBitcoin/libtor/issues/14#issuecomment-1232727762, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGYN666JZIZDFAP2BRBCXTV34UC3ANCNFSM4YV2ODOQ . You are receiving this because you commented.Message ID: @.***>

JeremyRubin avatar Aug 31 '22 15:08 JeremyRubin

@somehowchris arti seems cool but probably for the project i'm doing i'd rather use the mainline tor.

JeremyRubin avatar Aug 31 '22 19:08 JeremyRubin