Browse Source

invite: убрать BOTH-протокол — адрес либо UDP либо TCP

topo_upd
Evgeny 2 months ago
parent
commit
bcea4bc335
  1. 1
      src/chat/invite_link.h
  2. 6
      src/transport_layer/etcp_connect.c
  3. 1
      tools/chatgui/src/invite_link.h
  4. 5
      tools/chatgui/transport/utun_node.cpp

1
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" {

6
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;

1
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

5
tools/chatgui/transport/utun_node.cpp

@ -234,13 +234,14 @@ QList<NodeAddr> 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);
}
}

Loading…
Cancel
Save