Require known peer admission as an ETCP connection creation policy
This commit is contained in:
1 parent
bd25e4abfc
commit
1e07d7c69c
2 files changed
+8
-2
No files matched your search
@@ -156,7 +156,7 @@ static void etcp_down_timer_cancel(struct ETCP_CONN* conn) {
|
||||
conn->log_name, conn->links_up, conn->close_requested);
|
||||
}
|
||||
|
||||
struct ETCP_CONN* etcp_connection_create(struct UTUN_INSTANCE* instance, char* name) {
|
||||
struct ETCP_CONN* etcp_connection_create(struct UTUN_INSTANCE* instance, char* name, int require_known_node) {
|
||||
DEBUG_TRACE(DEBUG_CATEGORY_ETCP, "");
|
||||
if (!instance) return NULL;
|
||||
|
||||
@@ -168,6 +168,7 @@ struct ETCP_CONN* etcp_connection_create(struct UTUN_INSTANCE* instance, char* n
|
||||
}
|
||||
|
||||
etcp->instance = instance;
|
||||
etcp->require_known_node = !!require_known_node;
|
||||
etcp->input_queue = queue_new(instance->ua, 0, 0, 0, "ETCP input"); // No hash for input_queue
|
||||
queue_set_threshold(etcp->input_queue, 0, 0); // Backpressure: ждать полного освобождения
|
||||
etcp->output_queue = queue_new(instance->ua, 0, 0, 0, "ETCP output"); // No hash for output_queue
|
||||
@@ -617,6 +618,10 @@ void etcp_conn_ready(struct ETCP_CONN* conn) {
|
||||
if (!conn || conn->close_requested) return;
|
||||
if (conn->state == 2) { DEBUG_WARN(DEBUG_CATEGORY_ETCP, "[%s] conn_ready on deleted conn", conn->log_name); return; }
|
||||
if (conn->initialized || conn->session_required) return; // ready or awaiting authenticated confirmation
|
||||
if (conn->require_known_node && !topo_groups_peer_key_known(conn->instance, conn->crypto_ctx.peer_public_key)) {
|
||||
DEBUG_WARN(DEBUG_CATEGORY_ETCP, "[%s] ready denied: authenticated peer key is not a known group member", conn->log_name);
|
||||
return;
|
||||
}
|
||||
|
||||
conn->initialized = 1;
|
||||
conn->reset_done = 1;
|
||||
|
||||
@@ -139,6 +139,7 @@ struct ETCP_CONN {
|
||||
|
||||
// Peer info
|
||||
uint64_t peer_node_id; // Peer node ID
|
||||
uint8_t require_known_node; // 1: при handshake ключ должен принадлежать известному участнику своей CHAT-группы.
|
||||
uint8_t peer_ed25519_pubkey[SC_PUBKEY_SIZE]; // Ed25519 pubkey пира (из INIT)
|
||||
uint8_t peer_sleep_phase; // 1 = пир в SLEEP-фазе (троттлить), 0 = ACTIVE-окно (обмен)
|
||||
uint16_t peer_active_remaining; // до SLEEP-фазы (x0.1с), из keepalive
|
||||
@@ -269,7 +270,7 @@ struct ETCP_CONN {
|
||||
/* Создать транспортный объект в instance, name копируется (может быть NULL).
|
||||
* Жизненным циклом прикладного соединения управляет NCD. Возвращает объект либо NULL при ошибке/отмене из callback.
|
||||
* New-connection/NEW callbacks могут закрыть объект; после отмены конструктор завершает закрытие и не возвращает handle. */
|
||||
struct ETCP_CONN* etcp_connection_create(struct UTUN_INSTANCE* instance, char* name);
|
||||
struct ETCP_CONN* etcp_connection_create(struct UTUN_INSTANCE* instance, char* name, int require_known_node);
|
||||
|
||||
#define ETCP_DOWN_TIMEOUT_TB 300000 /* 30 секунд в 0.1 ms */
|
||||
|
||||
|
||||
Reference in new issue
Block a user