From 63b1f1bc16e0e9dd649aa28bca22eb98ecf96428 Mon Sep 17 00:00:00 2001 From: evgeny Date: Tue, 11 Aug 2026 13:31:18 +0300 Subject: [PATCH] fix: init client_type and keepalive_interval in utun_instance_init() utun_instance_init() did not call instance_init_common(), leaving instance->client_type and instance->keepalive_interval as 0. This broke the INIT handshake in V4 protocol: server wrote keepalive=0 into INIT_RESPONSE, causing negotiate_keepalive to see 0 and client to receive empty keepalive. Also added guard: keepalive < 100ms clamped to 100ms with ERROR log. --- src/utun_instance.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/utun_instance.c b/src/utun_instance.c index 428b3437..48f034ee 100644 --- a/src/utun_instance.c +++ b/src/utun_instance.c @@ -654,6 +654,15 @@ static int mkdir_recursive(const char *path) { int utun_instance_init(struct UTUN_INSTANCE *instance) { if (!instance) return -1; + struct utun_config* config = instance->config; + if (config) { + instance->client_type = config->global.client_type; + uint16_t ka = (uint16_t)config->global.keepalive_interval; + if (ka == 0) ka = 200; + if (ka < 100) { DEBUG_ERROR(DEBUG_CATEGORY_KEEPALIVE, "keepalive_interval %u < 100ms, clamped to 100ms", (unsigned)ka); ka = 100; } + instance->keepalive_interval = ka; + } + // db_sync — распределённая таблица с репликацией db_sync_init(instance);