Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Cargo.lock

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

62 changes: 0 additions & 62 deletions crates/ironrdp-mstsgu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,63 +16,6 @@ categories.workspace = true
doctest = false
test = false

[[test]]
name = "http_auth"
path = "tests/http_auth.rs"
required-features = ["native-tls"]

[[test]]
name = "udp"
path = "tests/udp.rs"

[[test]]
name = "http_control"
path = "tests/http_control.rs"

[[test]]
name = "rpc_pdu"
path = "tests/rpc_pdu.rs"

[[test]]
name = "rpch_v2"
path = "tests/rpch_v2.rs"

[[test]]
name = "rpc_tsgu_stubs"
path = "tests/rpc_tsgu_stubs.rs"

[[test]]
name = "rpch_http"
path = "tests/rpch_http.rs"

[[test]]
name = "rpch_session"
path = "tests/rpch_session.rs"

[[test]]
name = "tunnel_policy"
path = "tests/tunnel_policy.rs"

[[test]]
name = "packet_io"
path = "tests/packet_io.rs"
required-features = ["native-tls", "test-support"]

[[test]]
name = "packet_io_rustls"
path = "tests/packet_io_rustls.rs"
required-features = ["rustls", "test-support"]

[[test]]
name = "proxy"
path = "tests/proxy.rs"
required-features = ["native-tls", "test-support"]

[[test]]
name = "consent"
path = "tests/consent.rs"
required-features = ["native-tls", "test-support"]

[features]
default = []
rustls = ["ironrdp-tls/rustls", "tokio-tungstenite/rustls-tls-native-roots"]
Expand Down Expand Up @@ -107,10 +50,5 @@ picky = { version = "=7.0.0-rc.25", optional = true }
picky-asn1-der = { version = "0.5", optional = true }
picky-asn1-x509 = { version = "0.15", optional = true }

[dev-dependencies]
hyper = { version = "1.9", features = ["server", "http1"] }
tokio = { version = "1.52", features = ["io-util", "macros", "net", "rt", "sync"] }
tokio-native-tls = "0.3"

[lints]
workspace = true
3 changes: 0 additions & 3 deletions crates/ironrdp-mstsgu/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#![cfg_attr(doc, doc = include_str!("../README.md"))]
#![doc(html_logo_url = "https://cdnweb.devolutions.net/images/projects/devolutions/logos/devolutions-icon-shadow.svg")]

#[cfg(test)]
use tokio_native_tls as _;

#[macro_use]
mod macros;

Expand Down
42 changes: 29 additions & 13 deletions crates/ironrdp-mstsgu/src/proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,16 @@ impl Encode for HandshakeReqPkt {

/// 2.2.10.11 HTTP_HANDSHAKE_RESPONSE_PACKET Structure
#[derive(Debug)]
pub(crate) struct HandshakeRespPkt {
pub error_code: u32,
pub ver_major: u8,
pub ver_minor: u8,
pub server_version: u16,
pub extended_auth: HttpExtendedAuth,
#[cfg_attr(
not(feature = "test-support"),
expect(unreachable_pub, reason = "exposed only through test-support")
)]
pub struct HandshakeRespPkt {
pub(crate) error_code: u32,
pub(crate) ver_major: u8,
pub(crate) ver_minor: u8,
pub(crate) server_version: u16,
pub(crate) extended_auth: HttpExtendedAuth,
}

impl HandshakeRespPkt {
Expand All @@ -193,11 +197,15 @@ const HTTP_TUNNEL_PACKET_FIELD_REAUTH: u16 = 0x2;

/// 2.2.10.18 HTTP_TUNNEL_PACKET
#[derive(Default)]
pub(crate) struct TunnelReqPkt {
pub caps: u32,
pub fields_present: u16,
pub _reserved: u16,
pub reauth_tunnel_context: Option<u64>,
#[cfg_attr(
not(feature = "test-support"),
expect(unreachable_pub, reason = "exposed only through test-support")
)]
pub struct TunnelReqPkt {
pub(crate) caps: u32,
pub(crate) fields_present: u16,
pub(crate) _reserved: u16,
pub(crate) reauth_tunnel_context: Option<u64>,
}

