diff --git a/.travis.yml b/.travis.yml index cefd94242..706f0856b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,7 +65,8 @@ matrix: before_cache: - rm -rf /home/travis/.cargo/registry install: - - cargo install cargo-travis --debug || echo "cargo-travis has been already installed" + - cargo install cargo-update --debug || echo "cargo-update has been already installed" + - cargo install-update -i cargo-travis script: - mkdir -p target # fix for cargo-coveralls - cargo coveralls diff --git a/Cargo.toml b/Cargo.toml index 633300cb0..f0aab16a2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,6 +18,7 @@ repository = "https://github.com/tox-rs/tox/" keywords = ["p2p", "instant-messaging", "tox", "toxcore", "networking"] categories = ["multimedia"] license = "MIT OR GPL-3.0+" +edition = "2018" [badges] travis-ci = { repository = "tox-rs/tox" } diff --git a/examples/dht_server.rs b/examples/dht_server.rs index 6946a7cc1..a03fe1bda 100644 --- a/examples/dht_server.rs +++ b/examples/dht_server.rs @@ -1,14 +1,7 @@ // an example of DHT node with current code // -extern crate tox; -extern crate failure; -extern crate futures; -extern crate tokio; -extern crate hex; - #[macro_use] extern crate log; -extern crate env_logger; use std::io::Error; diff --git a/examples/tcp_client.rs b/examples/tcp_client.rs index 8bf16d2b6..971b77be0 100644 --- a/examples/tcp_client.rs +++ b/examples/tcp_client.rs @@ -1,13 +1,5 @@ -extern crate tox; -extern crate futures; -extern crate tokio; -extern crate tokio_codec; - #[macro_use] extern crate log; -extern crate env_logger; -extern crate hex; -extern crate failure; use tox::toxcore::crypto_core::*; use tox::toxcore::tcp::connection_id::ConnectionId; diff --git a/examples/tcp_server.rs b/examples/tcp_server.rs index 831e85404..043ef19fe 100644 --- a/examples/tcp_server.rs +++ b/examples/tcp_server.rs @@ -1,11 +1,5 @@ -extern crate tox; -extern crate futures; -extern crate tokio; -extern crate tokio_codec; - #[macro_use] extern crate log; -extern crate env_logger; use tox::toxcore::crypto_core::*; use tox::toxcore::tcp::server::{Server, ServerExt}; diff --git a/src/lib.rs b/src/lib.rs index 5b07795cf..9a1cda9be 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,29 +10,12 @@ Repo: https://github.com/tox-rs/tox // Remove it when it will be fixed in nom parser #![allow(clippy::redundant_closure)] -extern crate bytes; -extern crate byteorder; -extern crate futures; #[macro_use] extern crate log; #[macro_use] extern crate nom; #[macro_use] extern crate cookie_factory; -extern crate sodiumoxide; - -extern crate tokio; -extern crate tokio_codec; -extern crate get_if_addrs; -extern crate parking_lot; -#[macro_use] -extern crate failure; -extern crate lru; - -#[cfg(test)] -extern crate tokio_timer; -#[cfg(test)] -extern crate tokio_executor; /** Core Tox module. Provides an API on top of which other modules and applications may be build. diff --git a/src/toxcore/binary_io.rs b/src/toxcore/binary_io.rs index ffcd89bd9..3225ba128 100644 --- a/src/toxcore/binary_io.rs +++ b/src/toxcore/binary_io.rs @@ -102,7 +102,7 @@ macro_rules! encode_decode_test ( #[test] fn $test() { #[cfg(test)] - use toxcore::crypto_core::*; + use crate::toxcore::crypto_core::*; crypto_init().unwrap(); diff --git a/src/toxcore/crypto_core.rs b/src/toxcore/crypto_core.rs index 0e2c6de5c..2ee0cc675 100644 --- a/src/toxcore/crypto_core.rs +++ b/src/toxcore/crypto_core.rs @@ -7,7 +7,7 @@ pub use sodiumoxide::crypto::secretbox; use byteorder::{ByteOrder, LittleEndian, NativeEndian}; -use toxcore::binary_io::*; +use crate::toxcore::binary_io::*; // TODO: check if `#[inline]` is actually useful diff --git a/src/toxcore/dht/codec.rs b/src/toxcore/dht/codec.rs index 3e1f2fd9a..46aeb3903 100644 --- a/src/toxcore/dht/codec.rs +++ b/src/toxcore/dht/codec.rs @@ -6,9 +6,9 @@ use std::io::Error as IoError; use failure::{Backtrace, Context, Fail}; -use toxcore::dht::packet::*; -use toxcore::binary_io::*; -use toxcore::stats::*; +use crate::toxcore::dht::packet::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::stats::*; use bytes::BytesMut; use cookie_factory::GenError; @@ -236,8 +236,8 @@ impl Encoder for DhtCodec { #[cfg(test)] mod tests { use super::*; - use toxcore::onion::packet::*; - use toxcore::crypto_core::*; + use crate::toxcore::onion::packet::*; + use crate::toxcore::crypto_core::*; const ONION_RETURN_1_PAYLOAD_SIZE: usize = ONION_RETURN_1_SIZE - secretbox::NONCEBYTES; const ONION_RETURN_2_PAYLOAD_SIZE: usize = ONION_RETURN_2_SIZE - secretbox::NONCEBYTES; diff --git a/src/toxcore/dht/daemon_state.rs b/src/toxcore/dht/daemon_state.rs index d439200ae..9a4d42973 100644 --- a/src/toxcore/dht/daemon_state.rs +++ b/src/toxcore/dht/daemon_state.rs @@ -7,11 +7,11 @@ Toxcore daemon may serialize its states to file with some interval. use futures::{future, Future, Stream, stream}; use futures::future::Either; -use toxcore::dht::server::*; -use toxcore::dht::packed_node::*; -use toxcore::state_format::old::*; -use toxcore::binary_io::*; -use toxcore::dht::kbucket::*; +use crate::toxcore::dht::server::*; +use crate::toxcore::dht::packed_node::*; +use crate::toxcore::state_format::old::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::dht::kbucket::*; use std::fmt; @@ -152,8 +152,8 @@ impl DaemonState { mod tests { use super::*; - use toxcore::crypto_core::*; - use toxcore::dht::packet::*; + use crate::toxcore::crypto_core::*; + use crate::toxcore::dht::packet::*; use futures::sync::mpsc; diff --git a/src/toxcore/dht/dht_friend.rs b/src/toxcore/dht/dht_friend.rs index 1eaeb6a8f..0fd6e610e 100644 --- a/src/toxcore/dht/dht_friend.rs +++ b/src/toxcore/dht/dht_friend.rs @@ -5,12 +5,12 @@ Module for friend. use std::time::Instant; use std::net::SocketAddr; -use toxcore::time::*; -use toxcore::dht::kbucket::*; -use toxcore::dht::nodes_queue::*; -use toxcore::crypto_core::*; -use toxcore::dht::packed_node::*; -use toxcore::dht::server::hole_punching::*; +use crate::toxcore::time::*; +use crate::toxcore::dht::kbucket::*; +use crate::toxcore::dht::nodes_queue::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::dht::packed_node::*; +use crate::toxcore::dht::server::hole_punching::*; /// Number of bootstrap nodes each friend has. pub const FRIEND_BOOTSTRAP_NODES_COUNT: u8 = 4; @@ -102,8 +102,8 @@ mod tests { use tokio_executor; use tokio_timer::clock::*; - use toxcore::dht::dht_node::*; - use toxcore::time::ConstNow; + use crate::toxcore::dht::dht_node::*; + use crate::toxcore::time::ConstNow; #[test] fn addr_is_unknown() { diff --git a/src/toxcore/dht/dht_node.rs b/src/toxcore/dht/dht_node.rs index f1be2b4b4..9b90cfbe3 100644 --- a/src/toxcore/dht/dht_node.rs +++ b/src/toxcore/dht/dht_node.rs @@ -9,9 +9,9 @@ Here, GOOD node is the node responded within 162 seconds, BAD node is the node n use std::net::{SocketAddr, SocketAddrV4, SocketAddrV6}; use std::time::{Duration, Instant}; -use toxcore::crypto_core::*; -use toxcore::dht::packed_node::*; -use toxcore::time::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::dht::packed_node::*; +use crate::toxcore::time::*; /// Ping interval in seconds for each node in our lists. pub const PING_INTERVAL: u64 = 60; diff --git a/src/toxcore/dht/kbucket.rs b/src/toxcore/dht/kbucket.rs index d011ce3b0..a56b62787 100644 --- a/src/toxcore/dht/kbucket.rs +++ b/src/toxcore/dht/kbucket.rs @@ -16,12 +16,12 @@ use std::cmp::{Ord, Ordering}; use std::convert::Into; use std::net::SocketAddr; -use toxcore::crypto_core::*; -use toxcore::dht::dht_node::*; -use toxcore::dht::packed_node::*; -use toxcore::dht::ip_port::IsGlobal; -use toxcore::dht::nodes_queue::*; -use toxcore::time::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::dht::dht_node::*; +use crate::toxcore::dht::packed_node::*; +use crate::toxcore::dht::ip_port::IsGlobal; +use crate::toxcore::dht::nodes_queue::*; +use crate::toxcore::time::*; /** Calculate the [`k-bucket`](./struct.Ktree.html) index of a PK compared to "own" PK. @@ -57,7 +57,7 @@ impl Into for PackedNode { pub trait Distance { /// Check whether distance between PK1 and own PK is smaller than distance /// between PK2 and own PK. - fn distance(&self, &PublicKey, &PublicKey) -> Ordering; + fn distance(&self, pk1: &PublicKey, pk2: &PublicKey) -> Ordering; } impl Distance for PublicKey { @@ -552,7 +552,7 @@ mod tests { use tokio_executor; use tokio_timer::clock::*; - use toxcore::time::ConstNow; + use crate::toxcore::time::ConstNow; // PublicKey::distance() diff --git a/src/toxcore/dht/lan_discovery.rs b/src/toxcore/dht/lan_discovery.rs index 62ac595fe..2243a89a3 100644 --- a/src/toxcore/dht/lan_discovery.rs +++ b/src/toxcore/dht/lan_discovery.rs @@ -17,9 +17,9 @@ use tokio::timer::Interval; use tokio::timer::Error as TimerError; use tokio::timer::timeout::Error as TimeoutError; -use toxcore::crypto_core::*; -use toxcore::io_tokio::*; -use toxcore::dht::packet::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::io_tokio::*; +use crate::toxcore::dht::packet::*; /// Error that can happen during lan discovery #[derive(Debug)] diff --git a/src/toxcore/dht/nodes_queue.rs b/src/toxcore/dht/nodes_queue.rs index 6316c0945..ec9ac12a2 100644 --- a/src/toxcore/dht/nodes_queue.rs +++ b/src/toxcore/dht/nodes_queue.rs @@ -4,9 +4,9 @@ use std::net::SocketAddr; -use toxcore::crypto_core::*; -use toxcore::dht::kbucket::*; -use toxcore::dht::packed_node::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::dht::kbucket::*; +use crate::toxcore::dht::packed_node::*; /** `NodesQueue` holds `PackedNode`s that are close to a some `PublicKey`. diff --git a/src/toxcore/dht/packed_node.rs b/src/toxcore/dht/packed_node.rs index 6dac57940..1c24d2974 100644 --- a/src/toxcore/dht/packed_node.rs +++ b/src/toxcore/dht/packed_node.rs @@ -11,8 +11,8 @@ use std::net::{ SocketAddrV4 }; -use toxcore::binary_io::*; -use toxcore::crypto_core::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; /** `PackedNode` format is a way to store the node info in a small yet easy to parse format. diff --git a/src/toxcore/dht/packet/bootstrap_info.rs b/src/toxcore/dht/packet/bootstrap_info.rs index 0ff494768..c59ff2054 100644 --- a/src/toxcore/dht/packet/bootstrap_info.rs +++ b/src/toxcore/dht/packet/bootstrap_info.rs @@ -3,7 +3,7 @@ use nom::{be_u32, rest}; -use toxcore::binary_io::*; +use crate::toxcore::binary_io::*; /** Sent by both client and server, only server will respond. When server receives this packet it may respond with the version of the library @@ -62,7 +62,7 @@ impl FromBytes for BootstrapInfo { #[cfg(test)] mod tests { - use toxcore::dht::packet::bootstrap_info::*; + use crate::toxcore::dht::packet::bootstrap_info::*; encode_decode_test!( bootstrap_info_encode_decode, diff --git a/src/toxcore/dht/packet/cookie.rs b/src/toxcore/dht/packet/cookie.rs index 4de17f2ed..4375a238e 100644 --- a/src/toxcore/dht/packet/cookie.rs +++ b/src/toxcore/dht/packet/cookie.rs @@ -5,10 +5,10 @@ use nom::be_u64; use std::time::SystemTime; -use toxcore::binary_io::*; -use toxcore::crypto_core::*; -use toxcore::time::*; -use toxcore::dht::packet::errors::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::time::*; +use crate::toxcore::dht::packet::errors::*; /// Number of seconds that generated cookie is valid pub const COOKIE_TIMEOUT: u64 = 15; diff --git a/src/toxcore/dht/packet/cookie_request.rs b/src/toxcore/dht/packet/cookie_request.rs index fc202975e..0ca764b14 100644 --- a/src/toxcore/dht/packet/cookie_request.rs +++ b/src/toxcore/dht/packet/cookie_request.rs @@ -3,9 +3,9 @@ use nom::be_u64; -use toxcore::binary_io::*; -use toxcore::crypto_core::*; -use toxcore::dht::packet::errors::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::dht::packet::errors::*; /** CookieRequest packet struct. According to https://zetok.github.io/tox-spec/#net-crypto @@ -149,7 +149,7 @@ impl FromBytes for CookieRequestPayload { #[cfg(test)] mod tests { - use toxcore::dht::packet::cookie_request::*; + use crate::toxcore::dht::packet::cookie_request::*; encode_decode_test!( cookie_request_encode_decode, diff --git a/src/toxcore/dht/packet/cookie_response.rs b/src/toxcore/dht/packet/cookie_response.rs index a41a4b241..538d8269e 100644 --- a/src/toxcore/dht/packet/cookie_response.rs +++ b/src/toxcore/dht/packet/cookie_response.rs @@ -3,10 +3,10 @@ use nom::be_u64; -use toxcore::binary_io::*; -use toxcore::crypto_core::*; -use toxcore::dht::packet::cookie::EncryptedCookie; -use toxcore::dht::packet::errors::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::dht::packet::cookie::EncryptedCookie; +use crate::toxcore::dht::packet::errors::*; /** Response to a `CookieRequest` packet. diff --git a/src/toxcore/dht/packet/crypto_data.rs b/src/toxcore/dht/packet/crypto_data.rs index a40915f0f..fa8392771 100644 --- a/src/toxcore/dht/packet/crypto_data.rs +++ b/src/toxcore/dht/packet/crypto_data.rs @@ -4,9 +4,9 @@ use byteorder::{ByteOrder, BigEndian}; use nom::{be_u16, be_u32, rest}; -use toxcore::binary_io::*; -use toxcore::crypto_core::*; -use toxcore::dht::packet::errors::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::dht::packet::errors::*; /// The maximum size of `CryptoData` packet including two bytes of nonce and /// packet kind byte. diff --git a/src/toxcore/dht/packet/crypto_handshake.rs b/src/toxcore/dht/packet/crypto_handshake.rs index 3e3453f9a..dd5dca6dc 100644 --- a/src/toxcore/dht/packet/crypto_handshake.rs +++ b/src/toxcore/dht/packet/crypto_handshake.rs @@ -1,10 +1,10 @@ /*! CryptoHandshake packet */ -use toxcore::binary_io::*; -use toxcore::crypto_core::*; -use toxcore::dht::packet::cookie::EncryptedCookie; -use toxcore::dht::packet::errors::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::dht::packet::cookie::EncryptedCookie; +use crate::toxcore::dht::packet::errors::*; /** Packet used to establish `net_crypto` connection between two peers. diff --git a/src/toxcore/dht/packet/dht_request.rs b/src/toxcore/dht/packet/dht_request.rs index 997db12bd..82ceade32 100644 --- a/src/toxcore/dht/packet/dht_request.rs +++ b/src/toxcore/dht/packet/dht_request.rs @@ -3,10 +3,10 @@ use nom::{be_u64, rest}; -use toxcore::binary_io::*; -use toxcore::crypto_core::*; -use toxcore::dht::codec::*; -use toxcore::dht::packet::errors::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::dht::codec::*; +use crate::toxcore::dht::packet::errors::*; /** DHT Request packet struct. DHT Request packet consists of NatPingRequest and NatPingResponse. diff --git a/src/toxcore/dht/packet/lan_discovery.rs b/src/toxcore/dht/packet/lan_discovery.rs index 5b12d9296..8e61db8c0 100644 --- a/src/toxcore/dht/packet/lan_discovery.rs +++ b/src/toxcore/dht/packet/lan_discovery.rs @@ -1,8 +1,8 @@ /*! LanDiscovery packet */ -use toxcore::binary_io::*; -use toxcore::crypto_core::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; /** LanDiscovery packet struct. LanDiscovery packets contain the DHT public key of the sender. When a LanDiscovery packet @@ -45,7 +45,7 @@ impl FromBytes for LanDiscovery { #[cfg(test)] mod tests { - use toxcore::dht::packet::lan_discovery::*; + use crate::toxcore::dht::packet::lan_discovery::*; encode_decode_test!( lan_discovery_encode_decode, diff --git a/src/toxcore/dht/packet/mod.rs b/src/toxcore/dht/packet/mod.rs index badd407e0..cca1e33ed 100644 --- a/src/toxcore/dht/packet/mod.rs +++ b/src/toxcore/dht/packet/mod.rs @@ -33,8 +33,8 @@ pub use self::crypto_data::*; pub use self::cookie::*; pub use self::errors::*; -use toxcore::binary_io::*; -use toxcore::onion::packet::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::onion::packet::*; /** DHT packet enum that encapsulates all types of DHT packets. */ diff --git a/src/toxcore/dht/packet/nodes_request.rs b/src/toxcore/dht/packet/nodes_request.rs index 561c6acbb..f186f3980 100644 --- a/src/toxcore/dht/packet/nodes_request.rs +++ b/src/toxcore/dht/packet/nodes_request.rs @@ -3,10 +3,10 @@ use nom::{be_u64, rest}; -use toxcore::binary_io::*; -use toxcore::crypto_core::*; -use toxcore::dht::codec::*; -use toxcore::dht::packet::errors::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::dht::codec::*; +use crate::toxcore::dht::packet::errors::*; /** Nodes request packet struct. It's used to get up to 4 closest nodes to requested public key. Every 20 seconds DHT node sends `NodesRequest` packet to @@ -141,8 +141,8 @@ impl FromBytes for NodesRequestPayload { #[cfg(test)] mod tests { - use toxcore::dht::packet::nodes_request::*; - use toxcore::dht::packet::Packet; + use crate::toxcore::dht::packet::nodes_request::*; + use crate::toxcore::dht::packet::Packet; encode_decode_test!( nodes_request_payload_encode_decode, diff --git a/src/toxcore/dht/packet/nodes_response.rs b/src/toxcore/dht/packet/nodes_response.rs index 57b15a662..8d767d307 100644 --- a/src/toxcore/dht/packet/nodes_response.rs +++ b/src/toxcore/dht/packet/nodes_response.rs @@ -3,11 +3,11 @@ use nom::{le_u8, be_u64, rest}; -use toxcore::binary_io::*; -use toxcore::crypto_core::*; -use toxcore::dht::packed_node::PackedNode; -use toxcore::dht::codec::*; -use toxcore::dht::packet::errors::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::dht::packed_node::PackedNode; +use crate::toxcore::dht::codec::*; +use crate::toxcore::dht::packet::errors::*; /** Nodes response packet struct. When DHT node receives `NodesRequest` it should respond with `NodesResponse` that contains up to to 4 closest nodes to @@ -157,8 +157,8 @@ impl FromBytes for NodesResponsePayload { #[cfg(test)] mod tests { - use toxcore::dht::packet::nodes_response::*; - use toxcore::dht::packet::Packet; + use crate::toxcore::dht::packet::nodes_response::*; + use crate::toxcore::dht::packet::Packet; use std::net::SocketAddr; encode_decode_test!( diff --git a/src/toxcore/dht/packet/ping_request.rs b/src/toxcore/dht/packet/ping_request.rs index 61eca2f88..1e9afe3de 100644 --- a/src/toxcore/dht/packet/ping_request.rs +++ b/src/toxcore/dht/packet/ping_request.rs @@ -3,10 +3,10 @@ use nom::{be_u64, rest}; -use toxcore::binary_io::*; -use toxcore::crypto_core::*; -use toxcore::dht::codec::*; -use toxcore::dht::packet::errors::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::dht::codec::*; +use crate::toxcore::dht::packet::errors::*; /** Ping request packet struct. Every 60 seconds DHT node sends `PingRequest` packet to peers to check whether it is alive. When `PingRequest` is received @@ -152,8 +152,8 @@ impl ToBytes for PingRequestPayload { #[cfg(test)] mod tests { - use toxcore::dht::packet::ping_request::*; - use toxcore::dht::packet::Packet; + use crate::toxcore::dht::packet::ping_request::*; + use crate::toxcore::dht::packet::Packet; encode_decode_test!( ping_request_payload_encode_decode, diff --git a/src/toxcore/dht/packet/ping_response.rs b/src/toxcore/dht/packet/ping_response.rs index 0ac4baba3..589a20b27 100644 --- a/src/toxcore/dht/packet/ping_response.rs +++ b/src/toxcore/dht/packet/ping_response.rs @@ -3,10 +3,10 @@ use nom::{be_u64, rest}; -use toxcore::binary_io::*; -use toxcore::crypto_core::*; -use toxcore::dht::codec::*; -use toxcore::dht::packet::errors::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::dht::codec::*; +use crate::toxcore::dht::packet::errors::*; /** Ping response packet struct. When `PingRequest` is received DHT node should respond with `PingResponse` that contains the same ping id inside it's encrypted @@ -149,8 +149,8 @@ impl ToBytes for PingResponsePayload { #[cfg(test)] mod tests { - use toxcore::dht::packet::ping_response::*; - use toxcore::dht::packet::Packet; + use crate::toxcore::dht::packet::ping_response::*; + use crate::toxcore::dht::packet::Packet; encode_decode_test!( ping_response_payload_encode_decode, diff --git a/src/toxcore/dht/precomputed_cache.rs b/src/toxcore/dht/precomputed_cache.rs index a48c16916..903705969 100644 --- a/src/toxcore/dht/precomputed_cache.rs +++ b/src/toxcore/dht/precomputed_cache.rs @@ -5,7 +5,7 @@ use std::sync::Arc; use lru::LruCache; use parking_lot::Mutex; -use toxcore::crypto_core::*; +use crate::toxcore::crypto_core::*; /// LRU cache for `PrecomputedKey`s. /// diff --git a/src/toxcore/dht/request_queue.rs b/src/toxcore/dht/request_queue.rs index d0796dd6a..897fd0f06 100644 --- a/src/toxcore/dht/request_queue.rs +++ b/src/toxcore/dht/request_queue.rs @@ -3,8 +3,8 @@ use std::collections::HashMap; use std::time::{Duration, Instant}; -use toxcore::crypto_core::*; -use toxcore::time::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::time::*; /** Struct that stores and manages requests IDs and timeouts. @@ -75,7 +75,7 @@ mod tests { use tokio_executor; use tokio_timer::clock::*; - use toxcore::time::ConstNow; + use crate::toxcore::time::ConstNow; #[test] fn clone() { diff --git a/src/toxcore/dht/server/hole_punching.rs b/src/toxcore/dht/server/hole_punching.rs index 714e22baf..8ba3d9f05 100644 --- a/src/toxcore/dht/server/hole_punching.rs +++ b/src/toxcore/dht/server/hole_punching.rs @@ -8,9 +8,9 @@ use std::net::{IpAddr, SocketAddr}; use std::time::{Duration, Instant}; use std::collections::HashMap; -use toxcore::dht::dht_friend::*; -use toxcore::dht::server::*; -use toxcore::utils::*; +use crate::toxcore::dht::dht_friend::*; +use crate::toxcore::dht::server::*; +use crate::toxcore::utils::*; /// Interval in seconds for sending `NatPingRequest` packet and doing hole /// punching. diff --git a/src/toxcore/dht/server/mod.rs b/src/toxcore/dht/server/mod.rs index 8e8e3296b..669d4df26 100644 --- a/src/toxcore/dht/server/mod.rs +++ b/src/toxcore/dht/server/mod.rs @@ -17,24 +17,24 @@ use std::sync::Arc; use std::time::{Duration, Instant}; use std::{iter, mem}; -use toxcore::time::*; -use toxcore::crypto_core::*; -use toxcore::dht::packet::*; -use toxcore::dht::packed_node::*; -use toxcore::dht::kbucket::*; -use toxcore::dht::nodes_queue::*; -use toxcore::dht::precomputed_cache::*; -use toxcore::onion::packet::*; -use toxcore::onion::onion_announce::*; -use toxcore::dht::request_queue::*; -use toxcore::io_tokio::*; -use toxcore::dht::dht_friend::*; -use toxcore::dht::dht_node::*; -use toxcore::dht::server::hole_punching::*; -use toxcore::tcp::packet::OnionRequest; -use toxcore::net_crypto::*; -use toxcore::dht::ip_port::IsGlobal; -use toxcore::utils::*; +use crate::toxcore::time::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::dht::packet::*; +use crate::toxcore::dht::packed_node::*; +use crate::toxcore::dht::kbucket::*; +use crate::toxcore::dht::nodes_queue::*; +use crate::toxcore::dht::precomputed_cache::*; +use crate::toxcore::onion::packet::*; +use crate::toxcore::onion::onion_announce::*; +use crate::toxcore::dht::request_queue::*; +use crate::toxcore::io_tokio::*; +use crate::toxcore::dht::dht_friend::*; +use crate::toxcore::dht::dht_node::*; +use crate::toxcore::dht::server::hole_punching::*; +use crate::toxcore::tcp::packet::OnionRequest; +use crate::toxcore::net_crypto::*; +use crate::toxcore::dht::ip_port::IsGlobal; +use crate::toxcore::utils::*; /// Shorthand for the transmit half of the message channel. type Tx = mpsc::Sender<(Packet, SocketAddr)>; @@ -1409,7 +1409,7 @@ mod tests { use tokio_executor; use tokio_timer::clock::*; - use toxcore::time::ConstNow; + use crate::toxcore::time::ConstNow; const ONION_RETURN_1_PAYLOAD_SIZE: usize = ONION_RETURN_1_SIZE - secretbox::NONCEBYTES; const ONION_RETURN_2_PAYLOAD_SIZE: usize = ONION_RETURN_2_SIZE - secretbox::NONCEBYTES; diff --git a/src/toxcore/dht/server_ext.rs b/src/toxcore/dht/server_ext.rs index 79273c41e..cbb3d63bf 100644 --- a/src/toxcore/dht/server_ext.rs +++ b/src/toxcore/dht/server_ext.rs @@ -8,11 +8,11 @@ use futures::sync::mpsc::Receiver; use tokio::net::{UdpSocket, UdpFramed}; use failure::Fail; -use toxcore::io_tokio::*; -use toxcore::dht::codec::*; -use toxcore::dht::packet::Packet; -use toxcore::dht::server::Server; -use toxcore::stats::Stats; +use crate::toxcore::io_tokio::*; +use crate::toxcore::dht::codec::*; +use crate::toxcore::dht::packet::Packet; +use crate::toxcore::dht::server::Server; +use crate::toxcore::stats::Stats; /// Extension trait for running DHT server on `UdpSocket`. pub trait ServerExt { @@ -80,8 +80,8 @@ mod tests { use futures::sync::mpsc; use tokio; - use toxcore::crypto_core::*; - use toxcore::dht::packet::*; + use crate::toxcore::crypto_core::*; + use crate::toxcore::dht::packet::*; #[test] fn run_socket() { diff --git a/src/toxcore/friend_connection/packet/alive.rs b/src/toxcore/friend_connection/packet/alive.rs index b086312d0..2eb152bf3 100644 --- a/src/toxcore/friend_connection/packet/alive.rs +++ b/src/toxcore/friend_connection/packet/alive.rs @@ -1,7 +1,7 @@ /*! Alive struct */ -use toxcore::binary_io::*; +use crate::toxcore::binary_io::*; /** Alive is a struct that holds nothing. diff --git a/src/toxcore/friend_connection/packet/friend_requests.rs b/src/toxcore/friend_connection/packet/friend_requests.rs index f20869d49..deb2be1f8 100644 --- a/src/toxcore/friend_connection/packet/friend_requests.rs +++ b/src/toxcore/friend_connection/packet/friend_requests.rs @@ -3,10 +3,10 @@ use nom::rest; -use toxcore::binary_io::*; -use toxcore::onion::packet::*; -use toxcore::crypto_core::*; -use toxcore::toxid::NoSpam; +use crate::toxcore::binary_io::*; +use crate::toxcore::onion::packet::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::toxid::NoSpam; const ONION_SEND_BASE: usize = PUBLICKEYBYTES + SIZE_IPPORT + MACBYTES; const ONION_SEND_1: usize = secretbox::NONCEBYTES + ONION_SEND_BASE * 3; diff --git a/src/toxcore/friend_connection/packet/mod.rs b/src/toxcore/friend_connection/packet/mod.rs index 0111cbba7..da9afc3ad 100644 --- a/src/toxcore/friend_connection/packet/mod.rs +++ b/src/toxcore/friend_connection/packet/mod.rs @@ -1,7 +1,7 @@ /*! Top-level Friend connection Packets */ -use toxcore::binary_io::*; +use crate::toxcore::binary_io::*; mod alive; mod share_relays; @@ -44,8 +44,8 @@ impl FromBytes for Packet { #[cfg(test)] mod tests { use super::*; - use toxcore::toxid::NoSpam; - use toxcore::dht::packed_node::*; + use crate::toxcore::toxid::NoSpam; + use crate::toxcore::dht::packed_node::*; encode_decode_test!( packet_alive_encode_decode, diff --git a/src/toxcore/friend_connection/packet/share_relays.rs b/src/toxcore/friend_connection/packet/share_relays.rs index e913b5575..0b0b51dd3 100644 --- a/src/toxcore/friend_connection/packet/share_relays.rs +++ b/src/toxcore/friend_connection/packet/share_relays.rs @@ -1,8 +1,8 @@ /*! ShareRalays struct */ -use toxcore::binary_io::*; -use toxcore::dht::packed_node::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::dht::packed_node::*; /** ShareRelays is a struct that holds at most 3 TCP relays as a PackedNode format. diff --git a/src/toxcore/messenger/packet/mod.rs b/src/toxcore/messenger/packet/mod.rs index 49aa35957..07716eb61 100644 --- a/src/toxcore/messenger/packet/mod.rs +++ b/src/toxcore/messenger/packet/mod.rs @@ -1,7 +1,7 @@ /*! Top-level Messenger Packets */ -use toxcore::binary_io::*; +use crate::toxcore::binary_io::*; mod online; mod offline; diff --git a/src/toxcore/messenger/packet/nickname.rs b/src/toxcore/messenger/packet/nickname.rs index b8bbefd80..fd181bd74 100644 --- a/src/toxcore/messenger/packet/nickname.rs +++ b/src/toxcore/messenger/packet/nickname.rs @@ -4,7 +4,7 @@ use std::str; use nom::rest; -use toxcore::binary_io::*; +use crate::toxcore::binary_io::*; /// Maximum size in bytes of nickname string of nickname packet const MAX_NICKNAME_DATA_SIZE: usize = 128; diff --git a/src/toxcore/messenger/packet/offline.rs b/src/toxcore/messenger/packet/offline.rs index f75c04562..570f32bee 100644 --- a/src/toxcore/messenger/packet/offline.rs +++ b/src/toxcore/messenger/packet/offline.rs @@ -1,7 +1,7 @@ /*! Offline struct */ -use toxcore::binary_io::*; +use crate::toxcore::binary_io::*; /** Offline is a struct that holds nothing. diff --git a/src/toxcore/messenger/packet/online.rs b/src/toxcore/messenger/packet/online.rs index 2479b3952..206667742 100644 --- a/src/toxcore/messenger/packet/online.rs +++ b/src/toxcore/messenger/packet/online.rs @@ -1,7 +1,7 @@ /*! Online struct */ -use toxcore::binary_io::*; +use crate::toxcore::binary_io::*; /** Online is a struct that holds nothing. diff --git a/src/toxcore/net_crypto/crypto_connection.rs b/src/toxcore/net_crypto/crypto_connection.rs index a200f7984..912587faa 100644 --- a/src/toxcore/net_crypto/crypto_connection.rs +++ b/src/toxcore/net_crypto/crypto_connection.rs @@ -5,9 +5,9 @@ use std::time::{Duration, Instant}; use super::packets_array::*; -use toxcore::crypto_core::*; -use toxcore::dht::packet::*; -use toxcore::time::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::dht::packet::*; +use crate::toxcore::time::*; /// Interval in ms between sending cookie request/handshake packets. pub const CRYPTO_SEND_PACKET_INTERVAL: u64 = 1000; @@ -594,7 +594,7 @@ mod tests { use tokio_executor; use tokio_timer::clock::*; - use toxcore::time::ConstNow; + use crate::toxcore::time::ConstNow; #[test] fn status_packet_should_be_sent() { diff --git a/src/toxcore/net_crypto/mod.rs b/src/toxcore/net_crypto/mod.rs index aa424fa74..1e65966e8 100644 --- a/src/toxcore/net_crypto/mod.rs +++ b/src/toxcore/net_crypto/mod.rs @@ -29,12 +29,12 @@ use futures::sync::mpsc; use parking_lot::RwLock; use tokio::timer::Interval; -use toxcore::binary_io::*; -use toxcore::crypto_core::*; -use toxcore::dht::packet::*; -use toxcore::dht::precomputed_cache::*; -use toxcore::io_tokio::*; -use toxcore::time::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::dht::packet::*; +use crate::toxcore::dht::precomputed_cache::*; +use crate::toxcore::io_tokio::*; +use crate::toxcore::time::*; /// Maximum size of `Packet` when we try to send it to UDP address even if /// it's considered dead. @@ -769,7 +769,7 @@ mod tests { use tokio_executor; use tokio_timer::clock::*; - use toxcore::time::ConstNow; + use crate::toxcore::time::ConstNow; #[test] fn net_crypto_clone() { diff --git a/src/toxcore/onion/onion_announce.rs b/src/toxcore/onion/onion_announce.rs index aa77e1495..d0ef9d6b2 100644 --- a/src/toxcore/onion/onion_announce.rs +++ b/src/toxcore/onion/onion_announce.rs @@ -5,11 +5,11 @@ use std::io::{ErrorKind, Error}; use std::net::{IpAddr, SocketAddr}; use std::time::{Duration, Instant, SystemTime}; -use toxcore::binary_io::*; -use toxcore::crypto_core::*; -use toxcore::time::*; -use toxcore::onion::packet::*; -use toxcore::dht::kbucket::Distance; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::time::*; +use crate::toxcore::onion::packet::*; +use crate::toxcore::dht::kbucket::Distance; /// Number of secret random bytes to make onion ping id unique for each node. pub const SECRET_BYTES_SIZE: usize = 32; @@ -341,7 +341,7 @@ mod tests { use tokio_executor; use tokio_timer::clock::*; - use toxcore::time::ConstNow; + use crate::toxcore::time::ConstNow; const ONION_RETURN_3_PAYLOAD_SIZE: usize = ONION_RETURN_3_SIZE - secretbox::NONCEBYTES; diff --git a/src/toxcore/onion/packet/inner_onion_request.rs b/src/toxcore/onion/packet/inner_onion_request.rs index 7ff1cc008..e0ffac95e 100644 --- a/src/toxcore/onion/packet/inner_onion_request.rs +++ b/src/toxcore/onion/packet/inner_onion_request.rs @@ -3,7 +3,7 @@ use super::*; -use toxcore::binary_io::*; +use crate::toxcore::binary_io::*; /** Onion requests that can be enclosed in onion packets and sent through onion path. diff --git a/src/toxcore/onion/packet/inner_onion_response.rs b/src/toxcore/onion/packet/inner_onion_response.rs index 109d5613d..3cdef33f1 100644 --- a/src/toxcore/onion/packet/inner_onion_response.rs +++ b/src/toxcore/onion/packet/inner_onion_response.rs @@ -3,7 +3,7 @@ use super::*; -use toxcore::binary_io::*; +use crate::toxcore::binary_io::*; /** Onion responses that can be enclosed in onion packets and sent through onion path. diff --git a/src/toxcore/onion/packet/mod.rs b/src/toxcore/onion/packet/mod.rs index 094e05520..ae3c05f50 100644 --- a/src/toxcore/onion/packet/mod.rs +++ b/src/toxcore/onion/packet/mod.rs @@ -27,9 +27,9 @@ pub use self::onion_response_1::*; pub use self::onion_response_2::*; pub use self::onion_response_3::*; -use toxcore::binary_io::*; -use toxcore::crypto_core::*; -use toxcore::dht::packed_node::PackedNode; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::dht::packed_node::PackedNode; use nom::{be_u16, le_u8, rest}; use std::net::{ diff --git a/src/toxcore/onion/packet/onion_announce_request.rs b/src/toxcore/onion/packet/onion_announce_request.rs index e33731c87..3c0532172 100644 --- a/src/toxcore/onion/packet/onion_announce_request.rs +++ b/src/toxcore/onion/packet/onion_announce_request.rs @@ -3,8 +3,8 @@ use super::*; -use toxcore::binary_io::*; -use toxcore::crypto_core::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; use nom::{le_u64, rest}; use std::io::{Error, ErrorKind}; diff --git a/src/toxcore/onion/packet/onion_announce_response.rs b/src/toxcore/onion/packet/onion_announce_response.rs index ed5c29522..4d20a283c 100644 --- a/src/toxcore/onion/packet/onion_announce_response.rs +++ b/src/toxcore/onion/packet/onion_announce_response.rs @@ -3,8 +3,8 @@ use super::*; -use toxcore::binary_io::*; -use toxcore::crypto_core::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; use nom::{le_u64, rest}; use std::io::{Error, ErrorKind}; diff --git a/src/toxcore/onion/packet/onion_data_request.rs b/src/toxcore/onion/packet/onion_data_request.rs index 784321cf7..16b5afa14 100644 --- a/src/toxcore/onion/packet/onion_data_request.rs +++ b/src/toxcore/onion/packet/onion_data_request.rs @@ -3,8 +3,8 @@ use super::*; -use toxcore::binary_io::*; -use toxcore::crypto_core::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; use nom::rest; diff --git a/src/toxcore/onion/packet/onion_data_response.rs b/src/toxcore/onion/packet/onion_data_response.rs index bc8f01f59..bd048fbda 100644 --- a/src/toxcore/onion/packet/onion_data_response.rs +++ b/src/toxcore/onion/packet/onion_data_response.rs @@ -3,8 +3,8 @@ use super::*; -use toxcore::binary_io::*; -use toxcore::crypto_core::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; use nom::rest; diff --git a/src/toxcore/onion/packet/onion_request_0.rs b/src/toxcore/onion/packet/onion_request_0.rs index be45c264d..52b2afd18 100644 --- a/src/toxcore/onion/packet/onion_request_0.rs +++ b/src/toxcore/onion/packet/onion_request_0.rs @@ -3,8 +3,8 @@ use super::*; -use toxcore::binary_io::*; -use toxcore::crypto_core::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; use nom::rest; use std::io::{Error, ErrorKind}; diff --git a/src/toxcore/onion/packet/onion_request_1.rs b/src/toxcore/onion/packet/onion_request_1.rs index fa0157e2b..790b8259d 100644 --- a/src/toxcore/onion/packet/onion_request_1.rs +++ b/src/toxcore/onion/packet/onion_request_1.rs @@ -3,8 +3,8 @@ use super::*; -use toxcore::binary_io::*; -use toxcore::crypto_core::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; use nom::rest; use std::io::{Error, ErrorKind}; diff --git a/src/toxcore/onion/packet/onion_request_2.rs b/src/toxcore/onion/packet/onion_request_2.rs index a982f4329..666ebe2b0 100644 --- a/src/toxcore/onion/packet/onion_request_2.rs +++ b/src/toxcore/onion/packet/onion_request_2.rs @@ -3,8 +3,8 @@ use super::*; -use toxcore::binary_io::*; -use toxcore::crypto_core::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; use std::io::{Error, ErrorKind}; diff --git a/src/toxcore/onion/packet/onion_response_1.rs b/src/toxcore/onion/packet/onion_response_1.rs index 981b3f9c2..b155a43a9 100644 --- a/src/toxcore/onion/packet/onion_response_1.rs +++ b/src/toxcore/onion/packet/onion_response_1.rs @@ -3,7 +3,7 @@ use super::*; -use toxcore::binary_io::*; +use crate::toxcore::binary_io::*; /** First onion response packet. It's sent back from the second to the first node from onion chain. diff --git a/src/toxcore/onion/packet/onion_response_2.rs b/src/toxcore/onion/packet/onion_response_2.rs index 8f94fb131..2093453b4 100644 --- a/src/toxcore/onion/packet/onion_response_2.rs +++ b/src/toxcore/onion/packet/onion_response_2.rs @@ -3,7 +3,7 @@ use super::*; -use toxcore::binary_io::*; +use crate::toxcore::binary_io::*; /** Second onion response packet. It's sent back from the third to the second node from onion chain. diff --git a/src/toxcore/onion/packet/onion_response_3.rs b/src/toxcore/onion/packet/onion_response_3.rs index 7c6d34c6f..561c46465 100644 --- a/src/toxcore/onion/packet/onion_response_3.rs +++ b/src/toxcore/onion/packet/onion_response_3.rs @@ -3,7 +3,7 @@ use super::*; -use toxcore::binary_io::*; +use crate::toxcore::binary_io::*; /** Third onion response packet. It's sent back from the destination node to the third node from onion chain. diff --git a/src/toxcore/state_format/old.rs b/src/toxcore/state_format/old.rs index 45dcc73d4..b83030200 100644 --- a/src/toxcore/state_format/old.rs +++ b/src/toxcore/state_format/old.rs @@ -11,11 +11,11 @@ use std::net::{ use byteorder::{ByteOrder, LittleEndian}; use nom::{le_u16, be_u16, le_u8, le_u32, le_u64, rest}; -use toxcore::binary_io::*; -use toxcore::crypto_core::*; -use toxcore::dht::packed_node::*; -use toxcore::toxid::{NoSpam, NOSPAMBYTES}; -use toxcore::onion::packet::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::dht::packed_node::*; +use crate::toxcore::toxid::{NoSpam, NOSPAMBYTES}; +use crate::toxcore::onion::packet::*; const REQUEST_MSG_LEN: usize = 1024; diff --git a/src/toxcore/tcp/client/client.rs b/src/toxcore/tcp/client/client.rs index ba8bacafe..bc21d6eb3 100644 --- a/src/toxcore/tcp/client/client.rs +++ b/src/toxcore/tcp/client/client.rs @@ -13,16 +13,16 @@ use tokio_codec::Framed; use tokio; use tokio::net::TcpStream; -use toxcore::crypto_core::*; -use toxcore::io_tokio::*; -use toxcore::onion::packet::InnerOnionResponse; -use toxcore::stats::Stats; -use toxcore::tcp::codec::{Codec, EncodeError}; -use toxcore::tcp::connection_id::ConnectionId; -use toxcore::tcp::handshake::make_client_handshake; -use toxcore::tcp::links::*; -use toxcore::tcp::packet::*; -use toxcore::time::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::io_tokio::*; +use crate::toxcore::onion::packet::InnerOnionResponse; +use crate::toxcore::stats::Stats; +use crate::toxcore::tcp::codec::{Codec, EncodeError}; +use crate::toxcore::tcp::connection_id::ConnectionId; +use crate::toxcore::tcp::handshake::make_client_handshake; +use crate::toxcore::tcp::links::*; +use crate::toxcore::tcp::packet::*; +use crate::toxcore::time::*; /// Buffer size (in packets) for outgoing packets. This number shouldn't be high /// to minimize latency. If some relay can't take more packets we can use @@ -516,8 +516,8 @@ pub mod tests { use tokio::net::TcpListener; use tokio::timer::Interval; - use toxcore::onion::packet::*; - use toxcore::tcp::server::{Server, ServerExt}; + use crate::toxcore::onion::packet::*; + use crate::toxcore::tcp::server::{Server, ServerExt}; pub fn create_client() -> (mpsc::UnboundedReceiver<(PublicKey, IncomingPacket)>, mpsc::Receiver, Client) { crypto_init().unwrap(); diff --git a/src/toxcore/tcp/client/connections.rs b/src/toxcore/tcp/client/connections.rs index dc5cbf0a0..96702ae77 100644 --- a/src/toxcore/tcp/client/connections.rs +++ b/src/toxcore/tcp/client/connections.rs @@ -24,10 +24,10 @@ use futures::future::Either; use futures::sync::mpsc; use tokio::timer::Interval; -use toxcore::crypto_core::*; -use toxcore::tcp::client::client::*; -use toxcore::tcp::packet::*; -use toxcore::time::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::tcp::client::client::*; +use crate::toxcore::tcp::packet::*; +use crate::toxcore::time::*; /// The amount of maximum connections for each friend. const MAX_FRIEND_TCP_CONNECTIONS: usize = 6; @@ -134,9 +134,7 @@ impl Connections { /// via this relay will be added as well. pub fn add_relay_connection(&self, relay_addr: SocketAddr, relay_pk: PublicKey, node_pk: PublicKey) -> impl Future + Send { let mut clients = self.clients.write(); - // TODO: NLL - if clients.contains_key(&relay_pk) { - let client = clients.get(&relay_pk).unwrap(); + if let Some(client) = clients.get(&relay_pk) { Box::new(self.add_connection_inner(client, node_pk)) } else { let mut connections = self.connections.write(); @@ -368,10 +366,10 @@ mod tests { use tokio_executor; use tokio_timer::clock::*; - use toxcore::tcp::client::client::tests::*; - use toxcore::tcp::connection_id::ConnectionId; - use toxcore::time::ConstNow; - use toxcore::onion::packet::*; + use crate::toxcore::tcp::client::client::tests::*; + use crate::toxcore::tcp::connection_id::ConnectionId; + use crate::toxcore::time::ConstNow; + use crate::toxcore::onion::packet::*; #[test] fn add_relay_global() { diff --git a/src/toxcore/tcp/codec.rs b/src/toxcore/tcp/codec.rs index 7c63ef284..cbca25f1e 100644 --- a/src/toxcore/tcp/codec.rs +++ b/src/toxcore/tcp/codec.rs @@ -3,11 +3,12 @@ use std::io::{Error as IoError}; -use toxcore::binary_io::*; -use toxcore::tcp::packet::*; -use toxcore::tcp::secure::*; -use toxcore::stats::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::tcp::packet::*; +use crate::toxcore::tcp::secure::*; +use crate::toxcore::stats::*; +use failure::Fail; use nom::{ErrorKind, Needed, Offset}; use bytes::BytesMut; use tokio_codec::{Decoder, Encoder}; @@ -174,10 +175,10 @@ impl Encoder for Codec { #[cfg(test)] mod tests { - use ::toxcore::crypto_core::*; - use ::toxcore::onion::packet::*; - use ::toxcore::tcp::codec::*; - use ::toxcore::tcp::connection_id::ConnectionId; + use crate::toxcore::crypto_core::*; + use crate::toxcore::onion::packet::*; + use crate::toxcore::tcp::codec::*; + use crate::toxcore::tcp::connection_id::ConnectionId; use std::io::{ErrorKind as IoErrorKind}; use std::net::{ diff --git a/src/toxcore/tcp/connection_id.rs b/src/toxcore/tcp/connection_id.rs index 055ed4956..1e6d34d58 100644 --- a/src/toxcore/tcp/connection_id.rs +++ b/src/toxcore/tcp/connection_id.rs @@ -2,8 +2,8 @@ use std::num::NonZeroU8; -use toxcore::binary_io::*; -use toxcore::tcp::links::MAX_LINKS_N; +use crate::toxcore::binary_io::*; +use crate::toxcore::tcp::links::MAX_LINKS_N; use nom::be_u8; diff --git a/src/toxcore/tcp/handshake/codec.rs b/src/toxcore/tcp/handshake/codec.rs index 2e48e515a..2e0c7af2e 100644 --- a/src/toxcore/tcp/handshake/codec.rs +++ b/src/toxcore/tcp/handshake/codec.rs @@ -1,8 +1,8 @@ /*! Codecs to deal with ClientHandshake and ServerHandshake in terms of tokio-io */ -use toxcore::binary_io::*; -use toxcore::tcp::handshake::packet::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::tcp::handshake::packet::*; use nom::Offset; use bytes::BytesMut; @@ -89,8 +89,8 @@ impl Encoder for ServerHandshakeCodec { #[cfg(test)] mod tests { - use ::toxcore::tcp::handshake::codec::*; - use ::toxcore::crypto_core::*; + use crate::toxcore::tcp::handshake::codec::*; + use crate::toxcore::crypto_core::*; use bytes::BytesMut; #[test] diff --git a/src/toxcore/tcp/handshake/mod.rs b/src/toxcore/tcp/handshake/mod.rs index f847eddb6..611f997fa 100644 --- a/src/toxcore/tcp/handshake/mod.rs +++ b/src/toxcore/tcp/handshake/mod.rs @@ -9,9 +9,9 @@ pub mod codec; pub use self::packet::*; pub use self::codec::*; -use toxcore::binary_io::*; -use toxcore::crypto_core::*; -use toxcore::tcp::secure; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::tcp::secure; use futures::{self, Stream, Sink, Future}; use std::io::{Error, ErrorKind}; @@ -187,9 +187,9 @@ pub fn make_server_handshake(socket: TcpStream, #[cfg(test)] mod tests { - use toxcore::crypto_core::*; - use toxcore::tcp::*; - use toxcore::tcp::handshake::*; + use crate::toxcore::crypto_core::*; + use crate::toxcore::tcp::*; + use crate::toxcore::tcp::handshake::*; fn create_channels_with_handshake() -> (secure::Channel, secure::Channel) { crypto_init().unwrap(); diff --git a/src/toxcore/tcp/handshake/packet.rs b/src/toxcore/tcp/handshake/packet.rs index 14a3f7144..4cb5c1207 100644 --- a/src/toxcore/tcp/handshake/packet.rs +++ b/src/toxcore/tcp/handshake/packet.rs @@ -3,8 +3,8 @@ handshake using [`diagram`](https://zetok.github.io/tox-spec/#handshake-diagram) */ -use toxcore::binary_io::*; -use toxcore::crypto_core::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; /** The request of the client to create a TCP handshake. diff --git a/src/toxcore/tcp/links.rs b/src/toxcore/tcp/links.rs index 79b034e7f..67f46f4ea 100644 --- a/src/toxcore/tcp/links.rs +++ b/src/toxcore/tcp/links.rs @@ -1,7 +1,7 @@ /*! The implementation of links used by server and clients */ -use toxcore::crypto_core::*; +use crate::toxcore::crypto_core::*; use std::collections::HashMap; @@ -169,8 +169,8 @@ impl Links { #[cfg(test)] mod tests { - use ::toxcore::crypto_core::*; - use ::toxcore::tcp::links::*; + use crate::toxcore::crypto_core::*; + use crate::toxcore::tcp::links::*; #[test] fn link_new() { diff --git a/src/toxcore/tcp/packet/connect_notification.rs b/src/toxcore/tcp/packet/connect_notification.rs index 715cb1b8d..af35b1001 100644 --- a/src/toxcore/tcp/packet/connect_notification.rs +++ b/src/toxcore/tcp/packet/connect_notification.rs @@ -1,8 +1,8 @@ /*! ConnectNotification packet */ -use toxcore::binary_io::*; -use toxcore::tcp::connection_id::ConnectionId; +use crate::toxcore::binary_io::*; +use crate::toxcore::tcp::connection_id::ConnectionId; /** Sent by server to client. Tell the client that connection_id is now connected meaning the other diff --git a/src/toxcore/tcp/packet/data.rs b/src/toxcore/tcp/packet/data.rs index f2cd15f63..359269e5b 100644 --- a/src/toxcore/tcp/packet/data.rs +++ b/src/toxcore/tcp/packet/data.rs @@ -1,8 +1,8 @@ /*! Data packet */ -use toxcore::binary_io::*; -use toxcore::tcp::connection_id::ConnectionId; +use crate::toxcore::binary_io::*; +use crate::toxcore::tcp::connection_id::ConnectionId; use nom::rest; diff --git a/src/toxcore/tcp/packet/disconnect_notification.rs b/src/toxcore/tcp/packet/disconnect_notification.rs index 1e690c566..bdf463b7f 100644 --- a/src/toxcore/tcp/packet/disconnect_notification.rs +++ b/src/toxcore/tcp/packet/disconnect_notification.rs @@ -1,8 +1,8 @@ /*! DisconnectNotification packet */ -use toxcore::binary_io::*; -use toxcore::tcp::connection_id::ConnectionId; +use crate::toxcore::binary_io::*; +use crate::toxcore::tcp::connection_id::ConnectionId; /** Sent by client to server. Sent when client wants the server to forget about the connection related diff --git a/src/toxcore/tcp/packet/mod.rs b/src/toxcore/tcp/packet/mod.rs index 35eabe335..60de3e5e8 100644 --- a/src/toxcore/tcp/packet/mod.rs +++ b/src/toxcore/tcp/packet/mod.rs @@ -26,7 +26,7 @@ pub use self::onion_request::OnionRequest; pub use self::onion_response::OnionResponse; pub use self::data::Data; -use toxcore::binary_io::*; +use crate::toxcore::binary_io::*; use nom::be_u16; diff --git a/src/toxcore/tcp/packet/onion_request.rs b/src/toxcore/tcp/packet/onion_request.rs index 65d43b701..7abe1e2d0 100644 --- a/src/toxcore/tcp/packet/onion_request.rs +++ b/src/toxcore/tcp/packet/onion_request.rs @@ -1,9 +1,9 @@ /*! OnionRequest packet */ -use toxcore::binary_io::*; -use toxcore::crypto_core::*; -use toxcore::onion::packet::{ +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::onion::packet::{ IpPort, ONION_MAX_PACKET_SIZE, ONION_RETURN_1_SIZE, @@ -88,7 +88,7 @@ impl ToBytes for OnionRequest { mod test { use super::*; - use toxcore::onion::packet::ProtocolType; + use crate::toxcore::onion::packet::ProtocolType; encode_decode_test!( onion_request_encode_decode, diff --git a/src/toxcore/tcp/packet/onion_response.rs b/src/toxcore/tcp/packet/onion_response.rs index dbd29bae6..f284b619f 100644 --- a/src/toxcore/tcp/packet/onion_response.rs +++ b/src/toxcore/tcp/packet/onion_response.rs @@ -1,8 +1,8 @@ /*! OnionResponse packet */ -use toxcore::binary_io::*; -use toxcore::onion::packet::InnerOnionResponse; +use crate::toxcore::binary_io::*; +use crate::toxcore::onion::packet::InnerOnionResponse; /** Sent by server to client. The server just sends payload from `OnionResponse1` packet that it got from a @@ -43,7 +43,7 @@ impl ToBytes for OnionResponse { mod test { use super::*; - use toxcore::onion::packet::{OnionAnnounceResponse, OnionDataResponse}; + use crate::toxcore::onion::packet::{OnionAnnounceResponse, OnionDataResponse}; encode_decode_test!( onion_response_with_announce_encode_decode, diff --git a/src/toxcore/tcp/packet/oob_receive.rs b/src/toxcore/tcp/packet/oob_receive.rs index c1265e5ef..1ab6966ef 100644 --- a/src/toxcore/tcp/packet/oob_receive.rs +++ b/src/toxcore/tcp/packet/oob_receive.rs @@ -1,8 +1,8 @@ /*! OobReceive packet */ -use toxcore::binary_io::*; -use toxcore::crypto_core::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; use nom::rest; diff --git a/src/toxcore/tcp/packet/oob_send.rs b/src/toxcore/tcp/packet/oob_send.rs index a134c880c..bba7f3284 100644 --- a/src/toxcore/tcp/packet/oob_send.rs +++ b/src/toxcore/tcp/packet/oob_send.rs @@ -1,8 +1,8 @@ /*! OobSend packet */ -use toxcore::binary_io::*; -use toxcore::crypto_core::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; use nom::rest; diff --git a/src/toxcore/tcp/packet/ping_request.rs b/src/toxcore/tcp/packet/ping_request.rs index 371d3a59a..3b7ecc11f 100644 --- a/src/toxcore/tcp/packet/ping_request.rs +++ b/src/toxcore/tcp/packet/ping_request.rs @@ -1,7 +1,7 @@ /*! PingRequest packet */ -use toxcore::binary_io::*; +use crate::toxcore::binary_io::*; use nom::be_u64; diff --git a/src/toxcore/tcp/packet/pong_response.rs b/src/toxcore/tcp/packet/pong_response.rs index 78690060e..1c37bef91 100644 --- a/src/toxcore/tcp/packet/pong_response.rs +++ b/src/toxcore/tcp/packet/pong_response.rs @@ -1,7 +1,7 @@ /*! PongResponse packet */ -use toxcore::binary_io::*; +use crate::toxcore::binary_io::*; use nom::be_u64; diff --git a/src/toxcore/tcp/packet/route_request.rs b/src/toxcore/tcp/packet/route_request.rs index f89bb4879..4b181725f 100644 --- a/src/toxcore/tcp/packet/route_request.rs +++ b/src/toxcore/tcp/packet/route_request.rs @@ -1,8 +1,8 @@ /*! RouteRequest packet */ -use toxcore::binary_io::*; -use toxcore::crypto_core::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; /** Sent by client to server. Send a routing request to the server that we want to connect diff --git a/src/toxcore/tcp/packet/route_response.rs b/src/toxcore/tcp/packet/route_response.rs index 80ed86572..f570cbcd8 100644 --- a/src/toxcore/tcp/packet/route_response.rs +++ b/src/toxcore/tcp/packet/route_response.rs @@ -1,9 +1,9 @@ /*! RouteResponse packet */ -use toxcore::binary_io::*; -use toxcore::crypto_core::*; -use toxcore::tcp::connection_id::ConnectionId; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::tcp::connection_id::ConnectionId; /** Sent by server to client. The response to the routing request, tell the client if the diff --git a/src/toxcore/tcp/secure.rs b/src/toxcore/tcp/secure.rs index 13fe778e3..1b8a7c616 100644 --- a/src/toxcore/tcp/secure.rs +++ b/src/toxcore/tcp/secure.rs @@ -45,7 +45,7 @@ assert_eq!( bob_msg.as_bytes().to_vec(), alice_channel.decrypt(bob_msg_encrypted */ -use toxcore::crypto_core::*; +use crate::toxcore::crypto_core::*; use std::cell::RefCell; @@ -137,7 +137,7 @@ impl Channel { #[cfg(test)] mod tests { - use ::toxcore::tcp::secure::*; + use crate::toxcore::tcp::secure::*; fn create_channels() -> (Channel, Channel) { crypto_init().unwrap(); diff --git a/src/toxcore/tcp/server/client.rs b/src/toxcore/tcp/server/client.rs index d313edbd1..8b9c93c02 100644 --- a/src/toxcore/tcp/server/client.rs +++ b/src/toxcore/tcp/server/client.rs @@ -1,14 +1,14 @@ /*! The inner implementation of client used only by relay server. */ -use toxcore::crypto_core::*; -use toxcore::tcp::packet::*; -use toxcore::tcp::connection_id::ConnectionId; -use toxcore::tcp::links::Links; -use toxcore::io_tokio::*; -use toxcore::onion::packet::InnerOnionResponse; -use toxcore::time::*; -use toxcore::utils::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::tcp::packet::*; +use crate::toxcore::tcp::connection_id::ConnectionId; +use crate::toxcore::tcp::links::Links; +use crate::toxcore::io_tokio::*; +use crate::toxcore::onion::packet::InnerOnionResponse; +use crate::toxcore::time::*; +use crate::toxcore::utils::*; use std::io::Error; use std::net::IpAddr; diff --git a/src/toxcore/tcp/server/server.rs b/src/toxcore/tcp/server/server.rs index 04684524b..18bca605d 100644 --- a/src/toxcore/tcp/server/server.rs +++ b/src/toxcore/tcp/server/server.rs @@ -1,12 +1,12 @@ /*! The implementation of relay server */ -use toxcore::crypto_core::*; -use toxcore::onion::packet::InnerOnionResponse; -use toxcore::tcp::server::client::Client; -use toxcore::tcp::connection_id::ConnectionId; -use toxcore::tcp::links::*; -use toxcore::tcp::packet::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::onion::packet::InnerOnionResponse; +use crate::toxcore::tcp::server::client::Client; +use crate::toxcore::tcp::connection_id::ConnectionId; +use crate::toxcore::tcp::links::*; +use crate::toxcore::tcp::packet::*; use std::io::{Error, ErrorKind}; use std::collections::HashMap; @@ -184,73 +184,64 @@ impl Server { fn handle_route_request(&self, pk: &PublicKey, packet: &RouteRequest) -> impl Future + Send { let mut state = self.state.write(); - let (b_id_in_client_a, client_a_route_response) = { - // get client_a - let mut client_a = if let Some(client) = state.connected_clients.get_mut(pk) { - client - } else { - return Box::new(future::err( - Error::new(ErrorKind::Other, - "RouteRequest: no such PK" - ))) as Box + Send> - }; + // get client_a + let client_a = if let Some(client) = state.connected_clients.get_mut(pk) { + client + } else { + return Box::new(future::err( + Error::new(ErrorKind::Other, + "RouteRequest: no such PK" + ))) as Box + Send> + }; - if pk == &packet.pk { - // send RouteResponse(0) if client requests its own pk - return Box::new(client_a.send_route_response(pk, ConnectionId::zero())) - } + if pk == &packet.pk { + // send RouteResponse(0) if client requests its own pk + return Box::new(client_a.send_route_response(pk, ConnectionId::zero())) + } - // check if client_a is already linked - if let Some(index) = client_a.links().id_by_pk(&packet.pk) { - // send RouteResponse if client was already linked to pk - return Box::new(client_a.send_route_response(&packet.pk, ConnectionId::from_index(index))) - } + // check if client_a is already linked + if let Some(index) = client_a.links().id_by_pk(&packet.pk) { + // send RouteResponse if client was already linked to pk + return Box::new(client_a.send_route_response(&packet.pk, ConnectionId::from_index(index))) + } - // try to insert a new link - let b_id_in_client_a = if let Some(index) = client_a.links_mut().insert(&packet.pk) { - index - } else { - // send RouteResponse(0) if no space to insert new link - return Box::new(client_a.send_route_response(&packet.pk, ConnectionId::zero())) - }; + // try to insert a new link + let b_id_in_client_a = if let Some(index) = client_a.links_mut().insert(&packet.pk) { + index + } else { + // send RouteResponse(0) if no space to insert new link + return Box::new(client_a.send_route_response(&packet.pk, ConnectionId::zero())) + }; - let client_a_route_response = client_a.send_route_response(&packet.pk, ConnectionId::from_index(b_id_in_client_a)); + let client_a_route_response = client_a.send_route_response(&packet.pk, ConnectionId::from_index(b_id_in_client_a)); - (b_id_in_client_a, client_a_route_response) + // get client_b + let client_b = if let Some(client) = state.connected_clients.get(&packet.pk) { + client + } else { + // send RouteResponse only to current client + return Box::new(client_a_route_response) }; // check if current pk is linked inside other_client - let a_id_in_client_b = { - // get client_b - let client_b = if let Some(client) = state.connected_clients.get(&packet.pk) { - client - } else { - // send RouteResponse only to current client - return Box::new(client_a_route_response) - }; - - if let Some(index) = client_b.links().id_by_pk(pk) { - index - } else { - // they are not linked - // send RouteResponse only to current client - return Box::new(client_a_route_response) - } + let a_id_in_client_b = if let Some(index) = client_b.links().id_by_pk(pk) { + index + } else { + // they are not linked + // send RouteResponse only to current client + return Box::new(client_a_route_response) }; // they are both linked, send RouteResponse and // send each other ConnectNotification // we don't care if connect notifications fail - let client_a_notification = { - let client_a = state.connected_clients.get_mut(pk).unwrap(); - client_a.links_mut().upgrade(b_id_in_client_a); - client_a.send_connect_notification(ConnectionId::from_index(b_id_in_client_a)) - }; - let client_b_notification = { - let client_b = state.connected_clients.get_mut(&packet.pk).unwrap(); - client_b.links_mut().upgrade(a_id_in_client_b); - client_b.send_connect_notification(ConnectionId::from_index(a_id_in_client_b)) - }; + let client_a = state.connected_clients.get_mut(pk).unwrap(); + client_a.links_mut().upgrade(b_id_in_client_a); + let client_a_notification = client_a.send_connect_notification(ConnectionId::from_index(b_id_in_client_a)); + + let client_b = state.connected_clients.get_mut(&packet.pk).unwrap(); + client_b.links_mut().upgrade(a_id_in_client_b); + let client_b_notification = client_b.send_connect_notification(ConnectionId::from_index(a_id_in_client_b)); Box::new( client_a_route_response @@ -311,7 +302,7 @@ impl Server { LinkStatus::Online => { let client_b_pk = a_link.pk; // get client_b - let mut client_b = if let Some(client) = state.connected_clients.get_mut(&client_b_pk) { + let client_b = if let Some(client) = state.connected_clients.get_mut(&client_b_pk) { client } else { // client_b is not connected to the server @@ -525,9 +516,9 @@ impl Server { mod tests { use super::*; - use ::toxcore::onion::packet::*; - use ::toxcore::tcp::server::{Client, Server}; - use ::toxcore::tcp::server::client::*; + use crate::toxcore::onion::packet::*; + use crate::toxcore::tcp::server::{Client, Server}; + use crate::toxcore::tcp::server::client::*; use futures::sync::mpsc; use futures::{Stream, Future}; @@ -537,7 +528,7 @@ mod tests { use tokio_executor; use tokio_timer::clock::*; - use toxcore::time::*; + use crate::toxcore::time::*; #[test] fn server_is_clonable() { diff --git a/src/toxcore/tcp/server/server_ext.rs b/src/toxcore/tcp/server/server_ext.rs index fe65319f7..deb770b6e 100644 --- a/src/toxcore/tcp/server/server_ext.rs +++ b/src/toxcore/tcp/server/server_ext.rs @@ -6,6 +6,7 @@ use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering}; use std::time::{Duration, Instant}; +use failure::Fail; use futures::{future, Future, Sink, Stream}; use futures::sync::mpsc; use tokio; @@ -13,11 +14,11 @@ use tokio::net::{TcpStream, TcpListener}; use tokio_codec::Framed; use tokio::timer::{Error as TimerError, Interval}; -use toxcore::crypto_core::*; -use toxcore::tcp::codec::{DecodeError, EncodeError, Codec}; -use toxcore::tcp::handshake::make_server_handshake; -use toxcore::tcp::server::{Client, Server}; -use toxcore::stats::*; +use crate::toxcore::crypto_core::*; +use crate::toxcore::tcp::codec::{DecodeError, EncodeError, Codec}; +use crate::toxcore::tcp::handshake::make_server_handshake; +use crate::toxcore::tcp::server::{Client, Server}; +use crate::toxcore::stats::*; /// Interval in seconds for Tcp Ping sender const TCP_PING_INTERVAL: u64 = 1; @@ -231,15 +232,15 @@ mod tests { use tokio; use tokio::runtime::Runtime; - use toxcore::tcp::codec::Codec; - use toxcore::tcp::handshake::make_client_handshake; - use toxcore::tcp::packet::{Packet, PingRequest, PongResponse}; + use crate::toxcore::tcp::codec::Codec; + use crate::toxcore::tcp::handshake::make_client_handshake; + use crate::toxcore::tcp::packet::{Packet, PingRequest, PongResponse}; use tokio_executor; use tokio_timer::clock::*; - use toxcore::time::*; - use toxcore::tcp::server::client::*; + use crate::toxcore::time::*; + use crate::toxcore::tcp::server::client::*; #[test] fn server_run_error_display() { diff --git a/src/toxcore/toxid.rs b/src/toxcore/toxid.rs index ee48a4035..6a2bdadc1 100644 --- a/src/toxcore/toxid.rs +++ b/src/toxcore/toxid.rs @@ -8,8 +8,8 @@ use std::fmt; -use toxcore::binary_io::*; -use toxcore::crypto_core::*; +use crate::toxcore::binary_io::*; +use crate::toxcore::crypto_core::*; /** Calculate XOR checksum for 2 [u8; 2]. @@ -301,8 +301,8 @@ impl fmt::Display for ToxId { #[cfg(test)] mod tests { - use ::toxcore::crypto_core::*; - use ::toxcore::toxid::*; + use crate::toxcore::crypto_core::*; + use crate::toxcore::toxid::*; fn test_is_hexdump_uppercase(s: &str) -> bool { fn test_is_hexdump_uppercase_b(b: u8) -> bool { diff --git a/src/toxcore/utils.rs b/src/toxcore/utils.rs index 3d5737034..199824ff1 100644 --- a/src/toxcore/utils.rs +++ b/src/toxcore/utils.rs @@ -1,7 +1,7 @@ /*! Common utility functions */ -use toxcore::crypto_core::*; +use crate::toxcore::crypto_core::*; /// Generate non-zero ping_id pub fn gen_ping_id() -> u64 { diff --git a/src/toxencryptsave/mod.rs b/src/toxencryptsave/mod.rs index 5e1c0eda9..5bbda8078 100644 --- a/src/toxencryptsave/mod.rs +++ b/src/toxencryptsave/mod.rs @@ -21,6 +21,8 @@ assert_eq!(plaintext, ``` */ +use failure::Fail; + use sodiumoxide::crypto::pwhash::{ MEMLIMIT_INTERACTIVE, OPSLIMIT_INTERACTIVE, Salt, OpsLimit, @@ -41,7 +43,7 @@ pub use sodiumoxide::crypto::pwhash::SALTBYTES as SALT_LENGTH; /// Length in bytes of the key used to encrypt/decrypt data. pub use sodiumoxide::crypto::box_::PRECOMPUTEDKEYBYTES as KEY_LENGTH; -use ::toxcore::crypto_core; +use crate::toxcore::crypto_core; /// Length (in bytes) of [`MAGIC_NUMBER`](./constant.MAGIC_NUMBER.html). @@ -111,9 +113,6 @@ impl PassKey { E.g. ``` - extern crate sodiumoxide; - extern crate tox; - # fn main() { use sodiumoxide::crypto::pwhash::gen_salt; use tox::toxencryptsave::*; diff --git a/src/toxencryptsave_tests/encryptsave_tests.rs b/src/toxencryptsave_tests/encryptsave_tests.rs index c087a0353..4b6fb936f 100644 --- a/src/toxencryptsave_tests/encryptsave_tests.rs +++ b/src/toxencryptsave_tests/encryptsave_tests.rs @@ -1,5 +1,5 @@ -use toxencryptsave::*; -use toxcore::crypto_core::*; +use crate::toxencryptsave::*; +use crate::toxcore::crypto_core::*; // is_encrypted() diff --git a/tests/state-format-old.rs b/tests/state-format-old.rs index c25a90c63..1291be469 100644 --- a/tests/state-format-old.rs +++ b/tests/state-format-old.rs @@ -1,5 +1,3 @@ -extern crate tox; - use tox::toxcore::binary_io::*; use tox::toxcore::state_format::old::*;