Keep NAT remeasurement fixture isolated from new direct helper links

This commit is contained in:
evgeny committed 2026-10-24 20:20:09 +02:00
1 parent a3f004772a
commit b83a28becc
1 file changed
+12
+12
View File
@@ -210,6 +210,16 @@ static void test_tcp_presence(void) {
DEBUG_INFO(DEBUG_CATEGORY_NAT, "PASS TCP NAT presence: one peer, public/private IP, ignored ports, signed IP:0 and SQLite");
}
/* Прямое подключение helper к owner подтвердило бы OPEN вместо нового измерения через next hop. */
static void block_owner_link(struct ETCP_CONN* conn, struct ETCP_LINK* link, int old_state, int old_status, void* arg) {
(void)old_status;
struct UTUN_INSTANCE* owner = arg;
if (old_state != -1 || conn->peer_node_id != owner->node_id) return;
DEBUG_INFO(DEBUG_CATEGORY_NAT, "NAT test: block helper direct transport to owner node=%016llx protocol=%s",
(unsigned long long)owner->node_id, link->is_tcp ? "TCP" : "UDP");
etcp_link_close(link);
}
/* Недостаточная UTUN-группа и достаточная CHAT-группа; helper доступен только через TCP next hop. */
static void test_all_groups_tcp(void) {
struct nat_fixture fixture; nat_fixture_init(&fixture);
@@ -267,6 +277,7 @@ static void test_all_groups_tcp(void) {
assert(!instance_find_conn(owner, helper->node_id));
/* Реально заблокированный UDP endpoint: UNKNOWN не запускает лишних проверок, подписанный OPEN запускает одну. */
uint64_t verified_round = status.round;
etcp_add_link_status_cbk(helper, block_owner_link, owner);
struct NODE_CONN_DIRECT **failed_handle = &fixture.handles[fixture.handle_count++];
node = topo_node_registry_find(owner->topo_groups, helper->node_id);
assert(node_conn_direct_open_node(owner, helper->node_id, NULL, NULL, failed_handle, node, socket) != NCD_ERR);
@@ -308,6 +319,7 @@ static void test_all_groups_tcp(void) {
assert(!nat_detection_get_status(owner->nat_det, socket, &status) && !status.phase && !status.group_id);
assert(socket->address_profile.mapping == ADDRESS_MAP_UNCHANGED && socket->address_profile.inbound == ADDRESS_IN_OPEN);
assert(ab->links_up && topo_group_peer_ready(topo_groups_find(owner->topo_groups, TOPO_GROUP_UTUN), observer->node_id));
etcp_remove_link_status_cbk(helper, block_owner_link, owner);
nat_fixture_cleanup(&fixture);
}