Browse Source

test(nat): isolate active measurements from incoming transport evidence

stream-multiview
evgeny 1 week ago
parent
commit
49385ab91c
  1. 7
      tests/test_nat_detection.c
  2. 5
      tests/test_nat_detection_faults.c

7
tests/test_nat_detection.c

@ -262,14 +262,12 @@ int main(void) {
struct SC_MYKEYS swap = first; first = second; second = swap; struct SC_MYKEYS swap = first; first = second; second = swap;
} }
struct UTUN_INSTANCE *owner = nat_fixture_node(&fixture, "127.0.0.2", NULL, struct UTUN_INSTANCE *owner = nat_fixture_node(&fixture, "127.0.0.2", NULL,
"[server:second]\naddr=127.0.0.5:0\ntype=public\n" "[server:second]\naddr=127.0.0.5:0\ntype=public\n");
"[server:tcp]\naddr=127.0.0.2:0\ntype=public\ntransport=tcp\n");
struct UTUN_INSTANCE *observer = nat_fixture_node(&fixture, "127.0.0.3", NULL, NULL); struct UTUN_INSTANCE *observer = nat_fixture_node(&fixture, "127.0.0.3", NULL, NULL);
struct UTUN_INSTANCE *same_ip = nat_fixture_node(&fixture, "127.0.0.3", &first, NULL); struct UTUN_INSTANCE *same_ip = nat_fixture_node(&fixture, "127.0.0.3", &first, NULL);
struct UTUN_INSTANCE *helper = nat_fixture_node(&fixture, "127.0.0.4", &second, NULL); struct UTUN_INSTANCE *helper = nat_fixture_node(&fixture, "127.0.0.4", &second, NULL);
struct ETCP_SOCKET *socket = test_etcp_bound_socket(owner, "udp"); struct ETCP_SOCKET *socket = test_etcp_bound_socket(owner, "udp");
struct ETCP_SOCKET *second_socket = test_etcp_bound_socket(owner, "second"); struct ETCP_SOCKET *second_socket = test_etcp_bound_socket(owner, "second");
struct ETCP_SOCKET *tcp = test_etcp_bound_socket(owner, "tcp");
struct ETCP_SOCKET *observer_socket = test_etcp_bound_socket(observer, "udp"); struct ETCP_SOCKET *observer_socket = test_etcp_bound_socket(observer, "udp");
assert(socket->sock_id != observer_socket->sock_id); assert(socket->sock_id != observer_socket->sock_id);
@ -299,9 +297,6 @@ int main(void) {
assert(status.round != second_status.round); assert(status.round != second_status.round);
check_snapshot(owner, socket); check_snapshot(owner, socket);
check_snapshot(owner, second_socket); check_snapshot(owner, second_socket);
assert(tcp->address_profile.inbound == ADDRESS_IN_UNKNOWN);
struct nat_check_status tcp_status;
assert(!nat_detection_get_status(owner->nat_det, tcp, &tcp_status) && !tcp_status.rounds && !tcp_status.helper);
/* Профиль B не заимствует профиль A, даже когда транспорт переиспользуется в обе стороны. */ /* Профиль B не заимствует профиль A, даже когда транспорт переиспользуется в обе стороны. */
assert(!route_ping_addr_equal(&socket->local_addr, &observer_socket->local_addr, 1)); assert(!route_ping_addr_equal(&socket->local_addr, &observer_socket->local_addr, 1));

5
tests/test_nat_detection_faults.c

@ -384,9 +384,12 @@ static void run_endpoint_retry(void) {
nat_detection_set_automatic(observer->nat_det, 0); nat_detection_set_automatic(helper->nat_det, 0); nat_detection_set_automatic(observer->nat_det, 0); nat_detection_set_automatic(helper->nat_det, 0);
struct ETCP_SOCKET *bad = test_etcp_bound_socket(observer, "udp"); struct ETCP_SOCKET *bad = test_etcp_bound_socket(observer, "udp");
assert(!uasync_remove_socket_t(fixture.ua, bad->fd)); bad->socket_id = NULL; assert(!uasync_remove_socket_t(fixture.ua, bad->fd)); bad->socket_id = NULL;
/* Управляющие TCP-пиры не должны параллельно открывать входящий UDP и обходить проверяемый retry. */
struct ETCP_SOCKET *socket = test_etcp_bound_socket(owner, "udp");
socket->type = CFG_SERVER_TYPE_PRIVATE; assert(topo_node_update_my_addresses(owner) >= 0);
nat_fixture_connect(&fixture, observer, "tcp", helper); nat_fixture_connect(&fixture, owner, "tcp", observer); nat_fixture_connect(&fixture, observer, "tcp", helper); nat_fixture_connect(&fixture, owner, "tcp", observer);
nat_detection_set_automatic(owner->nat_det, 0); nat_detection_set_automatic(owner->nat_det, 0);
struct ETCP_SOCKET *socket = test_etcp_bound_socket(owner, "udp"); socket->type = CFG_SERVER_TYPE_PUBLIC; /* До публикации измерения NCD видит запрет входящего транспорта. */
struct nat_check_status status = {0}; uint64_t end = get_time_tb() + 400000; struct nat_check_status status = {0}; uint64_t end = get_time_tb() + 400000;
nat_detection_get_status(owner->nat_det, socket, &status); uint32_t rounds = status.rounds; nat_detection_get_status(owner->nat_det, socket, &status); uint32_t rounds = status.rounds;
assert(!nat_detection_request_check_socket(owner->nat_det, socket, observer->node_id)); assert(!nat_detection_request_check_socket(owner->nat_det, socket, observer->node_id));

Loading…
Cancel
Save