|
@ -839,7 +839,6 @@ void send_query_peer (n2n_edge_t * eee, |
|
|
// skip a random number of supernodes between top and remaining
|
|
|
// skip a random number of supernodes between top and remaining
|
|
|
n_o_skip_sn = HASH_COUNT(eee->conf.supernodes) - n_o_pings; |
|
|
n_o_skip_sn = HASH_COUNT(eee->conf.supernodes) - n_o_pings; |
|
|
n_o_skip_sn = (n_o_skip_sn < 0) ? 0 : n2n_rand_sqr(n_o_skip_sn); |
|
|
n_o_skip_sn = (n_o_skip_sn < 0) ? 0 : n2n_rand_sqr(n_o_skip_sn); |
|
|
|
|
|
|
|
|
HASH_ITER(hh, eee->conf.supernodes, peer, tmp) { |
|
|
HASH_ITER(hh, eee->conf.supernodes, peer, tmp) { |
|
|
if(n_o_top_sn) { |
|
|
if(n_o_top_sn) { |
|
|
n_o_top_sn--; |
|
|
n_o_top_sn--; |
|
@ -1405,6 +1404,7 @@ static void readFromMgmtSocket (n2n_edge_t *eee, int *keep_running) { |
|
|
time_t now; |
|
|
time_t now; |
|
|
struct peer_info *peer, *tmpPeer; |
|
|
struct peer_info *peer, *tmpPeer; |
|
|
macstr_t mac_buf; |
|
|
macstr_t mac_buf; |
|
|
|
|
|
char time_buf[10]; /* 9 digits + 1 terminating zero */ |
|
|
/* dec_ip_bit_str_t ip_bit_str = {'\0'}; */ |
|
|
/* dec_ip_bit_str_t ip_bit_str = {'\0'}; */ |
|
|
/* dec_ip_str_t ip_str = {'\0'}; */ |
|
|
/* dec_ip_str_t ip_str = {'\0'}; */ |
|
|
in_addr_t net; |
|
|
in_addr_t net; |
|
@ -1485,47 +1485,53 @@ 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), |
|
|
"community: %s\n", |
|
|
"COMMUNITY '%s'\n\n", |
|
|
eee->conf.community_name); |
|
|
eee->conf.community_name); |
|
|
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), |
|
|
" id tun_tap MAC edge hint last_seen\n"); |
|
|
" ### | TAP | MAC | EDGE | HINT | LAST SEEN\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), |
|
|
"-----------------------------------------------------------------------------------------------\n"); |
|
|
"================================================================================================\n"); |
|
|
|
|
|
|
|
|
|
|
|
// dump nodes with forwarding through supernodes
|
|
|
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), |
|
|
"supernode_forward:\n"); |
|
|
"SUPERNODE FORWARD\n"); |
|
|
num = 0; |
|
|
num = 0; |
|
|
HASH_ITER(hh, eee->pending_peers, peer, tmpPeer) { |
|
|
HASH_ITER(hh, eee->pending_peers, peer, tmpPeer) { |
|
|
++num_pending_peers; |
|
|
++num_pending_peers; |
|
|
if(peer->dev_addr.net_addr == 0) continue; |
|
|
|
|
|
net = htonl(peer->dev_addr.net_addr); |
|
|
net = htonl(peer->dev_addr.net_addr); |
|
|
|
|
|
sprintf (time_buf, "%9u", now - peer->last_seen); |
|
|
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), |
|
|
" %-4u %-15s %-17s %-21s %-15s %lu\n", |
|
|
"%4u | %-15s | %-17s | %-21s | %-15s | %9s\n", |
|
|
++num, inet_ntoa(*(struct in_addr *) &net), |
|
|
++num, |
|
|
|
|
|
(peer->dev_addr.net_addr == 0) ? "" : inet_ntoa(*(struct in_addr *) &net), |
|
|
macaddr_str(mac_buf, peer->mac_addr), |
|
|
macaddr_str(mac_buf, peer->mac_addr), |
|
|
sock_to_cstr(sockbuf, &(peer->sock)), |
|
|
sock_to_cstr(sockbuf, &(peer->sock)), |
|
|
peer->dev_desc, |
|
|
peer->dev_desc, |
|
|
now - peer->last_seen); |
|
|
(peer->last_seen) ? time_buf : ""); |
|
|
|
|
|
|
|
|
sendto(eee->udp_mgmt_sock, udp_buf, msg_len, 0/*flags*/, |
|
|
sendto(eee->udp_mgmt_sock, udp_buf, msg_len, 0/*flags*/, |
|
|
(struct sockaddr *) &sender_sock, sizeof(struct sockaddr_in)); |
|
|
(struct sockaddr *) &sender_sock, sizeof(struct sockaddr_in)); |
|
|
msg_len = 0; |
|
|
msg_len = 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// dump peer-to-peer nodes
|
|
|
|
|
|
msg_len += snprintf((char *) (udp_buf + msg_len), (N2N_PKT_BUF_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), |
|
|
"peer_to_peer:\n"); |
|
|
"PEER TO PEER\n"); |
|
|
num = 0; |
|
|
num = 0; |
|
|
HASH_ITER(hh, eee->known_peers, peer, tmpPeer) { |
|
|
HASH_ITER(hh, eee->known_peers, peer, tmpPeer) { |
|
|
++num_known_peers; |
|
|
++num_known_peers; |
|
|
if(peer->dev_addr.net_addr == 0) continue; |
|
|
|
|
|
net = htonl(peer->dev_addr.net_addr); |
|
|
net = htonl(peer->dev_addr.net_addr); |
|
|
|
|
|
sprintf (time_buf, "%9u", now - peer->last_seen); |
|
|
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), |
|
|
" %-4u %-15s %-17s %-21s %-15s %lu\n", |
|
|
"%4u | %-15s | %-17s | %-21s | %-15s | %9s\n", |
|
|
++num, inet_ntoa(*(struct in_addr *) &net), |
|
|
++num, |
|
|
|
|
|
(peer->dev_addr.net_addr == 0) ? "" : inet_ntoa(*(struct in_addr *) &net), |
|
|
macaddr_str(mac_buf, peer->mac_addr), |
|
|
macaddr_str(mac_buf, peer->mac_addr), |
|
|
sock_to_cstr(sockbuf, &(peer->sock)), |
|
|
sock_to_cstr(sockbuf, &(peer->sock)), |
|
|
peer->dev_desc, |
|
|
peer->dev_desc, |
|
|
now - peer->last_seen); |
|
|
(peer->last_seen) ? time_buf : ""); |
|
|
|
|
|
|
|
|
sendto(eee->udp_mgmt_sock, udp_buf, msg_len, 0/*flags*/, |
|
|
sendto(eee->udp_mgmt_sock, udp_buf, msg_len, 0/*flags*/, |
|
|
(struct sockaddr *) &sender_sock, sizeof(struct sockaddr_in)); |
|
|
(struct sockaddr *) &sender_sock, sizeof(struct sockaddr_in)); |
|
@ -1534,30 +1540,31 @@ static void readFromMgmtSocket (n2n_edge_t *eee, int *keep_running) { |
|
|
|
|
|
|
|
|
// dump supernodes
|
|
|
// dump supernodes
|
|
|
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), |
|
|
"-----------------------------------------------------------------------------------------------\n"); |
|
|
"------------------------------------------------------------------------------------------------\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), |
|
|
"supernodes:\n"); |
|
|
"SUPERNODES\n"); |
|
|
|
|
|
|
|
|
HASH_ITER(hh, eee->conf.supernodes, peer, tmpPeer) { |
|
|
HASH_ITER(hh, eee->conf.supernodes, peer, tmpPeer) { |
|
|
net = htonl(peer->dev_addr.net_addr); |
|
|
net = htonl(peer->dev_addr.net_addr); |
|
|
|
|
|
sprintf (time_buf, "%9u", now - peer->last_seen); |
|
|
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), |
|
|
" %-4u %-15s %-17s %-21s %-14s %lu\n", |
|
|
"%4u | %-15s | %-17s | %-21s | %-15s | %9s\n", |
|
|
++num, |
|
|
++num, |
|
|
(peer->purgeable == SN_UNPURGEABLE) ? "-l" : "", |
|
|
(peer->purgeable == SN_UNPURGEABLE) ? "-l" : "", |
|
|
macaddr_str(mac_buf, peer->mac_addr), |
|
|
is_null_mac(peer->mac_addr) ? "" : macaddr_str(mac_buf, peer->mac_addr), |
|
|
sock_to_cstr(sockbuf, &(peer->sock)), |
|
|
sock_to_cstr(sockbuf, &(peer->sock)), |
|
|
sn_selection_criterion_str(sel_buf, peer), |
|
|
sn_selection_criterion_str(sel_buf, peer), |
|
|
now - peer->last_seen); |
|
|
(peer->last_seen) ? time_buf : ""); |
|
|
|
|
|
|
|
|
sendto(eee->udp_mgmt_sock, udp_buf, msg_len, 0, |
|
|
sendto(eee->udp_mgmt_sock, udp_buf, msg_len, 0, |
|
|
(struct sockaddr *) &sender_sock, sizeof(struct sockaddr_in)); |
|
|
(struct sockaddr *) &sender_sock, sizeof(struct sockaddr_in)); |
|
|
msg_len = 0; |
|
|
msg_len = 0; |
|
|
} |
|
|
} |
|
|
// end dump supernodes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// further stats
|
|
|
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), |
|
|
"-----------------------------------------------------------------------------------------------\n"); |
|
|
"================================================================================================\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 | ", |
|
|
"uptime %lu | ", |
|
@ -2199,7 +2206,7 @@ void readFromIPSocket (n2n_edge_t * eee, int in_sock) { |
|
|
sprintf (sn->ip_addr, "%s:%u", sn->ip_addr, (uint16_t)(payload->sock.port)); |
|
|
sprintf (sn->ip_addr, "%s:%u", sn->ip_addr, (uint16_t)(payload->sock.port)); |
|
|
} |
|
|
} |
|
|
sn_selection_criterion_default(&(sn->selection_criterion)); |
|
|
sn_selection_criterion_default(&(sn->selection_criterion)); |
|
|
sn->last_seen = now - LAST_SEEN_SN_NEW; |
|
|
sn->last_seen = 0; /* as opposed to payload handling in supernode */ |
|
|
traceEvent(TRACE_NORMAL, "Supernode '%s' added to the list of supernodes.", sn->ip_addr); |
|
|
traceEvent(TRACE_NORMAL, "Supernode '%s' added to the list of supernodes.", sn->ip_addr); |
|
|
} |
|
|
} |
|
|
// shift to next payload entry
|
|
|
// shift to next payload entry
|
|
|