使用 tor c# 更改 IP 地址
本文关键字:IP 地址 更改 tor 使用 | 更新日期: 2023-09-27 18:36:47
我想在Windows平台中使用TOR和C#以x时间间隔更改IP,任何人都可以帮助我吗?
蒂亚。
我试过这段代码
public string Refresh()
{
TcpClient client = new TcpClient("localhost", 9051);
string response = string.Empty;
string authenticate = MakeTcpRequest("AUTHENTICATE'r'n", client);
if (authenticate.Equals("250"))
{
response = MakeTcpRequest("SIGNAL NEWNYM'r'n", client);
}
client.Close();
return response;
}
public string MakeTcpRequest(string message, TcpClient client)
{
client.ReceiveTimeout = 20000;
client.SendTimeout = 20000;
string proxyResponse = string.Empty;
try
{
// Send message
StreamWriter streamWriter = new StreamWriter(client.GetStream());
streamWriter.Write(message);
streamWriter.Flush();
// Read response
StreamReader streamReader = new StreamReader(client.GetStream());
proxyResponse = streamReader.ReadToEnd();
}
catch (Exception ex)
{
// Ignore
}
return proxyResponse;
}
我收到 514 需要身份验证错误
你的托尔克是什么?没有这个,帮助你是很棘手的。有关身份验证的示例,请参阅...
https://stem.torproject.org/faq.html#can-i-interact-with-tors-controller-interface-directly
更一般地说,如果您只是想以一定的间隔循环电路,那么这就是MaxCircuitDirtiness torrc选项的作用......
https://www.torproject.org/docs/tor-manual.html.en#MaxCircuitDirtiness