From af134a964cffd4d4ebdeb40e8a362511d3021846 Mon Sep 17 00:00:00 2001 From: Daniel Heater Date: Tue, 8 Feb 2022 15:49:10 -0600 Subject: [PATCH] Update to Rust 2018 edition --- .gitignore | 5 +++++ Cargo.toml | 3 ++- src/codec/rle.rs | 2 +- src/core/capability.rs | 6 +++--- src/core/client.rs | 22 +++++++++++----------- src/core/event.rs | 4 ++-- src/core/gcc.rs | 8 ++++---- src/core/global.rs | 16 ++++++++-------- src/core/license.rs | 4 ++-- src/core/mcs.rs | 14 +++++++------- src/core/per.rs | 4 ++-- src/core/sec.rs | 12 ++++++------ src/core/tpkt.rs | 14 +++++++------- src/core/x224.rs | 8 ++++---- src/model/data.rs | 2 +- src/model/link.rs | 4 ++-- src/model/unicode.rs | 2 +- src/nla/asn1.rs | 2 +- src/nla/cssp.rs | 8 ++++---- src/nla/ntlm.rs | 10 +++++----- src/nla/sspi.rs | 2 +- 21 files changed, 79 insertions(+), 73 deletions(-) diff --git a/.gitignore b/.gitignore index aa982cd..5416aa3 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,9 @@ Cargo.lock # These are backup files generated by rustfmt **/*.rs.bk + +# IDE/editor .idea/ +*~ +tags + diff --git a/Cargo.toml b/Cargo.toml index 07d020c..b4ec28e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ keywords = ["rdp", "security", "network", "windows"] categories = ["network"] license = "MIT" documentation = "https://docs.rs/rdp-rs" +edition = "2018" [lib] name = "rdp" @@ -44,4 +45,4 @@ hex = { version = "^0.4", optional = true } winapi = { version = "^0.3", features = ["winsock2"], optional = true } minifb = { version = "^0.15", optional = true } clap = { version = "^2.33", optional = true} -libc = { version = "^0.2", optional = true} \ No newline at end of file +libc = { version = "^0.2", optional = true} diff --git a/src/codec/rle.rs b/src/codec/rle.rs index 8e7f684..ab909d0 100644 --- a/src/codec/rle.rs +++ b/src/codec/rle.rs @@ -1,4 +1,4 @@ -use model::error::{RdpResult, Error, RdpError, RdpErrorKind}; +use crate::model::error::{RdpResult, Error, RdpError, RdpErrorKind}; use std::io::{Cursor, Read}; use byteorder::{ReadBytesExt, LittleEndian}; diff --git a/src/core/capability.rs b/src/core/capability.rs index a3cf40e..b84d261 100644 --- a/src/core/capability.rs +++ b/src/core/capability.rs @@ -1,7 +1,7 @@ -use model::data::{Component, U16, U32, DynOption, MessageOption, Message, DataType, Check, Trame, to_vec}; -use model::error::{RdpResult, Error, RdpError, RdpErrorKind}; +use crate::model::data::{Component, U16, U32, DynOption, MessageOption, Message, DataType, Check, Trame, to_vec}; +use crate::model::error::{RdpResult, Error, RdpError, RdpErrorKind}; use std::io::Cursor; -use core::gcc::{KeyboardLayout, KeyboardType}; +use crate::core::gcc::{KeyboardLayout, KeyboardType}; use num_enum::TryFromPrimitive; use std::convert::TryFrom; diff --git a/src/core/client.rs b/src/core/client.rs index 91ab8ed..0216a41 100644 --- a/src/core/client.rs +++ b/src/core/client.rs @@ -1,15 +1,15 @@ -use core::x224; -use core::gcc::KeyboardLayout; -use core::mcs; -use core::tpkt; -use core::sec; -use core::global; +use crate::core::x224; +use crate::core::gcc::KeyboardLayout; +use crate::core::mcs; +use crate::core::tpkt; +use crate::core::sec; +use crate::core::global; use std::io::{Read, Write}; -use model::error::{RdpResult, Error, RdpError, RdpErrorKind}; -use model::link::{Link, Stream}; -use core::event::{RdpEvent, PointerButton}; -use core::global::{ts_pointer_event, PointerFlag, ts_keyboard_event, KeyboardFlag}; -use nla::ntlm::Ntlm; +use crate::model::error::{RdpResult, Error, RdpError, RdpErrorKind}; +use crate::model::link::{Link, Stream}; +use crate::core::event::{RdpEvent, PointerButton}; +use crate::core::global::{ts_pointer_event, PointerFlag, ts_keyboard_event, KeyboardFlag}; +use crate::nla::ntlm::Ntlm; impl From<&str> for KeyboardLayout { fn from(e: &str) -> Self { diff --git a/src/core/event.rs b/src/core/event.rs index b379171..73d3a1d 100644 --- a/src/core/event.rs +++ b/src/core/event.rs @@ -1,6 +1,6 @@ -use model::error::{RdpResult, Error, RdpError, RdpErrorKind}; +use crate::model::error::{RdpResult, Error, RdpError, RdpErrorKind}; use num_enum::TryFromPrimitive; -use codec::rle::{rle_32_decompress, rle_16_decompress, rgb565torgb32}; +use crate::codec::rle::{rle_32_decompress, rle_16_decompress, rgb565torgb32}; /// A bitmap event is used /// to notify client that it received diff --git a/src/core/gcc.rs b/src/core/gcc.rs index 6ca719f..188f312 100644 --- a/src/core/gcc.rs +++ b/src/core/gcc.rs @@ -1,7 +1,7 @@ -use model::data::{Component, U32, U16, Trame, to_vec, Message, DataType, DynOption, MessageOption, Check, Array}; -use model::unicode::Unicode; -use model::error::{RdpResult, RdpError, RdpErrorKind, Error}; -use core::per; +use crate::model::data::{Component, U32, U16, Trame, to_vec, Message, DataType, DynOption, MessageOption, Check, Array}; +use crate::model::unicode::Unicode; +use crate::model::error::{RdpResult, RdpError, RdpErrorKind, Error}; +use crate::core::per; use std::io::{Cursor, Read}; use std::collections::HashMap; diff --git a/src/core/global.rs b/src/core/global.rs index 8d9cf69..27f02ca 100644 --- a/src/core/global.rs +++ b/src/core/global.rs @@ -1,14 +1,14 @@ -use core::mcs; -use core::tpkt; +use crate::core::mcs; +use crate::core::tpkt; use std::io::{Read, Write, Cursor}; -use model::error::{RdpResult, Error, RdpErrorKind, RdpError}; -use model::data::{Component, MessageOption, U32, DynOption, U16, DataType, Message, Array, Trame, Check, to_vec}; -use core::event::{RdpEvent, BitmapEvent}; +use crate::model::error::{RdpResult, Error, RdpErrorKind, RdpError}; +use crate::model::data::{Component, MessageOption, U32, DynOption, U16, DataType, Message, Array, Trame, Check, to_vec}; +use crate::core::event::{RdpEvent, BitmapEvent}; use num_enum::TryFromPrimitive; use std::convert::TryFrom; -use core::capability::{Capability, capability_set}; -use core::capability; -use core::gcc::KeyboardLayout; +use crate::core::capability::{Capability, capability_set}; +use crate::core::capability; +use crate::core::gcc::KeyboardLayout; /// Raw PDU type use by the protocol diff --git a/src/core/license.rs b/src/core/license.rs index 960c6b1..be2974d 100644 --- a/src/core/license.rs +++ b/src/core/license.rs @@ -1,5 +1,5 @@ -use model::data::{Component, Check, DynOption, U16, MessageOption, U32, DataType, Message}; -use model::error::{RdpResult, Error, RdpError, RdpErrorKind}; +use crate::model::data::{Component, Check, DynOption, U16, MessageOption, U32, DataType, Message}; +use crate::model::error::{RdpResult, Error, RdpError, RdpErrorKind}; use std::io::{Cursor, Read}; use num_enum::TryFromPrimitive; use std::convert::TryFrom; diff --git a/src/core/mcs.rs b/src/core/mcs.rs index 8fd6128..1c2439e 100644 --- a/src/core/mcs.rs +++ b/src/core/mcs.rs @@ -1,12 +1,12 @@ -use core::x224; -use core::tpkt; -use model::error::{RdpResult, Error, RdpError, RdpErrorKind}; -use core::gcc::{KeyboardLayout, client_core_data, ClientData, ServerData, client_security_data, client_network_data, block_header, write_conference_create_request, MessageType, read_conference_create_response, Version}; -use model::data::{Trame, to_vec, Message, DataType, U16}; -use nla::asn1::{Sequence, ImplicitTag, OctetString, Enumerate, ASN1Type, Integer, to_der, from_ber}; +use crate::core::x224; +use crate::core::tpkt; +use crate::model::error::{RdpResult, Error, RdpError, RdpErrorKind}; +use crate::core::gcc::{KeyboardLayout, client_core_data, ClientData, ServerData, client_security_data, client_network_data, block_header, write_conference_create_request, MessageType, read_conference_create_response, Version}; +use crate::model::data::{Trame, to_vec, Message, DataType, U16}; +use crate::nla::asn1::{Sequence, ImplicitTag, OctetString, Enumerate, ASN1Type, Integer, to_der, from_ber}; use yasna::{Tag}; use std::io::{Write, Read, BufRead, Cursor}; -use core::per; +use crate::core::per; use std::collections::HashMap; #[allow(dead_code)] diff --git a/src/core/per.rs b/src/core/per.rs index 453073c..b6bd5f2 100644 --- a/src/core/per.rs +++ b/src/core/per.rs @@ -1,6 +1,6 @@ -use model::data::{Message, U16, Trame, U32}; +use crate::model::data::{Message, U16, Trame, U32}; use std::io::{Read, Write}; -use model::error::{RdpResult, Error, RdpError, RdpErrorKind}; +use crate::model::error::{RdpResult, Error, RdpError, RdpErrorKind}; /// PER encoding length diff --git a/src/core/sec.rs b/src/core/sec.rs index 606cd05..8ec936b 100644 --- a/src/core/sec.rs +++ b/src/core/sec.rs @@ -1,10 +1,10 @@ -use core::mcs; -use core::license; -use core::tpkt; -use model::error::{RdpResult, Error, RdpError, RdpErrorKind}; -use model::data::{Message, Component, U16, U32, DynOption, MessageOption, Trame, DataType}; +use crate::core::mcs; +use crate::core::license; +use crate::core::tpkt; +use crate::model::error::{RdpResult, Error, RdpError, RdpErrorKind}; +use crate::model::data::{Message, Component, U16, U32, DynOption, MessageOption, Trame, DataType}; use std::io::{Write, Read}; -use model::unicode::Unicode; +use crate::model::unicode::Unicode; /// Security flag send as header flage in core ptotocol /// https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/e13405c5-668b-4716-94b2-1c2654ca1ad4?redirectedfrom=MSDN diff --git a/src/core/tpkt.rs b/src/core/tpkt.rs index cb06e37..909074f 100644 --- a/src/core/tpkt.rs +++ b/src/core/tpkt.rs @@ -1,9 +1,9 @@ -use model::link::{Link}; -use model::data::{Message, U16, Component, Trame}; -use model::error::{RdpResult, RdpError, RdpErrorKind, Error}; +use crate::model::link::{Link}; +use crate::model::data::{Message, U16, Component, Trame}; +use crate::model::error::{RdpResult, RdpError, RdpErrorKind, Error}; use std::io::{Cursor, Write, Read}; -use nla::cssp::cssp_connect; -use nla::sspi::AuthenticationProtocol; +use crate::nla::cssp::cssp_connect; +use crate::nla::sspi::AuthenticationProtocol; /// TPKT must implement this two kind of payload pub enum Payload { @@ -223,8 +223,8 @@ impl Client { mod test { use super::*; use std::io::Cursor; - use model::data::{U32, DataType}; - use model::link::Stream; + use crate::model::data::{U32, DataType}; + use crate::model::link::Stream; /// Test the tpkt header type in write context #[test] diff --git a/src/core/x224.rs b/src/core/x224.rs index 9a19062..ec2659d 100644 --- a/src/core/x224.rs +++ b/src/core/x224.rs @@ -1,9 +1,9 @@ -use core::tpkt; -use model::data::{Message, Check, U16, U32, Component, DataType, Trame}; -use model::error::{Error, RdpError, RdpResult, RdpErrorKind}; +use crate::core::tpkt; +use crate::model::data::{Message, Check, U16, U32, Component, DataType, Trame}; +use crate::model::error::{Error, RdpError, RdpResult, RdpErrorKind}; use std::io::{Read, Write}; use std::option::{Option}; -use nla::sspi::AuthenticationProtocol; +use crate::nla::sspi::AuthenticationProtocol; use num_enum::TryFromPrimitive; use std::convert::TryFrom; diff --git a/src/model/data.rs b/src/model/data.rs index 98ed3c8..5555e3d 100644 --- a/src/model/data.rs +++ b/src/model/data.rs @@ -1,5 +1,5 @@ use std::io::{Write, Read, Cursor}; -use model::error::{RdpResult, RdpErrorKind, RdpError, Error}; +use crate::model::error::{RdpResult, RdpErrorKind, RdpError, Error}; use byteorder::{WriteBytesExt, ReadBytesExt, LittleEndian, BigEndian}; use indexmap::IndexMap; use std::collections::{HashSet, HashMap}; diff --git a/src/model/link.rs b/src/model/link.rs index 424a1c2..e6b5a8f 100644 --- a/src/model/link.rs +++ b/src/model/link.rs @@ -1,9 +1,9 @@ extern crate native_tls; -use model::error::{RdpResult, Error, RdpError, RdpErrorKind}; +use crate::model::error::{RdpResult, Error, RdpError, RdpErrorKind}; use std::io::{Cursor, Read, Write}; use self::native_tls::{TlsConnector, TlsStream, Certificate}; -use model::data::{Message}; +use crate::model::data::{Message}; /// This a wrapper to work equals /// for a stream and a TLS stream diff --git a/src/model/unicode.rs b/src/model/unicode.rs index 5246a71..3729767 100644 --- a/src/model/unicode.rs +++ b/src/model/unicode.rs @@ -1,4 +1,4 @@ -use model::data::{Message, U16}; +use crate::model::data::{Message, U16}; use std::io::Cursor; /// Use to to_unicode function for String diff --git a/src/nla/asn1.rs b/src/nla/asn1.rs index 5b09bae..aee8d5a 100644 --- a/src/nla/asn1.rs +++ b/src/nla/asn1.rs @@ -1,5 +1,5 @@ use yasna::{Tag, DERWriter, BERReader}; -use model::error::{RdpResult, Error}; +use crate::model::error::{RdpResult, Error}; use indexmap::map::IndexMap; /// Enum all possible value diff --git a/src/nla/cssp.rs b/src/nla/cssp.rs index d327106..6842906 100644 --- a/src/nla/cssp.rs +++ b/src/nla/cssp.rs @@ -1,10 +1,10 @@ -use nla::asn1::{ASN1, Sequence, ExplicitTag, SequenceOf, ASN1Type, OctetString, Integer, to_der}; -use model::error::{RdpError, RdpErrorKind, Error, RdpResult}; +use crate::nla::asn1::{ASN1, Sequence, ExplicitTag, SequenceOf, ASN1Type, OctetString, Integer, to_der}; +use crate::model::error::{RdpError, RdpErrorKind, Error, RdpResult}; use num_bigint::{BigUint}; use yasna::Tag; use x509_parser::{parse_x509_der, X509Certificate}; -use nla::sspi::AuthenticationProtocol; -use model::link::Link; +use crate::nla::sspi::AuthenticationProtocol; +use crate::model::link::Link; use std::io::{Read, Write}; /// Create a ts request as expected by the specification diff --git a/src/nla/ntlm.rs b/src/nla/ntlm.rs index 3680c69..9d6aa04 100644 --- a/src/nla/ntlm.rs +++ b/src/nla/ntlm.rs @@ -1,13 +1,13 @@ -use nla::sspi::{AuthenticationProtocol, GenericSecurityService}; -use model::data::{Message, Component, U16, U32, Trame, DynOption, Check, DataType, MessageOption, to_vec}; +use crate::nla::sspi::{AuthenticationProtocol, GenericSecurityService}; +use crate::model::data::{Message, Component, U16, U32, Trame, DynOption, Check, DataType, MessageOption, to_vec}; use std::io::{Cursor}; -use model::error::{RdpResult, RdpError, RdpErrorKind, Error}; +use crate::model::error::{RdpResult, RdpError, RdpErrorKind, Error}; use std::collections::HashMap; use md4::{Md4, Digest}; use hmac::{Hmac, Mac}; use md5::{Md5}; -use model::rnd::{random}; -use nla::rc4::{Rc4}; +use crate::model::rnd::{random}; +use crate::nla::rc4::{Rc4}; use num_enum::TryFromPrimitive; use std::convert::TryFrom; diff --git a/src/nla/sspi.rs b/src/nla/sspi.rs index 4c8f848..26b16ea 100644 --- a/src/nla/sspi.rs +++ b/src/nla/sspi.rs @@ -1,4 +1,4 @@ -use model::error::RdpResult; +use crate::model::error::RdpResult; /// This is a trait use by authentication /// protocol to provide a context