mirror of
https://github.com/Devolutions/IronRDP.git
synced 2025-07-07 17:45:01 +00:00
fix: unnecessary qualification
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
934177d772
commit
adf2797ef7
37 changed files with 94 additions and 100 deletions
|
@ -66,7 +66,7 @@ impl Acceptor {
|
|||
}
|
||||
|
||||
pub fn get_result(&mut self) -> Option<AcceptorResult> {
|
||||
match std::mem::take(&mut self.state) {
|
||||
match mem::take(&mut self.state) {
|
||||
AcceptorState::Accepted {
|
||||
channels: _channels, // TODO: what about ChannelDef?
|
||||
client_capabilities,
|
||||
|
@ -201,7 +201,7 @@ impl Sequence for Acceptor {
|
|||
}
|
||||
|
||||
fn step(&mut self, input: &[u8], output: &mut WriteBuf) -> ConnectorResult<Written> {
|
||||
let (written, next_state) = match std::mem::take(&mut self.state) {
|
||||
let (written, next_state) = match mem::take(&mut self.state) {
|
||||
AcceptorState::InitiationWaitRequest => {
|
||||
let connection_request = decode::<nego::ConnectionRequest>(input).map_err(ConnectorError::pdu)?;
|
||||
|
||||
|
@ -375,7 +375,7 @@ impl Sequence for Acceptor {
|
|||
early_capability,
|
||||
channels,
|
||||
} => {
|
||||
let data: pdu::mcs::SendDataRequest<'_> = decode(input).map_err(ConnectorError::pdu)?;
|
||||
let data: mcs::SendDataRequest<'_> = decode(input).map_err(ConnectorError::pdu)?;
|
||||
let client_info: rdp::ClientInfoPdu = decode(data.user_data.as_ref()).map_err(ConnectorError::pdu)?;
|
||||
|
||||
debug!(message = ?client_info, "Received");
|
||||
|
@ -418,14 +418,12 @@ impl Sequence for Acceptor {
|
|||
let demand_active = rdp::headers::ShareControlHeader {
|
||||
share_id: 0,
|
||||
pdu_source: self.io_channel_id,
|
||||
share_control_pdu: rdp::headers::ShareControlPdu::ServerDemandActive(
|
||||
rdp::capability_sets::ServerDemandActive {
|
||||
pdu: rdp::capability_sets::DemandActive {
|
||||
source_descriptor: "".into(),
|
||||
capability_sets: self.server_capabilities.clone(),
|
||||
},
|
||||
share_control_pdu: ShareControlPdu::ServerDemandActive(rdp::capability_sets::ServerDemandActive {
|
||||
pdu: rdp::capability_sets::DemandActive {
|
||||
source_descriptor: "".into(),
|
||||
capability_sets: self.server_capabilities.clone(),
|
||||
},
|
||||
),
|
||||
}),
|
||||
};
|
||||
|
||||
debug!(message = ?demand_active, "Send");
|
||||
|
@ -546,7 +544,7 @@ fn create_gcc_blocks(
|
|||
requested: nego::SecurityProtocol,
|
||||
skip_channel_join: bool,
|
||||
) -> gcc::ServerGccBlocks {
|
||||
pdu::gcc::ServerGccBlocks {
|
||||
gcc::ServerGccBlocks {
|
||||
core: gcc::ServerCoreData {
|
||||
version: gcc::RdpVersion::V5_PLUS,
|
||||
optional_data: gcc::ServerCoreOptionalData {
|
||||
|
|
|
@ -210,7 +210,7 @@ fn create_control_confirm(user_id: u16) -> rdp::headers::ShareDataPdu {
|
|||
rdp::headers::ShareDataPdu::Control(rdp::finalization_messages::ControlPdu {
|
||||
action: rdp::finalization_messages::ControlAction::GrantedControl,
|
||||
grant_id: user_id,
|
||||
control_id: u32::from(pdu::rdp::capability_sets::SERVER_CHANNEL_ID),
|
||||
control_id: u32::from(rdp::capability_sets::SERVER_CHANNEL_ID),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -221,7 +221,7 @@ async fn active_session(
|
|||
active_stage.graceful_shutdown()?
|
||||
}
|
||||
RdpInputEvent::Clipboard(event) => {
|
||||
if let Some(cliprdr) = active_stage.get_svc_processor::<ironrdp::cliprdr::CliprdrClient>() {
|
||||
if let Some(cliprdr) = active_stage.get_svc_processor::<cliprdr::CliprdrClient>() {
|
||||
if let Some(svc_messages) = match event {
|
||||
ClipboardMessage::SendInitiateCopy(formats) => {
|
||||
Some(cliprdr.initiate_copy(&formats)
|
||||
|
|
|
@ -17,7 +17,7 @@ impl_pdu_pod!(Capabilities);
|
|||
|
||||
impl Capabilities {
|
||||
const NAME: &'static str = "CLIPRDR_CAPS";
|
||||
const FIXED_PART_SIZE: usize = std::mem::size_of::<u16>() * 2;
|
||||
const FIXED_PART_SIZE: usize = 2 /* capsLen */ + 2 /* padding */;
|
||||
|
||||
fn inner_size(&self) -> usize {
|
||||
Self::FIXED_PART_SIZE + self.capabilities.iter().map(|c| c.size()).sum::<usize>()
|
||||
|
@ -113,7 +113,7 @@ impl_pdu_pod!(CapabilitySet);
|
|||
|
||||
impl CapabilitySet {
|
||||
const NAME: &'static str = "CLIPRDR_CAPS_SET";
|
||||
const FIXED_PART_SIZE: usize = std::mem::size_of::<u16>() * 2;
|
||||
const FIXED_PART_SIZE: usize = 2 /* type */ + 2 /* len */;
|
||||
|
||||
const CAPSTYPE_GENERAL: u16 = 0x0001;
|
||||
|
||||
|
@ -187,7 +187,7 @@ pub struct GeneralCapabilitySet {
|
|||
|
||||
impl GeneralCapabilitySet {
|
||||
const NAME: &'static str = "CLIPRDR_GENERAL_CAPABILITY";
|
||||
const FIXED_PART_SIZE: usize = std::mem::size_of::<u32>() * 2;
|
||||
const FIXED_PART_SIZE: usize = 4 /* version */ + 4 /* flags */;
|
||||
}
|
||||
|
||||
impl PduEncode for GeneralCapabilitySet {
|
||||
|
|
|
@ -50,7 +50,7 @@ impl IntoOwnedPdu for FileContentsResponse<'_> {
|
|||
|
||||
impl<'a> FileContentsResponse<'a> {
|
||||
const NAME: &'static str = "CLIPRDR_FILECONTENTS_RESPONSE";
|
||||
const FIXED_PART_SIZE: usize = std::mem::size_of::<u32>();
|
||||
const FIXED_PART_SIZE: usize = 4 /* streamId */;
|
||||
|
||||
fn inner_size(&self) -> usize {
|
||||
Self::FIXED_PART_SIZE + self.data.len()
|
||||
|
@ -170,11 +170,11 @@ pub struct FileContentsRequest {
|
|||
|
||||
impl FileContentsRequest {
|
||||
const NAME: &'static str = "CLIPRDR_FILECONTENTS_REQUEST";
|
||||
const FIXED_PART_SIZE: usize = std::mem::size_of::<u32>() * 4 + std::mem::size_of::<u64>();
|
||||
const FIXED_PART_SIZE: usize = 4 /* streamId */ + 4 /* idx */ + 4 /* flags */ + 8 /* position */ + 4 /* reqSize */;
|
||||
|
||||
fn inner_size(&self) -> usize {
|
||||
let data_id_size = match self.data_id {
|
||||
Some(_) => std::mem::size_of::<u32>(),
|
||||
Some(_) => 4,
|
||||
None => 0,
|
||||
};
|
||||
|
||||
|
@ -222,7 +222,7 @@ impl<'de> PduDecode<'de> for FileContentsRequest {
|
|||
|
||||
let mut expected_size = Self::FIXED_PART_SIZE;
|
||||
if read_data_id {
|
||||
expected_size += std::mem::size_of::<u32>();
|
||||
expected_size += 4;
|
||||
}
|
||||
|
||||
ensure_size!(in: src, size: expected_size);
|
||||
|
|
|
@ -165,7 +165,7 @@ impl_pdu_pod!(PackedFileList);
|
|||
|
||||
impl PackedFileList {
|
||||
const NAME: &'static str = "CLIPRDR_FILELIST";
|
||||
const FIXED_PART_SIZE: usize = std::mem::size_of::<u32>(); // file count
|
||||
const FIXED_PART_SIZE: usize = 4; // file count
|
||||
}
|
||||
|
||||
impl PduEncode for PackedFileList {
|
||||
|
|
|
@ -46,7 +46,7 @@ pub struct PackedMetafile<'a> {
|
|||
|
||||
impl PackedMetafile<'_> {
|
||||
const NAME: &'static str = "CLIPRDR_MFPICT";
|
||||
const FIXED_PART_SIZE: usize = std::mem::size_of::<u32>() * 3;
|
||||
const FIXED_PART_SIZE: usize = 4 /* mode */ + 4 /* xExt */ + 4 /* yExt */;
|
||||
|
||||
pub fn new(
|
||||
mapping_mode: PackedMetafileMappingMode,
|
||||
|
|
|
@ -222,7 +222,7 @@ pub struct FormatDataRequest {
|
|||
|
||||
impl FormatDataRequest {
|
||||
const NAME: &'static str = "CLIPRDR_FORMAT_DATA_REQUEST";
|
||||
const FIXED_PART_SIZE: usize = std::mem::size_of::<u32>();
|
||||
const FIXED_PART_SIZE: usize = 4 /* format */;
|
||||
}
|
||||
|
||||
impl PduEncode for FormatDataRequest {
|
||||
|
|
|
@ -11,7 +11,7 @@ pub struct PaletteEntry {
|
|||
}
|
||||
|
||||
impl PaletteEntry {
|
||||
const SIZE: usize = std::mem::size_of::<u8>() * 4;
|
||||
const SIZE: usize = 1 /* R */ + 1 /* G */ + 1 /* B */ + 1 /* extra */;
|
||||
}
|
||||
|
||||
/// Represents `CLIPRDR_PALETTE`
|
||||
|
|
|
@ -234,7 +234,7 @@ impl FormatList<'_> {
|
|||
const NAME: &'static str = "CLIPRDR_FORMAT_LIST";
|
||||
|
||||
// `CLIPRDR_SHORT_FORMAT_NAME` size
|
||||
const SHORT_FORMAT_SIZE: usize = std::mem::size_of::<u32>() + 32;
|
||||
const SHORT_FORMAT_SIZE: usize = 4 /* formatId */ + 32 /* name */;
|
||||
|
||||
fn new_impl(formats: &[ClipboardFormat], use_long_format: bool, use_ascii: bool) -> PduResult<Self> {
|
||||
let charset = if use_ascii {
|
||||
|
@ -273,7 +273,7 @@ impl FormatList<'_> {
|
|||
}
|
||||
};
|
||||
|
||||
let required_size = std::mem::size_of::<u32>() + encoded_string.len();
|
||||
let required_size = 4 + encoded_string.len();
|
||||
if buffer.len() - bytes_written < required_size {
|
||||
buffer.resize(bytes_written + required_size, 0);
|
||||
}
|
||||
|
@ -331,7 +331,7 @@ impl FormatList<'_> {
|
|||
|
||||
if use_long_format {
|
||||
// Minimal `CLIPRDR_LONG_FORMAT_NAME` size (id + null-terminated name)
|
||||
const MINIMAL_FORMAT_SIZE: usize = std::mem::size_of::<u32>() + std::mem::size_of::<u16>();
|
||||
const MINIMAL_FORMAT_SIZE: usize = 4 /* id */ + 2 /* null-terminated name */;
|
||||
|
||||
let mut formats = Vec::with_capacity(16);
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ impl_pdu_pod!(LockDataId);
|
|||
|
||||
impl LockDataId {
|
||||
const NAME: &'static str = "CLIPRDR_(UN)LOCK_CLIPDATA";
|
||||
const FIXED_PART_SIZE: usize = std::mem::size_of::<u32>();
|
||||
const FIXED_PART_SIZE: usize = 4 /* Id */;
|
||||
}
|
||||
|
||||
impl PduEncode for LockDataId {
|
||||
|
|
|
@ -45,7 +45,7 @@ struct PartialHeader {
|
|||
|
||||
impl PartialHeader {
|
||||
const NAME: &'static str = "CLIPRDR_HEADER";
|
||||
const FIXED_PART_SIZE: usize = std::mem::size_of::<u16>() + std::mem::size_of::<u32>();
|
||||
const FIXED_PART_SIZE: usize = 2 /* flags */ + 4 /* len */;
|
||||
const SIZE: usize = Self::FIXED_PART_SIZE;
|
||||
|
||||
pub(crate) fn new(inner_data_length: u32) -> Self {
|
||||
|
@ -115,7 +115,7 @@ pub enum ClipboardPdu<'a> {
|
|||
|
||||
impl ClipboardPdu<'_> {
|
||||
const NAME: &'static str = "ClipboardPdu";
|
||||
const FIXED_PART_SIZE: usize = std::mem::size_of::<u16>();
|
||||
const FIXED_PART_SIZE: usize = 2 /* type */;
|
||||
|
||||
pub fn message_name(&self) -> &'static str {
|
||||
match self {
|
||||
|
|
|
@ -590,7 +590,7 @@ pub fn encode_send_data_request<T: PduEncode>(
|
|||
) -> ConnectorResult<usize> {
|
||||
let user_data = encode_vec(user_msg).map_err(ConnectorError::pdu)?;
|
||||
|
||||
let pdu = ironrdp_pdu::mcs::SendDataRequest {
|
||||
let pdu = mcs::SendDataRequest {
|
||||
initiator_id,
|
||||
channel_id,
|
||||
user_data: Cow::Owned(user_data),
|
||||
|
|
|
@ -119,7 +119,7 @@ impl Sequence for ConnectionActivationSequence {
|
|||
};
|
||||
|
||||
for c in &capability_sets {
|
||||
if let rdp::capability_sets::CapabilitySet::General(g) = c {
|
||||
if let CapabilitySet::General(g) = c {
|
||||
if g.protocol_version != rdp::capability_sets::PROTOCOL_VER {
|
||||
warn!(version = g.protocol_version, "Unexpected protocol version");
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ impl Sequence for ConnectionActivationSequence {
|
|||
let desktop_size = capability_sets
|
||||
.iter()
|
||||
.find_map(|c| match c {
|
||||
rdp::capability_sets::CapabilitySet::Bitmap(b) => Some(DesktopSize {
|
||||
CapabilitySet::Bitmap(b) => Some(DesktopSize {
|
||||
width: b.desktop_width,
|
||||
height: b.desktop_height,
|
||||
}),
|
||||
|
|
|
@ -44,7 +44,7 @@ const CREDSSP_TS_REQUEST_HINT: CredsspTsRequestHint = CredsspTsRequestHint;
|
|||
|
||||
impl PduHint for CredsspTsRequestHint {
|
||||
fn find_size(&self, bytes: &[u8]) -> ironrdp_pdu::PduResult<Option<usize>> {
|
||||
match sspi::credssp::TsRequest::read_length(bytes) {
|
||||
match credssp::TsRequest::read_length(bytes) {
|
||||
Ok(length) => Ok(Some(length)),
|
||||
Err(e) if e.kind() == std::io::ErrorKind::UnexpectedEof => Ok(None),
|
||||
Err(e) => Err(ironrdp_pdu::custom_err!("CredsspTsRequestHint", e)),
|
||||
|
@ -59,7 +59,7 @@ const CREDSSP_EARLY_USER_AUTH_RESULT_HINT: CredsspEarlyUserAuthResultHint = Cred
|
|||
|
||||
impl PduHint for CredsspEarlyUserAuthResultHint {
|
||||
fn find_size(&self, _: &[u8]) -> ironrdp_pdu::PduResult<Option<usize>> {
|
||||
Ok(Some(sspi::credssp::EARLY_USER_AUTH_RESULT_PDU_SIZE))
|
||||
Ok(Some(credssp::EARLY_USER_AUTH_RESULT_PDU_SIZE))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ impl CredsspSequence {
|
|||
}
|
||||
debug!(?credssp_config);
|
||||
|
||||
let client = credssp::CredSspClient::new(
|
||||
let client = CredSspClient::new(
|
||||
server_public_key,
|
||||
credentials.into(),
|
||||
credssp::CredSspMode::WithCredentials,
|
||||
|
@ -190,8 +190,8 @@ impl CredsspSequence {
|
|||
let (size, next_state) = match self.state {
|
||||
CredsspState::Ongoing => {
|
||||
let (ts_request_from_client, next_state) = match result {
|
||||
credssp::ClientState::ReplyNeeded(ts_request) => (ts_request, CredsspState::Ongoing),
|
||||
credssp::ClientState::FinalMessage(ts_request) => (
|
||||
ClientState::ReplyNeeded(ts_request) => (ts_request, CredsspState::Ongoing),
|
||||
ClientState::FinalMessage(ts_request) => (
|
||||
ts_request,
|
||||
if self.selected_protocol.contains(nego::SecurityProtocol::HYBRID_EX) {
|
||||
CredsspState::EarlyUserAuthResult
|
||||
|
|
|
@ -150,7 +150,7 @@ pub struct Config {
|
|||
|
||||
ironrdp_pdu::assert_impl!(Config: Send, Sync);
|
||||
|
||||
pub trait State: Send + core::fmt::Debug + 'static {
|
||||
pub trait State: Send + fmt::Debug + 'static {
|
||||
fn name(&self) -> &'static str;
|
||||
fn is_terminal(&self) -> bool;
|
||||
fn as_any(&self) -> &dyn Any;
|
||||
|
|
|
@ -132,7 +132,7 @@ impl Sequence for LicenseExchangeSequence {
|
|||
)
|
||||
}
|
||||
Err(error) => {
|
||||
if let server_license::ServerLicenseError::InvalidX509Certificate {
|
||||
if let ServerLicenseError::InvalidX509Certificate {
|
||||
source: error,
|
||||
cert_der,
|
||||
} = &error
|
||||
|
|
|
@ -79,13 +79,13 @@ pub fn encode_dvc_messages(
|
|||
.ok_or_else(|| other_err!("encode_dvc_messages", "overflow occurred"))?;
|
||||
|
||||
let pdu = if needs_splitting && first {
|
||||
pdu::DrdynvcDataPdu::DataFirst(pdu::DataFirstPdu::new(
|
||||
DrdynvcDataPdu::DataFirst(pdu::DataFirstPdu::new(
|
||||
channel_id,
|
||||
cast_length!("total_length", total_length)?,
|
||||
msg[off..end].to_vec(),
|
||||
))
|
||||
} else {
|
||||
pdu::DrdynvcDataPdu::Data(pdu::DataPdu::new(channel_id, msg[off..end].to_vec()))
|
||||
DrdynvcDataPdu::Data(pdu::DataPdu::new(channel_id, msg[off..end].to_vec()))
|
||||
};
|
||||
|
||||
let svc = SvcMessage::from(pdu).with_flags(flags);
|
||||
|
|
|
@ -148,7 +148,7 @@ impl SvcProcessor for DrdynvcServer {
|
|||
}
|
||||
c.state = ChannelState::Opened;
|
||||
let msg = c.processor.start(create_resp.channel_id)?;
|
||||
resp.extend(encode_dvc_messages(id, msg, ironrdp_svc::ChannelFlags::SHOW_PROTOCOL)?);
|
||||
resp.extend(encode_dvc_messages(id, msg, ChannelFlags::SHOW_PROTOCOL)?);
|
||||
}
|
||||
DrdynvcClientPdu::Close(close_resp) => {
|
||||
debug!("Got DVC Close Response PDU: {close_resp:?}");
|
||||
|
@ -166,11 +166,7 @@ impl SvcProcessor for DrdynvcServer {
|
|||
}
|
||||
if let Some(complete) = c.complete_data.process_data(data)? {
|
||||
let msg = c.processor.process(channel_id, &complete)?;
|
||||
resp.extend(encode_dvc_messages(
|
||||
channel_id,
|
||||
msg,
|
||||
ironrdp_svc::ChannelFlags::SHOW_PROTOCOL,
|
||||
)?);
|
||||
resp.extend(encode_dvc_messages(channel_id, msg, ChannelFlags::SHOW_PROTOCOL)?);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ impl<Kind> Error<Kind> {
|
|||
#[cfg(feature = "alloc")]
|
||||
{
|
||||
let mut this = self;
|
||||
this.source = Some(alloc::boxed::Box::new(source));
|
||||
this.source = Some(Box::new(source));
|
||||
this
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ pub struct BitmapUpdateData<'a> {
|
|||
|
||||
impl BitmapUpdateData<'_> {
|
||||
const NAME: &'static str = "TS_UPDATE_BITMAP_DATA";
|
||||
const FIXED_PART_SIZE: usize = core::mem::size_of::<u16>() * 2;
|
||||
const FIXED_PART_SIZE: usize = 2 /* flags */ + 2 /* nrect */;
|
||||
}
|
||||
|
||||
impl BitmapUpdateData<'_> {
|
||||
|
@ -97,7 +97,7 @@ pub struct BitmapData<'a> {
|
|||
|
||||
impl BitmapData<'_> {
|
||||
const NAME: &'static str = "TS_BITMAP_DATA";
|
||||
const FIXED_PART_SIZE: usize = InclusiveRectangle::ENCODED_SIZE + core::mem::size_of::<u16>() * 5;
|
||||
const FIXED_PART_SIZE: usize = InclusiveRectangle::ENCODED_SIZE + 2 /* width */ + 2 /* height */ + 2 /* bpp */ + 2 /* flags */ + 2 /* len */;
|
||||
|
||||
fn encoded_bitmap_data_length(&self) -> usize {
|
||||
self.bitmap_data.len() + self.compressed_data_header.as_ref().map(|hdr| hdr.size()).unwrap_or(0)
|
||||
|
@ -207,7 +207,7 @@ pub struct CompressedDataHeader {
|
|||
|
||||
impl CompressedDataHeader {
|
||||
const NAME: &'static str = "TS_CD_HEADER";
|
||||
const FIXED_PART_SIZE: usize = core::mem::size_of::<u16>() * 4;
|
||||
const FIXED_PART_SIZE: usize = 2 /* row_size */ + 2 /* body_size */ + 2 /* scan_width */ + 2 /* uncompressed_size */;
|
||||
|
||||
pub const ENCODED_SIZE: usize = Self::FIXED_PART_SIZE;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ pub struct FastPathHeader {
|
|||
|
||||
impl FastPathHeader {
|
||||
const NAME: &'static str = "TS_FP_UPDATE_PDU header";
|
||||
const FIXED_PART_SIZE: usize = std::mem::size_of::<EncryptionFlags>();
|
||||
const FIXED_PART_SIZE: usize = 1 /* EncryptionFlags */;
|
||||
|
||||
pub fn new(flags: EncryptionFlags, data_length: usize) -> Self {
|
||||
Self {
|
||||
|
@ -117,7 +117,7 @@ pub struct FastPathUpdatePdu<'a> {
|
|||
|
||||
impl FastPathUpdatePdu<'_> {
|
||||
const NAME: &'static str = "TS_FP_UPDATE";
|
||||
const FIXED_PART_SIZE: usize = std::mem::size_of::<u8>();
|
||||
const FIXED_PART_SIZE: usize = 1 /* header */;
|
||||
}
|
||||
|
||||
impl PduEncode for FastPathUpdatePdu<'_> {
|
||||
|
@ -152,13 +152,9 @@ impl PduEncode for FastPathUpdatePdu<'_> {
|
|||
}
|
||||
|
||||
fn size(&self) -> usize {
|
||||
let compression_flags_size = if self.compression_flags.is_some() {
|
||||
std::mem::size_of::<u8>()
|
||||
} else {
|
||||
0
|
||||
};
|
||||
let compression_flags_size = if self.compression_flags.is_some() { 1 } else { 0 };
|
||||
|
||||
Self::FIXED_PART_SIZE + compression_flags_size + std::mem::size_of::<u16>() + self.data.len()
|
||||
Self::FIXED_PART_SIZE + compression_flags_size + 2 /* len */ + self.data.len()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -179,7 +175,7 @@ impl<'de> PduDecode<'de> for FastPathUpdatePdu<'de> {
|
|||
let compression = Compression::from_bits_truncate(header.get_bits(6..8));
|
||||
|
||||
let (compression_flags, compression_type) = if compression.contains(Compression::COMPRESSION_USED) {
|
||||
let expected_size = std::mem::size_of::<u8>() + std::mem::size_of::<u16>();
|
||||
let expected_size = 1 /* flags_with_type */ + 2 /* len */;
|
||||
ensure_size!(in: src, size: expected_size);
|
||||
|
||||
let compression_flags_with_type = src.read_u8();
|
||||
|
@ -191,7 +187,7 @@ impl<'de> PduDecode<'de> for FastPathUpdatePdu<'de> {
|
|||
|
||||
(Some(compression_flags), Some(compression_type))
|
||||
} else {
|
||||
let expected_size = std::mem::size_of::<u16>();
|
||||
let expected_size = 2 /* len */;
|
||||
ensure_size!(in: src, size: expected_size);
|
||||
|
||||
(None, None)
|
||||
|
|
|
@ -10,7 +10,7 @@ pub struct Point16 {
|
|||
|
||||
impl Point16 {
|
||||
const NAME: &'static str = "TS_POINT16";
|
||||
const FIXED_PART_SIZE: usize = core::mem::size_of::<u16>() * 2;
|
||||
const FIXED_PART_SIZE: usize = 2 /* x */ + 2 /* y */;
|
||||
}
|
||||
|
||||
impl PduEncode for Point16 {
|
||||
|
@ -59,7 +59,8 @@ pub struct ColorPointerAttribute<'a> {
|
|||
|
||||
impl ColorPointerAttribute<'_> {
|
||||
const NAME: &'static str = "TS_COLORPOINTERATTRIBUTE";
|
||||
const FIXED_PART_SIZE: usize = core::mem::size_of::<u16>() * 5 + Point16::FIXED_PART_SIZE;
|
||||
const FIXED_PART_SIZE: usize =
|
||||
2 /* cacheIdx */ + 2 /* width */ + 2 /* height */ + 2 /* lenAnd */ + 2 /* lenOr */ + Point16::FIXED_PART_SIZE;
|
||||
|
||||
fn check_masks_alignment(and_mask: &[u8], xor_mask: &[u8], pointer_height: u16, large_ptr: bool) -> PduResult<()> {
|
||||
const AND_MASK_SIZE_FIELD: &str = "lengthAndMask";
|
||||
|
@ -162,7 +163,7 @@ pub struct PointerAttribute<'a> {
|
|||
|
||||
impl PointerAttribute<'_> {
|
||||
const NAME: &'static str = "TS_POINTERATTRIBUTE";
|
||||
const FIXED_PART_SIZE: usize = core::mem::size_of::<u16>();
|
||||
const FIXED_PART_SIZE: usize = 2 /* xorBpp */;
|
||||
}
|
||||
|
||||
impl PduEncode for PointerAttribute<'_> {
|
||||
|
@ -203,7 +204,7 @@ pub struct CachedPointerAttribute {
|
|||
|
||||
impl CachedPointerAttribute {
|
||||
const NAME: &'static str = "TS_CACHEDPOINTERATTRIBUTE";
|
||||
const FIXED_PART_SIZE: usize = core::mem::size_of::<u16>();
|
||||
const FIXED_PART_SIZE: usize = 2 /* cacheIdx */;
|
||||
}
|
||||
|
||||
impl PduEncode for CachedPointerAttribute {
|
||||
|
@ -249,7 +250,8 @@ pub struct LargePointerAttribute<'a> {
|
|||
impl LargePointerAttribute<'_> {
|
||||
const NAME: &'static str = "TS_FP_LARGEPOINTERATTRIBUTE";
|
||||
const FIXED_PART_SIZE: usize =
|
||||
core::mem::size_of::<u32>() * 2 + core::mem::size_of::<u16>() * 4 + core::mem::size_of::<Point16>();
|
||||
2 /* xorBpp */ + 2 /* cacheIdx */ + 4 /* hotSpot */ + 2 /* width */ + 2 /* height */ +
|
||||
4 /* andMaskLen */ + 4 /* xorMaskLen */;
|
||||
}
|
||||
|
||||
impl PduEncode for LargePointerAttribute<'_> {
|
||||
|
|
|
@ -21,7 +21,7 @@ pub enum SurfaceCommand<'a> {
|
|||
|
||||
impl SurfaceCommand<'_> {
|
||||
const NAME: &'static str = "TS_SURFCMD";
|
||||
const FIXED_PART_SIZE: usize = std::mem::size_of::<u16>();
|
||||
const FIXED_PART_SIZE: usize = 2 /* cmdType */;
|
||||
}
|
||||
|
||||
impl PduEncode for SurfaceCommand<'_> {
|
||||
|
@ -117,7 +117,7 @@ pub struct FrameMarkerPdu {
|
|||
|
||||
impl FrameMarkerPdu {
|
||||
const NAME: &'static str = "TS_FRAME_MARKER_PDU";
|
||||
const FIXED_PART_SIZE: usize = core::mem::size_of::<u16>() + core::mem::size_of::<u32>();
|
||||
const FIXED_PART_SIZE: usize = 2 /* frameAction */ + 4 /* frameId */;
|
||||
}
|
||||
|
||||
impl PduEncode for FrameMarkerPdu {
|
||||
|
@ -141,7 +141,7 @@ impl PduEncode for FrameMarkerPdu {
|
|||
|
||||
impl<'de> PduDecode<'de> for FrameMarkerPdu {
|
||||
fn decode(src: &mut ReadCursor<'de>) -> PduResult<Self> {
|
||||
ensure_size!(in: src, size: core::mem::size_of::<u16>());
|
||||
ensure_size!(in: src, size: 2);
|
||||
|
||||
let frame_action = src.read_u16();
|
||||
|
||||
|
@ -154,7 +154,7 @@ impl<'de> PduDecode<'de> for FrameMarkerPdu {
|
|||
|
||||
None
|
||||
} else {
|
||||
ensure_size!(in: src, size: core::mem::size_of::<u32>());
|
||||
ensure_size!(in: src, size: 4);
|
||||
Some(src.read_u32())
|
||||
};
|
||||
|
||||
|
@ -175,8 +175,7 @@ pub struct ExtendedBitmapDataPdu<'a> {
|
|||
|
||||
impl ExtendedBitmapDataPdu<'_> {
|
||||
const NAME: &'static str = "TS_BITMAP_DATA_EX";
|
||||
const FIXED_PART_SIZE: usize =
|
||||
core::mem::size_of::<u8>() * 4 + core::mem::size_of::<u16>() * 2 + core::mem::size_of::<u32>();
|
||||
const FIXED_PART_SIZE: usize = 1 /* bpp */ + 1 /* flags */ + 1 /* reserved */ + 1 /* codecId */ + 2 /* width */ + 2 /* height */ + 4 /* len */;
|
||||
}
|
||||
|
||||
impl PduEncode for ExtendedBitmapDataPdu<'_> {
|
||||
|
|
|
@ -172,7 +172,7 @@ impl Rectangle for ExclusiveRectangle {
|
|||
impl InclusiveRectangle {
|
||||
const NAME: &'static str = "InclusiveRectangle";
|
||||
|
||||
pub const FIXED_PART_SIZE: usize = std::mem::size_of::<u16>() * 4;
|
||||
pub const FIXED_PART_SIZE: usize = 2 /* left */ + 2 /* top */ + 2 /* right */ + 2 /* bottom */;
|
||||
|
||||
pub const ENCODED_SIZE: usize = Self::FIXED_PART_SIZE;
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ impl<'de> PduDecode<'de> for InclusiveRectangle {
|
|||
|
||||
impl ExclusiveRectangle {
|
||||
const NAME: &'static str = "ExclusiveRectangle";
|
||||
const FIXED_PART_SIZE: usize = std::mem::size_of::<u16>() * 4;
|
||||
const FIXED_PART_SIZE: usize = 2 /* left */ + 2 /* top */ + 2 /* right */ + 2 /* bottom */;
|
||||
|
||||
pub const ENCODED_SIZE: usize = Self::FIXED_PART_SIZE;
|
||||
}
|
||||
|
|
|
@ -302,8 +302,8 @@ pub fn find_size(bytes: &[u8]) -> PduResult<Option<PduInfo>> {
|
|||
|
||||
match action {
|
||||
Action::X224 => {
|
||||
ensure_enough!(bytes, crate::tpkt::TpktHeader::SIZE);
|
||||
let tpkt = crate::tpkt::TpktHeader::read(&mut ReadCursor::new(bytes))?;
|
||||
ensure_enough!(bytes, tpkt::TpktHeader::SIZE);
|
||||
let tpkt = tpkt::TpktHeader::read(&mut ReadCursor::new(bytes))?;
|
||||
|
||||
Ok(Some(PduInfo {
|
||||
action,
|
||||
|
@ -331,7 +331,7 @@ pub fn find_size(bytes: &[u8]) -> PduResult<Option<PduInfo>> {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait PduHint: Send + Sync + core::fmt::Debug + 'static {
|
||||
pub trait PduHint: Send + Sync + fmt::Debug + 'static {
|
||||
/// Finds next PDU size by reading the next few bytes.
|
||||
fn find_size(&self, bytes: &[u8]) -> PduResult<Option<usize>>;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::{fmt, mem};
|
||||
use std::fmt;
|
||||
|
||||
use bit_field::BitField;
|
||||
use num_derive::{FromPrimitive, ToPrimitive};
|
||||
|
@ -391,7 +391,7 @@ pub struct CacheToSurfacePdu {
|
|||
impl CacheToSurfacePdu {
|
||||
const NAME: &'static str = "CacheToSurfacePdu";
|
||||
|
||||
const FIXED_PART_SIZE: usize = mem::size_of::<u16>() * 3;
|
||||
const FIXED_PART_SIZE: usize = 2 /* cache_slot */ + 2 /* surface_id */ + 2 /* npoints */;
|
||||
}
|
||||
|
||||
impl PduEncode for CacheToSurfacePdu {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use byteorder::{LittleEndian, ReadBytesExt as _};
|
||||
use num_derive::{FromPrimitive, ToPrimitive};
|
||||
use std::fmt::Debug;
|
||||
use std::mem::size_of;
|
||||
use std::ops::Add;
|
||||
|
||||
use crate::cursor::{ReadCursor, WriteCursor};
|
||||
|
@ -8,7 +9,7 @@ use crate::PduResult;
|
|||
|
||||
pub fn split_u64(value: u64) -> (u32, u32) {
|
||||
let bytes = value.to_le_bytes();
|
||||
let (low, high) = bytes.split_at(std::mem::size_of::<u32>());
|
||||
let (low, high) = bytes.split_at(size_of::<u32>());
|
||||
(
|
||||
u32::from_le_bytes(low.try_into().unwrap()),
|
||||
u32::from_le_bytes(high.try_into().unwrap()),
|
||||
|
@ -16,9 +17,9 @@ pub fn split_u64(value: u64) -> (u32, u32) {
|
|||
}
|
||||
|
||||
pub fn combine_u64(lo: u32, hi: u32) -> u64 {
|
||||
let mut position_bytes = [0u8; std::mem::size_of::<u64>()];
|
||||
position_bytes[..std::mem::size_of::<u32>()].copy_from_slice(&lo.to_le_bytes());
|
||||
position_bytes[std::mem::size_of::<u32>()..].copy_from_slice(&hi.to_le_bytes());
|
||||
let mut position_bytes = [0u8; size_of::<u64>()];
|
||||
position_bytes[..size_of::<u32>()].copy_from_slice(&lo.to_le_bytes());
|
||||
position_bytes[size_of::<u32>()..].copy_from_slice(&hi.to_le_bytes());
|
||||
u64::from_le_bytes(position_bytes)
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ fn main() -> anyhow::Result<()> {
|
|||
});
|
||||
|
||||
stream.play()?;
|
||||
std::thread::sleep(Duration::from_secs(3));
|
||||
thread::sleep(Duration::from_secs(3));
|
||||
let _ = producer.join();
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -40,8 +40,8 @@ pub enum RdpServerSecurity {
|
|||
impl RdpServerSecurity {
|
||||
pub fn flag(&self) -> nego::SecurityProtocol {
|
||||
match self {
|
||||
RdpServerSecurity::None => ironrdp_pdu::nego::SecurityProtocol::empty(),
|
||||
RdpServerSecurity::Tls(_) => ironrdp_pdu::nego::SecurityProtocol::SSL,
|
||||
RdpServerSecurity::None => nego::SecurityProtocol::empty(),
|
||||
RdpServerSecurity::Tls(_) => nego::SecurityProtocol::SSL,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ impl Default for DecodingContext {
|
|||
Self {
|
||||
context: rfx::ContextPdu {
|
||||
flags: rfx::OperatingMode::empty(),
|
||||
entropy_algorithm: rfx::EntropyAlgorithm::Rlgr1,
|
||||
entropy_algorithm: EntropyAlgorithm::Rlgr1,
|
||||
},
|
||||
channels: rfx::ChannelsPdu(Vec::new()),
|
||||
decoding_tiles: DecodingTileContext::new(),
|
||||
|
|
|
@ -86,7 +86,7 @@ impl Processor {
|
|||
if channel_id == self.io_channel_id {
|
||||
self.process_io_channel(data_ctx)
|
||||
} else if let Some(svc) = self.static_channels.get_by_channel_id_mut(channel_id) {
|
||||
let response_pdus = svc.process(data_ctx.user_data).map_err(crate::SessionError::pdu)?;
|
||||
let response_pdus = svc.process(data_ctx.user_data).map_err(SessionError::pdu)?;
|
||||
process_svc_messages(response_pdus, channel_id, data_ctx.initiator_id)
|
||||
.map(|data| vec![ProcessorOutput::ResponseFrame(data)])
|
||||
} else {
|
||||
|
@ -180,7 +180,7 @@ impl Processor {
|
|||
///
|
||||
/// The caller is responsible for ensuring that the `channel_id` corresponds to the correct channel.
|
||||
fn process_svc_messages(messages: Vec<SvcMessage>, channel_id: u16, initiator_id: u16) -> SessionResult<Vec<u8>> {
|
||||
client_encode_svc_messages(messages, channel_id, initiator_id).map_err(crate::SessionError::pdu)
|
||||
client_encode_svc_messages(messages, channel_id, initiator_id).map_err(SessionError::pdu)
|
||||
}
|
||||
|
||||
/// Converts an [`ErrorInfo`] into a [`DisconnectReason`].
|
||||
|
|
|
@ -653,6 +653,8 @@ struct ChannelPduHeader {
|
|||
|
||||
impl ChannelPduHeader {
|
||||
const NAME: &'static str = "CHANNEL_PDU_HEADER";
|
||||
|
||||
const FIXED_PART_SIZE: usize = 4 /* len */ + 4 /* flags */;
|
||||
}
|
||||
|
||||
impl PduEncode for ChannelPduHeader {
|
||||
|
@ -668,6 +670,6 @@ impl PduEncode for ChannelPduHeader {
|
|||
|
||||
#[allow(clippy::arithmetic_side_effects)]
|
||||
fn size(&self) -> usize {
|
||||
std::mem::size_of::<u32>() * 2
|
||||
Self::FIXED_PART_SIZE
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,14 +16,14 @@ where
|
|||
.with_no_client_auth();
|
||||
|
||||
// This adds support for the SSLKEYLOGFILE env variable (https://wiki.wireshark.org/TLS#using-the-pre-master-secret)
|
||||
config.key_log = std::sync::Arc::new(tokio_rustls::rustls::KeyLogFile::new());
|
||||
config.key_log = std::sync::Arc::new(rustls::KeyLogFile::new());
|
||||
|
||||
// Disable TLS resumption because it’s not supported by some services such as CredSSP.
|
||||
//
|
||||
// > The CredSSP Protocol does not extend the TLS wire protocol. TLS session resumption is not supported.
|
||||
//
|
||||
// source: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-cssp/385a7489-d46b-464c-b224-f7340e308a5c
|
||||
config.resumption = tokio_rustls::rustls::client::Resumption::disabled();
|
||||
config.resumption = rustls::client::Resumption::disabled();
|
||||
|
||||
let config = std::sync::Arc::new(config);
|
||||
|
||||
|
|
|
@ -840,7 +840,7 @@ async fn connect(
|
|||
) -> Result<(connector::ConnectionResult, WebSocket), IronRdpError> {
|
||||
let mut framed = ironrdp_futures::LocalFuturesFramed::new(ws);
|
||||
|
||||
let mut connector = connector::ClientConnector::new(config);
|
||||
let mut connector = ClientConnector::new(config);
|
||||
|
||||
if let Some(clipboard_backend) = clipboard_backend {
|
||||
connector.attach_static_channel(CliprdrClient::new(Box::new(clipboard_backend)));
|
||||
|
@ -910,7 +910,7 @@ where
|
|||
{
|
||||
// RDCleanPath request
|
||||
|
||||
let ironrdp::connector::ClientConnectorState::ConnectionInitiationSendRequest = connector.state else {
|
||||
let connector::ClientConnectorState::ConnectionInitiationSendRequest = connector.state else {
|
||||
return Err(anyhow::Error::msg("invalid connector state (send request)").into());
|
||||
};
|
||||
|
||||
|
@ -970,7 +970,7 @@ where
|
|||
|
||||
connector.attach_server_addr(server_addr);
|
||||
|
||||
let ironrdp::connector::ClientConnectorState::ConnectionInitiationWaitConfirm { .. } = connector.state else {
|
||||
let connector::ClientConnectorState::ConnectionInitiationWaitConfirm { .. } = connector.state else {
|
||||
return Err(anyhow::Error::msg("invalid connector state (wait confirm)").into());
|
||||
};
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ use ironrdp_server::{
|
|||
};
|
||||
use rand::prelude::*;
|
||||
use rustls_pemfile::{certs, pkcs8_private_keys};
|
||||
use tokio::sync::mpsc::{self, UnboundedSender};
|
||||
use tokio::sync::mpsc::UnboundedSender;
|
||||
use tokio::time::{self, sleep, Duration};
|
||||
use tokio_rustls::rustls;
|
||||
use tokio_rustls::TlsAcceptor;
|
||||
|
@ -149,7 +149,7 @@ struct DisplayUpdates;
|
|||
impl RdpServerDisplayUpdates for DisplayUpdates {
|
||||
async fn next_update(&mut self) -> Option<DisplayUpdate> {
|
||||
sleep(Duration::from_millis(100)).await;
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut rng = thread_rng();
|
||||
|
||||
let top: u16 = rng.gen_range(0..HEIGHT);
|
||||
let height = NonZeroU16::new(rng.gen_range(1..=HEIGHT - top)).unwrap();
|
||||
|
@ -207,7 +207,7 @@ impl CliprdrServerFactory for StubCliprdrServerFactory {}
|
|||
|
||||
#[derive(Debug)]
|
||||
pub struct Inner {
|
||||
ev_sender: Option<mpsc::UnboundedSender<ServerEvent>>,
|
||||
ev_sender: Option<UnboundedSender<ServerEvent>>,
|
||||
}
|
||||
|
||||
struct StubSoundServerFactory {
|
||||
|
|
|
@ -47,7 +47,7 @@ pub(crate) fn build_dynamic_lib(sh: &xshell::Shell, release: bool) -> anyhow::Re
|
|||
create_dir_all(&dotnet_native_lib_dir_path)
|
||||
.with_context(|| format!("failed to create directory {}", dotnet_native_lib_dir_path.display()))?;
|
||||
|
||||
std::fs::copy(&output_lib_path, &dotnet_native_lib_path).with_context(|| {
|
||||
fs::copy(&output_lib_path, &dotnet_native_lib_path).with_context(|| {
|
||||
format!(
|
||||
"failed to copy {} to {}",
|
||||
output_lib_path.display(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue