mirror of
https://github.com/Devolutions/IronRDP.git
synced 2025-08-04 15:18:17 +00:00
refactor: fix new clippy warnings
This commit is contained in:
parent
780c5383e1
commit
19d6b1ea83
6 changed files with 16 additions and 15 deletions
|
@ -531,7 +531,7 @@ impl Sequence for Acceptor {
|
|||
if !protocol.intersects(SecurityProtocol::HYBRID | SecurityProtocol::HYBRID_EX) {
|
||||
let creds = client_info.client_info.credentials;
|
||||
|
||||
if self.creds.as_ref().map_or(true, |srv_creds| srv_creds != &creds) {
|
||||
if self.creds.as_ref() != Some(&creds) {
|
||||
// FIXME: How authorization should be denied with standard RDP security?
|
||||
// Since standard RDP security is not a priority, we just send a ServerDeniedConnection ServerSetErrorInfo PDU.
|
||||
let info = ServerSetErrorInfoPdu(ErrorInfo::ProtocolIndependentCode(
|
||||
|
@ -545,6 +545,7 @@ impl Sequence for Acceptor {
|
|||
return Err(ConnectorError::general("invalid credentials"));
|
||||
}
|
||||
}
|
||||
|
||||
(
|
||||
Written::Nothing,
|
||||
AcceptorState::LicensingExchange {
|
||||
|
|
|
@ -200,7 +200,7 @@ impl Header {
|
|||
|
||||
fn encode(&self, dst: &mut WriteCursor<'_>) -> EncodeResult<()> {
|
||||
ensure_fixed_part_size!(in: dst);
|
||||
dst.write_u8((self.cmd as u8) << 4 | Into::<u8>::into(self.sp) << 2 | Into::<u8>::into(self.cb_id));
|
||||
dst.write_u8(((self.cmd as u8) << 4) | (Into::<u8>::into(self.sp) << 2) | Into::<u8>::into(self.cb_id));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -779,7 +779,7 @@ impl<'de> McsPdu<'de> for DisconnectProviderUltimatum {
|
|||
let domain_mcspdu = DomainMcsPdu::DisconnectProviderUltimatum.as_u8();
|
||||
let reason = self.reason.as_u8();
|
||||
|
||||
let b1 = domain_mcspdu << 2 | (reason >> 1 & 0x03);
|
||||
let b1 = (domain_mcspdu << 2) | ((reason >> 1) & 0x03);
|
||||
let b2 = reason << 7;
|
||||
|
||||
dst.write_array([b1, b2]);
|
||||
|
@ -818,7 +818,7 @@ impl<'de> McsPdu<'de> for DisconnectProviderUltimatum {
|
|||
let [b1, b2] = src.read_array();
|
||||
|
||||
let domain_mcspdu_choice = b1 >> 2;
|
||||
let reason = (b1 & 0x03) << 1 | (b2 >> 7);
|
||||
let reason = ((b1 & 0x03) << 1) | (b2 >> 7);
|
||||
|
||||
DomainMcsPdu::from_u8(domain_mcspdu_choice)
|
||||
.ok_or_else(|| invalid_field_err(Self::MCS_NAME, "domain-mcspdu", "unexpected application tag for CHOICE"))?
|
||||
|
|
|
@ -181,7 +181,7 @@ impl Encode for DemandActive {
|
|||
|
||||
dst.write_u16(cast_length!(
|
||||
"sourceDescLen",
|
||||
self.source_descriptor.len() + NULL_TERMINATOR.as_bytes().len()
|
||||
self.source_descriptor.len() + NULL_TERMINATOR.len()
|
||||
)?);
|
||||
dst.write_u16(cast_length!("combinedLen", combined_length)?);
|
||||
dst.write_slice(self.source_descriptor.as_ref());
|
||||
|
|
|
@ -411,7 +411,7 @@ impl Encode for ClientAudioFormatPdu {
|
|||
ensure_size!(in: dst, size: self.size());
|
||||
|
||||
dst.write_u32(self.flags.bits());
|
||||
let volume = u32::from(self.volume_right) << 16 | u32::from(self.volume_left);
|
||||
let volume = (u32::from(self.volume_right) << 16) | u32::from(self.volume_left);
|
||||
dst.write_u32(volume);
|
||||
dst.write_u32(self.pitch);
|
||||
dst.write_u16_be(self.dgram_port);
|
||||
|
@ -765,8 +765,8 @@ impl Encode for SndWavePdu {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'de> SndWavePdu {
|
||||
fn decode(src: &mut ReadCursor<'de>, data_len: usize) -> DecodeResult<Self> {
|
||||
impl SndWavePdu {
|
||||
fn decode(src: &mut ReadCursor<'_>, data_len: usize) -> DecodeResult<Self> {
|
||||
ensure_fixed_part_size!(in: src);
|
||||
|
||||
read_padding!(src, 4);
|
||||
|
@ -825,8 +825,8 @@ impl Encode for WavePdu<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'de> WavePdu<'_> {
|
||||
fn decode(src: &mut ReadCursor<'de>, body_size: u16) -> DecodeResult<Self> {
|
||||
impl WavePdu<'_> {
|
||||
fn decode(src: &mut ReadCursor<'_>, body_size: u16) -> DecodeResult<Self> {
|
||||
let info = WaveInfoPdu::decode(src)?;
|
||||
let body_size = body_size as usize;
|
||||
let data_len = body_size
|
||||
|
@ -943,8 +943,8 @@ impl Encode for WaveEncryptPdu {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'de> WaveEncryptPdu {
|
||||
fn decode(src: &mut ReadCursor<'de>, version: Version) -> DecodeResult<Self> {
|
||||
impl WaveEncryptPdu {
|
||||
fn decode(src: &mut ReadCursor<'_>, version: Version) -> DecodeResult<Self> {
|
||||
ensure_fixed_part_size!(in: src);
|
||||
|
||||
let timestamp = src.read_u16();
|
||||
|
@ -1062,7 +1062,7 @@ impl Encode for VolumePdu {
|
|||
fn encode(&self, dst: &mut WriteCursor<'_>) -> EncodeResult<()> {
|
||||
ensure_size!(in: dst, size: self.size());
|
||||
|
||||
let volume = u32::from(self.volume_right) << 16 | u32::from(self.volume_left);
|
||||
let volume = (u32::from(self.volume_right) << 16) | u32::from(self.volume_left);
|
||||
dst.write_u32(volume);
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -21,7 +21,7 @@ impl TlsIdentityCtx {
|
|||
///
|
||||
/// The file format can be either PEM (if the file extension ends with .pem) or DER.
|
||||
pub fn init_from_paths(cert_path: &Path, key_path: &Path) -> anyhow::Result<Self> {
|
||||
let certs = if cert_path.extension().map_or(false, |ext| ext == "pem") {
|
||||
let certs = if cert_path.extension().is_some_and(|ext| ext == "pem") {
|
||||
CertificateDer::pem_file_iter(cert_path)
|
||||
.with_context(|| format!("reading server cert `{cert_path:?}`"))?
|
||||
.collect::<Result<Vec<_>, _>>()
|
||||
|
@ -34,7 +34,7 @@ impl TlsIdentityCtx {
|
|||
.with_context(|| format!("collecting server cert `{cert_path:?}`"))?
|
||||
};
|
||||
|
||||
let priv_key = if key_path.extension().map_or(false, |ext| ext == "pem") {
|
||||
let priv_key = if key_path.extension().is_some_and(|ext| ext == "pem") {
|
||||
PrivateKeyDer::from_pem_file(key_path).with_context(|| format!("reading server key `{key_path:?}`"))?
|
||||
} else {
|
||||
pkcs8_private_keys(&mut BufReader::new(File::open(key_path)?))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue