Skip to content

Commit 892a684

Browse files
rhammonds-teleportmmcallister
authored andcommitted
Upgrade IronRDP Dependency (#59661)
* * Update to latest commit of IronRDP. * resolve conflicting 'getrandom' dependencies. * Add necessary RUSTFLAG env var to ironrdp-wasm compilation. Needed by 'getrandom' dependency to enable its wasm_js feature. * Configure client to use remotefx codec. * Bump rust toolchain version to 1.86.0. * Unset existing rustup overrides before building rdpclient or ironrdp wasm module. * Fix lint warnings after Rust toolchain upgrade. * Simplify BitmapFrame rendering and fix some rendering glitches that were revealed after updating IronRDP * fix typo * Try to determine the active Rust toolchain and print a helpful warning if it does not match the version defined in our toolchain file.
1 parent f6c48ca commit 892a684

File tree

11 files changed

+449
-125
lines changed

11 files changed

+449
-125
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,19 @@ lto = "thin"
2121
[workspace.dependencies]
2222
# Note: To use a local IronRDP repository as a crate (for example, ironrdp-cliprdr), define the dependency as follows:
2323
# ironrdp-cliprdr = { path = "/path/to/local/IronRDP/crates/ironrdp-cliprdr" }
24-
ironrdp-cliprdr = { git = "https://github.com/Devolutions/IronRDP", rev = "dd221bf22401c4635798ec012724cba7e6d503b2" }
25-
ironrdp-connector = { git = "https://github.com/Devolutions/IronRDP", rev = "dd221bf22401c4635798ec012724cba7e6d503b2" }
26-
ironrdp-core = { git = "https://github.com/Devolutions/IronRDP", rev = "dd221bf22401c4635798ec012724cba7e6d503b2" }
27-
ironrdp-displaycontrol = { git = "https://github.com/Devolutions/IronRDP", rev = "dd221bf22401c4635798ec012724cba7e6d503b2" }
28-
ironrdp-dvc = { git = "https://github.com/Devolutions/IronRDP", rev = "dd221bf22401c4635798ec012724cba7e6d503b2" }
29-
ironrdp-graphics = { git = "https://github.com/Devolutions/IronRDP", rev = "dd221bf22401c4635798ec012724cba7e6d503b2" }
30-
ironrdp-pdu = { git = "https://github.com/Devolutions/IronRDP", rev = "dd221bf22401c4635798ec012724cba7e6d503b2" }
31-
ironrdp-rdpdr = { git = "https://github.com/Devolutions/IronRDP", rev = "dd221bf22401c4635798ec012724cba7e6d503b2" }
32-
ironrdp-rdpsnd = { git = "https://github.com/Devolutions/IronRDP", rev = "dd221bf22401c4635798ec012724cba7e6d503b2" }
33-
ironrdp-session = { git = "https://github.com/Devolutions/IronRDP", rev = "dd221bf22401c4635798ec012724cba7e6d503b2" }
34-
ironrdp-svc = { git = "https://github.com/Devolutions/IronRDP", rev = "dd221bf22401c4635798ec012724cba7e6d503b2" }
35-
ironrdp-tls = { git = "https://github.com/Devolutions/IronRDP", rev = "dd221bf22401c4635798ec012724cba7e6d503b2", features = [
24+
ironrdp-cliprdr = { git = "https://github.com/Devolutions/IronRDP", rev = "a0a3e750c9e4ee9c73b957fbcb26dbc59e57d07d" }
25+
ironrdp-connector = { git = "https://github.com/Devolutions/IronRDP", rev = "a0a3e750c9e4ee9c73b957fbcb26dbc59e57d07d" }
26+
ironrdp-core = { git = "https://github.com/Devolutions/IronRDP", rev = "a0a3e750c9e4ee9c73b957fbcb26dbc59e57d07d" }
27+
ironrdp-displaycontrol = { git = "https://github.com/Devolutions/IronRDP", rev = "a0a3e750c9e4ee9c73b957fbcb26dbc59e57d07d" }
28+
ironrdp-dvc = { git = "https://github.com/Devolutions/IronRDP", rev = "a0a3e750c9e4ee9c73b957fbcb26dbc59e57d07d" }
29+
ironrdp-graphics = { git = "https://github.com/Devolutions/IronRDP", rev = "a0a3e750c9e4ee9c73b957fbcb26dbc59e57d07d" }
30+
ironrdp-pdu = { git = "https://github.com/Devolutions/IronRDP", rev = "a0a3e750c9e4ee9c73b957fbcb26dbc59e57d07d" }
31+
ironrdp-rdpdr = { git = "https://github.com/Devolutions/IronRDP", rev = "a0a3e750c9e4ee9c73b957fbcb26dbc59e57d07d" }
32+
ironrdp-rdpsnd = { git = "https://github.com/Devolutions/IronRDP", rev = "a0a3e750c9e4ee9c73b957fbcb26dbc59e57d07d" }
33+
ironrdp-session = { git = "https://github.com/Devolutions/IronRDP", rev = "a0a3e750c9e4ee9c73b957fbcb26dbc59e57d07d" }
34+
ironrdp-svc = { git = "https://github.com/Devolutions/IronRDP", rev = "a0a3e750c9e4ee9c73b957fbcb26dbc59e57d07d" }
35+
ironrdp-tls = { git = "https://github.com/Devolutions/IronRDP", rev = "a0a3e750c9e4ee9c73b957fbcb26dbc59e57d07d", features = [
3636
"rustls",
3737
] }
38-
ironrdp-tokio = { git = "https://github.com/Devolutions/IronRDP", rev = "dd221bf22401c4635798ec012724cba7e6d503b2" }
38+
ironrdp-tokio = { git = "https://github.com/Devolutions/IronRDP", rev = "a0a3e750c9e4ee9c73b957fbcb26dbc59e57d07d" }
39+

Makefile

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ bpf-bytecode:
483483
endif
484484

485485
.PHONY: rdpclient
486-
rdpclient:
486+
rdpclient: rustup-toolchain-warning
487487
ifeq ("$(with_rdpclient)", "yes")
488488
$(RDPCLIENT_ENV) \
489489
cargo build -p rdp-client $(if $(FIPS),--features=fips) --release --locked $(CARGO_TARGET)
@@ -504,7 +504,7 @@ export ironrdp_package_json
504504
.PHONY: build-ironrdp-wasm
505505
build-ironrdp-wasm: ironrdp = web/packages/shared/libs/ironrdp
506506
build-ironrdp-wasm: ensure-wasm-deps
507-
cargo build --package ironrdp --lib --target $(CARGO_WASM_TARGET) --release
507+
RUSTFLAGS='--cfg getrandom_backend="wasm_js"' cargo build --package ironrdp --lib --target $(CARGO_WASM_TARGET) --release
508508
wasm-opt target/$(CARGO_WASM_TARGET)/release/ironrdp.wasm -o target/$(CARGO_WASM_TARGET)/release/ironrdp.wasm -O
509509
wasm-bindgen target/$(CARGO_WASM_TARGET)/release/ironrdp.wasm --out-dir $(ironrdp)/pkg --typescript --target web
510510
printenv ironrdp_package_json > $(ironrdp)/pkg/package.json
@@ -1866,7 +1866,7 @@ ensure-js-deps:
18661866
ifeq ($(WEBASSETS_SKIP_BUILD),1)
18671867
ensure-wasm-deps:
18681868
else
1869-
ensure-wasm-deps: ensure-wasm-bindgen ensure-wasm-opt
1869+
ensure-wasm-deps: rustup-toolchain-warning ensure-wasm-bindgen ensure-wasm-opt
18701870

18711871
WASM_BINDGEN_VERSION = $(shell awk ' \
18721872
$$1 == "name" && $$3 == "\"wasm-bindgen\"" { in_pkg=1; next } \
@@ -1923,6 +1923,26 @@ rustup-set-version: ; # obsoleted by toolchain file
19231923
rustup-install-target-toolchain:
19241924
rustup target add $(RUST_TARGET_ARCH)
19251925

1926+
1927+
define rust_toolchain_warning
1928+
The active Rust toolchain version does not match the toolchain required
1929+
to build Teleport. This is likely caused by a directory override. You
1930+
can inspect your current overrides with 'rustup show active-toolchain'
1931+
and clear directory overrides with 'rustup override unset'
1932+
endef
1933+
export rust_toolchain_warning
1934+
1935+
# inspect the current active toolchain and display a warning if it doesn't
1936+
# match the version defined in our toolchain file.
1937+
.PHONY: rustup-toolchain-warning
1938+
rustup-toolchain-warning: EXPECTED = $(shell $(MAKE) print-rust-toolchain-version)
1939+
rustup-toolchain-warning:
1940+
@if [ "$(shell rustup show active-toolchain | cut -d'-' -f1)" != "$(EXPECTED)" ]; then \
1941+
echo -en "\033[31m";\
1942+
echo "$$rust_toolchain_warning";\
1943+
echo -en "\033[0m";\
1944+
fi
1945+
19261946
# changelog generates PR changelog between the provided base tag and the tip of
19271947
# the specified branch.
19281948
#

lib/srv/desktop/rdp/rdpclient/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ tokio-boring = { git = "https://github.com/gravitational/boring", rev = "9989730
3737
utf16string = "0.2.0"
3838
uuid = { version = "1.16.0", features = ["v4"] }
3939
url = "2.5.7"
40-
picky = { version = "7.0.0-rc.11", default-features = false }
40+
picky = { version = "7.0.0-rc.17", default-features = false }
4141
picky-asn1-der = "0.5.2"
4242
picky-asn1-x509 = "0.14.6"
4343
reqwest = { version = "0.12", default-features = false }

lib/srv/desktop/rdp/rdpclient/src/client.rs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ use ironrdp_pdu::input::fast_path::{
4545
use ironrdp_pdu::input::mouse::PointerFlags;
4646
use ironrdp_pdu::input::{InputEventError, MousePdu};
4747
use ironrdp_pdu::nego::NegoRequestData;
48-
use ironrdp_pdu::rdp::capability_sets::MajorPlatformType;
49-
use ironrdp_pdu::rdp::client_info::PerformanceFlags;
48+
use ironrdp_pdu::rdp::capability_sets::{
49+
client_codecs_capabilities, BitmapCodecs, MajorPlatformType,
50+
};
51+
use ironrdp_pdu::rdp::client_info::{PerformanceFlags, TimezoneInfo};
5052
use ironrdp_pdu::rdp::RdpError;
5153
use ironrdp_pdu::PduError;
5254
use ironrdp_pdu::PduResult;
@@ -60,7 +62,7 @@ use ironrdp_session::SessionErrorKind::Reason;
6062
use ironrdp_session::{reason_err, SessionError, SessionResult};
6163
use ironrdp_svc::{SvcMessage, SvcProcessor, SvcProcessorMessages};
6264
use ironrdp_tokio::{single_sequence_step_read, Framed, FramedWrite, TokioStream};
63-
use log::debug;
65+
use log::{debug, error};
6466
use rand::{Rng, TryRngCore};
6567
use std::error::Error;
6668
use std::fmt::{Debug, Display, Formatter};
@@ -195,11 +197,11 @@ impl Client {
195197
});
196198
let drdynvc_client = DrdynvcClient::new().with_dynamic_channel(display_control);
197199

198-
let mut connector = ironrdp_connector::ClientConnector::new(connector_config.clone())
199-
.with_server_addr(server_socket_addr)
200-
.with_static_channel(drdynvc_client) // require for resizing
201-
.with_static_channel(Rdpsnd::new(Box::new(NoopRdpsndBackend {}))) // required for rdpdr to work
202-
.with_static_channel(rdpdr); // required for smart card + directory sharing
200+
let mut connector =
201+
ironrdp_connector::ClientConnector::new(connector_config.clone(), server_socket_addr)
202+
.with_static_channel(drdynvc_client) // require for resizing
203+
.with_static_channel(Rdpsnd::new(Box::new(NoopRdpsndBackend {}))) // required for rdpdr to work
204+
.with_static_channel(rdpdr); // required for smart card + directory sharing
203205

204206
if params.allow_clipboard {
205207
connector = connector.with_static_channel(Cliprdr::new(Box::new(
@@ -377,7 +379,6 @@ impl Client {
377379
&mut read_stream,
378380
sequence.as_mut(),
379381
&mut buf,
380-
None,
381382
)
382383
.await?;
383384

@@ -671,7 +672,7 @@ impl Client {
671672
event: FastPathInputEvent,
672673
) -> ClientResult<()> {
673674
write_stream
674-
.write_all(&encode_vec(&FastPathInput(vec![event]))?)
675+
.write_all(&encode_vec(&FastPathInput::single(event))?)
675676
.await?;
676677
Ok(())
677678
}
@@ -1387,6 +1388,8 @@ fn create_config(params: &ConnectParams, pin: String, cgo_handle: CgoHandle) ->
13871388
},
13881389
enable_tls: true,
13891390
enable_credssp: params.ad && params.nla,
1391+
enable_audio_playback: false,
1392+
timezone_info: TimezoneInfo::default(),
13901393
credentials: Credentials::SmartCard {
13911394
config: params.ad.then(|| SmartCardIdentity {
13921395
csp_name: "Microsoft Base Smart Card Crypto Provider".to_string(),
@@ -1413,13 +1416,19 @@ fn create_config(params: &ConnectParams, pin: String, cgo_handle: CgoHandle) ->
14131416
// Changing this to 16 gets us uncompressed bitmaps on machines configured like
14141417
// https://github.com/Devolutions/IronRDP/blob/55d11a5000ebd474c2ddc294b8b3935554443112/README.md?plain=1#L17-L36
14151418
color_depth: 32,
1419+
// Try to configure the client to use remotefx only. This should never fail in practice, but just in
1420+
// case we'll log an error and fall back to defaults.
1421+
codecs: client_codecs_capabilities(&["remotefx"]).unwrap_or_else(|err| {
1422+
error!("Failed to configure client for remotefx: {}", err);
1423+
BitmapCodecs::default()
1424+
}),
14161425
}),
14171426
dig_product_id: "".to_string(),
14181427
// `client_dir` is apparently unimportant, however most RDP clients hardcode this value (including FreeRDP):
14191428
// https://github.com/FreeRDP/FreeRDP/blob/4e24b966c86fdf494a782f0dfcfc43a057a2ea60/libfreerdp/core/settings.c#LL49C34-L49C70
14201429
client_dir: "C:\\Windows\\System32\\mstscax.dll".to_string(),
14211430
platform: MajorPlatformType::UNSPECIFIED,
1422-
no_server_pointer: false,
1431+
enable_server_pointer: true,
14231432
autologon: true,
14241433
pointer_software_rendering: false,
14251434
// Send the username in the request cookie, which is sent in the initial connection request.

lib/srv/desktop/rdp/rdpclient/src/cliprdr.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ impl CliprdrBackend for TeleportCliprdrBackend {
6969
".cliprdr"
7070
}
7171

72+
fn on_ready(&mut self) {}
73+
7274
fn client_capabilities(&self) -> ClipboardGeneralCapabilityFlags {
7375
trace!("CLIPRDR: client_capabilities");
7476
ClipboardGeneralCapabilityFlags::USE_LONG_FORMAT_NAMES

lib/srv/desktop/rdp/rdpclient/src/rdpdr/path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl UnixPath {
7575
}
7676

7777
pub fn last(&self) -> Option<&str> {
78-
self.path.split('/').last()
78+
self.path.split('/').next_back()
7979
}
8080
}
8181

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "1.81.0"
2+
channel = "1.86.0"
33
targets = [ "wasm32-unknown-unknown" ]

web/packages/shared/components/CanvasRenderer.tsx

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -231,21 +231,5 @@ function makeBitmapFrameRenderer(
231231
): (frame: BitmapFrame) => void {
232232
const ctx = canvas.getContext('2d');
233233

234-
// Buffered rendering logic
235-
let bitmapBuffer: BitmapFrame[] = [];
236-
const renderBuffer = () => {
237-
if (bitmapBuffer.length) {
238-
for (let i = 0; i < bitmapBuffer.length; i++) {
239-
if (bitmapBuffer[i].image_data.data.length != 0) {
240-
const bmpFrame = bitmapBuffer[i];
241-
ctx.putImageData(bmpFrame.image_data, bmpFrame.left, bmpFrame.top);
242-
}
243-
}
244-
bitmapBuffer = [];
245-
}
246-
requestAnimationFrame(renderBuffer);
247-
};
248-
requestAnimationFrame(renderBuffer);
249-
250-
return frame => bitmapBuffer.push(frame);
234+
return frame => ctx.putImageData(frame.image_data, frame.left, frame.top);
251235
}

web/packages/shared/libs/ironrdp/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ crate-type = ["cdylib"]
1212

1313
[dependencies]
1414
console_error_panic_hook = "0.1.7"
15-
getrandom = { version = "0.2", features = ["js"] }
15+
getrandom1 = { package = "getrandom", version = "0.2", features = ["js"] }
16+
getrandom2 = { package = "getrandom", version = "0.3", features = ["wasm_js"]}
1617
ironrdp-session.workspace = true
1718
ironrdp-pdu.workspace = true
1819
ironrdp-core.workspace = true

0 commit comments

Comments
 (0)