2

I would like to be able to use Tor programmatically in a c# application, for example I could have a function:

GetViaTor(someUrl);

What I currently do is I run the Tor process,wait a sufficient amount of time for it to connect, connect to it as a proxy and then run through it. I don't like that, it feels like a hack, opens a new process, I have to wait an arbitrary amount of time, and I have no feedback from the process ( i.e. IsTorGood())

I know that c# doesn't support socks, and if there was a solution for c/c++ that I could expose as unmanaged code, that too would help. I also know that Tor was written in c, so this seems all too possible, but I just don't understand how to do what I want from the source code.

P.S.

I know this may seem like a duplicate of some other questions, but I looked at them and couldn't understand what to do with the answers given ( some applied to java, some said to use it as a proxy (which I took to mean manually))

Roya
  • 3,240
  • 3
  • 19
  • 40
Binyamin
  • 121
  • 1
  • 2

1 Answers1

2

You can use a third party .net socks library to add support for socks proxy in your code, there are several to choose from.

There is a guide written here for c#

https://tor.stackexchange.com/a/2131/112

What i would do myself is to run the tor process next to the app process and just let it sit there and run in the background, then pipe the app through a socks library that uses the lib to connect to tor process.

The first initial startup will take some time since it needs to bootstrap to the network (regardless of how you implement it), after that just let it sit there for as long as your application is running.

It makes no sense to do the bootstrap every time you run your function.

implement it as what the tor browser bundle is doing to the bundled firefox.

IAmNoone
  • 1,863
  • 1
  • 11
  • 20