-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NuGet v4.8.14.11, BlockedIPs PR from @Jyck
- Loading branch information
Showing
112 changed files
with
4,433 additions
and
4,427 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
258 changes: 129 additions & 129 deletions
258
WatsonTcp/ClientMetadata.cs → src/WatsonTcp/ClientMetadata.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,130 +1,130 @@ | ||
using System; | ||
using System.IO; | ||
using System.Net.Security; | ||
using System.Net.Sockets; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace WatsonTcp | ||
{ | ||
internal class ClientMetadata : IDisposable | ||
{ | ||
internal TcpClient TcpClient | ||
{ | ||
get | ||
{ | ||
return _TcpClient; | ||
} | ||
} | ||
|
||
internal NetworkStream NetworkStream | ||
{ | ||
get | ||
{ | ||
return _NetworkStream; | ||
} | ||
set | ||
{ | ||
_NetworkStream = value; | ||
if (_NetworkStream != null) | ||
{ | ||
_DataStream = _NetworkStream; | ||
} | ||
} | ||
} | ||
|
||
internal SslStream SslStream | ||
{ | ||
get | ||
{ | ||
return _SslStream; | ||
} | ||
set | ||
{ | ||
_SslStream = value; | ||
if (_SslStream != null) | ||
{ | ||
_DataStream = _SslStream; | ||
} | ||
} | ||
} | ||
|
||
internal Stream DataStream | ||
{ | ||
get | ||
{ | ||
return _DataStream; | ||
} | ||
} | ||
|
||
internal string IpPort | ||
{ | ||
get | ||
{ | ||
return _IpPort; | ||
} | ||
} | ||
|
||
internal byte[] SendBuffer { get; set; } = new byte[65536]; | ||
internal Task DataReceiver { get; set; } = null; | ||
|
||
internal SemaphoreSlim WriteLock = new SemaphoreSlim(1, 1); | ||
internal SemaphoreSlim ReadLock = new SemaphoreSlim(1, 1); | ||
|
||
internal CancellationTokenSource TokenSource = new CancellationTokenSource(); | ||
internal CancellationToken Token; | ||
|
||
private TcpClient _TcpClient = null; | ||
private NetworkStream _NetworkStream = null; | ||
private SslStream _SslStream = null; | ||
private Stream _DataStream = null; | ||
private string _IpPort = null; | ||
|
||
internal ClientMetadata(TcpClient tcp) | ||
{ | ||
if (tcp == null) throw new ArgumentNullException(nameof(tcp)); | ||
|
||
_TcpClient = tcp; | ||
_IpPort = tcp.Client.RemoteEndPoint.ToString(); | ||
|
||
NetworkStream = tcp.GetStream(); | ||
Token = TokenSource.Token; | ||
} | ||
|
||
/// <summary> | ||
/// Tear down the object and dispose of resources. | ||
/// </summary> | ||
public void Dispose() | ||
{ | ||
if (TokenSource != null) | ||
{ | ||
if (!TokenSource.IsCancellationRequested) | ||
{ | ||
TokenSource.Cancel(); | ||
TokenSource.Dispose(); | ||
} | ||
} | ||
|
||
if (_SslStream != null) | ||
{ | ||
_SslStream.Close(); | ||
} | ||
|
||
if (_NetworkStream != null) | ||
{ | ||
_NetworkStream.Close(); | ||
} | ||
|
||
if (_TcpClient != null) | ||
{ | ||
_TcpClient.Close(); | ||
_TcpClient.Dispose(); | ||
} | ||
|
||
while (DataReceiver?.Status == TaskStatus.Running) | ||
{ | ||
Task.Delay(30).Wait(); | ||
} | ||
} | ||
} | ||
using System; | ||
using System.IO; | ||
using System.Net.Security; | ||
using System.Net.Sockets; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace WatsonTcp | ||
{ | ||
internal class ClientMetadata : IDisposable | ||
{ | ||
internal TcpClient TcpClient | ||
{ | ||
get | ||
{ | ||
return _TcpClient; | ||
} | ||
} | ||
|
||
internal NetworkStream NetworkStream | ||
{ | ||
get | ||
{ | ||
return _NetworkStream; | ||
} | ||
set | ||
{ | ||
_NetworkStream = value; | ||
if (_NetworkStream != null) | ||
{ | ||
_DataStream = _NetworkStream; | ||
} | ||
} | ||
} | ||
|
||
internal SslStream SslStream | ||
{ | ||
get | ||
{ | ||
return _SslStream; | ||
} | ||
set | ||
{ | ||
_SslStream = value; | ||
if (_SslStream != null) | ||
{ | ||
_DataStream = _SslStream; | ||
} | ||
} | ||
} | ||
|
||
internal Stream DataStream | ||
{ | ||
get | ||
{ | ||
return _DataStream; | ||
} | ||
} | ||
|
||
internal string IpPort | ||
{ | ||
get | ||
{ | ||
return _IpPort; | ||
} | ||
} | ||
|
||
internal byte[] SendBuffer { get; set; } = new byte[65536]; | ||
internal Task DataReceiver { get; set; } = null; | ||
|
||
internal SemaphoreSlim WriteLock = new SemaphoreSlim(1, 1); | ||
internal SemaphoreSlim ReadLock = new SemaphoreSlim(1, 1); | ||
|
||
internal CancellationTokenSource TokenSource = new CancellationTokenSource(); | ||
internal CancellationToken Token; | ||
|
||
private TcpClient _TcpClient = null; | ||
private NetworkStream _NetworkStream = null; | ||
private SslStream _SslStream = null; | ||
private Stream _DataStream = null; | ||
private string _IpPort = null; | ||
|
||
internal ClientMetadata(TcpClient tcp) | ||
{ | ||
if (tcp == null) throw new ArgumentNullException(nameof(tcp)); | ||
|
||
_TcpClient = tcp; | ||
_IpPort = tcp.Client.RemoteEndPoint.ToString(); | ||
|
||
NetworkStream = tcp.GetStream(); | ||
Token = TokenSource.Token; | ||
} | ||
|
||
/// <summary> | ||
/// Tear down the object and dispose of resources. | ||
/// </summary> | ||
public void Dispose() | ||
{ | ||
if (TokenSource != null) | ||
{ | ||
if (!TokenSource.IsCancellationRequested) | ||
{ | ||
TokenSource.Cancel(); | ||
TokenSource.Dispose(); | ||
} | ||
} | ||
|
||
if (_SslStream != null) | ||
{ | ||
_SslStream.Close(); | ||
} | ||
|
||
if (_NetworkStream != null) | ||
{ | ||
_NetworkStream.Close(); | ||
} | ||
|
||
if (_TcpClient != null) | ||
{ | ||
_TcpClient.Close(); | ||
_TcpClient.Dispose(); | ||
} | ||
|
||
while (DataReceiver?.Status == TaskStatus.Running) | ||
{ | ||
Task.Delay(30).Wait(); | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
62 changes: 31 additions & 31 deletions
62
WatsonTcp/TlsExtensions.cs → src/WatsonTcp/TlsExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
using System; | ||
using System.Security.Authentication; | ||
|
||
namespace WatsonTcp | ||
{ | ||
/// <summary> | ||
/// TLS extensions. | ||
/// </summary> | ||
public static class TlsExtensions | ||
{ | ||
/// <summary> | ||
/// TLS version to SSL protocol version. | ||
/// </summary> | ||
/// <param name="tlsVersion"></param> | ||
/// <returns></returns> | ||
public static SslProtocols ToSslProtocols(this TlsVersion tlsVersion) | ||
{ | ||
switch (tlsVersion) | ||
{ | ||
case TlsVersion.Tls12: | ||
return SslProtocols.Tls12; | ||
#if NET5_0_OR_GREATER | ||
case TlsVersion.Tls13: | ||
return SslProtocols.Tls13; | ||
#endif | ||
default: | ||
throw new ArgumentOutOfRangeException($"Unsupported TLS version {tlsVersion}."); | ||
} | ||
} | ||
} | ||
} | ||
using System; | ||
using System.Security.Authentication; | ||
|
||
namespace WatsonTcp | ||
{ | ||
/// <summary> | ||
/// TLS extensions. | ||
/// </summary> | ||
public static class TlsExtensions | ||
{ | ||
/// <summary> | ||
/// TLS version to SSL protocol version. | ||
/// </summary> | ||
/// <param name="tlsVersion"></param> | ||
/// <returns></returns> | ||
public static SslProtocols ToSslProtocols(this TlsVersion tlsVersion) | ||
{ | ||
switch (tlsVersion) | ||
{ | ||
case TlsVersion.Tls12: | ||
return SslProtocols.Tls12; | ||
#if NET5_0_OR_GREATER | ||
case TlsVersion.Tls13: | ||
return SslProtocols.Tls13; | ||
#endif | ||
default: | ||
throw new ArgumentOutOfRangeException($"Unsupported TLS version {tlsVersion}."); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.