Skip to content

Commit

Permalink
Fix for the issue 75 (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
kateryna-novak authored Oct 19, 2024
1 parent 585285d commit 341c4aa
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/libs/H.Formatters.Inferno/H.Formatters.Inferno.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

<ItemGroup>
<ProjectReference Include="..\H.Formatters\H.Formatters.csproj" />
<ProjectReference Include="..\H.Pipes.AccessControl\H.Pipes.AccessControl.csproj" />
<ProjectReference Include="..\H.Pipes\H.Pipes.csproj" />
</ItemGroup>

Expand Down
10 changes: 9 additions & 1 deletion src/libs/H.Formatters.Inferno/PipeServerExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Diagnostics;
using System.IO.Pipes;
using H.Pipes;
using H.Pipes.AccessControl;
using H.Pipes.Extensions;

namespace H.Formatters;
Expand All @@ -19,7 +21,8 @@ public static class PipeServerExtensions
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static void EnableEncryption<T>(
this IPipeServer<T> server,
Action<Exception>? exceptionAction = null)
Action<Exception>? exceptionAction = null,
PipeSecurity? pipeSecurity = null)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (windows-latest, true) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (windows-latest, true) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (windows-latest, true) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (windows-latest, true) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (windows-latest, true) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (windows-latest, true) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (windows-latest, true) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (windows-latest, true) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (windows-latest, true) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (windows-latest, true) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (macos-latest, false) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (macos-latest, false) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (macos-latest, false) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (macos-latest, false) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (macos-latest, false) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (macos-latest, false) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (macos-latest, false) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (macos-latest, false) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (macos-latest, false) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (macos-latest, false) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (ubuntu-latest, false) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (ubuntu-latest, false) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (ubuntu-latest, false) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (ubuntu-latest, false) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (ubuntu-latest, false) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (ubuntu-latest, false) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (ubuntu-latest, false) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (ubuntu-latest, false) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (ubuntu-latest, false) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)

Check warning on line 25 in src/libs/H.Formatters.Inferno/PipeServerExtensions.cs

View workflow job for this annotation

GitHub Actions / Build, test and publish (ubuntu-latest, false) / Build, test and publish

Parameter 'pipeSecurity' has no matching param tag in the XML comment for 'PipeServerExtensions.EnableEncryption<T>(IPipeServer<T>, Action<Exception>?, PipeSecurity?)' (but other parameters do)
{
server = server ?? throw new ArgumentNullException(nameof(server));
server.ClientConnected += async (_, args) =>
Expand All @@ -31,6 +34,11 @@ public static void EnableEncryption<T>(
var pipeName = $"{args.Connection.PipeName}_Inferno";
var server = new SingleConnectionPipeServer<byte[]>(pipeName, args.Connection.Formatter);
if (pipeSecurity != null)
{
server.SetPipeSecurity(pipeSecurity);
}
server.ExceptionOccurred += (_, args) =>
{
Debug.WriteLine($"{nameof(EnableEncryption)} server returns exception: {args.Exception}");
Expand Down
23 changes: 19 additions & 4 deletions src/libs/H.Pipes.AccessControl/PipeServerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static class PipeServerExtensions
{
/// <summary>
/// Sets <see cref="PipeSecurity"/>'s for each <see cref="NamedPipeServerStream"/> that will be created by <see cref="PipeServer{T}"/> <br/>
/// Overrides <see cref="PipeServer{T}.CreatePipeStreamFunc"/>
/// Overrides <see cref="PipeServer{T}.CreatePipeStreamFunc"/> and <see cref="PipeServer{T}.CreatePipeStreamForConnectionFunc"></see>
/// </summary>
/// <param name="server"></param>
/// <param name="pipeSecurity"></param>
Expand All @@ -22,16 +22,31 @@ public static void SetPipeSecurity<T>(this IPipeServer<T> server, PipeSecurity p
{
server = server ?? throw new ArgumentNullException(nameof(server));
pipeSecurity = pipeSecurity ?? throw new ArgumentNullException(nameof(pipeSecurity));

server.CreatePipeStreamFunc = pipeName => NamedPipeServerStreamConstructors.New(
#if NET6_0_OR_GREATER
server.CreatePipeStreamFunc = pipeName =>
NamedPipeServerStreamAcl.Create(
pipeName: pipeName,
direction: PipeDirection.InOut,
maxNumberOfServerInstances: 1,
transmissionMode: PipeTransmissionMode.Byte,
options: PipeOptions.Asynchronous | PipeOptions.WriteThrough,
inBufferSize: 0,
outBufferSize: 0,
pipeSecurity: pipeSecurity);
pipeSecurity);

//server.c
#else
server.CreatePipeStreamFunc = pipeName =>
NamedPipeServerStreamConstructors.New(
pipeName: pipeName,
direction: PipeDirection.InOut,
maxNumberOfServerInstances: 1,
transmissionMode: PipeTransmissionMode.Byte,
options: PipeOptions.Asynchronous | PipeOptions.WriteThrough,
inBufferSize: 0,
outBufferSize: 0,
pipeSecurity: pipeSecurity);
#endif
}

/// <summary>
Expand Down
22 changes: 21 additions & 1 deletion src/libs/H.Pipes/Factories/PipeServerFactory.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.IO.Pipes;
using System.Security.AccessControl;
using System.Security.Principal;

namespace H.Pipes.Factories;

Expand Down Expand Up @@ -44,13 +46,31 @@ public static async Task<NamedPipeServerStream> CreateAndWaitAsync(string pipeNa
/// <returns></returns>
public static NamedPipeServerStream Create(string pipeName)
{
return new NamedPipeServerStream(
#if NET6_0_OR_GREATER

#pragma warning disable CA1416
return NamedPipeServerStreamAcl.Create(
pipeName: pipeName,
direction: PipeDirection.InOut,
maxNumberOfServerInstances: 1,
transmissionMode: PipeTransmissionMode.Byte,
options: PipeOptions.Asynchronous | PipeOptions.WriteThrough,
inBufferSize: 0,
outBufferSize: 0,
null,
HandleInheritability.None,
(PipeAccessRights)0);
#pragma warning restore CA1416
#else
return new NamedPipeServerStream(
pipeName: pipeName,
direction: PipeDirection.InOut,
maxNumberOfServerInstances: 1,
transmissionMode: PipeTransmissionMode.Byte,
options: PipeOptions.Asynchronous | PipeOptions.WriteThrough,
inBufferSize: 0,
outBufferSize: 0);
#endif

}
}
2 changes: 1 addition & 1 deletion src/libs/H.Pipes/IO/PipeStreamWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public sealed class PipeStreamWriter : IDisposable
/// Gets the underlying <c>PipeStream</c> object.
/// </summary>
private PipeStream BaseStream { get; }
private SemaphoreSlim SemaphoreSlim { get; } = new SemaphoreSlim(1, 1);
private SemaphoreSlim SemaphoreSlim { get; } = new(1, 1);

#endregion

Expand Down

0 comments on commit 341c4aa

Please sign in to comment.