-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ws server): reply HTTP 403 on all failed conns #819
Conversation
@@ -253,45 +254,12 @@ async fn handshake<M: Middleware>(socket: tokio::net::TcpStream, mode: Handshake | |||
} | |||
HandshakeResponse::Accept { conn_id, methods, resources, cfg, stop_monitor, middleware, id_provider } => { | |||
tracing::debug!("Accepting new connection: {}", conn_id); | |||
let key = { | |||
let req = server.receive_request().await?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored to this into a helper function because once this returns Err
it's just dropped without sending a proper HTTP response.
so everything that returns an error we just send HTTP status code 403
Ok(key) => { | ||
match key_and_headers { | ||
Ok((key, headers)) => { | ||
middleware.on_connect(remote_addr, &headers); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will only be registered in the middleware on successful connections, it was like that before too.
maybe we should register this on failed ones as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm; if we want to log failed things, we probably should tweak the middleware thing to make it obvious when it's an error versus a normal connection, (maybe add a new method like on_connect_error
?).
I think this is good as it stands for now though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
Closing #818