joelverhagen / TorSharp

Use Tor for your C# HTTP clients. Use Privoxy or .NET 6+ SOCKS support to proxy HTTP traffic.
MIT License
323 stars 61 forks source link

GetNewIdentityAsync unique IP address #95

Closed glararan closed 1 year ago

glararan commented 1 year ago

Hi,

I wonder if you can provide sample for getting a new IP address per GetNewIdentityAsync call.

Maybe this scenario is not supported?

joelverhagen commented 1 year ago

This is not supported in the way you likely expect. TorSharp sends the NEWNYM control command to the Tor process. This may or may not result in a new IP address. See: https://stem.torproject.org/faq.html#how-do-i-request-a-new-identity-from-tor

An important thing to note is that a new circuit does not necessarily mean a new IP address. Paths are randomly selected based on heuristics like speed and stability. There are only so many large exits in the Tor network, so it's not uncommon to reuse an exit you have had previously.

Tor does not have a method for cycling your IP address. This is on purpose, and done for a couple reasons. The first is that this capability is usually requested for not-so-nice reasons such as ban evasion or SEO. Second, repeated circuit creation puts a very high load on the Tor network, so please don't!