diff --git a/tools/chatgui/transport/chat_core.c b/tools/chatgui/transport/chat_core.c index 8489e979..485ba02f 100644 --- a/tools/chatgui/transport/chat_core.c +++ b/tools/chatgui/transport/chat_core.c @@ -1006,6 +1006,15 @@ void chat_core_connect_auto(uint64_t node_id, } sqlite3_finalize(st); } + /* dedup by (addr, port) — can't have two links to same socket */ + { int uniq = 0; + for (int i = 0; i < addr_count; i++) { + int dup = 0; + for (int j = 0; j < uniq; j++) + if (memcmp(addrs[i].addr, addrs[j].addr, 4) == 0 && addrs[i].port == addrs[j].port) { dup = 1; break; } + if (!dup) { if (i != uniq) addrs[uniq] = addrs[i]; uniq++; } + } + addr_count = uniq; } if (addr_count == 0) { DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: auto_connect no IPv4 addrs for node 0x%016llx", CC_ID, (unsigned long long)node_id);