Skip to content

Commit

Permalink
Merge pull request #298 from tox-rs/edition_2018
Browse files Browse the repository at this point in the history
Edition 2018
  • Loading branch information
kpp authored Jan 12, 2019
2 parents c1b7787 + 3b476df commit 5abc688
Show file tree
Hide file tree
Showing 88 changed files with 349 additions and 397 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
7 changes: 0 additions & 7 deletions examples/dht_server.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
8 changes: 0 additions & 8 deletions examples/tcp_client.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 0 additions & 6 deletions examples/tcp_server.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
17 changes: 0 additions & 17 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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, pk1: &PublicKey, pk2: &PublicKey) -> Ordering;
}

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
Loading

0 comments on commit 5abc688

Please sign in to comment.