C# 结合 GeckoFX + Tor.NET 库

问题描述:

我正在尝试结合 GeckoFx 库和 Tor.NET 库.

I am trying to combine GeckoFx library and Tor.NET library.

在我的代码中,我做了所有准备使用 tor 网络,

In my code I do all preparing to use tor network,

ClientCreateParams createParameters = new ClientCreateParams();
createParameters.ConfigurationFile = ConfigurationManager.AppSettings["torConfigurationFile"];
createParameters.ControlPassword = ConfigurationManager.AppSettings["torControlPassword"];
createParameters.ControlPort = Convert.ToInt32(ConfigurationManager.AppSettings["torControlPort"]);
createParameters.DefaultConfigurationFile = ConfigurationManager.AppSettings["torDefaultConfigurationFile"];
createParameters.Path = Path.Combine(root, ConfigurationManager.AppSettings["torPath"]);

createParameters.SetConfig(ConfigurationNames.AvoidDiskWrites, true);
createParameters.SetConfig(ConfigurationNames.GeoIPFile, Path.Combine(root, @"Tor\Data\Tor\geoip"));
createParameters.SetConfig(ConfigurationNames.GeoIPv6File, Path.Combine(root, @"Tor\Data\Tor\geoip6"));

client = Client.Create(createParameters);


  <appSettings>
    <add key="torConfigurationFile" value=""/>
    <add key="torControlPassword" value=""/>
    <add key="torControlPort" value="9051"/>
    <add key="torDefaultConfigurationFile" value=""/>
    <add key="torPath" value="Tor\Tor\tor.exe"/>
 </appSettings>

WebBrowser1 是一个简单的浏览器,它适用于 Tor 设置.但是浏览器是 GeckoFx,它不起作用.

WebBrowser1 is a simple browser and it works with Tor settings. But browser is GeckoFx and it doesn't work.

webBrowser1.Navigate("https://duckduckgo.com/?q=my+ip&t=h_&ia=answer");
browser.Navigate("https://duckduckgo.com/?q=my+ip&t=h_&ia=answer");

如您所见,ip 应该在左侧控件中.您可以从此处下载并测试完整项目.它是 WinForms 项目,只是从解决方案中运行Gecko"项目.知道如何设置 GeckoFx 使用 Tor 网络吗?或者我可能需要以某种方式设置 GeckoFx 以使用代理?

As you see ip should be as on left control. You can download and test full project from here. It is WinForms project just run "Gecko" project from solution. Any idea how to set GeckoFx use Tor network? Or maybe I need somehow setup GeckoFx to use proxy?

        //GeckoPreferences.User["network.proxy.type"] = 1;
        //GeckoPreferences.User["network.proxy.socks"] = "127.0.0.1";
        //GeckoPreferences.User["network.proxy.socks_port"] = 9150;
        //GeckoPreferences.User["network.proxy.socks_version"] = 5;
        //GeckoPreferences.User["network.proxy.socks_remote_dns"] = true;

VisualStudio 2015.谢谢.

VisualStudio 2015. Thank you.

您是否设置了任何Firefox 首选项?

试试:

GeckoPreferences.Default["network.proxy.type"] = 1;
GeckoPreferences.Default["network.proxy.socks = "127.0.0.1"
GeckoPreferences.Default["network.proxy.socks_port"] = 9050
GeckoPreferences.Default["network.proxy.socks_remote_dns"] = 1
GeckoPreferences.Default["network.proxy.socks_version"] = 5

network.proxy.type 值为 1 相当于手动代理配置"设置.

The network.proxy.type value of 1 is equivalent to "Manual Proxy Configuration" settings.

以下设置将 SOCKS 代理设置配置为在 127.0.0.1:9050 使用 Tor,并通过 SOCKS (Tor) 进行 DNS 解析.

The following settings configure the SOCKS proxy settings to use Tor at 127.0.0.1:9050 with DNS resolution over SOCKS (Tor).

这似乎应该正确配置 GeckoFX 以使用 Tor.

It seems like this should properly configure GeckoFX to use Tor.