From 099f1625768f19d62e33995ab0d216e9d6a88b52 Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Thu, 20 Sep 2018 19:12:31 +0200 Subject: [PATCH] Update examples with dh_params --- Makefile | 4 ++-- .../{static_http_server.cpp => HttpServer.cpp} | 17 +++++++++-------- examples/{ => helpers}/FileCache.h | 0 examples/{ => helpers}/Middleware.h | 0 uSockets | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) rename examples/{static_http_server.cpp => HttpServer.cpp} (70%) rename examples/{ => helpers}/FileCache.h (100%) rename examples/{ => helpers}/Middleware.h (100%) diff --git a/Makefile b/Makefile index a4323ea..f22993c 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ default: rm *.o clang -flto -O3 -c -IuSockets/src uSockets/src/*.c uSockets/src/eventing/*.c - clang++ -flto -O3 -c -std=c++17 -Isrc -IuSockets/src examples/static_http_server.cpp - clang++ -flto -O3 -s *.o -o static_http_server -lssl -lcrypto -lpthread -lstdc++fs + clang++ -flto -O3 -c -std=c++17 -Isrc -IuSockets/src examples/HttpServer.cpp + clang++ -flto -O3 -s *.o -o HttpServer -lssl -lcrypto -lpthread -lstdc++fs main: rm *.o diff --git a/examples/static_http_server.cpp b/examples/HttpServer.cpp similarity index 70% rename from examples/static_http_server.cpp rename to examples/HttpServer.cpp index 22ce6e6..abe2fa0 100644 --- a/examples/static_http_server.cpp +++ b/examples/HttpServer.cpp @@ -3,13 +3,13 @@ #include /* Helpers for this example */ -#include "FileCache.h" -#include "Middleware.h" +#include "helpers/FileCache.h" +#include "helpers/Middleware.h" int main(int argc, char **argv) { - if (argc < 3 || argc > 6) { - std::cout << "Usage: static_http_server root port [ssl_cert ssl_key ssl_passphrase]" << std::endl; + if (argc < 3 || argc > 7) { + std::cout << "Usage: HttpServer root port [ssl_cert ssl_key ssl_dh_params ssl_passphrase]" << std::endl; return 0; } @@ -19,12 +19,13 @@ int main(int argc, char **argv) { FileCache fileCache(root); /* Either serve over HTTP or HTTPS */ - if (argc > 4) { + if (argc > 5) { /* HTTPS */ uWS::SSLApp({ - .cert_file_name = argv[3], - .key_file_name = argv[4], - .passphrase = (argc == 6 ? argv[5] : nullptr) + .cert_file_name = argv[3], /* Required */ + .key_file_name = argv[4], /* Required */ + .dh_params_file_name = argv[5], /* Required (in this example) */ + .passphrase = (argc == 7 ? argv[6] : nullptr) /* Passphrase is optional */ }).get("/*", [&fileCache](auto *res, auto *req) { serveFile(res, req)->write(fileCache.getFile(req->getUrl())); }).listen(port, [port, root](auto *token) { diff --git a/examples/FileCache.h b/examples/helpers/FileCache.h similarity index 100% rename from examples/FileCache.h rename to examples/helpers/FileCache.h diff --git a/examples/Middleware.h b/examples/helpers/Middleware.h similarity index 100% rename from examples/Middleware.h rename to examples/helpers/Middleware.h diff --git a/uSockets b/uSockets index 491a815..70e1cc0 160000 --- a/uSockets +++ b/uSockets @@ -1 +1 @@ -Subproject commit 491a8152dff8d8e199742d19e39d057938f4d39c +Subproject commit 70e1cc081f728c50347c28690b46fca58054a090