Skip to content

Commit 4277e8e

Browse files
rebase origin/master
1 parent 9c99133 commit 4277e8e

39 files changed

+1929
-56
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ironrdp/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ dvc = ["dep:ironrdp-dvc"]
3131
rdpdr = ["dep:ironrdp-rdpdr"]
3232
rdpsnd = ["dep:ironrdp-rdpsnd"]
3333
displaycontrol = ["dep:ironrdp-displaycontrol"]
34+
rdcleanpath = ["dep:ironrdp-rdcleanpath"]
3435
# Internal (PRIVATE!) features used to aid testing.
3536
# Don't rely on these whatsoever. They may disappear at any time.
3637
__bench = ["ironrdp-server/__bench"]
@@ -50,6 +51,7 @@ ironrdp-dvc = { path = "../ironrdp-dvc", version = "0.3", optional = true } # pu
5051
ironrdp-rdpdr = { path = "../ironrdp-rdpdr", version = "0.3", optional = true } # public
5152
ironrdp-rdpsnd = { path = "../ironrdp-rdpsnd", version = "0.5", optional = true } # public
5253
ironrdp-displaycontrol = { path = "../ironrdp-displaycontrol", version = "0.3", optional = true } # public
54+
ironrdp-rdcleanpath = { path = "../ironrdp-rdcleanpath", version = "0.1", optional = true } # public
5355

5456
[dev-dependencies]
5557
ironrdp-blocking = { path = "../ironrdp-blocking", version = "0.5.0" }

crates/ironrdp/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,7 @@ pub use ironrdp_session as session;
6363
#[cfg(feature = "svc")]
6464
#[doc(inline)]
6565
pub use ironrdp_svc as svc;
66+
67+
#[cfg(feature = "rdcleanpath")]
68+
#[doc(inline)]
69+
pub use ironrdp_rdcleanpath as rdclean_path;

ffi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ doctest = false
1414
[dependencies]
1515
diplomat = "0.7"
1616
diplomat-runtime = "0.7"
17-
ironrdp = { path = "../crates/ironrdp", features = ["session", "connector", "dvc", "svc", "rdpdr", "rdpsnd", "graphics", "input", "cliprdr", "displaycontrol"] }
17+
ironrdp = { path = "../crates/ironrdp", features = ["session", "connector", "dvc", "svc", "rdpdr", "rdpsnd", "graphics", "input", "cliprdr", "displaycontrol","rdcleanpath"] }
1818
ironrdp-cliprdr-native.path = "../crates/ironrdp-cliprdr-native"
1919
ironrdp-core = { path = "../crates/ironrdp-core", features = ["alloc"] }
2020
sspi = { version = "0.15", features = ["network_client"] }

ffi/dotnet/Devolutions.IronRdp.AvaloniaExample/MainWindow.axaml.cs

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System;
88
using System.ComponentModel;
99
using System.Diagnostics;
10+
using System.IO;
1011
using System.Net.Security;
1112
using System.Runtime.CompilerServices;
1213
using System.Runtime.InteropServices;
@@ -22,7 +23,7 @@ public partial class MainWindow : Window
2223
readonly InputDatabase? _inputDatabase = InputDatabase.New();
2324
ActiveStage? _activeStage;
2425
DecodedImage? _decodedImage;
25-
Framed<SslStream>? _framed;
26+
Framed<Stream>? _framed;
2627
WinCliprdr? _cliprdr;
2728
private readonly RendererModel _renderModel;
2829
private Image? _imageControl;
@@ -79,8 +80,10 @@ private void OnOpened(object? sender, EventArgs e)
7980
var password = Environment.GetEnvironmentVariable("IRONRDP_PASSWORD");
8081
var domain = Environment.GetEnvironmentVariable("IRONRDP_DOMAIN");
8182
var server = Environment.GetEnvironmentVariable("IRONRDP_SERVER");
83+
var wsProxy = Environment.GetEnvironmentVariable("IRONRDP_PROXY");
84+
var wsProxyToken = Environment.GetEnvironmentVariable("IRONRDP_PROXY_TOKEN");
8285

