tests: use ephemeral ports for ETCP traffic fixtures
This commit is contained in:
1 parent
3f4a67f552
commit
44522027e7
3 files changed
+17
-11
No files matched your search
@@ -3,6 +3,7 @@
|
||||
#include <string.h>
|
||||
#include "../lib/platform_compat.h"
|
||||
#include "test_utils.h"
|
||||
#include "test_net.h"
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <direct.h>
|
||||
@@ -47,7 +48,7 @@ static const char* server_config_content =
|
||||
"tun_ifname=tun99\n"
|
||||
"\n"
|
||||
"[server: test]\n"
|
||||
"addr=127.0.0.1:9021\n"
|
||||
"addr=127.0.0.1:0\n"
|
||||
"type=public\n"
|
||||
"\n"
|
||||
"[allowed_keys]\n"
|
||||
@@ -63,13 +64,13 @@ static const char* client_config_content =
|
||||
"tun_ifname=tun98\n"
|
||||
"\n"
|
||||
"[server: test]\n"
|
||||
"addr=127.0.0.1:9022\n"
|
||||
"addr=127.0.0.1:0\n"
|
||||
"type=public\n"
|
||||
"\n"
|
||||
"[client: test_client]\n"
|
||||
"keepalive=1\n"
|
||||
"peer_public_key=ce8871f07fa056c636d297115f231b08c29cdf94e0d440fce83a07c34416d36a\n"
|
||||
"link=test:127.0.0.1:9021\n";
|
||||
"link=test:127.0.0.1:0\n";
|
||||
|
||||
// Create temp config files
|
||||
static int create_temp_configs(void) {
|
||||
@@ -417,6 +418,7 @@ int main() {
|
||||
|
||||
printf("Creating client...\n");
|
||||
client_instance = utun_instance_create(ua, client_config_path);
|
||||
if (client_instance) test_etcp_set_peer(client_instance, "test_client", server_instance, "test");
|
||||
if (!client_instance || utun_instance_init(client_instance) < 0) {
|
||||
printf("Failed to create client\n");
|
||||
return 1;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <string.h>
|
||||
#include "../lib/platform_compat.h"
|
||||
#include "test_utils.h"
|
||||
#include "test_net.h"
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <direct.h>
|
||||
@@ -44,7 +45,7 @@ static char temp_dir[] = "/tmp/utun_test_XXXXXX";
|
||||
static char server_config_path[256];
|
||||
static char client_config_path[256];
|
||||
|
||||
// Server config content (uses ports 9031)
|
||||
// ОС выбирает порт слушателя при bind(0).
|
||||
static const char* server_config_content =
|
||||
"[global]\n"
|
||||
"my_node_id=0x1111111111111111\n"
|
||||
@@ -54,13 +55,13 @@ static const char* server_config_content =
|
||||
"tun_ifname=tun99\n"
|
||||
"\n"
|
||||
"[server: test]\n"
|
||||
"addr=127.0.0.1:9031\n"
|
||||
"addr=127.0.0.1:0\n"
|
||||
"type=public\n"
|
||||
"\n"
|
||||
"[allowed_keys]\n"
|
||||
"allow_all=1\n";
|
||||
|
||||
// Client config content (uses ports 9032)
|
||||
// Endpoint пира заполняется после создания слушателя.
|
||||
static const char* client_config_content =
|
||||
"[global]\n"
|
||||
"my_node_id=0x2222222222222222\n"
|
||||
@@ -70,13 +71,13 @@ static const char* client_config_content =
|
||||
"tun_ifname=tun98\n"
|
||||
"\n"
|
||||
"[server: test]\n"
|
||||
"addr=127.0.0.1:9032\n"
|
||||
"addr=127.0.0.1:0\n"
|
||||
"type=public\n"
|
||||
"\n"
|
||||
"[client: test_client]\n"
|
||||
"keepalive=1\n"
|
||||
"peer_public_key=ce8871f07fa056c636d297115f231b08c29cdf94e0d440fce83a07c34416d36a\n"
|
||||
"link=test:127.0.0.1:9031\n";
|
||||
"link=test:127.0.0.1:0\n";
|
||||
|
||||
// Create temp config files
|
||||
static int create_temp_configs(void) {
|
||||
@@ -572,6 +573,7 @@ int main() {
|
||||
|
||||
printf("Creating client...\n");
|
||||
client_instance = utun_instance_create(ua, client_config_path);
|
||||
if (client_instance) test_etcp_set_peer(client_instance, "test_client", server_instance, "test");
|
||||
if (!client_instance || utun_instance_init(client_instance) < 0) {
|
||||
printf("Failed to create client\n");
|
||||
return 1;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <string.h>
|
||||
#include "../lib/platform_compat.h"
|
||||
#include "test_utils.h"
|
||||
#include "test_net.h"
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <direct.h>
|
||||
@@ -46,7 +47,7 @@ static const char* server_config_content =
|
||||
"tun_ifname=tun99\n"
|
||||
"\n"
|
||||
"[server: test]\n"
|
||||
"addr=127.0.0.1:9041\n"
|
||||
"addr=127.0.0.1:0\n"
|
||||
"type=public\n"
|
||||
"\n"
|
||||
"[allowed_keys]\n"
|
||||
@@ -61,13 +62,13 @@ static const char* client_config_content =
|
||||
"tun_ifname=tun98\n"
|
||||
"\n"
|
||||
"[server: test]\n"
|
||||
"addr=127.0.0.1:9042\n"
|
||||
"addr=127.0.0.1:0\n"
|
||||
"type=public\n"
|
||||
"\n"
|
||||
"[client: test_client]\n"
|
||||
"keepalive=1\n"
|
||||
"peer_public_key=ce8871f07fa056c636d297115f231b08c29cdf94e0d440fce83a07c34416d36a\n"
|
||||
"link=test:127.0.0.1:9041\n";
|
||||
"link=test:127.0.0.1:0\n";
|
||||
|
||||
static struct UTUN_INSTANCE* server_instance = NULL;
|
||||
static struct UTUN_INSTANCE* client_instance = NULL;
|
||||
@@ -253,6 +254,7 @@ int main(void) {
|
||||
if (!server_instance || utun_instance_init(server_instance) < 0) { fprintf(stderr, "Failed to create server\n"); return 1; }
|
||||
|
||||
client_instance = utun_instance_create(ua, client_config_path);
|
||||
if (client_instance) test_etcp_set_peer(client_instance, "test_client", server_instance, "test");
|
||||
if (!client_instance || utun_instance_init(client_instance) < 0) { fprintf(stderr, "Failed to create client\n"); return 1; }
|
||||
|
||||
packet_timeout_id = uasync_set_timeout(ua, 500, NULL, monitor_and_send, "test_monitor");
|
||||
|
||||
Reference in new issue
Block a user