stcp: ed25519 pubkey exchange in handshake, fix instance destroy segfault, fix chat_tcp_test
- u_async.c: process immediate_queue BEFORE epoll_wait in uasync_poll - stcp_link.c: defensive NULL etcp_conn/etcp_link in stcp_link_close - utun_instance.c: move stcp_server_list_destroy_all to Phase J (before ETCP), add deferred drain in both Phase J and L - stcp.h/c: STCP_HS_ENC_CLIENT 6→38, STCP_HS_ENC_SERVER 7→39, exchange ed25519_pubkey in both handshake directions - etcp_connections.c: copy peer_ed25519 from STCP to ETCP_CONN in etcp_link_enter_ready_tcp; guard link->etcp in tcp_link_close_cb - chat_sync.c: fix lk->conn NULL dereference for TCP links - test_stcp.c: update stcp_server_create/stcp_client_connect callsites - tools/chat_tcp_test: change transport udp→tcp
This commit is contained in:
1 parent
a3783b5f55
commit
38c9f229bc
1272 files changed
+968388
-1
No files matched your search
@@ -0,0 +1,75 @@
|
||||
#ifndef TOPO_NODE_SQLITE_H
|
||||
#define TOPO_NODE_SQLITE_H
|
||||
|
||||
#include <sqlite3.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <time.h>
|
||||
#include "topo_node.h"
|
||||
|
||||
#define PEERS_JOIN_SIG_SIZE 64
|
||||
#define PEERS_JOIN_TS_SIZE 8
|
||||
#define PEERS_UPDATE_SIG_SIZE 64
|
||||
|
||||
/* flags byte in wire format */
|
||||
#define PEERS_FLAG_HAS_JOIN 0x01
|
||||
|
||||
int topo_node_sqlite_init(sqlite3* db);
|
||||
|
||||
int topo_node_sqlite_node_put(sqlite3* db, struct TOPO_GROUPS* groups, struct TOPO_GROUP_NODE* nq, time_t now_sec);
|
||||
|
||||
int topo_node_sqlite_channel_put(sqlite3* db, const char* channel_id,
|
||||
const char* name, uint64_t owner_node_id,
|
||||
const uint8_t* x25519_pub, const uint8_t* x25519_priv,
|
||||
const uint8_t* ed25519_pub, const uint8_t* ed25519_priv,
|
||||
const uint8_t* signature);
|
||||
|
||||
int topo_node_sqlite_member_put(sqlite3* db, const char* channel_id, uint64_t node_id,
|
||||
const uint8_t* join_sig, uint64_t join_ts,
|
||||
const uint8_t* update_sig, uint64_t update_ts,
|
||||
const uint8_t* x25519_pubkey, const uint8_t* ed25519_pubkey, const char* userinfo,
|
||||
const uint8_t* creator_sig,
|
||||
const char* adm_tags, const uint8_t* adm_tags_sig, int storage);
|
||||
|
||||
int topo_node_sqlite_member_get_join(sqlite3* db, const char* channel_id, uint64_t node_id,
|
||||
uint8_t* join_sig_out, uint64_t* join_ts_out);
|
||||
|
||||
int topo_node_sqlite_member_del(sqlite3* db, const char* channel_id, uint64_t node_id);
|
||||
|
||||
int topo_node_sqlite_node_update_verified(sqlite3* db, uint64_t node_id,
|
||||
const char* name, const uint8_t* x25519, const uint8_t* ed25519, uint64_t update_ts, time_t created_at);
|
||||
|
||||
int topo_node_sqlite_channel_get(sqlite3* db, const char* channel_id,
|
||||
char* name_out, int name_sz, uint64_t* owner_node_id,
|
||||
uint8_t* x25519_pub, uint8_t* ed25519_pub, uint8_t* signature);
|
||||
|
||||
int topo_node_sqlite_channel_peers_all(sqlite3* db, const char* channel_id,
|
||||
uint8_t* buf, size_t buf_sz, size_t* out_len);
|
||||
|
||||
int topo_node_sqlite_node_set_online(sqlite3* db, uint64_t node_id, int online);
|
||||
int topo_node_sqlite_node_get_online(sqlite3* db, uint64_t node_id);
|
||||
int topo_node_sqlite_get_ed25519_pubkey(sqlite3* db, uint64_t node_id, uint8_t pubkey_out[32]);
|
||||
|
||||
/** Пересчитывает node_type во всех peers_* таблицах на основе addr_type из node_addresses */
|
||||
int topo_node_sqlite_nodeinfo_updated(sqlite3* db, uint64_t node_id);
|
||||
|
||||
/** Обновляет RTT узла: node_addresses.rtt и все peers_*.node_RTT */
|
||||
void topo_node_sqlite_update_rtt(sqlite3* db, uint64_t node_id, uint16_t rtt);
|
||||
|
||||
/**
|
||||
* @brief Загружает TOPO_NODE из SQLite (ref_count=0).
|
||||
* @param groups нужен для выделения адресов из memory_pool
|
||||
* @return TOPO_NODE* или NULL если узел не найден/нет адресов
|
||||
*
|
||||
* Загружает pubkey, name из nodes, IPv4/UDP-адреса из node_addresses.
|
||||
* Вызывающий должен передать владение через topo_node_registry_acquire().
|
||||
*/
|
||||
struct TOPO_NODE* topo_node_sqlite_node_load(sqlite3* db, struct TOPO_GROUPS* groups, uint64_t node_id);
|
||||
|
||||
int topo_node_sqlite_set_connected(sqlite3* db, const char* channel_id, uint64_t node_id, int connected);
|
||||
int topo_node_sqlite_get_connected_peers(sqlite3* db, const char* channel_id, uint64_t** out_ids, int* out_count);
|
||||
int topo_node_sqlite_get_public_peers(sqlite3* db, const char* channel_id, uint64_t** out_ids, int* out_count, uint64_t self_node_id);
|
||||
int topo_node_sqlite_get_local_peers(sqlite3* db, const char* channel_id, uint64_t** out_ids, int* out_count, uint64_t self_node_id);
|
||||
int topo_node_sqlite_get_supernode_peers(sqlite3* db, const char* channel_id, uint64_t** out_ids, int* out_count);
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user