Skip to content

Commit

Permalink
0.7.55 (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
AtomXY authored Nov 8, 2021
1 parent 4571a04 commit 3836ece
Show file tree
Hide file tree
Showing 5 changed files with 269 additions and 269 deletions.
86 changes: 41 additions & 45 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,55 +1,51 @@

[package]

edition = '2018'
build = './common/build/build.rs'
name = 'adnl'
version = '0.7.53'
description = 'ADNL library'
edition = "2018"
build = "./common/build/build.rs"
name = "adnl"
version = "0.7.55"
description = "ADNL library"

[workspace]

[dependencies]

aes-ctr = '0.6.0'
arrayref = '0.3.5'
async-trait = '0.1.22'
base64 = '0.11.0'
curve25519-dalek = '2.0.0'
ed25519 = '1.0.1'
ed25519-dalek = '1.0.0-pre.4'
external-ip = { version = '4.1.0', optional = true }
failure = '0.1.6'
futures = '0.3.1'
log = '0.4.11'
num_cpus = '1.13'
rand = '0.7.2'
serde = { version = '1.0.105', features = [ 'derive', 'rc' ] }
serde_json = '1.0.41'
sha2 = '0.8.0'
socket2 = '0.3.19'
stream-cancel = '0.8.0'
tokio = { version = '1.5.0', features = [ 'io-util', 'macros', 'net', 'rt-multi-thread' ] }
tokio-io-timeout = '1.1.1'
tokio-stream = { version = '0.1.4', features = [ 'net' ] }
x25519-dalek = '0.6.0'
zstd = { version = '0.8', optional = true, features = [ 'pkg-config' ] }
ton_api = { git = 'https://github.com/tonlabs/ton-labs-tl.git', package = 'ton_api', tag = '0.2.110' }
ton_types = { git = 'https://github.com/tonlabs/ton-labs-types.git', tag = '1.10.10' }
lockfree = { git = 'https://github.com/tonlabs/lockfree.git' }
aes-ctr = "0.6.0"
async-trait = "0.1.22"
base64 = "0.13"
curve25519-dalek = "3.2"
ed25519 = "1.0"
ed25519-dalek = "1.0"
external-ip = { version = "4.1.0", optional = true }
failure = "0.1.6"
futures = "0.3.1"
log = "0.4"
num_cpus = "1.13"
rand = "0.7"
serde = { version = "1.0.105", features = ["derive", "rc"] }
serde_json = "1.0.41"
sha2 = "0.9"
socket2 = "0.3.19"
stream-cancel = "0.8.0"
tokio = { version = "1.5.0", features = ["io-util", "macros", "net", "rt-multi-thread"] }
tokio-io-timeout = "1.1.1"
tokio-stream = { version = "0.1.4", features = ["net"] }
x25519-dalek = "1.2"
zstd = { version = "0.8", optional = true, features = ["pkg-config"] }

ton_api = { git = 'https://github.com/tonlabs/ton-labs-tl.git', package = 'ton_api', tag = '0.2.111' }
ton_types = { git = 'https://github.com/tonlabs/ton-labs-types.git', tag = '1.10.11' }
lockfree = { git = "https://github.com/tonlabs/lockfree.git" }

[dev-dependencies]

external-ip = '4.1.0'
hex = '^0'
log4rs = '0.8.3'
external-ip = "4.1"
hex = "0.4"
log4rs = "1.0"

[features]
default = ["static_workers"]
client = []
server = []
node = ["external-ip"]
compression = ["zstd"]
static_workers = []
telemetry = []

default = [ 'static_workers' ]
client = [ ]
server = [ ]
node = [ 'external-ip' ]
compression = [ 'zstd' ]
static_workers = [ ]
telemetry = [ ]
24 changes: 10 additions & 14 deletions src/client.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
use crate::{
dump,
common::{
AdnlHandshake, AdnlStream, AdnlStreamCrypto, deserialize, get256,
KeyOption, KeyOptionJson, Query, serialize, TaggedTlObject, TARGET, Timeouts
KeyOption, KeyOptionJson, Query, serialize, TaggedTlObject, Timeouts
}
};
use rand::Rng;
use std::{net::SocketAddr, time::{Duration, SystemTime}};
use ton_api::{
ton::{
TLObject, adnl::{Message as AdnlMessage, Pong as AdnlPongBoxed},
rpc::adnl::Ping as AdnlPing
}
use std::{convert::TryInto, net::SocketAddr, time::{Duration, SystemTime}};
use ton_api::ton::{
TLObject, adnl::{Message as AdnlMessage, Pong as AdnlPongBoxed},
rpc::adnl::Ping as AdnlPing
};
#[cfg(feature = "telemetry")]
use ton_api::{BoxedSerialize, ConstructorNumber};
use ton_types::{fail, Result};
use ton_types::{error, fail, Result};

#[derive(serde::Deserialize, serde::Serialize)]
pub struct AdnlClientConfigJson {
Expand Down Expand Up @@ -113,7 +110,7 @@ impl AdnlClient {
//socket.bind(&"0.0.0.0:0".parse::<SocketAddr>()?.into())?;
socket.connect_timeout(
&config.server_address.into(),
config.timeouts.write().unwrap()
config.timeouts.write()
)?;

let mut stream = AdnlStream::from_stream_with_timeouts(
Expand Down Expand Up @@ -171,7 +168,7 @@ impl AdnlClient {
}
let answer = deserialize(&buf[..])?
.downcast::<AdnlMessage>()
.map_err(|answer| failure::format_err!("Unsupported ADNL message {:?}", answer))?;
.map_err(|answer| error!("Unsupported ADNL message {:?}", answer))?;
match answer {
AdnlMessage::Adnl_Message_Answer(answer) => if &query_id == get256(&answer.query_id) {
deserialize(&answer.answer)
Expand All @@ -188,15 +185,14 @@ impl AdnlClient {
) -> Result<AdnlStreamCrypto> {
let mut rng = rand::thread_rng();
let mut buf: Vec<u8> = (0..160).map(|_| rng.gen()).collect();
let nonce = arrayref::array_ref!(buf, 0, 160);
dump!(trace, TARGET, "Nonce", nonce);
let nonce = buf.as_slice().try_into()?;
let ret = AdnlStreamCrypto::with_nonce_as_client(nonce);
if let Some(client_key) = &config.client_key {
AdnlHandshake::build_packet(&mut buf, client_key, &config.server_key)?
} else {
AdnlHandshake::build_packet(
&mut buf,
&KeyOption::from_ed25519_secret_key(ed25519_dalek::SecretKey::generate(&mut rng)),
&KeyOption::from_ed25519_secret_key(ed25519_dalek::SecretKey::generate(&mut rng))?,
&config.server_key
)?
}
Expand Down
Loading

0 comments on commit 3836ece

Please sign in to comment.