A library to simplify proxy usage in .NET 7+
- Install package via Nuget or some other method
- Import modules:
using EzNetProxy;
- Use your preferred way to parse the proxy connection information.
- Requires .NET 7+
- Backbone connections supported
- ipv6 works (backbone connection)
host:port
host:port:user:pw
user:pw@host:port
Method #1:
var httpProxy = ProxyClient.Parse("http://host:port");
var socks4Proxy = ProxyClient.Parse("socks4://host:port:user:pw");
var socks4aProxy = ProxyClient.Parse("socks4a://user:pw@host:port");
var socks5Proxy = ProxyClient.Parse("socks5://host:port");
Method #2:
string proxy = "123.123.123.123:8080";
var httpProxy = ProxyClient.Parse(ProxyType.HTTP, proxy);
...
Method #3:
using EzNetProxy.Modals;
ProxyData data = new()
{
Type = ProxyType.HTTP,
Ip = "pornhub.com",
Port = 80,
Username = "username",
Password = "password"
};
var proxy = ProxyClient.Parse(data);
You can also use Fiddler's debugging proxy by:
var proxy = ProxyClient.DebugFiddler();
Here is a simple example:
// backbone connection; ipv4; 104.227.XXX.XXX
var proxy = ProxyClient.Parse(ProxyType.HTTP, "q.webshare.io:80");
HttpClientHandler httpClientHandler = new()
{
Proxy = proxy,
UseProxy = true // IMPORTANT!
};
using HttpClient client = new(httpClientHandler, true);
var str = await client.GetStringAsync("https://wtfismyip.com/text");
Console.WriteLine(str);
// str = 104.227.XXX.XXX
This project is inspired by xNet; the project is no longer maintained by its creator and even many forks of the project, such as Leaf.xNet. One of the main reasons why xNet was treasured was for its support of many proxy protocols, such as Socks-4 and Socks-5, and how simple it was to use. Hopefully, this project can be an excellent replacement for one part of the project — simple proxy usage.
Please check my profile if you'd like to contact me.