add server/client (S/C) indicator based on ETCP_LINK.is_server in connection monitor, member detail, and Android JSON
This commit is contained in:
1 parent
cf956cf2f0
commit
496f0f7d2b
4 files changed
+29
-32
No files matched your search
+10
-30
@@ -16,9 +16,6 @@
|
||||
#include "../transport_layer/etcp_connections.h"
|
||||
#include "../transport_layer/stcp_link.h"
|
||||
#include "../transport_layer/pkt_normalizer.h"
|
||||
#include "../proxy/tcp_proxy_server.h"
|
||||
#include "../proxy/udp_proxy.h"
|
||||
#include "../proxy/icmp_proxy.h"
|
||||
#include <string.h>
|
||||
|
||||
static const char* nat_type_str(uint8_t t) {
|
||||
@@ -150,17 +147,9 @@ static void collect_conn_list(void) {
|
||||
uint8_t flags = 0;
|
||||
if (conn->links_up) flags |= 1;
|
||||
if (conn->initialized) flags |= 2;
|
||||
if (g_cc.inst->tcp_proxy_client && ce->peer_node_id == g_cc.inst->config->global.tcp_proxy_client_via_node_id)
|
||||
flags |= 4;
|
||||
if (g_cc.inst->config->global.tcp_proxy_server_enabled) {
|
||||
for (struct tcp_proxy_server_conn* sc = g_cc.inst->tcp_proxy_server.conns; sc; sc = sc->next)
|
||||
if (sc->peer_node_id == ce->peer_node_id) { flags |= 8; break; }
|
||||
if (!(flags & 8) && g_udp_ctx && g_udp_ctx->is_exit)
|
||||
for (struct udp_flow* f = g_udp_ctx->flows; f; f = f->next)
|
||||
if (f->client_node_id == ce->peer_node_id) { flags |= 8; break; }
|
||||
if (!(flags & 8) && g_icmp_ctx && g_icmp_ctx->is_exit)
|
||||
for (struct icmp_request* r = g_icmp_ctx->pending; r; r = r->next)
|
||||
if (r->client_node_id == ce->peer_node_id) { flags |= 8; break; }
|
||||
if (conn->links) {
|
||||
if (!conn->links->is_server) flags |= 4;
|
||||
else flags |= 8;
|
||||
}
|
||||
*p++ = flags;
|
||||
|
||||
@@ -213,21 +202,8 @@ static void collect_conn_metrics(uint64_t peer_node_id) {
|
||||
char peername[64]; get_node_name(peer_node_id, peername, sizeof(peername));
|
||||
if (!peername[0]) snprintf(peername, sizeof(peername), "%016llX", (unsigned long long)peer_node_id);
|
||||
|
||||
int is_client = 0, is_server = 0;
|
||||
if (g_cc.inst->tcp_proxy_client && peer_node_id == g_cc.inst->config->global.tcp_proxy_client_via_node_id)
|
||||
is_client = 1;
|
||||
if (g_cc.inst->config->global.tcp_proxy_server_enabled) {
|
||||
for (struct tcp_proxy_server_conn* sc = g_cc.inst->tcp_proxy_server.conns; sc; sc = sc->next)
|
||||
if (sc->peer_node_id == peer_node_id) { is_server = 1; break; }
|
||||
if (!is_server && g_udp_ctx && g_udp_ctx->is_exit)
|
||||
for (struct udp_flow* f = g_udp_ctx->flows; f; f = f->next)
|
||||
if (f->client_node_id == peer_node_id) { is_server = 1; break; }
|
||||
if (!is_server && g_icmp_ctx && g_icmp_ctx->is_exit)
|
||||
for (struct icmp_request* r = g_icmp_ctx->pending; r; r = r->next)
|
||||
if (r->client_node_id == peer_node_id) { is_server = 1; break; }
|
||||
}
|
||||
const char* role_str = is_client && is_server ? "proxy client+server" :
|
||||
is_client ? "proxy client" : is_server ? "proxy server" : "none";
|
||||
int is_server = conn->links ? conn->links->is_server : -1;
|
||||
const char* role_str = is_server < 0 ? "none" : (is_server ? "server" : "client");
|
||||
|
||||
/* Count links */
|
||||
int link_count = 0, links_up_count = 0;
|
||||
@@ -326,7 +302,7 @@ void chat_core_collect_conn_metrics_trampoline(void* arg) {
|
||||
|
||||
/* ── Live-снапшот для панели деталей участника ──
|
||||
* packet: [node_id:8][flags:1][own_tcp_active:2][link_count:1](link:24B)*[sock_count:1](sock:48B)*
|
||||
* flags: bit0=conn_present bit1=conn_up(links_up) bit2=conn_initialized
|
||||
* flags: bit0=conn_present bit1=conn_up(links_up) bit2=conn_initialized bit3=client bit4=server
|
||||
* link: [is_tcp:1][link_state:1][link_status:1][tcp_ready:1][family:1][addr_len:1][addr:16][port:2]
|
||||
* sock: [sock_id:4][port:2][link_count:4][ifname:38]
|
||||
* Собирается в worker-потоке — читает живые структуры UTUN_INSTANCE безопасно. */
|
||||
@@ -361,6 +337,10 @@ static void collect_member_detail(uint64_t node_id) {
|
||||
flags |= 1;
|
||||
if (conn->links_up) flags |= 2;
|
||||
if (conn->initialized) flags |= 4;
|
||||
if (conn->links) {
|
||||
if (!conn->links->is_server) flags |= 8;
|
||||
else flags |= 16;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t own_tcp_active = 0;
|
||||
|
||||
Reference in new issue
Block a user