-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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(server): respect sockPath on transportMode: 'ws' (#2310) #2311
fix(server): respect sockPath on transportMode: 'ws' (#2310) #2311
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2311 +/- ##
==========================================
+ Coverage 93.84% 93.86% +0.02%
==========================================
Files 34 34
Lines 1283 1288 +5
Branches 366 367 +1
==========================================
+ Hits 1204 1209 +5
Misses 78 78
Partials 1 1
Continue to review full report at Codecov.
|
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.
/cc @Loonride
Please accept CLA |
lib/servers/WebsocketServer.js
Outdated
this.wsServer.on('error', (err) => { | ||
this.server.log.error(err.message); | ||
}); | ||
} | ||
|
||
shouldUpgrade(req) { | ||
const pathname = url.parse(req.url).pathname; |
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.
memo: we'll use URLSearchParams after major release.
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.
I fixed the code to use WebSocket.Server.shouldHandle()
https://github.com/websockets/ws/blob/master/doc/ws.md#servershouldhandlerequest
Should be more futureproof?
ee3e805
to
6bcddc9
Compare
Thanks for the quick reviews. I noticed a bug in the tests based on the code coverage difference report, should be fixed now and using the more forward compatible ws.Server.shouldHandle() |
This also fixes the bug that whole
|
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.
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.
@joonas-lahtinen I ran your new tests without the changes that you made, and they passed. How are your changes different from the existing behavior? The ws docs say for the path option - "Accept only connections matching this path" (https://github.com/websockets/ws/blob/master/doc/ws.md#new-websocketserveroptions-callback), so paths that do not match the one specified are already rejected.
Edit: I missed the explanation in #2310. Could you make a test demonstrating that proxying works?
6bcddc9
to
7d38597
Compare
Thanks for the patience. After some digging I found the spot to inject testing the different transportMode options with proxy. |
LGTM /cc @evilebottnawi @hiroppy |
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.
/cc @hiroppy
thanks |
For Bugs and Features; did you add new tests?
Added tests to verify that sockPath is respected.
Motivation / Use-Case
Fixes bug #2310.