83-
if (username == null || password == null || domain == null || server == null)
86+
if (username == null || password == null || server == null)
8487
{
8588
var errorMessage =
8689
"Please set the IRONRDP_USERNAME, IRONRDP_PASSWORD, IRONRDP_DOMAIN, and RONRDP_SERVER environment variables";
@@ -106,15 +109,41 @@ private void OnOpened(object? sender, EventArgs e)
106109
BeforeConnectSetup();
107110
Task.Run(async () =>
108111
{
109-
var (res, framed) = await Connection.Connect(config, server, factory);
110-
this._decodedImage = DecodedImage.New(PixelFormat.RgbA32, res.GetDesktopSize().GetWidth(),
111-
res.GetDesktopSize().GetHeight());
112-
this._activeStage = ActiveStage.New(res);
113-
this._framed = framed;
114-
ReadPduAndProcessActiveStage();
115-
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
112+
try
113+
{
114+
115+
ConnectionResult res;
116+
Framed<Stream> framed;
117+
//wsProxy = null;
118+
if (wsProxy != null && wsProxyToken != null)
119+
{
120+
Debug.WriteLine("Connecting via WebSocket proxy");
121+
(res, framed) = await Connection.ConnectWs(
122+
config,
123+
new RdcleanPathConfig(new Uri(wsProxy), wsProxyToken),
124+
server,
125+
factory);
126+
}
127+
else
128+
{
129+
Debug.WriteLine("Connecting directly to server");
130+
(res, framed) = await Connection.Connect(config, server, factory);
131+
}
132+
Debug.WriteLine("Connection success");
133+
this._decodedImage = DecodedImage.New(PixelFormat.RgbA32, res.GetDesktopSize().GetWidth(),
134+
res.GetDesktopSize().GetHeight());
135+
this._activeStage = ActiveStage.New(res);
136+
this._framed = framed;
137+
ReadPduAndProcessActiveStage();
138+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
139+
{
140+
HandleClipboardEvents();
141+
}
142+
}
143+
catch (Exception e)
116144
{
117-
HandleClipboardEvents();
145+
Debug.WriteLine(e);
146+
this.Close();
118147
}
119148
});
120149
}
@@ -260,12 +289,17 @@ private void HandleClipboardEvents()
260289
});
261290
}
262291

