Browse Source

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.
topo_upd
evgeny 2 months ago
parent
commit
63b1f1bc16
  1. 9
      src/utun_instance.c

9
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);

Loading…
Cancel
Save