I am trying to combine GeckoFx library and Tor.NET library.
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 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");
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.
Thank you.
Have you set any of the Firefox Preferences in your code before initializing the browser?
Try:
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
The network.proxy.type value of 1 is equivalent to "Manual Proxy Configuration" settings.
The following settings configure the SOCKS proxy settings to use Tor at 127.0.0.1:9050 with DNS resolution over SOCKS (Tor).
It seems like this should properly configure GeckoFX to use Tor.
Tor network is not designed for immediate HTTP proxy communications. Instead, TOR.NET implements web proxy, that listens for connections on port 8182 by default.
Also you can assign another port with
client.Proxy.Port = 8042;
Keep in mind, that if you changes proxy port, TOR.NET shutdowns existing http listener, and creates a new one.
So, you need to configure Gecko, to use this web proxy on localhost.
Related
I'm creating a client application with the idea of publish new messages to a remote RabbitMQ queue. I'm using MassTransit to create this client, and my code looks this way:
static IBusControl CreateBus()
{
return Bus.Factory.CreateUsingRabbitMq(x =>
{
var host = x.Host(new Uri(ConfigurationManager.AppSettings["RabbitMQHost"]), h =>
{
h.Username("user");
h.Password("password");
});
});
}
static IRequestClient<ISyncProject, IProjectSynced> CreateRequestClient(IBusControl busControl)
{
var serviceAddress = new Uri(ConfigurationManager.AppSettings["ServiceAddress"]);
IRequestClient<ISyncProject, IProjectSynced> client =
busControl.CreateRequestClient<ISyncProject, IProjectSynced>(serviceAddress, TimeSpan.FromDays(1));
return client;
}
private static async Task MainLogic(IBusControl busControl)
{
IRequestClient<ISyncProject, IProjectSynced> client = CreateRequestClient(busControl);
//I'm using the client here as I show below, this part is not important it works with localhost
IProjectSynced response = await client.Request(new ProjecToSync() { OriginalOOMID = OriginalOOMID });
}
And the config file looks like this:
<appSettings>
<add key="RabbitMQHost" value="rabbitmq://ServerName" />
<add key="ServiceQueueName" value="queueName" />
<add key="ServiceAddress" value="rabbitmq://ServerName/queueName" />
</appSettings>
I'm not using guest user, I created a new one and I added all the rights as administrator.
Now this code works if I run the client application in the same server where is running RabbitMQ and also changing ServerName by localhost. If I run the client in my local machine using whatever ServerName or IP address of server, RabbitMQ is blocking my connection:
I presume this is has to be with some configuration that I need to do in the server but I have not found it so far.
One thing I noticed now is disk space is in red and and a big amount of generic exchanges have been created
As your question shows, down at the bottom you have a connection, but it is blocked.
The RabbitMQ documentation lists some conditions where a connection is blocked. These generally have to do with resource limitations on the broker machine itself. In this case, we've managed to get a clear picture that the free disk space available to the broker is below its low-water mark. Thus, all connections will be blocked until this condition is resolved (either lower the mark - not recommended, or increase the available free space).
I want to create a VPN app in UWP and I have the following code:
var profile = new VpnNativeProfile();
profile.AlwaysOn = true;
profile.NativeProtocolType = VpnNativeProtocolType.IpsecIkev2;
profile.ProfileName = "My Profile";
profile.RememberCredentials = true;
profile.RequireVpnClientAppUI = true;
var agent = new VpnManagementAgent();
agent.ConnectProfileWithPasswordCredentialAsync(profile, new PasswordCredential
{
UserName = "test_username",
Password = "test_password"
};
My problem is: how do I set the endpoint (the VPN server IP address) for this VPN connection that I'm trying to create?
I don't see any property that specifies the endpoint of the VPN server that I want to connect to. Also, I haven't found any tutorial on this topic.
Any help will be greatly appreciated.
Thank you respectfully.
how do I set the endpoint (the VPN server IP address) for this VPN connection that I'm trying to create?
There is the Routes property in the VpnNativeProfile class. And it is the list of VpnRoute. You could make a new VpnRoute with specified IP address and add it to Routes like the following:
profile.Routes.Add(new VpnRoute(new Windows.Networking.HostName("address"), 128));
Please note that to use this API, you must specify the networkingVpnProvider capability in your application manifest.
<rescap:Capability Name="networkingVpnProvider" />
You can specify the endpoint (Server address) this way
profile.Servers.Add("ServerIpOrDomain");
I need to make a WCF service call to an external 3rd party using 2-way SSL from a class project. I have added the WSDL provided by the 3rd party to my project as a Service Reference. The problem is that all calls outside our domain (*.abc.com) pass through a proxy server
http://ironport:8080
This is what I have done in my code -
var binding = new WSHttpBinding();
binding.Security.Mode = SecurityMode.Transport;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
binding.BypassProxyOnLocal = false;
binding.UseDefaultWebProxy = true;
binding.AllowCookies = false;
binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
var endpoint = new EndpointAddress("https://blablabla.com/GetData.svc");
var client = new AccountClient(binding, endpoint);
X509Certificate2 certi = new X509Certificate2(#"path to pfx file", "password");
client.ClientCredentials.ClientCertificate.Certificate = certi;
I make the service call using -
var account = client.ExportAccounts(obj1, obj2, obj3);
It then gives me an error -
The remote server returned an Error (407): Proxy authentication required
That is but obvious because nowhere did I mention the proxy details the request needs to go through. What I need is a way to add the following info from a web.config file of a different project into my request above -
<system.net>
<defaultProxy useDefaultCredentials="true">
<proxy proxyaddress="http://ironport:8080" />
<bypasslist>
<add address="[\w]+\.abc\.com$" />
</bypasslist>
</defaultProxy>
</system.net>
Is there some way to achieve this in code? Or do I need to go about this in a different way altogether? Let me know if I need to post more information.
You could try using the WebProxy Class. Not tested, but something like this:
WebProxy proxy = new WebProxy("http://ironport:8080");
proxy.BypassList = new string[] { "[\w]+\.abc\.com$" };
Another alternative would be to move the relevant section of the config to the web/app.config of the application that is using your class library.
ADDED
Not 100% sure this will work, but you could try adding this line to your code:
WebRequest.DefaultProxy = proxy;
Taken from this answer
Another option might be to use the ProxyAddress property of WsHttpBinding (make sure in that case you set the UseDefaultProxy to false), but I don't see a way to add a bypass list with this one.
Update: I have tried HttpWebRequest and it is also exhibiting the same behaviour.
I'm trying to use WebClient DownloadStringAsync to retrieve some (very small) data in an Outlook add-in (VSTO/.Net 4.0). It's taking about 10-15 seconds before it even makes the request.
Having utilized the powers of google, I was pointed towards the fact that it was trying to pick up the proxy settings, and that I should set these to null. I tried that both in code:
WebClient serviceRequest = new WebClient();
serviceRequest.Proxy = null;
and by adding an App.config file and putting:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.net>
<defaultProxy enabled="false">
<proxy/>
<bypasslist/>
<module/>
</defaultProxy>
</system.net>
</configuration>
I added the file through the 'New Item' interface (I'm not sure if its being picked up and utilised).
Neither of these solutions has worked. Is there any things that I could try changing.
The code in question is as follows:
class MyClient
{
string url = "http://192.168.1.99:4567/contact.json?token={0}&email={1}";
WebClient serviceRequest = new WebClient();
public void getContact(string email, DownloadStringCompletedEventHandler methodName)
{
Uri target = new Uri(String.Format(url, "1234", email));
serviceRequest.Proxy = null;
if(serviceRequest.IsBusy)
{
serviceRequest.CancelAsync(); // Changed our mind and switched email
}
serviceRequest.DownloadStringCompleted += methodName;
serviceRequest.DownloadStringAsync(target);
}
}
Discovered what the problem was.
I was working on a Windows 2003 Server Virtual Machine (what I had available). As soon as I installed Windows 7 (and environment) on another VM and tried it the problem vanished.
The server machine does not have IE Enhanced Security turned on.
Hi
The code below works fine to instruct the system not to use a proxy and to not auto detect one, which causes a delay without the code. However while on a network with a proxy I just get the underlying connection is closed!
So four questions:
Am I specifying the proxy correctly?
If so how do I tell it to use default proxy credentials?
Should the used want to specify credentials how are they set?
How do I set it back to the original state?
if (!Properties.Settings.Default.UseProxyServer){
//set the system not to use a proxy server
//saves the delay seen when browser set to auto detect proxy and not proxy
//is used. This works well!!
WebRequest.DefaultWebProxy = new WebProxy();
}
else{
WebRequest.DefaultWebProxy =
new WebProxy(proxyServerAddress, proxyServerPort);
//proxyServerPort is an int.
//How do I add default credentials??
}
WebClient client = new WebClient();
//specify an encoding for uploading.
client.Encoding = System.Text.Encoding.ASCII;
// Upload the data.
var myReply = client.UploadValues(addressURL, data);
I need to this in code not in the app.config.
Thanks
You can create a Web proxy object
var proxy = new WebProxy("http://server:8080");
proxy.credentials = new system.net.Credentials.DefaultCredenialCache;
proxy.Other properties
You can also create a config
<configuration>
<system.net>
<defaultProxy>
<proxy
usesystemdefaults="true"
proxyaddress="http://192.168.1.10:3128"
bypassonlocal="true"
/>
<bypasslist
<add address="[a-z]+\.contoso\.com" />
</bypasslist>
</defaultProxy>
</system.net>
</configuration>
Try this:
http://weblogs.asp.net/jan/archive/2004/01/28/63771.aspx
You may also want to check this out:
http://geekswithblogs.net/ranganh/archive/2005/08/29/51474.aspx