mirror of
https://github.com/netbirdio/IronRDP.git
synced 2026-05-22 18:43:12 -07:00
fix: unnecessary qualification
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
committed by
Benoît Cortier
parent
934177d772
commit
adf2797ef7
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user