Skip to content

Commit bcb1868

Browse files
authored
Merge pull request #463 from tox-rs/bump
Update dependencies
2 parents 44858ce + 66dee09 commit bcb1868

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+206
-212
lines changed

.github/workflows/rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
os: [ubuntu-latest, macos-latest, windows-latest]
1515
rust:
1616
- stable
17-
- 1.56.1
17+
- 1.57
1818
steps:
1919
- uses: actions/checkout@v2
2020
- uses: actions-rs/toolchain@v1

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ issue / pull request should be filled on the reference repository.
3030
[CONTRIBUTING.md](/CONTRIBUTING.md).
3131

3232
## Building
33-
Fairly simple. First, install [Rust] >= 1.56.1 and a C compiler ([Build Tools
33+
Fairly simple. First, install [Rust] >= 1.57 and a C compiler ([Build Tools
3434
for Visual Studio][VSBuild] on Windows, GCC or Clang on other platforms).
3535

3636
Then you can build the debug version with

examples/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ rand = "0.8"
1919
anyhow = "1.0"
2020

2121
[dev-dependencies.tokio]
22-
version = "1.12"
22+
version = "1.20"
2323
default-features = false
2424
features = ["macros", "test-util", "net", "rt", "rt-multi-thread", "sync", "time"]
2525

2626
[dev-dependencies.tokio-util]
27-
version = "0.6"
27+
version = "0.7"
2828
features = ["codec", "net"]
2929

3030
[[example]]

examples/echo.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ async fn main() -> Result<(), Error> {
104104
net_crypto.set_tcp_sink(net_crypto_tcp_tx).await;
105105

106106
let friend_connections = FriendConnections::new(
107-
real_sk,
108-
real_pk,
109107
dht_server.clone(),
110108
tcp_connections.clone(),
111109
onion_client.clone(),

tox_binary_io/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ license = "GPL-3.0+"
1515
edition = "2021"
1616

1717
[dependencies]
18-
nom = "7.0"
18+
nom = "7.1"
1919
cookie-factory = "0.3"
20-
crypto_box = { version = "0.7", optional = true }
20+
crypto_box = { version = "0.8", optional = true }
2121

2222
[features]
2323
default = []

tox_binary_io/src/crypto.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ mod tests {
5151
let bytes = [42; KEY_SIZE];
5252
let (_rest, sk) = SecretKey::from_bytes(&bytes).unwrap();
5353

54-
assert_eq!(&sk.to_bytes()[..], &bytes as &[u8]);
54+
assert_eq!(sk.as_bytes(), &bytes as &[u8]);
5555
}
5656
}

tox_core/Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,31 @@ tox_binary_io = { version = "0.1.1", path = "../tox_binary_io" }
2121
tox_crypto = { version = "0.1.1", path = "../tox_crypto" }
2222
tox_packet = { version = "0.1.1", path = "../tox_packet" }
2323

24-
bytes = "1.0"
24+
bytes = "1.2"
2525
futures = { version = "0.3", default-features = false, features = ["std", "async-await"] }
2626
log = "0.4"
27-
nom = "7.0"
27+
nom = "7.1"
2828
cookie-factory = "0.3"
2929
get_if_addrs = "0.5"
3030
thiserror = "1.0"
31-
lru = "0.6"
31+
lru = "0.7"
3232
bitflags = "1.3"
3333
itertools = "0.10"
3434
rand = "0.8"
3535
sha2 = "0.9"
36-
xsalsa20poly1305 = "0.8"
37-
crypto_box = "0.7"
36+
xsalsa20poly1305 = "0.9"
37+
crypto_box = "0.8"
3838

3939
[dependencies.tokio]
40-
version = "1.12"
40+
version = "1.20"
4141
default-features = false
4242
features = ["net", "sync", "time"]
4343

4444
[dependencies.tokio-util]
45-
version = "0.6"
45+
version = "0.7"
4646
features = ["codec", "net"]
4747

4848
[dev-dependencies.tokio]
49-
version = "1.0"
49+
version = "1.20"
5050
default-features = false
5151
features = ["macros", "test-util", "net", "rt", "rt-multi-thread", "sync", "time"]

tox_core/src/dht/kbucket.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ where
249249
if self.is_full() {
250250
debug!(target: "Kbucket",
251251
"No free space left in the kbucket, the last (bad) node removed.");
252-
let eviction_index = Node::eviction_index(&self.nodes).unwrap_or_else(|| self.nodes.len() - 1);
252+
let eviction_index = Node::eviction_index(&self.nodes).unwrap_or(self.nodes.len() - 1);
253253
self.nodes.remove(eviction_index);
254254
let index = index - if eviction_index < index { 1 } else { 0 };
255255
self.nodes.insert(index, new_node.into());

tox_core/src/dht/server/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::net::SocketAddr;
1616
use std::sync::Arc;
1717
use std::time::{Duration, Instant};
1818
use std::{iter, mem};
19-
use xsalsa20poly1305::{XSalsa20Poly1305, aead::NewAead};
19+
use xsalsa20poly1305::{XSalsa20Poly1305, KeyInit};
2020

2121
use crate::time::*;
2222
use tox_crypto::*;
@@ -71,14 +71,16 @@ pub const PRECOMPUTED_LRU_CACHE_SIZE: usize = KBUCKET_DEFAULT_SIZE as usize * KB
7171
/// How often DHT main loop should be called.
7272
const MAIN_LOOP_INTERVAL: u64 = 1;
7373

74+
type MotdCallback = dyn Fn(&Server) -> Vec<u8> + Send + Sync;
75+
7476
/// Struct that contains necessary data for `BootstrapInfo` packet.
7577
#[derive(Clone)]
7678
struct ServerBootstrapInfo {
7779
/// Version of tox core which will be sent with `BootstrapInfo` packet.
7880
version: u32,
7981
/// Callback to get the message of the day which will be sent with
8082
/// `BootstrapInfo` packet.
81-
motd_cb: Arc<dyn Fn(&Server) -> Vec<u8> + Send + Sync>,
83+
motd_cb: Arc<MotdCallback>,
8284
}
8385

8486
/// DHT server state.
@@ -1358,7 +1360,7 @@ impl Server {
13581360
}
13591361

13601362
/// Set toxcore version and message of the day callback.
1361-
pub fn set_bootstrap_info(&mut self, version: u32, motd_cb: Box<dyn Fn(&Server) -> Vec<u8> + Send + Sync>) {
1363+
pub fn set_bootstrap_info(&mut self, version: u32, motd_cb: Box<MotdCallback>) {
13621364
self.bootstrap_info = Some(ServerBootstrapInfo {
13631365
version,
13641366
motd_cb: motd_cb.into(),
@@ -2456,7 +2458,7 @@ mod tests {
24562458

24572459
// send onion data request
24582460

2459-
let nonce = crypto_box::generate_nonce(&mut rng).into();
2461+
let nonce = SalsaBox::generate_nonce(&mut rng).into();
24602462
let temporary_pk = SecretKey::generate(&mut rng).public_key();
24612463
let payload = vec![42; 123];
24622464
let inner = InnerOnionDataRequest {

tox_core/src/friend_connection/mod.rs

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,6 @@ impl Friend {
9090
/// Friend connections module that handles friends and their connections.
9191
#[derive(Clone)]
9292
pub struct FriendConnections {
93-
/// Our long term `SecretKey`.
94-
real_sk: SecretKey,
95-
/// Our long term `PublicKey`.
96-
real_pk: PublicKey,
9793
/// List of friends we want to be connected to.
9894
friends: Arc<RwLock<HashMap<PublicKey, Friend>>>,
9995
/// Sink to send a connection status when it becomes connected or
@@ -112,16 +108,12 @@ pub struct FriendConnections {
112108
impl FriendConnections {
113109
/// Create new `FriendConnections`.
114110
pub fn new(
115-
real_sk: SecretKey,
116-
real_pk: PublicKey,
117111
dht: DhtServer,
118112
tcp_connections: TcpConnections,
119113
onion_client: OnionClient,
120114
net_crypto: NetCrypto,
121115
) -> Self {
122116
FriendConnections {
123-
real_sk,
124-
real_pk,
125117
friends: Arc::new(RwLock::new(HashMap::new())),
126118
connection_status_tx: Arc::new(RwLock::new(None)),
127119
dht,
@@ -450,13 +442,11 @@ mod tests {
450442
lossy_tx,
451443
dht_pk,
452444
dht_sk,
453-
real_pk: real_pk.clone(),
454-
real_sk: real_sk.clone(),
445+
real_pk,
446+
real_sk,
455447
precomputed_keys,
456448
});
457449
let friend_connections = FriendConnections::new(
458-
real_sk,
459-
real_pk,
460450
dht,
461451
tcp_connections,
462452
onion_client,
@@ -494,7 +484,7 @@ mod tests {
494484
let _ = friend_connections.tcp_connections.add_connection(relay_pk, friend_dht_pk.clone());
495485

496486
let session_precomputed_key = SalsaBox::new(&SecretKey::generate(&mut rng).public_key(), &SecretKey::generate(&mut rng));
497-
let sent_nonce = crypto_box::generate_nonce(&mut rng).into();
487+
let sent_nonce = SalsaBox::generate_nonce(&mut rng).into();
498488
friend_connections.net_crypto.add_established_connection(
499489
SecretKey::generate(&mut rng).public_key(),
500490
friend_pk.clone(),
@@ -547,7 +537,7 @@ mod tests {
547537
let _ = friend_connections.tcp_connections.add_connection(relay_pk, friend_dht_pk.clone());
548538

549539
let session_precomputed_key = SalsaBox::new(&SecretKey::generate(&mut rng).public_key(), &SecretKey::generate(&mut rng));
550-
let sent_nonce = crypto_box::generate_nonce(&mut rng).into();
540+
let sent_nonce = SalsaBox::generate_nonce(&mut rng).into();
551541
friend_connections.net_crypto.add_established_connection(
552542
SecretKey::generate(&mut rng).public_key(),
553543
friend_pk.clone(),
@@ -703,7 +693,7 @@ mod tests {
703693
friend_connections.friends.write().await.insert(friend_pk.clone(), friend);
704694

705695
let session_precomputed_key = SalsaBox::new(&SecretKey::generate(&mut rng).public_key(), &SecretKey::generate(&mut rng));
706-
let sent_nonce = crypto_box::generate_nonce(&mut rng).into();
696+
let sent_nonce = SalsaBox::generate_nonce(&mut rng).into();
707697
friend_connections.net_crypto.add_established_connection(
708698
SecretKey::generate(&mut rng).public_key(),
709699
friend_pk.clone(),
@@ -750,7 +740,7 @@ mod tests {
750740
friend_connections.friends.write().await.insert(friend_pk.clone(), friend);
751741

752742
let session_precomputed_key = SalsaBox::new(&SecretKey::generate(&mut rng).public_key(), &SecretKey::generate(&mut rng));
753-
let sent_nonce = crypto_box::generate_nonce(&mut rng).into();
743+
let sent_nonce = SalsaBox::generate_nonce(&mut rng).into();
754744
friend_connections.net_crypto.add_established_connection(
755745
SecretKey::generate(&mut rng).public_key(),
756746
friend_pk.clone(),
@@ -800,7 +790,7 @@ mod tests {
800790
friend_connections.friends.write().await.insert(friend_pk.clone(), friend);
801791

802792
let session_precomputed_key = SalsaBox::new(&SecretKey::generate(&mut rng).public_key(), &SecretKey::generate(&mut rng));
803-
let sent_nonce = crypto_box::generate_nonce(&mut rng).into();
793+
let sent_nonce = SalsaBox::generate_nonce(&mut rng).into();
804794
friend_connections.net_crypto.add_established_connection(
805795
SecretKey::generate(&mut rng).public_key(),
806796
friend_pk.clone(),
@@ -961,9 +951,9 @@ mod tests {
961951
let run_future = friend_connections.run()
962952
.map(Result::unwrap);
963953

964-
let precomputed_key = SalsaBox::new(&friend_connections.real_pk, &friend_sk);
954+
let precomputed_key = SalsaBox::new(friend_connections.net_crypto.real_pk(), &friend_sk);
965955
let cookie = friend_connections.net_crypto.get_cookie(&mut rng, friend_pk.clone(), friend_dht_pk);
966-
let sent_nonce = crypto_box::generate_nonce(&mut rng).into();
956+
let sent_nonce = SalsaBox::generate_nonce(&mut rng).into();
967957
let friend_session_sk = SecretKey::generate(&mut rng);
968958
let friend_session_pk = friend_session_sk.public_key();
969959
let our_cookie = EncryptedCookie {

0 commit comments

Comments
 (0)