Skip to content

Commit

Permalink
NuGet v4.8.14.11, BlockedIPs PR from @Jyck
Browse files Browse the repository at this point in the history
  • Loading branch information
jchristn committed May 30, 2022
1 parent 94db742 commit d2b115a
Show file tree
Hide file tree
Showing 112 changed files with 4,433 additions and 4,427 deletions.
8 changes: 4 additions & 4 deletions TestDebug.bat
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
@echo off
IF [%1] == [] GOTO Usage
cd Test.Server\bin\debug\net461
cd src\Test.Server\bin\debug\net461
start Test.Server.exe
TIMEOUT 4 > NUL
cd ..\..\..\..
cd ..\..\..\..\..

cd Test.Client\bin\debug\net461
cd src\Test.Client\bin\debug\net461
FOR /L %%i IN (1,1,%1) DO (
ECHO Starting client %%i
start Test.Client.exe
TIMEOUT 2 > NUL
)
cd ..\..\..\..
cd ..\..\..\..\..
@echo on
EXIT /b

Expand Down
8 changes: 4 additions & 4 deletions TestDebugStream.bat
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
@echo off
IF [%1] == [] GOTO Usage
cd Test.ServerStream\bin\debug\net461
cd src\Test.ServerStream\bin\debug\net461
start Test.ServerStream.exe
TIMEOUT 3 > NUL
cd ..\..\..\..
cd ..\..\..\..\..

cd Test.ClientStream\bin\debug\net461
cd src\Test.ClientStream\bin\debug\net461
FOR /L %%i IN (1,1,%1) DO (
ECHO Starting client %%i
start Test.ClientStream.exe
TIMEOUT 1 > NUL
)
cd ..\..\..\..
cd ..\..\..\..\..
@echo on
EXIT /b

Expand Down
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 WatsonTcp/ClientMetadata.cs → src/WatsonTcp/ClientMetadata.cs
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 WatsonTcp/TlsExtensions.cs → src/WatsonTcp/TlsExtensions.cs
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}.");
}
}
}
}
Loading

0 comments on commit d2b115a

Please sign in to comment.