mirror of
https://github.com/romanz/electrs.git
synced 2025-02-23 22:56:55 +01:00
Warn on attempt to connect over SSL
Also output underlying errors when a thread fails.
This commit is contained in:
parent
fe30cd605d
commit
cd348e72de
2 changed files with 8 additions and 0 deletions
|
@ -219,11 +219,18 @@ fn recv_loop(peer_id: usize, stream: &TcpStream, server_tx: Sender<Event>) -> Re
|
|||
let msg = Message::New(stream.try_clone()?);
|
||||
server_tx.send(Event { peer_id, msg })?;
|
||||
|
||||
let mut first_line = true;
|
||||
for line in BufReader::new(stream).lines() {
|
||||
if let Err(e) = &line {
|
||||
if first_line && e.kind() == std::io::ErrorKind::InvalidData {
|
||||
warn!("InvalidData on first line may indicate client attempted to connect using SSL when server expects unencrypted communication.")
|
||||
}
|
||||
}
|
||||
let line = line.with_context(|| format!("{}: recv failed", peer_id))?;
|
||||
debug!("{}: recv {}", peer_id, line);
|
||||
let msg = Message::Request(line);
|
||||
server_tx.send(Event { peer_id, msg })?;
|
||||
first_line = false;
|
||||
}
|
||||
|
||||
debug!("{}: disconnected", peer_id);
|
||||
|
|
|
@ -9,6 +9,7 @@ where
|
|||
.spawn(move || {
|
||||
if let Err(e) = f() {
|
||||
warn!("{} thread failed: {}", name, e);
|
||||
e.chain().skip(1).for_each(|e| warn!("because: {}", e));
|
||||
}
|
||||
})
|
||||
.expect("failed to spawn a thread")
|
||||
|
|
Loading…
Add table
Reference in a new issue