Skip to content

Socks4/Socks5 for IWebProxy [WebSocket / HttpClient]

Notifications You must be signed in to change notification settings

TheSuunny/Yove.Proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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();
    }
}

About

Socks4/Socks5 for IWebProxy [WebSocket / HttpClient]

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages