diff --git a/src/chat/invite_link.h b/src/chat/invite_link.h index 38309bef..9b74c3ea 100644 --- a/src/chat/invite_link.h +++ b/src/chat/invite_link.h @@ -17,7 +17,6 @@ #define INVITE_PROTO_UDP 0x01 #define INVITE_PROTO_TCP 0x02 -#define INVITE_PROTO_BOTH 0x03 #ifdef __cplusplus extern "C" { diff --git a/src/transport_layer/etcp_connect.c b/src/transport_layer/etcp_connect.c index 8ec685c0..81716419 100644 --- a/src/transport_layer/etcp_connect.c +++ b/src/transport_layer/etcp_connect.c @@ -79,11 +79,11 @@ static void connect_create_links_v4(struct ETCP_CONNECT* ctx, struct TOPO_GROUP_ memcpy(&sin.sin_addr.s_addr, a->addr, 4); sin.sin_port = htons(a->port); struct sockaddr_storage sa; memcpy(&sa, &sin, sizeof(sin)); int addr_links = 0; - if (!(a->protocol & TOPO_PROTO_TCP)) { + if (a->protocol & TOPO_PROTO_UDP) { struct ETCP_SOCKET* s = ctx->instance->etcp_sockets; while (s) { if (s->local_addr.ss_family == AF_INET && etcp_link_new(ctx->conn, s, &sa, 0)) { link_count++; addr_links++; } s = s->next; } } - if ((a->protocol & TOPO_PROTO_TCP)) { + if (a->protocol & TOPO_PROTO_TCP) { struct ETCP_SOCKET* s = ctx->instance->etcp_sockets; while (s) { if (s->is_tcp && s->local_addr.ss_family == AF_INET) { struct ETCP_LINK *tlink = etcp_link_new(ctx->conn, s, &sa, 0); @@ -111,7 +111,7 @@ static void connect_create_links_v6(struct ETCP_CONNECT* ctx, struct TOPO_GROUP_ memcpy(&sin6.sin6_addr, a->addr, 16); sin6.sin6_port = htons(a->port); int is_ll = (a->addr[0] == 0xfe && (a->addr[1] & 0xc0) == 0x80); int addr_links = 0; - if (!(a->protocol & TOPO_PROTO_TCP)) { + if (a->protocol & TOPO_PROTO_UDP) { struct ETCP_SOCKET* s = ctx->instance->etcp_sockets; while (s) { if (s->local_addr.ss_family == AF_INET6) { if (is_ll) sin6.sin6_scope_id = s->netif_index; diff --git a/tools/chatgui/src/invite_link.h b/tools/chatgui/src/invite_link.h index ea1c7b8c..64b0c03e 100644 --- a/tools/chatgui/src/invite_link.h +++ b/tools/chatgui/src/invite_link.h @@ -10,7 +10,6 @@ #define INVITE_PROTO_UDP 0x01 #define INVITE_PROTO_TCP 0x02 -#define INVITE_PROTO_BOTH 0x03 struct InviteAddr { int family; // 4=IPv4, 6=IPv6 diff --git a/tools/chatgui/transport/utun_node.cpp b/tools/chatgui/transport/utun_node.cpp index d294617a..45953866 100644 --- a/tools/chatgui/transport/utun_node.cpp +++ b/tools/chatgui/transport/utun_node.cpp @@ -234,13 +234,14 @@ QList UtunNode::getInviteAddresses(DbManager* db) { } } - /* 4) Merge: dedup by (addr,port), write result with merged proto */ + /* 4) Dedup by (addr,port); emit one entry per proto (UDP и TCP раздельно, без BOTH) */ for (auto it = addrProto.begin(); it != addrProto.end(); ++it) { QByteArray addr = it.key().first; quint16 port = it.key().second; uint8_t proto = it.value(); int family = (addr.size() == 16) ? 6 : 4; - append_from_addr_proto(addr, port, family, 0, proto); + if (proto & INVITE_PROTO_UDP) append_from_addr_proto(addr, port, family, 0, INVITE_PROTO_UDP); + if (proto & INVITE_PROTO_TCP) append_from_addr_proto(addr, port, family, 0, INVITE_PROTO_TCP); } }