From 952da5949f677e932f2a48a5474210df571472fb Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Sun, 29 Nov 2026 00:34:40 +0100 Subject: Warn about udp addresses already taken by other tracker instances --- src/opentracker.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/opentracker.c') diff --git a/src/opentracker.c b/src/opentracker.c index 36dff71..81b4df6 100644 --- a/src/opentracker.c +++ b/src/opentracker.c @@ -227,12 +227,25 @@ static void listen_bind_one(ot_listen *entry) { #endif } +static void listen_warn_if_taken(const ot_listen *entry) { + char address[64]; + + if (entry->proto != FLAG_UDP || !socket_udp_is_taken(entry->ip, entry->port)) + return; + + address[ip_format(address, entry->ip)] = 0; + fprintf(stderr, "Warning: udp address [%s]:%d is already in use, by another tracker instance perhaps.\n", address, entry->port); +} + /* Bound in the order the entries were given. Note: On macOS SO_REUSEPORT delivers everything to the socket that bound last. */ static void listen_bind_all(void) { size_t count, i; ot_listen *entries = config_listen_entries(&count); + for (i = 0; i < count; ++i) + listen_warn_if_taken(entries + i); + for (i = 0; i < count; ++i) listen_bind_one(entries + i); } -- cgit v1.3