Trigger more context functions when fuzzing
This commit is contained in:
+47
-38
@@ -13,45 +13,54 @@ void test() {
|
||||
/* Fill with user data */
|
||||
};
|
||||
|
||||
/* Keep in mind that uWS::SSLApp({options}) is the same as uWS::App() when compiled without SSL support.
|
||||
* You may swap to using uWS:App() if you don't need SSL */
|
||||
uWS::App({
|
||||
/* There are example certificates in uWebSockets.js repo */
|
||||
.key_file_name = "../misc/key.pem",
|
||||
.cert_file_name = "../misc/cert.pem",
|
||||
.passphrase = "1234"
|
||||
}).ws<PerSocketData>("/*", {
|
||||
/* Settings */
|
||||
.compression = uWS::SHARED_COMPRESSOR,
|
||||
.maxPayloadLength = 16 * 1024,
|
||||
.idleTimeout = 10,
|
||||
.maxBackpressure = 1 * 1024 * 1024,
|
||||
/* Handlers */
|
||||
.open = [](auto *ws) {
|
||||
/* Open event here, you may access ws->getUserData() which points to a PerSocketData struct */
|
||||
ws->getNativeHandle();
|
||||
ws->getRemoteAddressAsText();
|
||||
},
|
||||
.message = [](auto *ws, std::string_view message, uWS::OpCode opCode) {
|
||||
ws->send(message, opCode, true);
|
||||
},
|
||||
.drain = [](auto *ws) {
|
||||
/* Check ws->getBufferedAmount() here */
|
||||
},
|
||||
.ping = [](auto *ws) {
|
||||
/* Not implemented yet */
|
||||
},
|
||||
.pong = [](auto *ws) {
|
||||
/* Not implemented yet */
|
||||
},
|
||||
.close = [](auto *ws, int code, std::string_view message) {
|
||||
/* You may access ws->getUserData() here */
|
||||
}
|
||||
}).listen(9001, [](auto *listenSocket) {
|
||||
listen_socket = listenSocket;
|
||||
}).run();
|
||||
{
|
||||
/* Keep in mind that uWS::SSLApp({options}) is the same as uWS::App() when compiled without SSL support.
|
||||
* You may swap to using uWS:App() if you don't need SSL */
|
||||
auto app = uWS::App({
|
||||
/* There are example certificates in uWebSockets.js repo */
|
||||
.key_file_name = "../misc/key.pem",
|
||||
.cert_file_name = "../misc/cert.pem",
|
||||
.passphrase = "1234"
|
||||
}).ws<PerSocketData>("/*", {
|
||||
/* Settings */
|
||||
.compression = uWS::SHARED_COMPRESSOR,
|
||||
.maxPayloadLength = 16 * 1024,
|
||||
.idleTimeout = 10,
|
||||
.maxBackpressure = 1 * 1024 * 1024,
|
||||
/* Handlers */
|
||||
.open = [](auto *ws) {
|
||||
/* Open event here, you may access ws->getUserData() which points to a PerSocketData struct */
|
||||
ws->getNativeHandle();
|
||||
ws->getRemoteAddressAsText();
|
||||
},
|
||||
.message = [](auto *ws, std::string_view message, uWS::OpCode opCode) {
|
||||
ws->send(message, opCode, true);
|
||||
},
|
||||
.drain = [](auto *ws) {
|
||||
/* Check ws->getBufferedAmount() here */
|
||||
},
|
||||
.ping = [](auto *ws) {
|
||||
/* Not implemented yet */
|
||||
},
|
||||
.pong = [](auto *ws) {
|
||||
/* Not implemented yet */
|
||||
},
|
||||
.close = [](auto *ws, int code, std::string_view message) {
|
||||
/* You may access ws->getUserData() here */
|
||||
}
|
||||
}).listen(9001, [](auto *listenSocket) {
|
||||
listen_socket = listenSocket;
|
||||
});
|
||||
|
||||
uWS::Loop::get()->free();
|
||||
/* Trigger some context functions */
|
||||
app.addServerName("", {});
|
||||
app.removeServerName("");
|
||||
app.missingServerName(nullptr);
|
||||
app.getNativeHandle();
|
||||
|
||||
app.run();
|
||||
}
|
||||
uWS::Loop::get()->free();
|
||||
}
|
||||
|
||||
/* Thus function should shutdown the event-loop and let the test fall through */
|
||||
|
||||
Reference in New Issue
Block a user