diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-29 00:34:40 +0100 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-29 00:34:40 +0100 |
| commit | 952da5949f677e932f2a48a5474210df571472fb (patch) | |
| tree | d33525d29ee18b65b9e5df39d2e2fb1f5a868ca2 /src/opentracker.c | |
| parent | f08e7473ac51a024f49e5101fbc5e150fecef2d4 (diff) | |
Diffstat (limited to 'src/opentracker.c')
| -rw-r--r-- | src/opentracker.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/opentracker.c b/src/opentracker.c index 36dff71..81b4df6 100644 --- a/src/opentracker.c +++ b/src/opentracker.c | |||
| @@ -227,6 +227,16 @@ static void listen_bind_one(ot_listen *entry) { | |||
| 227 | #endif | 227 | #endif |
| 228 | } | 228 | } |
| 229 | 229 | ||
| 230 | static void listen_warn_if_taken(const ot_listen *entry) { | ||
| 231 | char address[64]; | ||
| 232 | |||
| 233 | if (entry->proto != FLAG_UDP || !socket_udp_is_taken(entry->ip, entry->port)) | ||
| 234 | return; | ||
| 235 | |||
| 236 | address[ip_format(address, entry->ip)] = 0; | ||
| 237 | fprintf(stderr, "Warning: udp address [%s]:%d is already in use, by another tracker instance perhaps.\n", address, entry->port); | ||
| 238 | } | ||
| 239 | |||
| 230 | /* Bound in the order the entries were given. | 240 | /* Bound in the order the entries were given. |
| 231 | Note: On macOS SO_REUSEPORT delivers everything to the socket that bound last. */ | 241 | Note: On macOS SO_REUSEPORT delivers everything to the socket that bound last. */ |
| 232 | static void listen_bind_all(void) { | 242 | static void listen_bind_all(void) { |
| @@ -234,6 +244,9 @@ static void listen_bind_all(void) { | |||
| 234 | ot_listen *entries = config_listen_entries(&count); | 244 | ot_listen *entries = config_listen_entries(&count); |
| 235 | 245 | ||
| 236 | for (i = 0; i < count; ++i) | 246 | for (i = 0; i < count; ++i) |
| 247 | listen_warn_if_taken(entries + i); | ||
| 248 | |||
| 249 | for (i = 0; i < count; ++i) | ||
| 237 | listen_bind_one(entries + i); | 250 | listen_bind_one(entries + i); |
| 238 | } | 251 | } |
| 239 | 252 | ||