263-
private static Config BuildConfig(string username, string password, string domain, int width, int height)
292+
private static Config BuildConfig(string username, string password, string? domain, int width, int height)
264293
{
265294
ConfigBuilder configBuilder = ConfigBuilder.New();
266295

267296
configBuilder.WithUsernameAndPassword(username, password);
268-
configBuilder.SetDomain(domain);
297+
if (domain != null)
298+
{
299+
configBuilder.SetDomain(domain);
300+
}
301+
configBuilder.SetEnableCredssp(true);
302+
configBuilder.SetEnableTls(true);
269303
configBuilder.SetDesktopSize((ushort)height, (ushort)width);
270304
configBuilder.SetClientName("IronRdp");
271305
configBuilder.SetClientDir("C:\\");
@@ -395,6 +429,7 @@ private async Task<bool> HandleActiveStageOutput(ActiveStageOutputIterator outpu
395429
var output =
396430
outputIterator
397431
.Next()!; // outputIterator.Next() is not null since outputIterator.IsEmpty() is false
432+
Debug.WriteLine($"Output type: {output.GetType()}, Output enum type : {output.GetEnumType()}");
398433
if (output.GetEnumType() == ActiveStageOutputType.Terminate)
399434
{
400435
return false;
@@ -418,7 +453,7 @@ private async Task<bool> HandleActiveStageOutput(ActiveStageOutputIterator outpu
418453
var writeBuf = WriteBuf.New();
419454
while (true)
420455
{
421-
await Connection.SingleSequenceStep(activationSequence, writeBuf,_framed!);
456+
await Connection.SingleSequenceStep(activationSequence, writeBuf, _framed!);
422457

423458
if (activationSequence.GetState().GetType() != ConnectionActivationStateType.Finalized)
424459
continue;

ffi/dotnet/Devolutions.IronRdp.ConnectExample/Devolutions.IronRdp.ConnectExample.csproj

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,19 @@
1919
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.7" />
2020
</ItemGroup>
2121

22+
<ItemGroup>
23+
<Compile Update="Properties\Resources.Designer.cs">
24+
<DesignTime>True</DesignTime>
25+
<AutoGen>True</AutoGen>
26+
<DependentUpon>Resources.resx</DependentUpon>
27+
</Compile>
28+
</ItemGroup>
29+
30+
<ItemGroup>
31+
<EmbeddedResource Update="Properties\Resources.resx">
32+
<Generator>ResXFileCodeGenerator</Generator>
33+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
34+
</EmbeddedResource>
35+
</ItemGroup>
36+
2237
</Project>

ffi/dotnet/Devolutions.IronRdp.ConnectExample/Program.cs

Lines changed: 56 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using SixLabors.ImageSharp;
1+
using System.Diagnostics;
2+
using SixLabors.ImageSharp;
23
using SixLabors.ImageSharp.PixelFormats;
34

45
namespace Devolutions.IronRdp.ConnectExample
@@ -19,11 +20,30 @@ static async Task Main(string[] args)
1920
var serverName = arguments["--serverName"];
2021
var username = arguments["--username"];
2122
var password = arguments["--password"];
22-
var domain = arguments["--domain"];
23+
arguments.TryGetValue("--domain", out var domain);
24+
arguments.TryGetValue("--proxy", out var wsProxy);
25+
arguments.TryGetValue("--proxyToken", out var wsProxyToken);
2326

2427
try
2528
{
26-
var (res, framed) = await Connection.Connect(buildConfig(serverName, username, password, domain, 1980, 1080), serverName, null);
29+
ConnectionResult res;
30+
Framed<Stream> framed;
31+
if (wsProxyToken != null && wsProxy != null)
32+
{
33+
(res, framed) = await Connection.ConnectWs(
34+
buildConfig(serverName, username, password, domain, 1980, 1080),
35+
new RdcleanPathConfig(new Uri(wsProxy), wsProxyToken),
36+
serverName,
37+
null);
38+
}
39+
else
40+
{
41+
(res, framed) = await Connection.Connect(
42+
buildConfig(serverName, username, password, domain, 1980, 1080),
43+
serverName,
44+
null);
45+
}
46+
2747
var decodedImage = DecodedImage.New(PixelFormat.RgbA32, res.GetDesktopSize().GetWidth(), res.GetDesktopSize().GetHeight());
2848
var activeState = ActiveStage.New(res);
2949
var keepLooping = true;
@@ -37,22 +57,22 @@ static async Task Main(string[] args)
3757
var pduReadTask = await readPduTask;
3858
action = pduReadTask.Item1;
3959
payload = pduReadTask.Item2;
40-
Console.WriteLine($"Action: {action}");
60+
Debug.WriteLine($"Action: {action}");
4161
}
4262
else
4363
{
44-
Console.WriteLine("Timeout");
64+
Debug.WriteLine("Timeout");
4565
break;
4666
}
4767
var outputIterator = activeState.Process(decodedImage, action, payload);
4868

4969
while (!outputIterator.IsEmpty())
5070
{
5171
var output = outputIterator.Next()!; // outputIterator.Next() is not null since outputIterator.IsEmpty() is false
52-
Console.WriteLine($"Output type: {output.GetType()}");
72+
Debug.WriteLine($"Output type: {output.GetType()}, Output enum type : {output.GetEnumType()}");
5373
if (output.GetEnumType() == ActiveStageOutputType.Terminate)
5474
{
55-
Console.WriteLine("Connection terminated.");
75+
Debug.WriteLine("Connection terminated.");
5676
keepLooping = false;
5777
}
5878

@@ -66,8 +86,7 @@ static async Task Main(string[] args)
6686
}
6787
}
6888

69-
saveImage(decodedImage, "output.png");
70-
89+
saveImage(decodedImage, "C:\\dev\\IronRDP\\output.bmp");
7190
}
7291
catch (Exception e)
7392
{
@@ -104,7 +123,7 @@ private static void saveImage(DecodedImage decodedImage, string v)
104123
}
105124

106125
// Save the image as bitmap.
107-
image.Save("./output.bmp");
126+
image.Save(v);
108127
}
109128

110129
static Dictionary<string, string>? ParseArguments(string[] args)
@@ -134,6 +153,10 @@ private static void saveImage(DecodedImage decodedImage, string v)
134153
return null;
135154
}
136155
lastKey = arg;
156+
}
157+
else if (arg == "\\" || arg == "//")
158+
{
159+
137160
}
138161
else
139162
{
@@ -160,34 +183,48 @@ private static void saveImage(DecodedImage decodedImage, string v)
160183

161184
static bool IsValidArgument(string argument)
162185
{
163-
var validArguments = new List<string> { "--serverName", "--username", "--password", "--domain" };
186+
var validArguments = new List<string>
187+
{
188+
"--serverName",
189+
"--username",
190+
"--password",
191+
"--domain",
192+
"--proxy",
193+
"--proxyToken"
194+
};
164195
return validArguments.Contains(argument);
165196
}
166197

167198
static void PrintHelp()
168199
{
169200
Console.WriteLine("Usage: dotnet run -- [OPTIONS]");
170201
Console.WriteLine("Options:");
171-
Console.WriteLine(" --serverName <serverName> The name of the server to connect to.");
172-
Console.WriteLine(" --username <username> The username for connection.");
173-
Console.WriteLine(" --password <password> The password for connection.");
174-
Console.WriteLine(" --domain <domain> The domain of the server.");
175-
Console.WriteLine(" --help Show this message and exit.");
202+
Console.WriteLine(" --serverName <serverName> The name of the server to connect to.");
203+
Console.WriteLine(" --username <username> The username for connection.");
204+
Console.WriteLine(" --password <password> The password for connection.");
205+
Console.WriteLine(" --domain <domain> The domain of the server.");
206+
Console.WriteLine(" --proxy <url> WebSocket proxy URL.");
207+
Console.WriteLine(" --proxyToken <token> Authentication token for the proxy.");
208+
Console.WriteLine(" --help Show this message and exit.");
176209
}
177210

178-
private static Config buildConfig(string servername, string username, string password, string domain, int width, int height)
211+
private static Config buildConfig(string servername, string username, string password, string? domain, int width, int height)
179212
{
180213
ConfigBuilder configBuilder = ConfigBuilder.New();
181214

182215
configBuilder.WithUsernameAndPassword(username, password);
183-
configBuilder.SetDomain(domain);
216+
if (domain != null)
217+
{
218+
configBuilder.SetDomain(domain);
219+
}
220+
configBuilder.SetEnableCredssp(true);
221+
configBuilder.SetEnableTls(true);
184222
configBuilder.SetDesktopSize((ushort)height, (ushort)width);
185223
configBuilder.SetClientName("IronRdp");
186224
configBuilder.SetClientDir("C:\\");
187225
configBuilder.SetPerformanceFlags(PerformanceFlags.NewDefault());
188226

189227
return configBuilder.Build();
190228
}
191-
192229
}
193230
}

ffi/dotnet/Devolutions.IronRdp.ConnectExample/Properties/Resources.Designer.cs

Lines changed: 63 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)