-
Notifications
You must be signed in to change notification settings - Fork 301
fix(client): answer auto-detect requests on the UDP tunnel #2009
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AKolenda
wants to merge
12
commits into
Devolutions:master
Choose a base branch
from
AKolenda:fix/rdpeudp-tunnel-autodetect
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,291
−112
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
27bddf6
feat(rdpeudp): carry tunnel sub-headers through the UDP transport
glamberson 505914b
test(rdpeudp): use a real Bandwidth Measure Start's sub-header data
glamberson 72705d9
review: drop the unused Default derive and correct the FramedRead com…
glamberson efe1777
review: pin the send_message header bound to the TunnelData encoder
glamberson f4ca57f
feat(session): answer bandwidth measurements during the session
82d8103
refactor(session): answer auto-detect requests through one responder
2898221
refactor(session): tidy the bandwidth responder
3fc5c27
fix(client): answer auto-detect requests on the UDP tunnel
aca65e9
test(client): run the tunnel auto-detect tests in CI
4ff2b8e
fix(client): handle tunnel auto-detect failures and byte accounting
a97dde1
fix(session): count complete bandwidth frames and reject untimed esti…
33080ea
test(client): verify tunnel fallback and complete frame accounting
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| //! Internal client handling for a reliable UDP tunnel. | ||
|
|
||
| use ironrdp_core::{Decode, Encode}; | ||
| use ironrdp_pdu::rdp::autodetect::{AutoDetectRequest, AutoDetectResponse}; | ||
| use ironrdp_rdpemt::{SubHeaderType, TunnelSubHeader}; | ||
| use ironrdp_rdpeudp_tokio::UdpTransport; | ||
| use ironrdp_session::{ActiveStage, SessionError, SessionResult}; | ||
| use tracing::{debug, warn}; | ||
|
|
||
| /// Decodes the auto-detect requests among the sub-headers of a Tunnel Data PDU. | ||
| /// | ||
| /// Each sub-header is the request structure itself: SubHeaderLength and SubHeaderType | ||
| /// are headerLength and headerTypeId ([MS-RDPEMT] 2.2.1.1.1). Unknown requests are skipped. | ||
| /// RTT requests are accepted for Windows interoperability in addition to the bandwidth | ||
| /// requests listed by MS-RDPEMT; RTT encapsulation on a tunnel is not specified there. | ||
| /// | ||
| /// [MS-RDPEMT]: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpemt/4f538fd7-3aca-4e7d-a213-13eb5f95c1ad | ||
| pub fn tunnel_auto_detect_requests(sub_headers: &[TunnelSubHeader]) -> Vec<AutoDetectRequest> { | ||
| sub_headers | ||
| .iter() | ||
| .filter(|sub_header| sub_header.sub_header_type == SubHeaderType::AutoDetectRequest) | ||
| .filter_map(|sub_header| match redecode(sub_header) { | ||
| Ok(request) => Some(request), | ||
| Err(error) => { | ||
| debug!(%error, data = ?sub_header.data, "Ignoring an undecodable auto-detect request on the tunnel"); | ||
| None | ||
| } | ||
| }) | ||
| .collect() | ||
| } | ||
|
|
||
| /// Encodes a response as its wire-compatible tunnel sub-header. | ||
| pub fn tunnel_auto_detect_sub_header(response: &AutoDetectResponse) -> Option<TunnelSubHeader> { | ||
| match redecode(response) { | ||
| Ok(sub_header) => Some(sub_header), | ||
| Err(error) => { | ||
| debug!(%error, ?response, "Could not encode an auto-detect response for the tunnel"); | ||
| None | ||
| } | ||
| } | ||
| } | ||
|
|
||
| fn redecode<T: for<'de> Decode<'de>>(value: &dyn Encode) -> Result<T, String> { | ||
| let bytes = ironrdp_core::encode_vec(value).map_err(|error| error.to_string())?; | ||
| ironrdp_core::decode(&bytes).map_err(|error| error.to_string()) | ||
| } | ||
|
|
||
| /// Drops a failed sideband and withdraws it from future Soft-Sync negotiation. | ||
| /// A channel already moved to the tunnel cannot resume over TCP without reconnecting. | ||
| /// Both receive closure and auto-detect send failures use this policy. | ||
| pub fn disable_failed_tunnel( | ||
| stage: &mut ActiveStage, | ||
| transport: &mut Option<UdpTransport>, | ||
| error: SessionError, | ||
| ) -> SessionResult<()> { | ||
| if stage.reliable_udp_dvc_tunnel_in_use() { | ||
| return Err(error); | ||
| } | ||
| *transport = None; | ||
| stage.disable_reliable_udp_dvc_tunnel()?; | ||
| warn!(%error, "Reliable UDP tunnel failed before channel migration; continuing with TCP"); | ||
| Ok(()) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.