mirror of
https://github.com/sochix/TLSharp.git
synced 2026-04-05 14:37:04 +00:00
Custom TCP hanlder to allow HTTP proxy auth
This commit is contained in:
parent
85c206cc24
commit
48077961ae
2 changed files with 18 additions and 9 deletions
|
|
@ -1,22 +1,28 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TLSharp.Core.Network
|
||||
{
|
||||
public delegate TcpClient TcpClientConnectionHandler(string address, int port);
|
||||
|
||||
public class TcpTransport : IDisposable
|
||||
{
|
||||
private readonly TcpClient _tcpClient;
|
||||
private int sendCounter = 0;
|
||||
|
||||
public TcpTransport(string address, int port)
|
||||
public TcpTransport(string address, int port, TcpClientConnectionHandler handler = null)
|
||||
{
|
||||
_tcpClient = new TcpClient();
|
||||
if (handler == null)
|
||||
{
|
||||
_tcpClient = new TcpClient();
|
||||
|
||||
var ipAddress = IPAddress.Parse(address);
|
||||
_tcpClient.Connect(ipAddress, port);
|
||||
var ipAddress = IPAddress.Parse(address);
|
||||
_tcpClient.Connect(ipAddress, port);
|
||||
}
|
||||
else
|
||||
_tcpClient = handler(address, port);
|
||||
}
|
||||
|
||||
public async Task Send(byte[] packet)
|
||||
|
|
@ -84,6 +90,6 @@ namespace TLSharp.Core.Network
|
|||
{
|
||||
if (_tcpClient.Connected)
|
||||
_tcpClient.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue