From 7df453f6c8a292bd1268969012713c52ae5236f5 Mon Sep 17 00:00:00 2001 From: cedrozor Date: Mon, 22 Oct 2018 13:23:08 +0200 Subject: [PATCH] disabled the myrtille application pool recycling moved the remote session counter (auto-increment) to the service layer myrtille pdf printer is now disabled by default in web.config fixed SSH on non-default port (thanks pk910) --- CHANGELOG | 8 +++- Myrtille.Common/Helpers/IISHelper.cs | 6 ++- Myrtille.Common/Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- Myrtille.Printer/Properties/AssemblyInfo.cs | 4 +- Myrtille.SSH/Properties/AssemblyInfo.cs | 4 +- .../IRemoteSessionCounter.cs | 11 +++++ .../Myrtille.Services.Contracts.csproj | 1 + .../Properties/AssemblyInfo.cs | 4 +- Myrtille.Services/Myrtille.Services.csproj | 1 + Myrtille.Services/Program.cs | 8 ++++ Myrtille.Services/Properties/AssemblyInfo.cs | 4 +- Myrtille.Services/RemoteSessionCounter.cs | 25 +++++++++++ Myrtille.Services/app.config | 8 ++++ Myrtille.Setup/Myrtille.Setup.vdproj | 12 +++--- Myrtille.Web/Default.aspx | 2 +- Myrtille.Web/Default.aspx.cs | 18 ++------ Myrtille.Web/Global.asax.cs | 4 -- Myrtille.Web/Myrtille.Web.csproj | 1 + Myrtille.Web/Properties/AssemblyInfo.cs | 4 +- Myrtille.Web/Web.Base.config | 3 +- .../src/RemoteSessionCounterClient.cs | 41 +++++++++++++++++++ Myrtille.Web/src/WebInstaller.cs | 10 ++--- 24 files changed, 139 insertions(+), 52 deletions(-) create mode 100644 Myrtille.Services.Contracts/IRemoteSessionCounter.cs create mode 100644 Myrtille.Services/RemoteSessionCounter.cs create mode 100644 Myrtille.Web/src/RemoteSessionCounterClient.cs diff --git a/CHANGELOG b/CHANGELOG index e102e9a..03ca2b5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,10 @@ -2018-08-19 Version 2.1.2 (stable) +2018-10-21 Version 2.2.0 (stable) + disabled the myrtille application pool recycling + moved the remote session counter (auto-increment) to the service layer + myrtille pdf printer is now disabled by default in web.config + fixed SSH on non-default port (thanks pk910) + +2018-08-19 Version 2.1.2 (stable) fixed an ipv6 connection issue (that may occurred when checking the link-local ipv6 address) 2018-08-14 Version 2.1.1 (stable) diff --git a/Myrtille.Common/Helpers/IISHelper.cs b/Myrtille.Common/Helpers/IISHelper.cs index 555b045..eacdaf9 100644 --- a/Myrtille.Common/Helpers/IISHelper.cs +++ b/Myrtille.Common/Helpers/IISHelper.cs @@ -111,11 +111,13 @@ public static bool IsIISApplicationPoolExists( /// /// /// true for IIS > 6 + /// enabled by default on IIS, this operation is destructive (creates a new IIS worker process); among other things, all http sessions are lost! public static void CreateIISApplicationPool( string poolName, string version, bool enable32BitAppOnWin64 = false, - bool loadUserProfile = true) + bool loadUserProfile = true, + bool allowRecycling = false) { Trace.TraceInformation("Creating IIS application pool {0}, .NET framework {1}", poolName, version); @@ -129,6 +131,8 @@ public static void CreateIISApplicationPool( pool.ManagedRuntimeVersion = version; pool.Enable32BitAppOnWin64 = enable32BitAppOnWin64; pool.ProcessModel.LoadUserProfile = loadUserProfile; + pool.ProcessModel.IdleTimeout = allowRecycling ? new TimeSpan(0, 20, 0) : new TimeSpan(0); + pool.Recycling.PeriodicRestart.Time = allowRecycling ? new TimeSpan(0, 1740, 0) : new TimeSpan(0); serverManager.CommitChanges(); } catch (Exception exc) diff --git a/Myrtille.Common/Properties/AssemblyInfo.cs b/Myrtille.Common/Properties/AssemblyInfo.cs index dacc07a..d68b679 100644 --- a/Myrtille.Common/Properties/AssemblyInfo.cs +++ b/Myrtille.Common/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // // Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de révision et de build par défaut // en utilisant '*', comme indiqué ci-dessous : -[assembly: AssemblyVersion("2.1.2.0")] -[assembly: AssemblyFileVersion("2.1.2.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/Myrtille.Enterprise/Properties/AssemblyInfo.cs b/Myrtille.Enterprise/Properties/AssemblyInfo.cs index e4168ef..03d2c88 100644 --- a/Myrtille.Enterprise/Properties/AssemblyInfo.cs +++ b/Myrtille.Enterprise/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.1.2.0")] -[assembly: AssemblyFileVersion("2.1.2.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/Myrtille.MFAProviders/Properties/AssemblyInfo.cs b/Myrtille.MFAProviders/Properties/AssemblyInfo.cs index 06b65ac..607a1ff 100644 --- a/Myrtille.MFAProviders/Properties/AssemblyInfo.cs +++ b/Myrtille.MFAProviders/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.1.2.0")] -[assembly: AssemblyFileVersion("2.1.2.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/Myrtille.Printer/Properties/AssemblyInfo.cs b/Myrtille.Printer/Properties/AssemblyInfo.cs index 9ad2971..f65009a 100644 --- a/Myrtille.Printer/Properties/AssemblyInfo.cs +++ b/Myrtille.Printer/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.1.2.0")] -[assembly: AssemblyFileVersion("2.1.2.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/Myrtille.SSH/Properties/AssemblyInfo.cs b/Myrtille.SSH/Properties/AssemblyInfo.cs index 714c47a..0ac0f84 100644 --- a/Myrtille.SSH/Properties/AssemblyInfo.cs +++ b/Myrtille.SSH/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.1.2.0")] -[assembly: AssemblyFileVersion("2.1.2.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/Myrtille.Services.Contracts/IRemoteSessionCounter.cs b/Myrtille.Services.Contracts/IRemoteSessionCounter.cs new file mode 100644 index 0000000..85968c2 --- /dev/null +++ b/Myrtille.Services.Contracts/IRemoteSessionCounter.cs @@ -0,0 +1,11 @@ +using System.ServiceModel; + +namespace Myrtille.Services.Contracts +{ + [ServiceContract] + public interface IRemoteSessionCounter + { + [OperationContract] + int GetRemoteSessionId(); + } +} \ No newline at end of file diff --git a/Myrtille.Services.Contracts/Myrtille.Services.Contracts.csproj b/Myrtille.Services.Contracts/Myrtille.Services.Contracts.csproj index 1ba0bdc..000d957 100644 --- a/Myrtille.Services.Contracts/Myrtille.Services.Contracts.csproj +++ b/Myrtille.Services.Contracts/Myrtille.Services.Contracts.csproj @@ -53,6 +53,7 @@ + diff --git a/Myrtille.Services.Contracts/Properties/AssemblyInfo.cs b/Myrtille.Services.Contracts/Properties/AssemblyInfo.cs index 9d57be3..473cb74 100644 --- a/Myrtille.Services.Contracts/Properties/AssemblyInfo.cs +++ b/Myrtille.Services.Contracts/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut // en utilisant '*', comme indiqué ci-dessous : // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.1.2.0")] -[assembly: AssemblyFileVersion("2.1.2.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/Myrtille.Services/Myrtille.Services.csproj b/Myrtille.Services/Myrtille.Services.csproj index d96c0f6..24a47cd 100644 --- a/Myrtille.Services/Myrtille.Services.csproj +++ b/Myrtille.Services/Myrtille.Services.csproj @@ -106,6 +106,7 @@ + Component diff --git a/Myrtille.Services/Program.cs b/Myrtille.Services/Program.cs index ff3861c..db8edc7 100644 --- a/Myrtille.Services/Program.cs +++ b/Myrtille.Services/Program.cs @@ -30,12 +30,16 @@ namespace Myrtille.Services { public class Program : ServiceBase { + private static ServiceHost _remoteSessionCounter; private static ServiceHost _remoteSessionProcess; private static ServiceHost _localFileStorage; private static ServiceHost _printerService; private static ServiceHost _mfaAuthentication; private static ServiceHost _enterpriseServices; + public static int _remoteSessionsCounter = 0; + public static object _remoteSessionsCounterLock = new object(); + public static IMultifactorAuthenticationAdapter _multifactorAdapter = null; public static IEnterpriseAdapter _enterpriseAdapter = null; @@ -104,6 +108,7 @@ private static void Main(string[] args) LoadMFAAdapter(); LoadEnterpriseAdapter(); + _remoteSessionCounter = OpenService(typeof(RemoteSessionCounter)); _remoteSessionProcess = OpenService(typeof(RemoteSessionProcess)); _localFileStorage = OpenService(typeof(FileStorage)); _printerService = OpenService(typeof(PrinterService)); @@ -113,6 +118,7 @@ private static void Main(string[] args) Console.WriteLine("press any key to exit..."); Console.ReadKey(); + CloseService(ref _remoteSessionCounter); CloseService(ref _remoteSessionProcess); CloseService(ref _localFileStorage); CloseService(ref _printerService); @@ -126,6 +132,7 @@ protected override void OnStart(string[] args) LoadMFAAdapter(); LoadEnterpriseAdapter(); + _remoteSessionCounter = OpenService(typeof(RemoteSessionCounter)); _remoteSessionProcess = OpenService(typeof(RemoteSessionProcess)); _localFileStorage = OpenService(typeof(FileStorage)); _printerService = OpenService(typeof(PrinterService)); @@ -135,6 +142,7 @@ protected override void OnStart(string[] args) protected override void OnStop() { + CloseService(ref _remoteSessionCounter); CloseService(ref _remoteSessionProcess); CloseService(ref _localFileStorage); CloseService(ref _printerService); diff --git a/Myrtille.Services/Properties/AssemblyInfo.cs b/Myrtille.Services/Properties/AssemblyInfo.cs index 57f83ca..b8c513c 100644 --- a/Myrtille.Services/Properties/AssemblyInfo.cs +++ b/Myrtille.Services/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut // en utilisant '*', comme indiqué ci-dessous : // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.1.2.0")] -[assembly: AssemblyFileVersion("2.1.2.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/Myrtille.Services/RemoteSessionCounter.cs b/Myrtille.Services/RemoteSessionCounter.cs new file mode 100644 index 0000000..260a5e4 --- /dev/null +++ b/Myrtille.Services/RemoteSessionCounter.cs @@ -0,0 +1,25 @@ +using System; +using System.Diagnostics; +using Myrtille.Services.Contracts; + +namespace Myrtille.Services +{ + public class RemoteSessionCounter : IRemoteSessionCounter + { + public int GetRemoteSessionId() + { + try + { + lock (Program._remoteSessionsCounterLock) + { + return ++Program._remoteSessionsCounter; + } + } + catch (Exception exc) + { + Trace.TraceError("Failed to get a remote session id ({0})", exc); + throw; + } + } + } +} \ No newline at end of file diff --git a/Myrtille.Services/app.config b/Myrtille.Services/app.config index 6e4cf52..f570940 100644 --- a/Myrtille.Services/app.config +++ b/Myrtille.Services/app.config @@ -84,6 +84,14 @@ + + + + + + + + diff --git a/Myrtille.Setup/Myrtille.Setup.vdproj b/Myrtille.Setup/Myrtille.Setup.vdproj index 3a79a37..f62caef 100644 --- a/Myrtille.Setup/Myrtille.Setup.vdproj +++ b/Myrtille.Setup/Myrtille.Setup.vdproj @@ -954,7 +954,7 @@ { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" - "AssemblyAsmDisplayName" = "8:Myrtille.Enterprise, Version=2.1.2.0, Culture=neutral, processorArchitecture=MSIL" + "AssemblyAsmDisplayName" = "8:Myrtille.Enterprise, Version=2.2.0.0, Culture=neutral, processorArchitecture=MSIL" "ScatterAssemblies" { "_51E1684E0AC9A2E6C91C688F2C9DD4B1" @@ -1633,7 +1633,7 @@ { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" - "AssemblyAsmDisplayName" = "8:Myrtille.Common, Version=2.1.2.0, Culture=neutral, processorArchitecture=MSIL" + "AssemblyAsmDisplayName" = "8:Myrtille.Common, Version=2.2.0.0, Culture=neutral, processorArchitecture=MSIL" "ScatterAssemblies" { "_DF64623992E0504E6E44F78E0DACDA36" @@ -1664,7 +1664,7 @@ { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" - "AssemblyAsmDisplayName" = "8:Myrtille.Services.Contracts, Version=2.1.2.0, Culture=neutral, processorArchitecture=MSIL" + "AssemblyAsmDisplayName" = "8:Myrtille.Services.Contracts, Version=2.2.0.0, Culture=neutral, processorArchitecture=MSIL" "ScatterAssemblies" { "_E385E6F4F7BC7295F537EC6B3C8250D3" @@ -1715,7 +1715,7 @@ { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" - "AssemblyAsmDisplayName" = "8:Myrtille.MFAProviders, Version=2.1.2.0, Culture=neutral, processorArchitecture=MSIL" + "AssemblyAsmDisplayName" = "8:Myrtille.MFAProviders, Version=2.2.0.0, Culture=neutral, processorArchitecture=MSIL" "ScatterAssemblies" { "_E76FFE893BD37BAA153E3EFB44999C4E" @@ -1936,14 +1936,14 @@ "Name" = "8:Microsoft Visual Studio" "ProductName" = "8:Myrtille" "ProductCode" = "8:{B00BCC6F-3958-4726-9D99-DBAC78513C26}" - "PackageCode" = "8:{9CE84769-AB32-4A10-881B-E65D133C9675}" + "PackageCode" = "8:{39BB370F-3D90-4207-A665-65EE1C27A1B4}" "UpgradeCode" = "8:{86A6145E-11DB-4EE7-9CE0-53F997050716}" "AspNetVersion" = "8:4.0.30319.0" "RestartWWWService" = "11:FALSE" "RemovePreviousVersions" = "11:TRUE" "DetectNewerInstalledVersion" = "11:TRUE" "InstallAllUsers" = "11:TRUE" - "ProductVersion" = "8:2.1.2" + "ProductVersion" = "8:2.2.0" "Manufacturer" = "8:Cedric Coste" "ARPHELPTELEPHONE" = "8:" "ARPHELPLINK" = "8:http://cedrozor.github.io/myrtille" diff --git a/Myrtille.Web/Default.aspx b/Myrtille.Web/Default.aspx index b9bab21..b74daec 100644 --- a/Myrtille.Web/Default.aspx +++ b/Myrtille.Web/Default.aspx @@ -176,7 +176,7 @@
- + myrtille diff --git a/Myrtille.Web/Default.aspx.cs b/Myrtille.Web/Default.aspx.cs index 4e3a125..fc70642 100644 --- a/Myrtille.Web/Default.aspx.cs +++ b/Myrtille.Web/Default.aspx.cs @@ -35,6 +35,7 @@ namespace Myrtille.Web { public partial class Default : Page { + private RemoteSessionCounterClient _remoteSessionCounterClient; private MFAAuthenticationClient _mfaAuthClient; private EnterpriseServiceClient _enterpriseClient; @@ -59,6 +60,7 @@ protected void Page_Init( object sender, EventArgs e) { + _remoteSessionCounterClient = new RemoteSessionCounterClient(); _mfaAuthClient = new MFAAuthenticationClient(); _enterpriseClient = new EnterpriseServiceClient(); @@ -464,16 +466,9 @@ private bool ConnectRemoteServer() // create a new remote session try { - Application.Lock(); - - // auto-increment the remote sessions counter - // note that it doesn't really count the active remote sessions... it's just an auto-increment for the remote session id, ensuring it's unique... - var remoteSessionsCounter = (int)Application[HttpApplicationStateVariables.RemoteSessionsCounter.ToString()]; - remoteSessionsCounter++; - // create the remote session RemoteSession = new RemoteSession( - remoteSessionsCounter, + _remoteSessionCounterClient.GetRemoteSessionId(), RemoteSessionState.NotConnected, loginHostName, loginHostType, @@ -496,19 +491,12 @@ private bool ConnectRemoteServer() // bind the remote session to the current http session Session[HttpSessionStateVariables.RemoteSession.ToString()] = RemoteSession; - - // update the remote sessions auto-increment counter - Application[HttpApplicationStateVariables.RemoteSessionsCounter.ToString()] = remoteSessionsCounter; } catch (Exception exc) { System.Diagnostics.Trace.TraceError("Failed to create remote session ({0})", exc); RemoteSession = null; } - finally - { - Application.UnLock(); - } // connect it if (RemoteSession != null) diff --git a/Myrtille.Web/Global.asax.cs b/Myrtille.Web/Global.asax.cs index 0a00626..f9dbc1f 100644 --- a/Myrtille.Web/Global.asax.cs +++ b/Myrtille.Web/Global.asax.cs @@ -27,7 +27,6 @@ namespace Myrtille.Web public enum HttpApplicationStateVariables { Cache, - RemoteSessionsCounter, SharedRemoteSessions } @@ -53,9 +52,6 @@ protected void Application_Start( // application cache Application[HttpApplicationStateVariables.Cache.ToString()] = Context.Cache; - // remote sessions auto-incremented counter - Application[HttpApplicationStateVariables.RemoteSessionsCounter.ToString()] = 0; - // shared remote sessions Application[HttpApplicationStateVariables.SharedRemoteSessions.ToString()] = new Dictionary(); } diff --git a/Myrtille.Web/Myrtille.Web.csproj b/Myrtille.Web/Myrtille.Web.csproj index 64bd0e7..f4cc6b1 100644 --- a/Myrtille.Web/Myrtille.Web.csproj +++ b/Myrtille.Web/Myrtille.Web.csproj @@ -151,6 +151,7 @@ SocketHandler.ashx + diff --git a/Myrtille.Web/Properties/AssemblyInfo.cs b/Myrtille.Web/Properties/AssemblyInfo.cs index 2e6c537..af326ca 100644 --- a/Myrtille.Web/Properties/AssemblyInfo.cs +++ b/Myrtille.Web/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("2.1.2.0")] -[assembly: AssemblyFileVersion("2.1.2.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/Myrtille.Web/Web.Base.config b/Myrtille.Web/Web.Base.config index 4c52139..7f08218 100644 --- a/Myrtille.Web/Web.Base.config +++ b/Myrtille.Web/Web.Base.config @@ -84,6 +84,7 @@ + @@ -119,7 +120,7 @@ - + diff --git a/Myrtille.Web/src/RemoteSessionCounterClient.cs b/Myrtille.Web/src/RemoteSessionCounterClient.cs new file mode 100644 index 0000000..a188ac4 --- /dev/null +++ b/Myrtille.Web/src/RemoteSessionCounterClient.cs @@ -0,0 +1,41 @@ +/* + Myrtille: A native HTML4/5 Remote Desktop Protocol client. + + Copyright(c) 2014-2018 Cedric Coste + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +using System; +using System.Diagnostics; +using System.ServiceModel; +using Myrtille.Services.Contracts; + +namespace Myrtille.Web +{ + public class RemoteSessionCounterClient : ClientBase, IRemoteSessionCounter + { + public int GetRemoteSessionId() + { + try + { + return Channel.GetRemoteSessionId(); + } + catch (Exception exc) + { + Trace.TraceError("Failed to get a remote session id ({0})", exc); + throw; + } + } + } +} \ No newline at end of file diff --git a/Myrtille.Web/src/WebInstaller.cs b/Myrtille.Web/src/WebInstaller.cs index 8dadeaa..c20a5b4 100644 --- a/Myrtille.Web/src/WebInstaller.cs +++ b/Myrtille.Web/src/WebInstaller.cs @@ -105,14 +105,10 @@ public override void Install( } // pdf printer - if (string.IsNullOrEmpty(Context.Parameters["PDFPRINTER"])) + var appSettings = XmlTools.GetNode(navigator, "/configuration/appSettings"); + if (appSettings != null) { - // app settings - var appSettings = XmlTools.GetNode(navigator, "/configuration/appSettings"); - if (appSettings != null) - { - XmlTools.WriteConfigKey(appSettings, "AllowPrintDownload", false.ToString().ToLower()); - } + XmlTools.WriteConfigKey(appSettings, "AllowPrintDownload", (!string.IsNullOrEmpty(Context.Parameters["PDFPRINTER"])).ToString().ToLower()); } // save config