aquatic_ws: use log crate for debug error messages

This commit is contained in:
Joakim Frostegård 2020-05-23 14:24:26 +02:00
parent 572aa632b6
commit 0f6d6d4b21
5 changed files with 12 additions and 10 deletions

1
Cargo.lock generated
View file

@ -101,6 +101,7 @@ dependencies = [
"flume",
"hashbrown",
"indexmap",
"log",
"mimalloc",
"mio",
"native-tls",

View file

@ -3,11 +3,11 @@
## aquatic_ws
* ipv4 / ipv6 split state?
* network
* panic/error in workers: exit program with non-zero exit code
* send/recv buffer size config
* limit ws message sizes?
* is it even necessary to check if event is readable in poll, since that
is all we're listening for?
* panic/error in workers: print error, exit program with non-zero exit code
* privdrop
## aquatic_udp
@ -29,7 +29,6 @@
Probably not really necessary. If it is an honest mistake, peer will just
keep announcing and after a few minutes, the peer in the map will be cleaned
out and everything will start working
* log crate instead of println/eprintln?
* stack-allocated vectors for announce request offers and scrape request info
hashes?

View file

@ -21,6 +21,7 @@ either = "1"
flume = "0.7"
hashbrown = { version = "0.7", features = ["serde"] }
indexmap = "1"
log = "0.4"
mimalloc = { version = "0.1", default-features = false }
mio = { version = "0.7", features = ["tcp", "os-poll", "os-util"] }
native-tls = "0.2"

View file

@ -3,6 +3,7 @@ use std::io::{Read, Write};
use either::Either;
use hashbrown::HashMap;
use log::info;
use mio::Token;
use mio::net::TcpStream;
use native_tls::{TlsAcceptor, TlsStream, MidHandshakeTlsStream};
@ -145,7 +146,7 @@ impl HandshakeMachine {
(Some(Either::Right(Self::TlsMidHandshake(handshake))), true)
},
Err(native_tls::HandshakeError::Failure(err)) => {
eprintln!("tls handshake error: {}", err);
info!("tls handshake error: {}", err);
(None, false)
}
@ -171,7 +172,7 @@ impl HandshakeMachine {
(Some(Either::Right(HandshakeMachine::WsMidHandshake(handshake))), true)
},
Err(HandshakeError::Failure(err)) => {
eprintln!("ws handshake error: {}", err);
info!("ws handshake error: {}", err);
(None, false)
}
@ -243,7 +244,7 @@ impl Connection {
// Required after ws.close()
if let Err(err) = ews.ws.write_pending(){
eprintln!(
info!(
"error writing pending messages after closing ws: {}",
err
)

View file

@ -2,8 +2,8 @@ use std::time::Duration;
use std::io::ErrorKind;
use hashbrown::HashMap;
use log::info;
use native_tls::TlsAcceptor;
use mio::{Events, Poll, Interest, Token};
use mio::net::TcpListener;
@ -145,7 +145,7 @@ fn accept_new_streams(
break
}
eprint!("error while accepting streams: {}", err);
info!("error while accepting streams: {}", err);
}
}
}
@ -189,7 +189,7 @@ pub fn run_handshakes_and_read_messages(
break
},
Err(err) => {
eprintln!("error reading messages: {}", err);
info!("error reading messages: {}", err);
remove_connection_if_exists(connections, poll_token);
@ -225,7 +225,7 @@ pub fn send_out_messages(
if let Some(established_ws) = opt_established_ws {
if established_ws.peer_addr != meta.peer_addr {
eprintln!("socket worker error: peer socket addrs didn't match");
info!("socket worker error: peer socket addrs didn't match");
continue;
}
@ -239,7 +239,7 @@ pub fn send_out_messages(
remove_connection_if_exists(connections, meta.poll_token);
},
Err(err) => {
eprintln!("error writing ws message: {}", err);
info!("error writing ws message: {}", err);
remove_connection_if_exists(
connections,