-
Notifications
You must be signed in to change notification settings - Fork 3
BlueDwarf Tunnel
Pascal Craponne edited this page Apr 13, 2015
·
2 revisions
(or everywhere else you want to put it).
The Blue Dwarf tunnel is a simple wrapper to tunnel proxy servers. Its initial purpose was to get out of corporate proxy servers (the ones who decide what's best for you to watch). It can be also used for anonymization, to preserve freedom of speech in countries where such things are not appreciated by authorities.
using BlueDwarf.Net.Proxy.Client;
// ...
var client = new TunnelProxyClient();
var route = client.CreateRoute("http=10.0.0.1:8080") // this is an example
using(var socket = route.Connect("mysite.com", 80))
{
// now your socket is secure
}
There are basically two entities you need to know in the BlueDwarf tunnel:
-
TunnelProxyClient
which implementsIProxyClient
(so you can configure dependency injection) is the class which creates routes, and creates the connections. -
Route
is a simple route to target, which may use an unlimited sequence of proxy servers (in protocol HTTP, using the CONNECT command or SOCKS4A). - Optionally there is a
ProxyServer
class used byTunnelProxyClient
andRoute
, but it can be ignored, since there are transparent conversions for it.
The TunnelProxyClient
has one public method:
-
Route CreateRoute(params ProxyServer[] proxyServers)
which creates a route using a list of proxy servers.
The Route
has more methods:
-
Socket Connect(IPAddress targetAddress, int targetPort)
,Socket Connect(EndPoint target)
andSocket Connect(string hostOrAddress, int port)
(this one being an extension method) allow to connect to a given target and return an established socket. It throws aProxyRouteException
in case of failure in the route, but may also throwIOException
when hosts can not be resolved. -
static Route operator +(Route route, ProxyServer proxyServer)
allows to add a new proxy server relay in the current route.