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