Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Jochen Bauer
spn-relayserver
Commits
f55221a9
Commit
f55221a9
authored
Apr 30, 2018
by
Hubert Denkmair
Browse files
handle invalid requests better
parent
a5ce9064
Changes
1
Hide whitespace changes
Inline
Side-by-side
relayserver/RelayServer.cpp
View file @
f55221a9
...
...
@@ -72,21 +72,28 @@ int RelayServer::Run()
h
.
onMessage
([](
uWS
::
WebSocket
<
uWS
::
SERVER
>
*
ws
,
char
*
message
,
size_t
length
,
uWS
::
OpCode
opCode
)
{
auto
*
con
=
static_cast
<
WebsocketConnection
*>
(
ws
->
getUserData
());
if
(
length
>
MAX_CLIENT_MESSAGE_SIZE
)
{
ws
->
close
(
413
,
"payload to large"
);
return
;
}
std
::
string
s
(
message
,
length
);
json
data
=
json
::
parse
(
s
,
nullptr
,
false
);
if
(
!
data
.
is_object
())
{
return
;
}
try
{
auto
*
con
=
static_cast
<
WebsocketConnection
*>
(
ws
->
getUserData
());
std
::
string
s
(
message
,
length
);
json
data
=
json
::
parse
(
s
,
nullptr
,
false
);
if
(
!
data
.
is_object
())
{
return
;
}
if
(
data
[
"viewer_key"
].
is_string
())
if
(
data
[
"viewer_key"
].
is_string
())
{
std
::
string
key
=
data
[
"viewer_key"
];
con
->
setViewerKey
(
static_cast
<
uint64_t
>
(
std
::
stol
(
key
)));
}
}
catch
(
std
::
exception
e
)
{
std
::
string
key
=
data
[
"viewer_key"
]
;
con
->
setViewerKey
(
static_cast
<
uint64_t
>
(
std
::
stol
(
key
)))
;
ws
->
close
(
418
,
"invalid request"
)
;
return
;
}
});
...
...
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