Skip to content

Commit

Permalink
fix: Small fixes for latest PR
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Oct 19, 2024
1 parent 341c4aa commit e51545e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 35 deletions.
1 change: 1 addition & 0 deletions src/libs/H.Formatters.Inferno/PipeServerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public static class PipeServerExtensions
/// <typeparam name="T"></typeparam>
/// <param name="server"></param>
/// <param name="exceptionAction"></param>
/// <param name="pipeSecurity"></param>
/// <exception cref="ArgumentNullException"></exception>
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static void EnableEncryption<T>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net4.6.2' ">
<PackageReference Include="System.Text.Json" Version="8.0.4" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.Text.Json" Version="8.0.4" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
</ItemGroup>

</Project>
23 changes: 10 additions & 13 deletions src/libs/H.Pipes.AccessControl/PipeServerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,18 @@ 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));
#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);

//server.c
#if NET6_0_OR_GREATER
NamedPipeServerStreamAcl.Create(
pipeName: pipeName,
direction: PipeDirection.InOut,
maxNumberOfServerInstances: 1,
transmissionMode: PipeTransmissionMode.Byte,
options: PipeOptions.Asynchronous | PipeOptions.WriteThrough,
inBufferSize: 0,
outBufferSize: 0,
pipeSecurity: pipeSecurity);
#else
server.CreatePipeStreamFunc = pipeName =>
NamedPipeServerStreamConstructors.New(
pipeName: pipeName,
direction: PipeDirection.InOut,
Expand Down
37 changes: 17 additions & 20 deletions src/libs/H.Pipes/Factories/PipeServerFactory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.IO.Pipes;
using System.Security.AccessControl;
using System.Security.Principal;

namespace H.Pipes.Factories;

Expand Down Expand Up @@ -47,30 +45,29 @@ public static async Task<NamedPipeServerStream> CreateAndWaitAsync(string pipeNa
public static NamedPipeServerStream Create(string pipeName)
{
#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(
if (OperatingSystem.IsWindows())
{
return NamedPipeServerStreamAcl.Create(
pipeName: pipeName,
direction: PipeDirection.InOut,
maxNumberOfServerInstances: 1,
transmissionMode: PipeTransmissionMode.Byte,
options: PipeOptions.Asynchronous | PipeOptions.WriteThrough,
inBufferSize: 0,
outBufferSize: 0,
pipeSecurity: null,
inheritability: HandleInheritability.None,
additionalAccessRights: 0);
}
#endif

return new NamedPipeServerStream(
pipeName: pipeName,
direction: PipeDirection.InOut,
maxNumberOfServerInstances: 1,
transmissionMode: PipeTransmissionMode.Byte,
options: PipeOptions.Asynchronous | PipeOptions.WriteThrough,
inBufferSize: 0,
outBufferSize: 0);
#endif

}
}

0 comments on commit e51545e

Please sign in to comment.