From 81e965a08f987b87fdf1a063c4f9110bb37ab54a Mon Sep 17 00:00:00 2001 From: Philipp Schafft Date: Sun, 6 Mar 2022 18:49:11 +0000 Subject: [PATCH] Feature: Warn on dashboard if IPv6 is not enabled --- src/admin.c | 7 ++++++- src/listensocket.c | 18 ++++++++++++++++++ src/listensocket.h | 3 +++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/admin.c b/src/admin.c index 9a4f53a8..270c5509 100644 --- a/src/admin.c +++ b/src/admin.c @@ -1621,6 +1621,7 @@ static void command_dashboard (client_t *client, source_t *source, adm bool has_many_clients; bool has_too_many_clients; bool has_legacy_sources; + bool inet6_enabled; resource = reportxml_node_new(REPORTXML_NODE_TYPE_RESOURCE, NULL, NULL, NULL); @@ -1646,13 +1647,14 @@ static void command_dashboard (client_t *client, source_t *source, adm has_many_clients = global.clients > ((75 * config->client_limit) / 100); has_too_many_clients = global.clients > ((90 * config->client_limit) / 100); has_legacy_sources = global.sources_legacy > 0; + inet6_enabled = listensocket_container_is_family_included(global.listensockets, SOCK_FAMILY_INET6); global_unlock(); reportxml_node_add_child(resource, node); refobject_unref(node); if (config->config_problems || has_too_many_clients) { status = command_dashboard__atbest(status, ADMIN_DASHBOARD_STATUS_ERROR); - } else if (!has_sources || has_many_clients) { + } else if (!has_sources || has_many_clients || !inet6_enabled) { status = command_dashboard__atbest(status, ADMIN_DASHBOARD_STATUS_WARNING); } @@ -1661,6 +1663,9 @@ static void command_dashboard (client_t *client, source_t *source, adm __reportxml_add_maintenance(reportnode, config->reportxml_db, "c704804e-d3b9-4544-898b-d477078135de", "warning", "Developer logging is active. This mode is not for production.", NULL); #endif + if (!inet6_enabled) + __reportxml_add_maintenance(reportnode, config->reportxml_db, "f90219e1-bd07-4b54-b1ee-0ba6a0289a15", "warning", "IPv6 not enabled.", NULL); + if (config->config_problems & CONFIG_PROBLEM_HOSTNAME) __reportxml_add_maintenance(reportnode, config->reportxml_db, "c4f25c51-2720-4b38-a806-19ef024b5289", "warning", "Hostname is not set to anything useful in .", NULL); if (config->config_problems & CONFIG_PROBLEM_LOCATION) diff --git a/src/listensocket.c b/src/listensocket.c index 6dea8319..ba1a8426 100644 --- a/src/listensocket.c +++ b/src/listensocket.c @@ -530,6 +530,24 @@ listensocket_t ** listensocket_container_list_sockets(listensocket_con return res; } +bool listensocket_container_is_family_included(listensocket_container_t *self, sock_family_t family) +{ + size_t i; + + thread_mutex_lock(&self->lock); + for (i = 0; i < self->sock_len; i++) { + if (self->sock[i] != NULL) { + if (listensocket_get_family(self->sock[i]) == family) { + thread_mutex_unlock(&self->lock); + return true; + } + } + } + thread_mutex_unlock(&self->lock); + + return false; +} + /* ---------------------------------------------------------------------------- */ static void __listensocket_free(refobject_t self, void **userdata) diff --git a/src/listensocket.h b/src/listensocket.h index 77c24c2c..f2211b41 100644 --- a/src/listensocket.h +++ b/src/listensocket.h @@ -9,6 +9,8 @@ #ifndef __LISTENSOCKET_H__ #define __LISTENSOCKET_H__ +#include + #include "common/net/sock.h" #include "icecasttypes.h" @@ -26,6 +28,7 @@ int listensocket_container_set_sockcount_cb(listensocket ssize_t listensocket_container_sockcount(listensocket_container_t *self); listensocket_t * listensocket_container_get_by_id(listensocket_container_t *self, const char *id); listensocket_t ** listensocket_container_list_sockets(listensocket_container_t *self); +bool listensocket_container_is_family_included(listensocket_container_t *self, sock_family_t family); REFOBJECT_FORWARD_TYPE(listensocket_t);