mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
added class for testing rdp version suppport
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace mRemoteNG.Connection.Protocol.RDP
|
||||
{
|
||||
@@ -22,4 +23,19 @@ namespace mRemoteNG.Connection.Protocol.RDP
|
||||
Rdc9,
|
||||
Rdc10
|
||||
}
|
||||
|
||||
public static class RdpVersionEnumExtensions
|
||||
{
|
||||
public static IEnumerable<RdpVersionEnum> GetAll(this RdpVersionEnum versionEnum)
|
||||
{
|
||||
return new[]
|
||||
{
|
||||
RdpVersionEnum.Rdc6,
|
||||
RdpVersionEnum.Rdc7,
|
||||
RdpVersionEnum.Rdc8,
|
||||
RdpVersionEnum.Rdc9,
|
||||
RdpVersionEnum.Rdc10
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace mRemoteNG.Connection.Protocol.RDP
|
||||
public RdpProtocol10()
|
||||
{
|
||||
Control = new AxMsRdpClient10NotSafeForScripting();
|
||||
RdpVersionEnum = RdpVersionEnum.Rdc10;
|
||||
}
|
||||
|
||||
protected override MsRdpClient6NotSafeForScripting CreateRdpClientControl()
|
||||
|
||||
@@ -77,15 +77,18 @@ namespace mRemoteNG.Connection.Protocol.RDP
|
||||
}
|
||||
|
||||
public bool LoadBalanceInfoUseUtf8 { get; set; }
|
||||
#endregion
|
||||
|
||||
public RdpVersionEnum RdpVersionEnum { get; protected set; }
|
||||
|
||||
#endregion
|
||||
|
||||
public RdpProtocol6()
|
||||
{
|
||||
Control = new AxMsRdpClient6NotSafeForScripting();
|
||||
Connecting += OnConnectingDebugMessage;
|
||||
RdpVersionEnum = RdpVersionEnum.Rdc6;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region Public Methods
|
||||
public override bool Initialize()
|
||||
@@ -554,7 +557,8 @@ namespace mRemoteNG.Connection.Protocol.RDP
|
||||
|
||||
private void OnConnectingDebugMessage(object sender, EventArgs args)
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, $"Using RDP version: {ConnectionInfo.RdpProtocolVersion}");
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.DebugMsg,
|
||||
$"Connection requested RDP version: '{ConnectionInfo.RdpProtocolVersion}'. Using RDP provider: '{sender.GetType().Name}'");
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace mRemoteNG.Connection.Protocol.RDP
|
||||
public RdpProtocol7()
|
||||
{
|
||||
Control = new AxMsRdpClient7NotSafeForScripting();
|
||||
RdpVersionEnum = RdpVersionEnum.Rdc7;
|
||||
}
|
||||
|
||||
protected override MsRdpClient6NotSafeForScripting CreateRdpClientControl()
|
||||
|
||||
@@ -42,7 +42,8 @@ namespace mRemoteNG.Connection.Protocol.RDP
|
||||
public RdpProtocol8()
|
||||
{
|
||||
Control = new AxMsRdpClient8NotSafeForScripting();
|
||||
}
|
||||
RdpVersionEnum = RdpVersionEnum.Rdc8;
|
||||
}
|
||||
|
||||
public override bool Initialize()
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace mRemoteNG.Connection.Protocol.RDP
|
||||
public RdpProtocol9()
|
||||
{
|
||||
Control = new AxMsRdpClient9NotSafeForScripting();
|
||||
RdpVersionEnum = RdpVersionEnum.Rdc9;
|
||||
}
|
||||
|
||||
protected override MsRdpClient6NotSafeForScripting CreateRdpClientControl()
|
||||
|
||||
@@ -2,12 +2,17 @@
|
||||
{
|
||||
public class RdpProtocolFactory
|
||||
{
|
||||
public ProtocolBase CreateProtocol(ConnectionInfo connectionInfo)
|
||||
public ProtocolBase CreateProtocol(ConnectionInfo connectionInfo)
|
||||
{
|
||||
return CreateProtocol(connectionInfo.RdpProtocolVersion);
|
||||
}
|
||||
|
||||
public ProtocolBase CreateProtocol(RdpVersionEnum version)
|
||||
{
|
||||
RdpProtocol6 newProtocol = null;
|
||||
|
||||
// ReSharper disable once SwitchStatementMissingSomeCases
|
||||
switch (connectionInfo.RdpProtocolVersion)
|
||||
switch (version)
|
||||
{
|
||||
case RdpVersionEnum.Rdc6:
|
||||
newProtocol = new RdpProtocol6();
|
||||
|
||||
46
mRemoteV1/Connection/Protocol/RDP/RdpSupportTester.cs
Normal file
46
mRemoteV1/Connection/Protocol/RDP/RdpSupportTester.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace mRemoteNG.Connection.Protocol.RDP
|
||||
{
|
||||
public class RdpSupportTester
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns a list of the RDP versions that can be used on the current
|
||||
/// host.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<RdpVersionEnum> GetSupportedRdpVersions()
|
||||
{
|
||||
var supportedVersions = new List<RdpVersionEnum>();
|
||||
var rdpFactory = new RdpProtocolFactory();
|
||||
|
||||
foreach (var version in RdpVersionEnum.Rdc6.GetAll())
|
||||
{
|
||||
var protocol = rdpFactory.CreateProtocol(version);
|
||||
if (RdpClientIsSupported(protocol))
|
||||
supportedVersions.Add(version);
|
||||
}
|
||||
|
||||
return supportedVersions;
|
||||
}
|
||||
|
||||
private bool RdpClientIsSupported(ProtocolBase rdpProtocol)
|
||||
{
|
||||
try
|
||||
{
|
||||
rdpProtocol.Initialize();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
rdpProtocol.Close();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -252,6 +252,7 @@
|
||||
<Compile Include="Connection\Protocol\RDP\RdpProtocol8.cs" />
|
||||
<Compile Include="Connection\Protocol\RDP\RdpProtocol9.cs" />
|
||||
<Compile Include="Connection\Protocol\RDP\RdpProtocolFactory.cs" />
|
||||
<Compile Include="Connection\Protocol\RDP\RdpSupportTester.cs" />
|
||||
<Compile Include="Connection\Protocol\VNC\VNCEnum.cs" />
|
||||
<Compile Include="Connection\WebHelper.cs" />
|
||||
<Compile Include="Credential\PlaceholderCredentialRecord.cs" />
|
||||
|
||||
Reference in New Issue
Block a user