C#代理网络通信控件支持SOCKS4/5 — ProxyClient for .NET

ProxyClient for .NET是一个针对Microsoft .NET平台的代理客户端组件,它允许从新的和现有的套接字(以及TcpClient实例)轻松建立代理连接。支持2.0-4.5的所有版本,它还可以侦听和接受针对远程代理服务器建立的传入连接,就像它们在本地被接受一样。
示例代码[code]

// Set up a new proxy client object, bound to a SOCKS 5 server

var proxy = new Socks5Client(IPAddress.Parse(“10.0.1.2”),
“john”,
“$ecrEt”);

// The target endpoint will be one of the Google’s webservers

var googleAddress = Dns.GetHostEntry(“www.google.com”).AddressList[0];
var targetEndPoint = new IPEndPoint(googleAddress, 80);

// Connect to a target IP endpoint via HTTP through a proxied connection

var proxiedConnection = proxyClient.Connect(targetEndPoint);

using (var proxiedStream = new NetworkStream(proxiedConnection.Socket))
using (var writer = new StreamWriter(proxiedStream, Encoding.ASCII))
{
// Send the HTTP request to www.google.com

writer.WriteLine(“GET / HTTP/1.1”);
writer.WriteLine();
writer.Flush();

// …
}

// Set up a new proxy client object, bound to a SOCKS 5 server

var proxy = new Socks5Client(IPAddress.Parse(“10.0.1.2”),
“john”,
“$ecrEt”);

Task.Run(async () =>
{
// Binds the remote socket to the remote HTTP port

var listeningSocket = await proxy.BindAsync(new IPv4EndPoint
{
Address = IPAddress.Any,
Port = 80 // The protocol does not guarantee to obey this
});

Console.WriteLine(“Remote socket listening on: {0}”,
listeningSocket.ListeningEndPoint);

// Accepts a remote connection

var acceptedSocket = await proxy.AcceptAsync(listeningSocket);

Console.WriteLine(“Accepted a connection from: {0}”,
acceptedSocket.RemoteEndPoint);

// Writes a message back, using the HTTP protocol

using (var proxiedStream = new NetworkStream(acceptedSocket.Socket))
using (var reader = new StreamReader(proxiedStream, Encoding.ASCII))
using (var writer = new StreamWriter(proxiedStream, Encoding.ASCII))
{
// TODO: Handle the request

while (reader.EndOfStream)
reader.ReadLine();

// Generates a useful reply

writer.WriteLine(“HTTP/1.0 200 OK”);
writer.WriteLine(“Content-Type: text/plain”);
writer.WriteLine();
writer.WriteLine(“hello, world”);
writer.Flush();
}

// Close the underlying socket connection

listeningSocket.Socket.Close();
});

[/code]

官网地址:官网

下载地址:https://AllRes.ctfile.com/dir/4028457-28708812-c396ba/

使用时在软件启动时验证注册信息:

[code]LicensingManager.SetLicenseKey(“注册码”);[/code]

特别信息:[login]h24CFSMy+C19D9LMcwyJxEGL7Y+8ZjoKsuqC+w/TBrGsxZS5x7Rl3CgV5u4jDfXk+MLsyA==[/login]

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容