1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-30 00:00:16 +01:00

add context construction option to skip server hostname lookup

Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
Andy Green 2012-10-22 12:29:57 +01:00
parent 15e31f373d
commit 788c4a8fa8
3 changed files with 36 additions and 24 deletions

View file

@ -2596,6 +2596,13 @@ libwebsocket_create_context(int port, const char *interf,
context->ssl_client_ctx = NULL; context->ssl_client_ctx = NULL;
openssl_websocket_private_data_index = 0; openssl_websocket_private_data_index = 0;
#endif #endif
if (options & LWS_SERVER_OPTION_SKIP_SERVER_CANONICAL_NAME) {
strcpy(context->canonical_hostname, "unknown");
} else {
/* find canonical hostname */ /* find canonical hostname */
hostname[(sizeof hostname) - 1] = '\0'; hostname[(sizeof hostname) - 1] = '\0';
@ -2608,7 +2615,7 @@ libwebsocket_create_context(int port, const char *interf,
if (strlen(hostname) < sizeof(sa.sa_data) - 1) { if (strlen(hostname) < sizeof(sa.sa_data) - 1) {
strcpy(sa.sa_data, hostname); strcpy(sa.sa_data, hostname);
// fprintf(stderr, "my host name is %s\n", sa.sa_data); // fprintf(stderr, "my host name is %s\n", sa.sa_data);
n = getnameinfo(&sa, sizeof(sa), hostname, n = getnameinfo(&sa, sizeof(sa), hostname,
(sizeof hostname) - 1, NULL, 0, 0); (sizeof hostname) - 1, NULL, 0, 0);
} }
@ -2622,8 +2629,9 @@ libwebsocket_create_context(int port, const char *interf,
strncpy(context->canonical_hostname, hostname, strncpy(context->canonical_hostname, hostname,
sizeof context->canonical_hostname - 1); sizeof context->canonical_hostname - 1);
// fprintf(stderr, "context->canonical_hostname = %s\n", // fprintf(stderr, "context->canonical_hostname = %s\n",
// context->canonical_hostname); // context->canonical_hostname);
}
/* split the proxy ads:port if given */ /* split the proxy ads:port if given */

View file

@ -65,6 +65,7 @@ typedef int ssize_t;
enum libwebsocket_context_options { enum libwebsocket_context_options {
LWS_SERVER_OPTION_DEFEAT_CLIENT_MASK = 1, LWS_SERVER_OPTION_DEFEAT_CLIENT_MASK = 1,
LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT = 2, LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT = 2,
LWS_SERVER_OPTION_SKIP_SERVER_CANONICAL_NAME = 4,
}; };
enum libwebsocket_callback_reasons { enum libwebsocket_callback_reasons {

View file

@ -258,6 +258,9 @@ else ignored
<dd>user id to change to after setting listen socket, or -1. <dd>user id to change to after setting listen socket, or -1.
<dt><b>options</b> <dt><b>options</b>
<dd>0, or LWS_SERVER_OPTION_DEFEAT_CLIENT_MASK <dd>0, or LWS_SERVER_OPTION_DEFEAT_CLIENT_MASK
<dt><b>user</b>
<dd>optional user pointer that can be recovered via the context
pointer using libwebsocket_context_user
</dl> </dl>
<h3>Description</h3> <h3>Description</h3>
<blockquote> <blockquote>