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

Edition 2018 #298

Merged
merged 8 commits into from
Jan 12, 2019
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
2 changes: 1 addition & 1 deletion src/toxcore/binary_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

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

Expand Down
10 changes: 5 additions & 5 deletions src/toxcore/dht/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 7 additions & 7 deletions src/toxcore/dht/daemon_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
16 changes: 8 additions & 8 deletions src/toxcore/dht/dht_friend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down
6 changes: 3 additions & 3 deletions src/toxcore/dht/dht_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 8 additions & 8 deletions src/toxcore/dht/kbucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -57,7 +57,7 @@ impl Into<DhtNode> 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, _: &PublicKey, _: &PublicKey) -> Ordering;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Give them a name

}

impl Distance for PublicKey {
Expand Down Expand Up @@ -552,7 +552,7 @@ mod tests {
use tokio_executor;
use tokio_timer::clock::*;

use toxcore::time::ConstNow;
use crate::toxcore::time::ConstNow;

// PublicKey::distance()

Expand Down
6 changes: 3 additions & 3 deletions src/toxcore/dht/lan_discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
6 changes: 3 additions & 3 deletions src/toxcore/dht/nodes_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down
4 changes: 2 additions & 2 deletions src/toxcore/dht/packed_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/toxcore/dht/packet/bootstrap_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions src/toxcore/dht/packet/cookie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/toxcore/dht/packet/cookie_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions src/toxcore/dht/packet/cookie_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
6 changes: 3 additions & 3 deletions src/toxcore/dht/packet/crypto_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions src/toxcore/dht/packet/crypto_handshake.rs
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
8 changes: 4 additions & 4 deletions src/toxcore/dht/packet/dht_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions src/toxcore/dht/packet/lan_discovery.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/toxcore/dht/packet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
12 changes: 6 additions & 6 deletions src/toxcore/dht/packet/nodes_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
14 changes: 7 additions & 7 deletions src/toxcore/dht/packet/nodes_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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!(
Expand Down
Loading