Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/dnsmasq_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#include <stddef.h>
// logg_rate_limit_message()
#include "database/message-table.h"
// http_init()
// http_init(), webserver_thread()
#include "webserver/webserver.h"
// type struct sqlite3_stmt_vec
#include "vector.h"
Expand Down Expand Up @@ -3359,12 +3359,17 @@ void FTL_fork_and_bind_sockets(struct passwd *ent_pw, bool dnsmasq_start)
exit(EXIT_FAILURE);
}

#ifdef HAVE_MBEDTLS
// Start webserver thread
if(pthread_create( &threads[WEBSERVER], &attr, webserver_thread, NULL ) != 0)
{
log_crit("Unable to create webserver thread. Exiting...");
exit(EXIT_FAILURE);
}
#else
// Initialize FTL HTTP server
http_init();
#endif /* HAVE_MBEDTLS */

// Chown files if FTL started as user root but a dnsmasq config
// option states to run as a different user/group (e.g. "nobody")
Expand Down
8 changes: 8 additions & 0 deletions src/webserver/webserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
// thread_names
#include "signals.h"

#ifdef HAVE_MBEDTLS
#include <mbedtls/ssl_ciphersuites.h>
#endif /* HAVE_MBEDTLS */

// Server context handle
static struct mg_context *ctx = NULL;
Expand Down Expand Up @@ -996,6 +998,7 @@ void http_terminate(void)
free(login_uri);
}

#ifdef HAVE_MBEDTLS
static void restart_http(void)
{
// Stop the server
Expand All @@ -1004,6 +1007,7 @@ static void restart_http(void)
// Reinitialize the webserver
http_init();
}
#endif /* HAVE_MBEDTLS */

/**
* @brief Prints all supported TLS cipher suites by mbedTLS.
Expand All @@ -1019,6 +1023,7 @@ static void restart_http(void)
*/
void get_all_supported_ciphersuites(void)
{
#ifdef HAVE_MBEDTLS
const int *all = mbedtls_ssl_list_ciphersuites();
printf("Supported TLS cipher suites:\n");
for (size_t i = 0; all[i] != 0; ++i)
Expand All @@ -1029,8 +1034,10 @@ void get_all_supported_ciphersuites(void)
const size_t bitlen = mbedtls_ssl_ciphersuite_get_cipher_key_bitlen(suite_info);
printf("- %s (Cipher ID: %d, Key length: %zu bits)\n", suite_name, all[i], bitlen);
}
#endif /* HAVE_MBEDTLS */
}

#ifdef HAVE_MBEDTLS
void *webserver_thread(void *val)
{
(void)val;
Expand Down Expand Up @@ -1082,3 +1089,4 @@ void *webserver_thread(void *val)
log_info("Terminating webserver thread");
return NULL;
}
#endif /* HAVE_MBEDTLS */
Loading