mirror of
https://github.com/ekzhang/bore.git
synced 2025-12-16 03:47:50 +01:00
Improve stability by exiting immediately on common errors (#2)
* Kill connections immediately on missing or close * Add timeout to initial protocol messages * Add low-level tracing for JSON messages * Add timeout to initial TCP connections
This commit is contained in:
@@ -13,7 +13,9 @@ use tracing::{info, info_span, warn, Instrument};
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::auth::Authenticator;
|
||||
use crate::shared::{proxy, recv_json, send_json, ClientMessage, ServerMessage, CONTROL_PORT};
|
||||
use crate::shared::{
|
||||
proxy, recv_json_timeout, send_json, ClientMessage, ServerMessage, CONTROL_PORT,
|
||||
};
|
||||
|
||||
/// State structure for the server.
|
||||
pub struct Server {
|
||||
@@ -71,10 +73,7 @@ impl Server {
|
||||
}
|
||||
}
|
||||
|
||||
let mut buf = Vec::new();
|
||||
let msg = recv_json(&mut stream, &mut buf).await?;
|
||||
|
||||
match msg {
|
||||
match recv_json_timeout(&mut stream).await? {
|
||||
Some(ClientMessage::Authenticate(_)) => {
|
||||
warn!("unexpected authenticate");
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user