From d2b96d1340f9093a8380e4a8464e10b3b8bca91c Mon Sep 17 00:00:00 2001 From: evgeny Date: Mon, 12 Oct 2026 20:48:33 +0200 Subject: [PATCH] Release cold priority after a completed partial measurement --- src/routing_layer/nat_detection.c | 2 ++ tests/test_nat_detection.c | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/routing_layer/nat_detection.c b/src/routing_layer/nat_detection.c index 05e4844b..694291e3 100644 --- a/src/routing_layer/nat_detection.c +++ b/src/routing_layer/nat_detection.c @@ -1235,6 +1235,7 @@ uint64_t nat_detection_probe_delay(struct NAT_DETECTION *detector) { for (struct nat_socket *state = detector->sockets; state; state = state->next) { if (state->socket->is_tcp || !state->reservation_fingerprint || state->cold_until <= now || (!detector->automatic && !state->phase && !state->forced) || + (state->completed_tb && !state->phase && !state->cycling && !state->forced && state->due > now + 2500) || (state->measured_profile.source == ADDRESS_SOURCE_ETCP && state->measured_profile.mapping && state->measured_profile.inbound)) continue; if (state->cold_until - now > delay) delay = state->cold_until - now; @@ -1250,6 +1251,7 @@ int nat_detection_ping_allowed(struct NAT_DETECTION *detector, struct ETCP_SOCKE struct nat_socket *state = socket_state(detector, socket, 0); if (!state || (!state->reservation_fingerprint && !state->available_fingerprint) || state->cold_until <= get_time_tb() || (!detector->automatic && !state->phase && !state->forced) || + (state->completed_tb && !state->phase && !state->cycling && !state->forced && state->due > get_time_tb() + 2500) || (state->measured_profile.source == ADDRESS_SOURCE_ETCP && state->measured_profile.mapping && state->measured_profile.inbound)) return 1; uint64_t peer = sc_derive_node_id_from_pubkey(peer_key); if (!(flags & ETCP_PING_FLAG_OBSERVE)) { diff --git a/tests/test_nat_detection.c b/tests/test_nat_detection.c index cd81bf69..f6e2d585 100644 --- a/tests/test_nat_detection.c +++ b/tests/test_nat_detection.c @@ -74,9 +74,12 @@ static void test_all_groups_tcp(void) { sqlite3 *db = nodes[i]->topo_sqlite_db; assert(!topo_node_sqlite_channel_put(db, "42", "NAT group test", owner->node_id, owner->my_keys.public_key, NULL, owner->my_ed25519_pubkey, NULL, signature)); - for (unsigned j = 0; j < 3; j++) + for (unsigned j = 0; j < 3; j++) { + assert(!topo_node_sqlite_node_update_verified(db, nodes[j]->node_id, nodes[j]->name, + nodes[j]->my_keys.public_key, nodes[j]->my_ed25519_pubkey, 1, 1)); assert(!topo_node_sqlite_member_block_put(db, "42", nodes[j]->node_id, signature, 1, signature, 1, nodes[j]->my_keys.public_key, nodes[j]->my_ed25519_pubkey, "{}", NULL, 0, signature)); + } groups[i] = topo_groups_create_group(nodes[i]->topo_groups, 42, TOPO_GROUP_TYPE_CHAT, "42"); assert(groups[i]); }