Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nginx-push-stream-module
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
nginx-push-stream-module
Commits
020a6882
Commit
020a6882
authored
Jul 06, 2015
by
Wandenberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
close websocket connection if the client sends a unsupported frame
parent
bbc74d46
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
0 deletions
+39
-0
websocket_spec.rb
misc/spec/subscriber/websocket_spec.rb
+30
-0
ngx_http_push_stream_module_websocket.c
src/ngx_http_push_stream_module_websocket.c
+9
-0
No files found.
misc/spec/subscriber/websocket_spec.rb
View file @
020a6882
...
...
@@ -704,4 +704,34 @@ describe "Subscriber WebSocket" do
end
end
end
it
"should reject unsupported frames"
do
channel
=
'ch_test_reject_unsupported_frames'
frame
=
"%c%c%c%c%c%c%c%c%c%c%c"
%
[
0x82
,
0x85
,
0xBD
,
0xD0
,
0xE5
,
0x2A
,
0xD5
,
0xB5
,
0x89
,
0x46
,
0xD2
]
#send binary frame
request
=
"GET /ws/
#{
channel
}
.b1 HTTP/1.0
\r\n
Connection: Upgrade
\r\n
Sec-WebSocket-Key: /mQoZf6pRiv8+6o72GncLQ==
\r\n
Upgrade: websocket
\r\n
Sec-WebSocket-Version: 8
\r\n
"
nginx_run_server
(
config
)
do
|
conf
|
socket
=
open_socket
(
nginx_host
,
nginx_port
)
socket
.
print
(
"
#{
request
}
\r\n
"
)
headers
,
body
=
read_response_on_socket
(
socket
)
socket
.
print
(
frame
)
body
,
dummy
=
read_response_on_socket
(
socket
,
"
\210\000
"
)
expect
(
body
).
to
eql
(
"
\210\000
"
)
EventMachine
.
run
do
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:timeout
=>
30
pub
.
callback
do
socket
.
close
expect
(
pub
).
to
be_http_status
(
200
).
with_body
response
=
JSON
.
parse
(
pub
.
response
)
expect
(
response
[
"channel"
].
to_s
).
to
eql
(
channel
)
expect
(
response
[
"published_messages"
].
to_i
).
to
eql
(
0
)
expect
(
response
[
"stored_messages"
].
to_i
).
to
eql
(
0
)
expect
(
response
[
"subscribers"
].
to_i
).
to
eql
(
0
)
EventMachine
.
stop
end
end
end
end
end
src/ngx_http_push_stream_module_websocket.c
View file @
020a6882
...
...
@@ -257,6 +257,15 @@ ngx_http_push_stream_websocket_reading(ngx_http_request_t *r)
break
;
case
NGX_HTTP_PUSH_STREAM_WEBSOCKET_READ_GET_PAYLOAD_STEP
:
if
(
(
ctx
->
frame
->
opcode
!=
NGX_HTTP_PUSH_STREAM_WEBSOCKET_TEXT_OPCODE
)
&&
(
ctx
->
frame
->
opcode
!=
NGX_HTTP_PUSH_STREAM_WEBSOCKET_CLOSE_OPCODE
)
&&
(
ctx
->
frame
->
opcode
!=
NGX_HTTP_PUSH_STREAM_WEBSOCKET_PING_OPCODE
)
&&
(
ctx
->
frame
->
opcode
!=
NGX_HTTP_PUSH_STREAM_WEBSOCKET_PONG_OPCODE
)
)
{
rc
=
ngx_http_push_stream_send_response_text
(
r
,
NGX_HTTP_PUSH_STREAM_WEBSOCKET_CLOSE_LAST_FRAME_BYTE
,
sizeof
(
NGX_HTTP_PUSH_STREAM_WEBSOCKET_CLOSE_LAST_FRAME_BYTE
),
1
);
goto
finalize
;
}
if
(
ctx
->
frame
->
payload_len
>
0
)
{
//create a temporary pool to allocate temporary elements
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment