Skip to content

Commit

Permalink
Adds the extended keycode where appropriate and updates to the latest…
Browse files Browse the repository at this point in the history
… IronRDP master commit hash. (#37962)

* Adds the extended keycode where appropriate and updates to the latest IronRDP master commit hash.

* cleaning up disconnect result

* Pipes disconnect messages through to the client.

This required a change to the state management for DesktopSession. State
is still quite complex to get right here, but this is a step in the right
direction.

* Updates desktopPlaybackHandle to the new authenticated websocket paradigm as it was forgotten in #37520

* prettier formatting

* adding clarifying comments

* Further refactoring to make DesktopSession's state machine more comprehensible

* Remove unnecessary items from dependency lists
  • Loading branch information
Isaiah Becker-Mayer committed Feb 27, 2024
1 parent 7b7abee commit f21f2e2
Show file tree
Hide file tree
Showing 17 changed files with 839 additions and 554 deletions.
24 changes: 12 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ codegen-units = 1
[workspace.dependencies]
# Note: To use a local IronRDP repository as a crate (for example, ironrdp-cliprdr), define the dependency as follows:
# ironrdp-cliprdr = { path = "/path/to/local/IronRDP/crates/ironrdp-cliprdr" }
ironrdp-cliprdr = { git = "https://github.com/Devolutions/IronRDP", rev = "d24000a2aeab74f2610a0b01c629f7a4ef3c77ef" }
ironrdp-connector = { git = "https://github.com/Devolutions/IronRDP", rev = "d24000a2aeab74f2610a0b01c629f7a4ef3c77ef" }
ironrdp-graphics = { git = "https://github.com/Devolutions/IronRDP", rev = "d24000a2aeab74f2610a0b01c629f7a4ef3c77ef" }
ironrdp-pdu = { git = "https://github.com/Devolutions/IronRDP", rev = "d24000a2aeab74f2610a0b01c629f7a4ef3c77ef" }
ironrdp-rdpdr = { git = "https://github.com/Devolutions/IronRDP", rev = "d24000a2aeab74f2610a0b01c629f7a4ef3c77ef" }
ironrdp-rdpsnd = { git = "https://github.com/Devolutions/IronRDP", rev = "d24000a2aeab74f2610a0b01c629f7a4ef3c77ef" }
ironrdp-session = { git = "https://github.com/Devolutions/IronRDP", rev = "d24000a2aeab74f2610a0b01c629f7a4ef3c77ef" }
ironrdp-svc = { git = "https://github.com/Devolutions/IronRDP", rev = "d24000a2aeab74f2610a0b01c629f7a4ef3c77ef" }
ironrdp-tls = { git = "https://github.com/Devolutions/IronRDP", rev = "d24000a2aeab74f2610a0b01c629f7a4ef3c77ef", features = ["rustls"]}
ironrdp-tokio = { git = "https://github.com/Devolutions/IronRDP", rev = "d24000a2aeab74f2610a0b01c629f7a4ef3c77ef" }
ironrdp-cliprdr = { git = "https://github.com/Devolutions/IronRDP", rev = "c944674ecbb0952f9e7ecb964a6c79cdca669a08" }
ironrdp-connector = { git = "https://github.com/Devolutions/IronRDP", rev = "c944674ecbb0952f9e7ecb964a6c79cdca669a08" }
ironrdp-graphics = { git = "https://github.com/Devolutions/IronRDP", rev = "c944674ecbb0952f9e7ecb964a6c79cdca669a08" }
ironrdp-pdu = { git = "https://github.com/Devolutions/IronRDP", rev = "c944674ecbb0952f9e7ecb964a6c79cdca669a08" }
ironrdp-rdpdr = { git = "https://github.com/Devolutions/IronRDP", rev = "c944674ecbb0952f9e7ecb964a6c79cdca669a08" }
ironrdp-rdpsnd = { git = "https://github.com/Devolutions/IronRDP", rev = "c944674ecbb0952f9e7ecb964a6c79cdca669a08" }
ironrdp-session = { git = "https://github.com/Devolutions/IronRDP", rev = "c944674ecbb0952f9e7ecb964a6c79cdca669a08" }
ironrdp-svc = { git = "https://github.com/Devolutions/IronRDP", rev = "c944674ecbb0952f9e7ecb964a6c79cdca669a08" }
ironrdp-tls = { git = "https://github.com/Devolutions/IronRDP", rev = "c944674ecbb0952f9e7ecb964a6c79cdca669a08", features = ["rustls"]}
ironrdp-tokio = { git = "https://github.com/Devolutions/IronRDP", rev = "c944674ecbb0952f9e7ecb964a6c79cdca669a08" }
40 changes: 34 additions & 6 deletions lib/srv/desktop/rdp/rdpclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import "C"

import (
"context"
"fmt"
"os"
"runtime/cgo"
"sync"
Expand Down Expand Up @@ -263,6 +264,10 @@ func (c *Client) readClientSize() error {
}
}

func (c *Client) sendTDPNotification(message string, severity tdp.Severity) error {
return c.cfg.Conn.WriteMessage(tdp.Notification{Message: message, Severity: severity})
}

func (c *Client) startRustRDP(ctx context.Context) error {
c.cfg.Log.Info("Rust RDP loop starting")
defer c.cfg.Log.Info("Rust RDP loop finished")
Expand Down Expand Up @@ -292,7 +297,7 @@ func (c *Client) startRustRDP(ctx context.Context) error {
return trace.BadParameter("user key was nil")
}

if res := C.client_run(
res := C.client_run(
C.uintptr_t(c.handle),
C.CGOConnectParams{
go_addr: addr,
Expand All @@ -308,14 +313,37 @@ func (c *Client) startRustRDP(ctx context.Context) error {
allow_directory_sharing: C.bool(c.cfg.AllowDirectorySharing),
show_desktop_wallpaper: C.bool(c.cfg.ShowDesktopWallpaper),
},
); res.err_code != C.ErrCodeSuccess {
if res.message == nil {
return trace.Errorf("unknown error: %v", res.err_code)
}
)

var message string
if res.message != nil {
message = C.GoString(res.message)
defer C.free_string(res.message)
return trace.Errorf("%s", C.GoString(res.message))
}

// If the client exited with an error, send a tdp error notification and return it.
if res.err_code != C.ErrCodeSuccess {
var err error

if message != "" {
err = trace.Errorf("RDP client exited with an error: %v", message)
} else {
err = trace.Errorf("RDP client exited with an unknown error")
}

c.sendTDPNotification(err.Error(), tdp.SeverityError)
return err
}

if message != "" {
message = fmt.Sprintf("RDP client exited gracefully with message: %v", message)
} else {
message = "RDP client exited gracefully"
}

c.cfg.Log.Info(message)
c.sendTDPNotification(message, tdp.SeverityInfo)

return nil
}

Expand Down
Loading

0 comments on commit f21f2e2

Please sign in to comment.