Skip to content

Commit

Permalink
Add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
LiveOrDevTrying committed Aug 1, 2023
1 parent b3f6003 commit 6bf8365
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Tcp.NET.Client/Tcp.NET.Client.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon>Logo.ico</ApplicationIcon>
<Version>7.0.0</Version>
<Authors>Rob Engel - LiveOrDevTrying</Authors>
Expand Down
2 changes: 1 addition & 1 deletion Tcp.NET.Core/Tcp.NET.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<Version>7.0.0</Version>
<Authors>Rob Engel - LiveOrDevTrying</Authors>
<Company>Rob Engel - LiveOrDevTrying - Pixel Horror Studios</Company>
Expand Down
8 changes: 8 additions & 0 deletions Tcp.NET.Server/Handlers/TcpHandlerServerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public override void Start(CancellationToken cancellationToken = default)
{
try
{
Console.WriteLine("Starting");
if (_server != null)
{
Stop(cancellationToken);
Expand All @@ -62,10 +63,12 @@ public override void Start(CancellationToken cancellationToken = default)

if (_certificate == null)
{
Console.WriteLine("Listen for connections");
_ = Task.Run(async () => { await ListenForConnectionsAsync(cancellationToken).ConfigureAwait(false); }, cancellationToken).ConfigureAwait(false);
}
else
{
Console.WriteLine("Listen for connections SSL");
_ = Task.Run(async () => { await ListenForConnectionsSSLAsync(cancellationToken).ConfigureAwait(false); }, cancellationToken).ConfigureAwait(false);
}
return;
Expand Down Expand Up @@ -169,13 +172,17 @@ protected virtual async Task ListenForConnectionsSSLAsync(CancellationToken canc

try
{
Console.WriteLine("Accepting socket");
client = await _server.AcceptTcpClientAsync(cancellationToken).ConfigureAwait(false);
Console.WriteLine("Received socket");
var sslStream = new SslStream(client.GetStream());
Console.WriteLine("Authentication as Server");
await sslStream.AuthenticateAsServerAsync(new SslServerAuthenticationOptions
{
ServerCertificate = new X509Certificate2(_certificate, _certificatePassword)
}, cancellationToken).ConfigureAwait(false);

Console.WriteLine("Finished Authentication");
if (sslStream.IsAuthenticated && sslStream.IsEncrypted)
{
var connection = CreateConnection(new ConnectionTcpServer
Expand Down Expand Up @@ -215,6 +222,7 @@ protected virtual async Task ListenForConnectionsSSLAsync(CancellationToken canc
}
catch (Exception ex)
{
Console.WriteLine("Authentication error");
FireEvent(this, CreateErrorEventArgs(new ErrorEventArgs<Z>
{
Exception = ex,
Expand Down
2 changes: 1 addition & 1 deletion Tcp.NET.Server/Tcp.NET.Server.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon>Logo.ico</ApplicationIcon>
<Version>7.0.0</Version>
<Authors>Rob Engel - LiveOrDevTrying</Authors>
Expand Down
2 changes: 1 addition & 1 deletion Tcp.NET/Tcp.NET.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon>Logo.ico</ApplicationIcon>
<Version>7.0.0</Version>
<Authors>Rob Engel - LiveOrDevTrying</Authors>
Expand Down

0 comments on commit 6bf8365

Please sign in to comment.