How devolutions/ironrdp works
Project Purpose and Type
• IronRDP is a suite of Rust libraries (crates) that implements various parts of the RDP protocol. It serves both as a full client/server implementation and as lower-level libraries for things like protocol decoding/encoding, connection management, graphics rendering, clipboard redirection, and security (including TLS and CredSSP).
• The project also offers different usage patterns (blocking vs. non-blocking/async) and provides cross-interface support via FFI for integrations (e.g., .NET interop) and a web client (Svelte/JS frontend).
File Structure
• The “crates” directory contains many individual crates that each focus on one aspect of the protocol:
• Core protocol implementations: e.g., ironrdp-core, ironrdp-pdu, ironrdp-error.
• Connection modules: ironrdp-connector, ironrdp-acceptor, ironrdp-session.
• I/O variations: asynchronous (ironrdp-async), blocking (ironrdp-blocking), and tokio-based (ironrdp-tokio).
• Graphics and display modules: ironrdp-graphics, ironrdp-glutin-renderer, ironrdp-displaycontrol.
• Clipboard and multimedia: ironrdp-cliprdr, ironrdp-rdpsnd.
• Testing suites: ironrdp-testsuite-core and ironrdp-testsuite-extra.
• A separate “ffi” directory suggests interoperability layers (e.g., for .NET) and then there is a web-client for the remote GUI.
• Additionally, “xtask” is a custom tooling crate for automation (building, cleaning, versioning, fuzzing, etc.).
Main Components
a. Core Library and Protocol Handling:
– ironrdp-core: The central library for protocol primitives.
– ironrdp-pdu: Handles message encoding/decoding, encapsulating all PDUs.
– ironrdp-error: Central error handling.
b. Connection Handlers:
– ironrdp-connector and ironrdp-acceptor: Manage outbound/inbound connection setup.
– ironrdp-session: Maintains session state, including handshake, active stages, and finalization.
c. Communication Variants:
– Separate async, blocking, and tokio-based modules, which indicate that the project supports both non-blocking/asynchronous and blocking I/O models.
d. Media and Graphics:
– ironrdp-graphics and its sub-components (e.g., displaycontrol, glutin-renderer): Manage the decoding and rendering of graphics updates and handling of video codecs (RFX, raw, RLE, etc.).
e. Additional Functional Modules:
– Clipboard redirection (ironrdp-cliprdr, cliprdr-format, cliprdr-native).
– Audio handling (ironrdp-rdpsnd and its native version).
f. External Integrations and Interfaces:
– FFI layer under “ffi”: Offers bindings for .NET and possibly other languages.
– Web client modules (“web-client”): Split between iron-remote-gui and iron-svelte-client, representing the frontend user interface.
g. Testing and Automation:
– The testsuite crates and “fuzz” directory emphasize testing and fuzzing.
– “xtask” provides command-line operations for building, cleaning, testing, and deploying.
Relationships and Interactions
• That the connection handlers feed into the session management (ironrdp-session) where the handshake and activation occur.
• The graphics/decoder components (ironrdp-graphics, glutin-renderer, etc.) interact with the protocol modules by consuming decoded PDUs (for bitmap updates, pointer movements, etc.) and then rendering them.
• The clipboard, audio, and other peripheral channel modules work in parallel with the primary data stream.
• Integration points: the FFI layer and the web-client are consumers of the core libraries, exposing functionality via a .NET or JavaScript interface.
Architectural Patterns and Technologies
• Modular design: Each functionality is isolated into a separate crate for enhanced reusability and testing.
• Layered architecture: A core layer (protocol, error handling) underpins higher-level modules (session, rendering, channels).
• Support for multiple I/O paradigms (async, blocking, tokio-based): Emphasize separation of concerns within networking.
• Use of Rust’s package and dependency management (Cargo.toml, Cargo.lock) ensures each module’s dependencies are well-contained.
• FFI and Web integration: Illustrate how native Rust libraries interface with other environments (like .NET or JS via WebAssembly).