|
|
|
@ -16,6 +16,9 @@ |
|
|
|
#include "../transport_layer/etcp_connections.h" |
|
|
|
#include "../transport_layer/etcp_connections.h" |
|
|
|
#include "../transport_layer/stcp_link.h" |
|
|
|
#include "../transport_layer/stcp_link.h" |
|
|
|
#include "../transport_layer/pkt_normalizer.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> |
|
|
|
#include <string.h> |
|
|
|
|
|
|
|
|
|
|
|
static const char* nat_type_str(uint8_t t) { |
|
|
|
static const char* nat_type_str(uint8_t t) { |
|
|
|
@ -147,6 +150,18 @@ static void collect_conn_list(void) { |
|
|
|
uint8_t flags = 0; |
|
|
|
uint8_t flags = 0; |
|
|
|
if (conn->links_up) flags |= 1; |
|
|
|
if (conn->links_up) flags |= 1; |
|
|
|
if (conn->initialized) flags |= 2; |
|
|
|
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; } |
|
|
|
|
|
|
|
} |
|
|
|
*p++ = flags; |
|
|
|
*p++ = flags; |
|
|
|
|
|
|
|
|
|
|
|
uint8_t lc = 0; |
|
|
|
uint8_t lc = 0; |
|
|
|
@ -198,12 +213,29 @@ static void collect_conn_metrics(uint64_t peer_node_id) { |
|
|
|
char peername[64]; get_node_name(peer_node_id, peername, sizeof(peername)); |
|
|
|
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); |
|
|
|
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"; |
|
|
|
|
|
|
|
|
|
|
|
/* Count links */ |
|
|
|
/* Count links */ |
|
|
|
int link_count = 0, links_up_count = 0; |
|
|
|
int link_count = 0, links_up_count = 0; |
|
|
|
struct ETCP_LINK* tl = conn->links; while (tl) { if (tl->link_status) links_up_count++; link_count++; tl = tl->next; } |
|
|
|
struct ETCP_LINK* tl = conn->links; while (tl) { if (tl->link_status) links_up_count++; link_count++; tl = tl->next; } |
|
|
|
|
|
|
|
|
|
|
|
off += snprintf(buf + off, sizeof(buf) - off, |
|
|
|
off += snprintf(buf + off, sizeof(buf) - off, |
|
|
|
"=== PEER: %04llX\u2192%04llX [%s] ===\n" |
|
|
|
"=== PEER: %04llX\u2192%04llX [%s] ===\n" |
|
|
|
|
|
|
|
"Role: %s\n" |
|
|
|
"Status: %s Links: %d/%d Initialized: %s Session: 0x%X MTU: %d\n" |
|
|
|
"Status: %s Links: %d/%d Initialized: %s Session: 0x%X MTU: %d\n" |
|
|
|
"Reinit: %u Reset: %u Tx_state: %d Routing_exchange: %d\n" |
|
|
|
"Reinit: %u Reset: %u Tx_state: %d Routing_exchange: %d\n" |
|
|
|
"\n--- ETCP ---\n" |
|
|
|
"\n--- ETCP ---\n" |
|
|
|
@ -214,6 +246,7 @@ static void collect_conn_metrics(uint64_t peer_node_id) { |
|
|
|
"IDs: next_tx=%u last_rx=%u last_del=%u rx_ack_till=%u\n" |
|
|
|
"IDs: next_tx=%u last_rx=%u last_del=%u rx_ack_till=%u\n" |
|
|
|
"\n--- Queues ---\n", |
|
|
|
"\n--- Queues ---\n", |
|
|
|
(unsigned long long)(my_id & 0xFFFF), (unsigned long long)(peer_node_id & 0xFFFF), peername, |
|
|
|
(unsigned long long)(my_id & 0xFFFF), (unsigned long long)(peer_node_id & 0xFFFF), peername, |
|
|
|
|
|
|
|
role_str, |
|
|
|
conn->links_up ? "UP" : "DOWN", links_up_count, link_count, |
|
|
|
conn->links_up ? "UP" : "DOWN", links_up_count, link_count, |
|
|
|
conn->initialized ? "yes" : "no", conn->session_id, conn->mtu, |
|
|
|
conn->initialized ? "yes" : "no", conn->session_id, conn->mtu, |
|
|
|
conn->reinit_count, conn->reset_count, conn->tx_state, conn->routing_exchange_active, |
|
|
|
conn->reinit_count, conn->reset_count, conn->tx_state, conn->routing_exchange_active, |
|
|
|
|