Skip to content

Commit

Permalink
disabled the myrtille application pool recycling
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
cedrozor committed Oct 22, 2018
1 parent 70284ac commit 7df453f
Show file tree
Hide file tree
Showing 24 changed files with 139 additions and 52 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
6 changes: 5 additions & 1 deletion Myrtille.Common/Helpers/IISHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,13 @@ public static bool IsIISApplicationPoolExists(
/// <param name="version"></param>
/// <param name="enable32BitAppOnWin64"></param>
/// <param name="loadUserProfile">true for IIS > 6</param>
/// <param name="allowRecycling">enabled by default on IIS, this operation is destructive (creates a new IIS worker process); among other things, all http sessions are lost!</param>
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);

Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions Myrtille.Common/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
4 changes: 2 additions & 2 deletions Myrtille.Enterprise/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
4 changes: 2 additions & 2 deletions Myrtille.MFAProviders/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
4 changes: 2 additions & 2 deletions Myrtille.Printer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
4 changes: 2 additions & 2 deletions Myrtille.SSH/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
11 changes: 11 additions & 0 deletions Myrtille.Services.Contracts/IRemoteSessionCounter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.ServiceModel;

namespace Myrtille.Services.Contracts
{
[ServiceContract]
public interface IRemoteSessionCounter
{
[OperationContract]
int GetRemoteSessionId();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<Compile Include="IEnterpriseService.cs" />
<Compile Include="IFileStorage.cs" />
<Compile Include="IMFAAuthentication.cs" />
<Compile Include="IRemoteSessionCounter.cs" />
<Compile Include="IPrinterService.cs" />
<Compile Include="IRemoteSessionProcess.cs" />
<Compile Include="Models\EnterpriseAuthenticationErrorHelper.cs" />
Expand Down
4 changes: 2 additions & 2 deletions Myrtille.Services.Contracts/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
1 change: 1 addition & 0 deletions Myrtille.Services/Myrtille.Services.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<Compile Include="EnterpriseService.cs" />
<Compile Include="FileStorage.cs" />
<Compile Include="MFAAuthentication.cs" />
<Compile Include="RemoteSessionCounter.cs" />
<Compile Include="PrinterService.cs" />
<Compile Include="Program.cs">
<SubType>Component</SubType>
Expand Down
8 changes: 8 additions & 0 deletions Myrtille.Services/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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));
Expand All @@ -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);
Expand All @@ -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));
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions Myrtille.Services/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
25 changes: 25 additions & 0 deletions Myrtille.Services/RemoteSessionCounter.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
}
8 changes: 8 additions & 0 deletions Myrtille.Services/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@
<system.serviceModel>

<services>
<service name="Myrtille.Services.RemoteSessionCounter">
<endpoint address="" binding="basicHttpBinding" contract="Myrtille.Services.Contracts.IRemoteSessionCounter"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/Myrtille/RemoteSessionCounter"/>
</baseAddresses>
</host>
</service>
<service name="Myrtille.Services.RemoteSessionProcess">
<endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="wsDualHttpBindingCallback" contract="Myrtille.Services.Contracts.IRemoteSessionProcess"/>
<host>
Expand Down
12 changes: 6 additions & 6 deletions Myrtille.Setup/Myrtille.Setup.vdproj
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion Myrtille.Web/Default.aspx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@

<!-- myrtille version -->
<div id="version">
<a href="http://cedrozor.github.io/myrtille/" title="myrtille">
<a href="http://cedrozor.github.io/myrtille/" target="_blank" title="myrtille">
<img src="img/myrtille.png" alt="myrtille" width="15px" height="15px"/>
</a>
<span>
Expand Down
18 changes: 3 additions & 15 deletions Myrtille.Web/Default.aspx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace Myrtille.Web
{
public partial class Default : Page
{
private RemoteSessionCounterClient _remoteSessionCounterClient;
private MFAAuthenticationClient _mfaAuthClient;
private EnterpriseServiceClient _enterpriseClient;

Expand All @@ -59,6 +60,7 @@ protected void Page_Init(
object sender,
EventArgs e)
{
_remoteSessionCounterClient = new RemoteSessionCounterClient();
_mfaAuthClient = new MFAAuthenticationClient();
_enterpriseClient = new EnterpriseServiceClient();

Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions Myrtille.Web/Global.asax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ namespace Myrtille.Web
public enum HttpApplicationStateVariables
{
Cache,
RemoteSessionsCounter,
SharedRemoteSessions
}

Expand All @@ -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<string, RemoteSession>();
}
Expand Down
1 change: 1 addition & 0 deletions Myrtille.Web/Myrtille.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
<DependentUpon>SocketHandler.ashx</DependentUpon>
</Compile>
<Compile Include="src\EnterpriseServiceClient.cs" />
<Compile Include="src\RemoteSessionCounterClient.cs" />
<Compile Include="src\PrinterServiceClient.cs" />
<Compile Include="src\FileStorageClient.cs" />
<Compile Include="src\MFAAuthenticationClient.cs" />
Expand Down
4 changes: 2 additions & 2 deletions Myrtille.Web/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
3 changes: 2 additions & 1 deletion Myrtille.Web/Web.Base.config
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
<system.serviceModel>

<client>
<endpoint address="http://localhost:8080/Myrtille/RemoteSessionCounter" binding="basicHttpBinding" contract="Myrtille.Services.Contracts.IRemoteSessionCounter"/>
<endpoint address="http://localhost:8080/Myrtille/RemoteSessionProcess" binding="wsDualHttpBinding" bindingConfiguration="wsDualHttpBindingCallback" contract="Myrtille.Services.Contracts.IRemoteSessionProcess"/>
<endpoint address="http://localhost:8080/Myrtille/FileStorage" binding="basicHttpBinding" bindingConfiguration="basicHttpBindingFileStream" contract="Myrtille.Services.Contracts.IFileStorage"/>
<endpoint address="http://localhost:8080/Myrtille/PrinterService" binding="basicHttpBinding" bindingConfiguration="basicHttpBindingFileStream" contract="Myrtille.Services.Contracts.IPrinterService"/>
Expand Down Expand Up @@ -119,7 +120,7 @@
<!-- allow file transfer (requires a domain to be specified on connect) -->
<add key="AllowFileTransfer" value="true"/>
<!-- allow print download (through a pdf virtual printer). requires the "Myrtille PDF" printer to be installed -->
<add key="AllowPrintDownload" value="true"/>
<add key="AllowPrintDownload" value="false"/>
<!-- allow remote session sharing (the session is broadcasted to all guests, as spectators) -->
<add key="AllowSessionSharing" value="true"/>
<!-- client ip protection -->
Expand Down
Loading

0 comments on commit 7df453f

Please sign in to comment.