diff --git a/src/main.c b/src/main.c index cfdfbef..a12189f 100644 --- a/src/main.c +++ b/src/main.c @@ -609,10 +609,7 @@ int parse_cmdline(int argc, char **argv, int *port, int *enableUpload, char **sh int main(int argc, char ** argv) { struct MHD_Daemon *d; - -#if MHD_VERSION <= 0x00092100 struct MHD_Daemon *d6; -#endif struct stat sBuf; @@ -708,7 +705,6 @@ int main(int argc, char ** argv) { faviconResponse = create_favicon_response(); // start daemons -#if MHD_VERSION <= 0x00092100 d = MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION, port, NULL, @@ -724,7 +720,16 @@ int main(int argc, char ** argv) { LOG(LVL_DEBUG, "IPv4 daemon startup successful."); } - d6 = MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION | MHD_USE_IPv6, +#if MHD_VERSION <= 0x00092100 + unsigned int flags = MHD_USE_THREAD_PER_CONNECTION | MHD_USE_IPv6; +#else + /* MHD_USE_DUAL_STACK does actually not bind the socket to both IPv4 and + * IPv6, but bind the socket to IPv6 ONLY (just the opposite of what is + * documented. WATCH THIS CLOSELY FOR UPDATES! */ + unsigned int flags = MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DUAL_STACK; +#endif // MHD_VERSION + + d6 = MHD_start_daemon(flags, port, NULL, NULL, @@ -743,24 +748,6 @@ int main(int argc, char ** argv) { LOG(LVL_FATAL, "Both IPv4 and IPv6 servers failed to start. Terminating."); return EXIT_FAILURE; } -#else - d = MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DUAL_STACK, - port, - NULL, - NULL, - &connection_handler, - NULL, - MHD_OPTION_NOTIFY_COMPLETED, - &request_completed, NULL, - MHD_OPTION_END); - - if (d == NULL) { - LOG(LVL_FATAL, "Cannot start up libmicrohttpd listening on dual stack socket."); - return EXIT_FAILURE; - } else { - LOG(LVL_DEBUG, "Dual stack daemon startup successful."); - } -#endif // MHD_VERSION LOG(LVL_INFO, "Startup successful. Here are the IP addresses for this computer:"); print_urls(port); @@ -772,10 +759,7 @@ int main(int argc, char ** argv) { LOG(LVL_INFO, "Shutting down..."); MHD_stop_daemon(d); - -#if MHD_VERSION <= 0x00092100 MHD_stop_daemon(d6); -#endif MHD_destroy_response(error403Response); MHD_destroy_response(error404Response);