Browse Source

Merge pull request #363 from Logan007/edgMgmtPrt

extended edge's management port output
pull/365/head
Luca Deri 4 years ago
committed by GitHub
parent
commit
ed5b793379
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 49
      src/edge_utils.c

49
src/edge_utils.c

@ -201,7 +201,6 @@ n2n_edge_t* edge_init(const n2n_edge_conf_t *conf, int *rv) {
traceEvent(TRACE_ERROR, "LZO compression error"); traceEvent(TRACE_ERROR, "LZO compression error");
goto edge_init_error; goto edge_init_error;
} }
#ifdef N2N_HAVE_ZSTD #ifdef N2N_HAVE_ZSTD
// zstd does not require initialization. if it were required, this would be a good place // zstd does not require initialization. if it were required, this would be a good place
#endif #endif
@ -1141,6 +1140,11 @@ static void readFromMgmtSocket(n2n_edge_t * eee, int * keep_running) {
socklen_t i; socklen_t i;
size_t msg_len; size_t msg_len;
time_t now; time_t now;
n2n_sock_str_t sockbuf;
macstr_t mac_buf;
struct peer_info *peer, *tmpPeer;
dec_ip_bit_str_t ip_bit_str = {'\0'};
uint32_t num = 0;
now = time(NULL); now = time(NULL);
i = sizeof(sender_sock); i = sizeof(sender_sock);
@ -1229,7 +1233,48 @@ static void readFromMgmtSocket(n2n_edge_t * eee, int * keep_running) {
msg_len=0; msg_len=0;
msg_len += snprintf((char *)(udp_buf+msg_len), (N2N_PKT_BUF_SIZE-msg_len), msg_len += snprintf((char *)(udp_buf+msg_len), (N2N_PKT_BUF_SIZE-msg_len),
"Statistics for edge\n"); "STATISTICS FOR EDGE\n");
msg_len += snprintf(udp_buf + msg_len, N2N_SN_PKTBUF_SIZE - msg_len,
"community: %s\n", eee->conf.community_name);
msg_len += snprintf(udp_buf + msg_len, N2N_SN_PKTBUF_SIZE - msg_len,
"\tid tun_tap MAC edge last_seen\n");
msg_len += snprintf(udp_buf + msg_len, N2N_SN_PKTBUF_SIZE - msg_len,
"--- pending peers -------------------------------------------------------------------\n");
sendto(eee->udp_mgmt_sock, udp_buf, msg_len, 0/*flags*/,
(struct sockaddr *)&sender_sock, sizeof(struct sockaddr_in));
msg_len = 0;
HASH_ITER(hh, eee->pending_peers, peer, tmpPeer) {
msg_len += snprintf(udp_buf + msg_len, N2N_SN_PKTBUF_SIZE - msg_len,
"\t%-4u %-18s %-17s %-21s %lu\n",
++num, ip_subnet_to_str(ip_bit_str, &peer->dev_addr),
macaddr_str(mac_buf, peer->mac_addr),
sock_to_cstr(sockbuf, &(peer->sock)), now - peer->last_seen);
sendto(eee->udp_mgmt_sock, udp_buf, msg_len, 0/*flags*/,
(struct sockaddr *)&sender_sock, sizeof(struct sockaddr_in));
msg_len = 0;
}
msg_len += snprintf(udp_buf + msg_len, N2N_SN_PKTBUF_SIZE - msg_len,
"--- known peers ---------------------------------------------------------------------\n");
HASH_ITER(hh, eee->known_peers, peer, tmpPeer) {
msg_len += snprintf(udp_buf + msg_len, N2N_SN_PKTBUF_SIZE - msg_len,
"\t%-4u %-18s %-17s %-21s %lu\n",
++num, ip_subnet_to_str(ip_bit_str, &peer->dev_addr),
macaddr_str(mac_buf, peer->mac_addr),
sock_to_cstr(sockbuf, &(peer->sock)), now - peer->last_seen);
sendto(eee->udp_mgmt_sock, udp_buf, msg_len, 0/*flags*/,
(struct sockaddr *)&sender_sock, sizeof(struct sockaddr_in));
msg_len = 0;
}
msg_len += snprintf(udp_buf + msg_len, N2N_SN_PKTBUF_SIZE - msg_len,
"-------------------------------------------------------------------------------------\n");
msg_len += snprintf((char *)(udp_buf+msg_len), (N2N_PKT_BUF_SIZE-msg_len), msg_len += snprintf((char *)(udp_buf+msg_len), (N2N_PKT_BUF_SIZE-msg_len),
"uptime %lu\n", "uptime %lu\n",

Loading…
Cancel
Save