impl Encode for TunnelReqPkt {
Expand Down Expand Up @@ -344,7 +352,11 @@ impl Decode<'_> for TunnelRespPkt {

/// 2.2.10.7 HTTP_EXTENDED_AUTH_PACKET Structure
#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct ExtendedAuthPkt {
#[cfg_attr(
not(feature = "test-support"),
expect(unreachable_pub, reason = "exposed only through test-support")
)]
pub struct ExtendedAuthPkt {
pub(crate) error_code: u32,
pub(crate) auth_blob: Vec<u8>,
}
Expand Down Expand Up @@ -444,7 +456,11 @@ const HTTP_TUNNEL_AUTH_RESPONSE_FIELD_SOH_RESPONSE: u16 = 0x4;
/// [2.2.10.16]: https://winprotocoldocs-bhdugrdyduf5h2e4.b02.azurefd.net/MS-TSGU/%5bMS-TSGU%5d.pdf#page=70
/// [2.2.10.17]: https://winprotocoldocs-bhdugrdyduf5h2e4.b02.azurefd.net/MS-TSGU/%5bMS-TSGU%5d.pdf#page=70
#[derive(Debug, Default)]
pub(crate) struct TunnelAuthRespPkt {
#[cfg_attr(
not(feature = "test-support"),
expect(unreachable_pub, reason = "exposed only through test-support")
)]
pub struct TunnelAuthRespPkt {
pub(crate) error_code: u32,
fields_present: u16,
_reserved: u16,
Expand Down
45 changes: 45 additions & 0 deletions crates/ironrdp-mstsgu/src/test_support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,51 @@ use crate::packet_io::{
};
use crate::{ConsentFallback, Error, GwClient, GwConnectTarget, GwConsentCallback};

/// Test-only constructors and accessors for internal MS-TSGU protocol packets.
pub mod proto {
pub use crate::proto::{ExtendedAuthPkt, HandshakeRespPkt, TunnelAuthRespPkt, TunnelReqPkt};

/// Constructs an HTTP tunnel request packet.
pub fn tunnel_request(caps: u32, fields_present: u16, reauth_tunnel_context: Option<u64>) -> TunnelReqPkt {
TunnelReqPkt {
caps,
fields_present,
_reserved: 0,
reauth_tunnel_context,
}
}

/// Constructs an HTTP extended authentication packet.
pub fn extended_auth_packet(error_code: u32, auth_blob: Vec<u8>) -> ExtendedAuthPkt {
ExtendedAuthPkt { error_code, auth_blob }
}

/// Returns the advertised HTTP extended-authentication flags.
pub fn handshake_extended_auth_bits(packet: &HandshakeRespPkt) -> u16 {
packet.extended_auth.bits()
}

/// Returns the bit representation for no HTTP extended authentication.
pub const fn no_extended_auth_bits() -> u16 {
0
}

/// Returns tunnel authorization redirection flags.
pub fn tunnel_auth_response_redirection_flags(packet: &TunnelAuthRespPkt) -> Option<u32> {
packet.redirection_flags
}

/// Returns tunnel authorization idle timeout in minutes.
pub fn tunnel_auth_response_idle_timeout_minutes(packet: &TunnelAuthRespPkt) -> Option<u32> {
packet.idle_timeout_minutes
}

/// Returns the tunnel authorization statement-of-health response.
pub fn tunnel_auth_response_soh_response(packet: &TunnelAuthRespPkt) -> Option<&[u8]> {
packet.soh_response.as_deref()
}
}

/// In-memory gateway transport used by the registered integration tests.
pub struct GatewayTransport(NetworkGatewayTransport);

Expand Down
Loading
Loading