Skip to content
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

Merged
merged 1 commit into from
Jul 18, 2022
Merged

Conversation

niklasad1
Copy link
Member

Closing #818

@niklasad1 niklasad1 requested a review from a team as a code owner July 7, 2022 08:28
@@ -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?;
Copy link
Member Author

@niklasad1 niklasad1 Jul 7, 2022

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);
Copy link
Member Author

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?

Copy link
Collaborator

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.

Copy link
Collaborator

@jsdw jsdw left a 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!

@jsdw jsdw merged commit 538854b into master Jul 18, 2022
@jsdw jsdw deleted the na-fix-818 branch July 18, 2022 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants