Skip to content

Latest commit

 

History

History
executable file
·
72 lines (58 loc) · 1.84 KB

README.md

File metadata and controls

executable file
·
72 lines (58 loc) · 1.84 KB

Yove.Proxy | Socks4/Socks5 for IWebProxy

This project is suitable for all WebProxy, HTTP Client, WebSocket and for others.

NuGet version Downloads Target

Nuget: https://www.nuget.org/packages/Yove.Proxy/

Install-Package Yove.Proxy
dotnet add package Yove.Proxy

Example

ProxyClient proxy = new ProxyClient("138.68.161.60", 1080, ProxyType.Socks5);
ProxyClient proxy = new ProxyClient("138.68.161.60:1080", ProxyType.Socks5);
ProxyClient proxy = new ProxyClient("138.68.161.60:1080", "UserID / Username", ProxyType.Socks4);
ProxyClient proxy = new ProxyClient("138.68.161.60:1080", "Username", "Password", ProxyType.Socks5);

WebSocket

using (ProxyClient proxy = new ProxyClient("36.67.195.34", 57456, ProxyType.Socks5)
{
    ReadWriteTimeOut = 10000
})
{
    ClientWebSocket webSocket = new ClientWebSocket
    {
        Options.Proxy = proxy
    };

    await webSocket.ConnectAsync(new Uri("wss://echo.websocket.org"), TokenSource.Token);
}

HttpClient

using (ProxyClient proxy = new ProxyClient("36.67.195.34", 57456, ProxyType.Socks4)
{
    ReadWriteTimeOut = 10000
})
{
    HttpClientHandler handler = new HttpClientHandler { Proxy = proxy };
    HttpClient client = new HttpClient(handler);

    try
    {
        string response = await client.GetStringAsync("https://api.ipify.org/?format=json");

        Console.WriteLine(response);
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex);
    }
    finally
    {
        handler.Dispose();
        client.Dispose();
    }
}