Browse Source

Use `TcpStream` to connect to address

Not only this now automatically support IPv6, it is also shorter.
new-http-api
Thomas Eizinger 3 years ago
parent
commit
cf5e50029c
No known key found for this signature in database GPG Key ID: 651AC83A6C6C8B96
  1. 5
      daemon/src/connection.rs

5
daemon/src/connection.rs

@ -5,6 +5,7 @@ use futures::{FutureExt, StreamExt};
use std::net::SocketAddr;
use std::sync::{Arc, Mutex};
use std::time::{Duration, SystemTime};
use tokio::net::TcpStream;
use tokio::sync::watch;
use tokio_util::codec::FramedRead;
use xtra::prelude::MessageChannel;
@ -84,11 +85,11 @@ impl Actor {
ctx: &mut xtra::Context<Self>,
) -> Result<()> {
let (read, write, noise) = {
let socket = tokio::net::TcpSocket::new_v4().expect("Be able to create a socket");
let mut connection = socket.connect(maker_addr).await?;
let mut connection = TcpStream::connect(&maker_addr).await?;
let noise =
noise::initiator_handshake(&mut connection, &self.identity_sk, &maker_identity_pk)
.await?;
let (read, write) = connection.into_split();
(read, write, Arc::new(Mutex::new(noise)))
};

Loading…
Cancel
Save