|
|
|
|
@ -28,6 +28,7 @@
|
|
|
|
|
#include "../lib/mem.h" |
|
|
|
|
#include "test_utils.h" |
|
|
|
|
#include "test_clock.h" |
|
|
|
|
#include "test_net.h" |
|
|
|
|
|
|
|
|
|
#include <sqlite3.h> |
|
|
|
|
#define OPENSSL_API_COMPAT 0x10100000L |
|
|
|
|
@ -56,7 +57,6 @@ static uint64_t g_nid[MAX_NODES];
|
|
|
|
|
static char g_tdir[256] = "/tmp/utun_cj_XXXXXX"; |
|
|
|
|
static char g_cfg[MAX_NODES][256]; |
|
|
|
|
static char g_db_dir[MAX_NODES][320]; |
|
|
|
|
static int g_port[MAX_NODES]; |
|
|
|
|
static uint64_t g_group_id = 0; |
|
|
|
|
|
|
|
|
|
/* ── крипто-хелперы ── */ |
|
|
|
|
@ -286,10 +286,9 @@ static void write_comp_config(void) {
|
|
|
|
|
snprintf(g_cfg[0], sizeof(g_cfg[0]), "%s/comp.conf", g_tdir); |
|
|
|
|
snprintf(g_db_dir[0], sizeof(g_db_dir[0]), "%s/dbcomp", g_tdir); |
|
|
|
|
utun_mkdir(g_db_dir[0], 0755); |
|
|
|
|
g_port[0] = 54000 + (getpid() % 4000); |
|
|
|
|
wf(g_cfg[0], "[global]\ntun_ip=10.98.70.1/24\ntun_ifname=tun70\ndb_path=%s\n" |
|
|
|
|
"[server: s1]\naddr=127.0.0.1:%d\ntype=public\n[allowed_keys]\nallow_all=1\n", |
|
|
|
|
g_db_dir[0], g_port[0]); |
|
|
|
|
"[server: s1]\naddr=127.0.0.1:0\ntype=public\n[allowed_keys]\nallow_all=1\n", |
|
|
|
|
g_db_dir[0]); |
|
|
|
|
config_ensure_keys_and_node_id(g_cfg[0]); |
|
|
|
|
struct utun_config* c = parse_config(g_cfg[0]); g_nid[0] = c->global.my_node_id; free_config(c); |
|
|
|
|
} |
|
|
|
|
@ -300,12 +299,11 @@ static void write_int_configs(void) {
|
|
|
|
|
snprintf(g_cfg[i], sizeof(g_cfg[i]), "%s/%s.conf", g_tdir, i ? "c" : "a"); |
|
|
|
|
snprintf(g_db_dir[i], sizeof(g_db_dir[i]), "%s/db%s", g_tdir, i ? "c" : "a"); |
|
|
|
|
utun_mkdir(g_db_dir[i], 0755); |
|
|
|
|
g_port[i] = 55000 + (getpid() % 3000) + i * 1000; |
|
|
|
|
} |
|
|
|
|
for (int i = 0; i < 2; i++) { |
|
|
|
|
wf(g_cfg[i], "[global]\ntun_ip=10.98.%d.1/24\ntun_ifname=tun%d0\ndb_path=%s\n" |
|
|
|
|
"[server: s1]\naddr=127.0.0.1:%d\ntype=public\n[allowed_keys]\nallow_all=1\n", |
|
|
|
|
i, i, g_db_dir[i], g_port[i]); |
|
|
|
|
"[server: s1]\naddr=127.0.0.1:0\ntype=public\n[allowed_keys]\nallow_all=1\n", |
|
|
|
|
i, i, g_db_dir[i]); |
|
|
|
|
config_ensure_keys_and_node_id(g_cfg[i]); |
|
|
|
|
struct utun_config* c = parse_config(g_cfg[i]); g_nid[i] = c->global.my_node_id; free_config(c); |
|
|
|
|
} |
|
|
|
|
@ -314,9 +312,9 @@ static void write_int_configs(void) {
|
|
|
|
|
char* pr = gv(g_cfg[1], "priv"); char* pu = gv(g_cfg[1], "pub"); |
|
|
|
|
char* p0_pu = gv(g_cfg[0], "pub"); |
|
|
|
|
wf(g_cfg[1], "[global]\nmy_private_key=%s\nmy_public_key=%s\ntun_ip=10.98.1.1/24\ntun_ifname=tun10\n" |
|
|
|
|
"db_path=%s\n[server: s1]\naddr=127.0.0.1:%d\ntype=public\n" |
|
|
|
|
"[client: to_a]\nkeepalive=1\npeer_public_key=%s\nlink=s1:127.0.0.1:%d\n[allowed_keys]\nallow_all=1\n", |
|
|
|
|
pr, pu, g_db_dir[1], g_port[1], p0_pu, g_port[0]); |
|
|
|
|
"db_path=%s\n[server: s1]\naddr=127.0.0.1:0\ntype=public\n" |
|
|
|
|
"[client: to_a]\nkeepalive=1\npeer_public_key=%s\nlink=s1:127.0.0.1:0\n[allowed_keys]\nallow_all=1\n", |
|
|
|
|
pr, pu, g_db_dir[1], p0_pu); |
|
|
|
|
u_free(pr); u_free(pu); u_free(p0_pu); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -325,6 +323,7 @@ static int create_instances(int n) {
|
|
|
|
|
for (int i = 0; i < n; i++) { |
|
|
|
|
g_inst[i] = utun_instance_create(g_ua, g_cfg[i]); |
|
|
|
|
if (!g_inst[i]) { printf("FAIL: create n%d\n", i); return -1; } |
|
|
|
|
if (i == 1) test_etcp_set_peer(g_inst[i], "to_a", g_inst[0], "s1"); |
|
|
|
|
utun_instance_init(g_inst[i]); |
|
|
|
|
member_sync_init(g_inst[i]); |
|
|
|
|
} |
|
|
|
|
|