Skip to content
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

Update to Rust 2018 edition #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

# IDE/editor
.idea/
*~
tags

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ keywords = ["rdp", "security", "network", "windows"]
categories = ["network"]
license = "MIT"
documentation = "https://docs.rs/rdp-rs"
edition = "2018"

[lib]
name = "rdp"
Expand Down Expand Up @@ -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}
libc = { version = "^0.2", optional = true}
2 changes: 1 addition & 1 deletion src/codec/rle.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down
6 changes: 3 additions & 3 deletions src/core/capability.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
22 changes: 11 additions & 11 deletions src/core/client.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/core/event.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/core/gcc.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
16 changes: 8 additions & 8 deletions src/core/global.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/core/license.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
14 changes: 7 additions & 7 deletions src/core/mcs.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
4 changes: 2 additions & 2 deletions src/core/per.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/core/sec.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 7 additions & 7 deletions src/core/tpkt.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -223,8 +223,8 @@ impl<S: Read + Write> Client<S> {
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]
Expand Down
8 changes: 4 additions & 4 deletions src/core/x224.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/model/data.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
4 changes: 2 additions & 2 deletions src/model/link.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/model/unicode.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/nla/asn1.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/nla/cssp.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/nla/ntlm.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/nla/sspi.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down