Add basic ServerName example & impl.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
EXAMPLE_FILES := HelloWorld EchoServer BroadcastingEchoServer UpgradeSync UpgradeAsync
|
EXAMPLE_FILES := HelloWorld ServerName EchoServer BroadcastingEchoServer UpgradeSync UpgradeAsync
|
||||||
THREADED_EXAMPLE_FILES := HelloWorldThreaded EchoServerThreaded
|
THREADED_EXAMPLE_FILES := HelloWorldThreaded EchoServerThreaded
|
||||||
override CXXFLAGS += -lpthread -Wconversion -std=c++17 -Isrc -IuSockets/src
|
override CXXFLAGS += -lpthread -Wconversion -std=c++17 -Isrc -IuSockets/src
|
||||||
override LDFLAGS += uSockets/*.o -lz
|
override LDFLAGS += uSockets/*.o -lz
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#include "App.h"
|
||||||
|
|
||||||
|
/* Note that uWS::SSLApp({options}) is the same as uWS::App() when compiled without SSL support */
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
/* Overly simple hello world app (SNI) */
|
||||||
|
uWS::SSLApp({
|
||||||
|
.key_file_name = "../misc/key.pem",
|
||||||
|
.cert_file_name = "../misc/cert.pem",
|
||||||
|
.passphrase = "1234"
|
||||||
|
}).addServerName("localhost", {
|
||||||
|
.key_file_name = "../misc/key.pem",
|
||||||
|
.cert_file_name = "../misc/cert.pem",
|
||||||
|
.passphrase = "1234"
|
||||||
|
}).get("/*", [](auto *res, auto *req) {
|
||||||
|
res->end("Hello world!");
|
||||||
|
}).listen(3000, [](auto *token) {
|
||||||
|
if (token) {
|
||||||
|
std::cout << "Listening on port " << 3000 << std::endl;
|
||||||
|
}
|
||||||
|
}).run();
|
||||||
|
|
||||||
|
std::cout << "Failed to listen on port 3000" << std::endl;
|
||||||
|
}
|
||||||
@@ -38,6 +38,13 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
/* Server name */
|
||||||
|
TemplatedApp &&addServerName(std::string hostname_pattern, us_socket_context_options_t options = {}) {
|
||||||
|
|
||||||
|
us_socket_context_add_server_name(SSL, (struct us_socket_context_t *) httpContext, hostname_pattern.c_str(), options);
|
||||||
|
return std::move(*this);
|
||||||
|
}
|
||||||
|
|
||||||
/* Returns the SSL_CTX of this app, or nullptr. */
|
/* Returns the SSL_CTX of this app, or nullptr. */
|
||||||
void *getNativeHandle() {
|
void *getNativeHandle() {
|
||||||
return us_socket_context_get_native_handle(SSL, (struct us_socket_context_t *) httpContext);
|
return us_socket_context_get_native_handle(SSL, (struct us_socket_context_t *) httpContext);
|
||||||
|
|||||||
+1
-1
Submodule uSockets updated: 716c51be44...5c4116f2fa
Reference in New Issue
Block a user