missingServerName and updated ServerName example
This commit is contained in:
@@ -51,6 +51,19 @@ public:
|
||||
return std::move(*this);
|
||||
}
|
||||
|
||||
TemplatedApp &&missingServerName(fu2::unique_function<void(const char *hostname)> handler) {
|
||||
|
||||
httpContext->getSocketContextData()->missingServerNameHandler = std::move(handler);
|
||||
|
||||
us_socket_context_on_server_name(SSL, (struct us_socket_context_t *) httpContext, [](struct us_socket_context_t *context, const char *hostname) {
|
||||
|
||||
/* This is the only requirements of being friends with HttpContextData */
|
||||
HttpContext<SSL> *httpContext = (HttpContext<SSL> *) context;
|
||||
httpContext->getSocketContextData()->missingServerNameHandler(hostname);
|
||||
});
|
||||
return std::move(*this);
|
||||
}
|
||||
|
||||
/* Returns the SSL_CTX of this app, or nullptr. */
|
||||
void *getNativeHandle() {
|
||||
return us_socket_context_get_native_handle(SSL, (struct us_socket_context_t *) httpContext);
|
||||
|
||||
@@ -31,9 +31,12 @@ template <bool SSL>
|
||||
struct alignas(16) HttpContextData {
|
||||
template <bool> friend struct HttpContext;
|
||||
template <bool> friend struct HttpResponse;
|
||||
template <bool> friend struct TemplatedApp;
|
||||
private:
|
||||
std::vector<fu2::unique_function<void(HttpResponse<SSL> *, int)>> filterHandlers;
|
||||
|
||||
fu2::unique_function<void(const char *hostname)> missingServerNameHandler;
|
||||
|
||||
struct RouterData {
|
||||
HttpResponse<SSL> *httpResponse;
|
||||
HttpRequest *httpRequest;
|
||||
|
||||
Reference in New Issue
Block a user