- src/dm/: dm_core/dm_crypto/dm_mailbox — прямой обмен сообщениями (DM) - lib/soundtouch-master/: vendored SoundTouch (изменение темпа/высоты аудио) - doc/dm_arch.md, doc/chat_call_arch.md: архитектура DM и звонков - tests: test_dm.c, test_dm_e2e.c - chat: рефакторинг chat_* модулей, member_sync, invite_build - chatgui/chatgui-android: синхронизация с новым API чата - lib/u_async, debug_config, utun_instance: сопутствующие изменения
69 lines
2.6 KiB
C
69 lines
2.6 KiB
C
/*
|
|
* instance_lite.h — lightweight uTun instance lifecycle for Android
|
|
*
|
|
* Kotlin generates INI config text, passes to instance_lite_start().
|
|
* C side parses it, creates uasync+ETCP+bgp+chat stack, runs in a pthread.
|
|
* Mirrors UtunNode::runLoop() from tools/chatgui/transport/utun_node.cpp.
|
|
*/
|
|
#ifndef INSTANCE_LITE_H
|
|
#define INSTANCE_LITE_H
|
|
|
|
#include <stdint.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
struct UASYNC;
|
|
struct UTUN_INSTANCE;
|
|
|
|
/* Start full uTun stack from INI config text.
|
|
* Creates a pthread for uasync event loop.
|
|
* Returns 0 on success, -1 on error.
|
|
* Config format: same as utun INI (see node_config.cpp saveFull). */
|
|
int instance_lite_start(const char* config_text);
|
|
|
|
/* Signal stop and wait for thread to exit.
|
|
* Calls chat_sync_destroy, chat_core_destroy, utun_instance_destroy, uasync_destroy. */
|
|
void instance_lite_stop(void);
|
|
|
|
/* Returns non-zero if instance is running. */
|
|
int instance_lite_is_running(void);
|
|
|
|
/* Get current uasync handle (NULL if not running). */
|
|
struct UASYNC* instance_lite_get_uasync(void);
|
|
|
|
/* Get current UTUN_INSTANCE handle (NULL if not running). */
|
|
struct UTUN_INSTANCE* instance_lite_get_instance(void);
|
|
|
|
/* Set Kotlin callback for chat events (CONNECT_RESULT, MSG_RECEIVED, ...) */
|
|
typedef void (*instance_lite_event_fn)(int type, const uint8_t* data, int len);
|
|
void instance_lite_set_event_handler(instance_lite_event_fn handler);
|
|
|
|
/* Regenerate X25519 keys in the worker thread. Saves to keys.conf file.
|
|
* Call from any thread. Keys are regenerated asynchronously. */
|
|
void instance_lite_regenerate_keys(void);
|
|
|
|
/* Restart the instance internally (no thread kill). Stops chat_sync/chat_core,
|
|
* re-parses config, regenerates keys if needed, reopens DB, re-inits.
|
|
* Posts to uasync thread — restart happens asynchronously. */
|
|
void instance_lite_restart(const char* new_config_text);
|
|
|
|
/* Лёгкое обновление сокетов (auto_sockets=android): перечитывает [server] секции
|
|
* из нового конфига и сверяет сокеты без полного рестарта. Posts to uasync thread.
|
|
* Если ядро не запущено — только логирует ошибку и дропает вызов. */
|
|
void instance_lite_update_sockets(const char* config_text);
|
|
|
|
/* Health check: posts a ping to uasync, returns responsiveness after delay */
|
|
void instance_lite_ping(void);
|
|
int instance_lite_is_responsive(void);
|
|
|
|
/* Connection monitor: post collect_conn_list/conn_metrics to uasync thread */
|
|
void instance_lite_collect_conn_list(void);
|
|
void instance_lite_collect_conn_metrics(uint64_t peer_node_id);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif /* INSTANCE_LITE_H */
|