From e4b0d401c61c22b32bad71ca9eaadba7bbe4fc84 Mon Sep 17 00:00:00 2001 From: rainbird Date: Fri, 22 Nov 2024 23:40:19 +0100 Subject: [PATCH] - Updated nuget dependencies - Some small naming fixes --- ...uthentication.GenericOsAuthProvider.csproj | 9 +++-- ...Authentication.LinuxPamAuthProvider.csproj | 8 ++-- ....Authentication.WindowsAuthProvider.csproj | 10 +++-- CoreRemoting.Tests/RpcTests.cs | 15 +++---- .../Tools/CustomMessageBuilder.cs | 14 ++++--- CoreRemoting/Channels/Tcp/TcpClientChannel.cs | 2 +- CoreRemoting/CoreRemoting.csproj | 40 ++++++++++++------- CoreRemoting/RemotingSession.cs | 1 + .../Serialization/SerializableException.cs | 12 +++--- 9 files changed, 65 insertions(+), 46 deletions(-) diff --git a/CoreRemoting.Authentication.GenericOsAuthProvider/CoreRemoting.Authentication.GenericOsAuthProvider.csproj b/CoreRemoting.Authentication.GenericOsAuthProvider/CoreRemoting.Authentication.GenericOsAuthProvider.csproj index 1d8b294..008105d 100644 --- a/CoreRemoting.Authentication.GenericOsAuthProvider/CoreRemoting.Authentication.GenericOsAuthProvider.csproj +++ b/CoreRemoting.Authentication.GenericOsAuthProvider/CoreRemoting.Authentication.GenericOsAuthProvider.csproj @@ -4,10 +4,10 @@ netstandard2.0 CoreRemoting.Authentication CoreRemoting.Authentication.GenericOsAuthProvider - 1.1.7 + 1.2.1 Hagen Siegel Generic OS user authentication provider for CoreRemoting - 2020 Hagen Siegel + 2024 Hagen Siegel https://github.com/theRainbird/CoreRemoting true @@ -15,15 +15,18 @@ https://github.com/theRainbird/CoreRemoting.git git Remoting RPC Network Authentication Windows Linux - 1.1.7 + 1.2.1 8 + + + diff --git a/CoreRemoting.Authentication.LinuxPamAuthProvider/CoreRemoting.Authentication.LinuxPamAuthProvider.csproj b/CoreRemoting.Authentication.LinuxPamAuthProvider/CoreRemoting.Authentication.LinuxPamAuthProvider.csproj index 45a7577..7094dbd 100644 --- a/CoreRemoting.Authentication.LinuxPamAuthProvider/CoreRemoting.Authentication.LinuxPamAuthProvider.csproj +++ b/CoreRemoting.Authentication.LinuxPamAuthProvider/CoreRemoting.Authentication.LinuxPamAuthProvider.csproj @@ -4,10 +4,10 @@ netstandard2.0 CoreRemoting.Authentication CoreRemoting.Authentication.LinuxPamAuthProvider - 1.1.7 + 1.2.1 Hagen Siegel Linux user authentication provider for CoreRemoting - 2020 Hagen Siegel + 2024 Hagen Siegel https://github.com/theRainbird/CoreRemoting true @@ -15,13 +15,15 @@ https://github.com/theRainbird/CoreRemoting.git git Remoting RPC Network Authentication Linux - 1.1.7 + 1.2.1 8 + + diff --git a/CoreRemoting.Authentication.WindowsAuthProvider/CoreRemoting.Authentication.WindowsAuthProvider.csproj b/CoreRemoting.Authentication.WindowsAuthProvider/CoreRemoting.Authentication.WindowsAuthProvider.csproj index 1b98626..c491277 100644 --- a/CoreRemoting.Authentication.WindowsAuthProvider/CoreRemoting.Authentication.WindowsAuthProvider.csproj +++ b/CoreRemoting.Authentication.WindowsAuthProvider/CoreRemoting.Authentication.WindowsAuthProvider.csproj @@ -4,10 +4,10 @@ netstandard2.0 CoreRemoting.Authentication CoreRemoting.Authentication.WindowsAuthProvider - 1.1.7 + 1.2.1 Hagen Siegel Windows user authentication provider for CoreRemoting - 2020 Hagen Siegel + 2024 Hagen Siegel https://github.com/theRainbird/CoreRemoting true @@ -15,13 +15,15 @@ https://github.com/theRainbird/CoreRemoting.git git Remoting RPC Network Authentication Windows - 1.1.7 + 1.2.1 8 + - + + diff --git a/CoreRemoting.Tests/RpcTests.cs b/CoreRemoting.Tests/RpcTests.cs index 3f04fb3..cff6b0d 100644 --- a/CoreRemoting.Tests/RpcTests.cs +++ b/CoreRemoting.Tests/RpcTests.cs @@ -1,10 +1,7 @@ using System; -using System.ComponentModel; using System.Diagnostics; using System.Threading; using System.Threading.Tasks; -using CoreRemoting.Channels.Websocket; -using CoreRemoting.DependencyInjection; using CoreRemoting.Serialization; using CoreRemoting.Tests.ExternalTypes; using CoreRemoting.Tests.Tools; @@ -516,21 +513,21 @@ public void NonSerializableError_method_throws_Exception() [Fact] public async Task Disposed_client_subscription_doesnt_break_other_clients() { - async Task roundtrip(bool encryption) + async Task Roundtrip(bool encryption) { var oldEncryption = _serverFixture.Server.Config.MessageEncryption; _serverFixture.Server.Config.MessageEncryption = encryption; try { - RemotingClient createClient() => new RemotingClient(new ClientConfig() + RemotingClient CreateClient() => new RemotingClient(new ClientConfig() { ServerPort = _serverFixture.Server.Config.NetworkPort, MessageEncryption = encryption, }); - using var client1 = createClient(); - using var client2 = createClient(); + using var client1 = CreateClient(); + using var client2 = CreateClient(); client1.Connect(); client2.Connect(); @@ -558,10 +555,10 @@ async Task roundtrip(bool encryption) } // works! - await roundtrip(encryption: false); + await Roundtrip(encryption: false); // fails! - await roundtrip(encryption: true); + await Roundtrip(encryption: true); } } } \ No newline at end of file diff --git a/CoreRemoting.Tests/Tools/CustomMessageBuilder.cs b/CoreRemoting.Tests/Tools/CustomMessageBuilder.cs index 338e02b..80c8759 100644 --- a/CoreRemoting.Tests/Tools/CustomMessageBuilder.cs +++ b/CoreRemoting.Tests/Tools/CustomMessageBuilder.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Reflection; using CoreRemoting.RpcMessaging; using CoreRemoting.Serialization; @@ -16,11 +17,13 @@ public CustomMessageBuilder() Builder = new MethodCallMessageBuilder(); } - public Action ProcessMethodCallMessage { get; set; } = m => { }; + public Action ProcessMethodCallMessage { get; set; } = _ => { }; - public Action> ProcessMethodParameterInfos { get; set; } = m => { }; + // ReSharper disable once MemberCanBePrivate.Global + public Action> ProcessMethodParameterInfos { get; set; } = _ => { }; - public Action ProcessMethodCallResultMessage { get; set; } = m => { }; + // ReSharper disable once MemberCanBePrivate.Global + public Action ProcessMethodCallResultMessage { get; set; } = _ => { }; private MethodCallMessageBuilder Builder { get; set; } @@ -34,8 +37,9 @@ public MethodCallMessage BuildMethodCallMessage(ISerializerAdapter serializer, s public IEnumerable BuildMethodParameterInfos(ISerializerAdapter serializer, MethodInfo targetMethod, object[] args) { var m = Builder.BuildMethodParameterInfos(serializer, targetMethod, args); - ProcessMethodParameterInfos(m); - return m; + var methodCallParameterMessages = m as MethodCallParameterMessage[] ?? m.ToArray(); + ProcessMethodParameterInfos(methodCallParameterMessages); + return methodCallParameterMessages; } public MethodCallResultMessage BuildMethodCallResultMessage(ISerializerAdapter serializer, Guid uniqueCallKey, MethodInfo method, object[] args, object returnValue) diff --git a/CoreRemoting/Channels/Tcp/TcpClientChannel.cs b/CoreRemoting/Channels/Tcp/TcpClientChannel.cs index 791dc2e..a544890 100644 --- a/CoreRemoting/Channels/Tcp/TcpClientChannel.cs +++ b/CoreRemoting/Channels/Tcp/TcpClientChannel.cs @@ -86,7 +86,7 @@ private void OnMessage(object sender, MessageReceivedEventArgs e) { if (e.Metadata != null && e.Metadata.ContainsKey("ServerAcceptConnection")) { - if (!_tcpClient.SendAsync(new byte[1] { 0x0 }, _handshakeMetadata).Result && !_tcpClient.Connected) + if (!_tcpClient.SendAsync(new byte[] { 0x0 }, _handshakeMetadata).Result && !_tcpClient.Connected) _tcpClient = null; } else diff --git a/CoreRemoting/CoreRemoting.csproj b/CoreRemoting/CoreRemoting.csproj index 30e2721..e74b7f6 100644 --- a/CoreRemoting/CoreRemoting.csproj +++ b/CoreRemoting/CoreRemoting.csproj @@ -2,24 +2,34 @@ default - true + true CoreRemoting Hagen Siegel Easy to use Remoting library for .NET Core and .NET Framework - 2024 Hagen Siegel + 2024 Hagen Siegel Remoting RPC Network Hagen Siegel - 1.2.0.0 - netstandard2.0 + 1.2.1.0 + netstandard2.0 https://github.com/theRainbird/CoreRemoting https://github.com/theRainbird/CoreRemoting.git git - 1.2.0.0 - - Added support for cross framework serialization -- Fixed possible thread deadlocks -- Improved service registration and methods for getting service registration metadata. - + 1.2.1.0 + - Change default serializer to BSON to align with non-classic API's default +- Change default channel to TCP to align with non-classic API's default +- Implement TCP channel recognition from Classic Remoting API configuration +- Preventing Leakage of the Remoting Session +- Use Async methods for WatsonTCP +- Replace obsolete methods for Aes encryption +- Remove RemotingSession in a separate task +- Avoid nested envelopes +- RemotingSession shouldn't overwrite the serialized exception with an empty MessageCallResult message. +- Try to keep useful information from the non-serializable exceptions. +- Fix a hang due to a WireMessage deserialization error. +- Demonstrate failing event dispatch when one of the clients disconnects unexpectedly. +- Don't try to dispatch the client events to a disposed remoting session. +- Try your best not to fail event dispatch even if the client had power failure @@ -32,12 +42,12 @@ - + - - + + - + @@ -45,8 +55,8 @@ - - + + diff --git a/CoreRemoting/RemotingSession.cs b/CoreRemoting/RemotingSession.cs index dacbc2a..b3284e3 100644 --- a/CoreRemoting/RemotingSession.cs +++ b/CoreRemoting/RemotingSession.cs @@ -419,6 +419,7 @@ private void ProcessRpcMessage(WireMessage request) var serializedResult = Array.Empty(); var method = default(MethodInfo); var parameterValues = Array.Empty(); + // ReSharper disable once RedundantAssignment var parameterTypes = Array.Empty(); var oneWay = false; diff --git a/CoreRemoting/Serialization/SerializableException.cs b/CoreRemoting/Serialization/SerializableException.cs index ca3105b..95a8192 100644 --- a/CoreRemoting/Serialization/SerializableException.cs +++ b/CoreRemoting/Serialization/SerializableException.cs @@ -42,7 +42,7 @@ public SerializableException(string typeName, string message, string newStackTra : base(message) { SourceTypeName = typeName; - stackTrace = newStackTrace; + _stackTrace = newStackTrace; } /// @@ -56,7 +56,7 @@ public SerializableException(string typeName, string message, Exception innerExc : base(message, innerException) { SourceTypeName = typeName; - stackTrace = newStackTrace; + _stackTrace = newStackTrace; } /// @@ -67,7 +67,7 @@ public SerializableException(string typeName, string message, Exception innerExc protected SerializableException(SerializationInfo info, StreamingContext context) : base(info, context) { - stackTrace = info.GetString("MyStackTrace"); + _stackTrace = info.GetString("MyStackTrace"); SourceTypeName = info.GetString("SourceTypeName"); } @@ -81,11 +81,11 @@ protected SerializableException(SerializationInfo info, StreamingContext context public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); - info.AddValue("MyStackTrace", stackTrace); + info.AddValue("MyStackTrace", _stackTrace); info.AddValue("SourceTypeName", SourceTypeName); } - private string stackTrace; + private string _stackTrace; /// /// Gets a string representation of the immediate frames on the call stack. @@ -94,7 +94,7 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont /// /// /// - public override string StackTrace => stackTrace ?? base.StackTrace; + public override string StackTrace => _stackTrace ?? base.StackTrace; /// /// Gets the type name of source exception.