etcp: add link addresses to all UP/DOWN/close log messages
- etcp_on_up: list up-link addresses after connection summary - etcp_on_down: show all link addresses that were lost - Link UP (server/client): add addr=X - Connection established: add addr=X - Link closed: add addr=X before traffic stats - Link down (keepalive timeout): add addr=X Now: [conn] Link 1 UP (server, mtu=1600, addr=192.168.40.247:2122)
This commit is contained in:
1 parent
cf8236266b
commit
83aba82887
5 files changed
+79
-27
No files matched your search
@@ -747,6 +747,29 @@ int topo_node_sqlite_get_public_peers(sqlite3* db, const char* channel_id,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int topo_node_sqlite_get_supernode_peers(sqlite3* db, const char* channel_id,
|
||||
uint64_t** out_ids, int* out_count) {
|
||||
if (!db || !channel_id || !out_ids || !out_count) return -1;
|
||||
*out_ids = NULL; *out_count = 0;
|
||||
char peers_tbl[80]; peers_table_name(channel_id, peers_tbl, sizeof(peers_tbl));
|
||||
char sql[256]; snprintf(sql, sizeof(sql),
|
||||
"SELECT p.node_id FROM \"%s\" p WHERE p.node_type=4"
|
||||
" AND EXISTS (SELECT 1 FROM node_addresses na WHERE na.node_id=p.node_id AND na.family=4)",
|
||||
peers_tbl);
|
||||
sqlite3_stmt* st = NULL;
|
||||
if (sqlite3_prepare_v2(db, sql, -1, &st, NULL) != SQLITE_OK) return -1;
|
||||
int cnt = 0;
|
||||
while (sqlite3_step(st) == SQLITE_ROW) cnt++;
|
||||
if (cnt == 0) { sqlite3_finalize(st); return 0; }
|
||||
uint64_t* ids = u_malloc((size_t)cnt * sizeof(uint64_t));
|
||||
if (!ids) { sqlite3_finalize(st); return -1; }
|
||||
sqlite3_reset(st); int i = 0;
|
||||
while (sqlite3_step(st) == SQLITE_ROW) ids[i++] = (uint64_t)sqlite3_column_int64(st, 0);
|
||||
sqlite3_finalize(st);
|
||||
*out_ids = ids; *out_count = cnt;
|
||||
return 0;
|
||||
}
|
||||
|
||||
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) {
|
||||
if (!db || !out_ids || !out_count) return -1;
|
||||
|
||||
Reference in new issue
Block a user