Browse Source

Merge pull request #346 from skyformat99/fix_edge_register_super

fix register supernode loop - Another way
pull/351/head
Luca Deri 4 years ago
committed by GitHub
parent
commit
2b59850b77
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      src/edge_utils.c

7
src/edge_utils.c

@ -735,8 +735,7 @@ static void check_join_multicast_group(n2n_edge_t *eee) {
/* ************************************** */ /* ************************************** */
/** Send a REGISTER_SUPER packet to the current supernode. */ /** Send a REGISTER_SUPER packet to the current supernode. */
static void send_register_super(n2n_edge_t * eee, static void send_register_super(n2n_edge_t *eee, const n2n_sock_t *supernode, int sn_idx) {
const n2n_sock_t * supernode) {
uint8_t pktbuf[N2N_PKT_BUF_SIZE] = {0}; uint8_t pktbuf[N2N_PKT_BUF_SIZE] = {0};
size_t idx; size_t idx;
/* ssize_t sent; */ /* ssize_t sent; */
@ -751,7 +750,7 @@ static void send_register_super(n2n_edge_t * eee,
cmn.flags = 0; cmn.flags = 0;
memcpy(cmn.community, eee->conf.community_name, N2N_COMMUNITY_SIZE); memcpy(cmn.community, eee->conf.community_name, N2N_COMMUNITY_SIZE);
for(idx=0; idx < N2N_COOKIE_SIZE; ++idx) for (idx = 0; (sn_idx==0) && (idx < N2N_COOKIE_SIZE); ++idx)
eee->last_cookie[idx] = n2n_rand() % 0xff; eee->last_cookie[idx] = n2n_rand() % 0xff;
memcpy(reg.cookie, eee->last_cookie, N2N_COOKIE_SIZE); memcpy(reg.cookie, eee->last_cookie, N2N_COOKIE_SIZE);
@ -938,7 +937,7 @@ static void update_supernode_reg(n2n_edge_t * eee, time_t nowTime) {
sn_idx+1, eee->conf.sn_num, sn_idx+1, eee->conf.sn_num,
supernode_ip(eee), (unsigned int)eee->sup_attempts); supernode_ip(eee), (unsigned int)eee->sup_attempts);
send_register_super(eee, &(eee->supernode)); send_register_super(eee, &(eee->supernode), sn_idx);
} }
} }

Loading…
Cancel
Save