Browse Source

When multiple supernodes are specified, the edge registers to all of them

pull/53/head
Luca Deri 6 years ago
parent
commit
1c7b14995b
  1. 6
      edge.c
  2. 15
      edge_utils.c

6
edge.c

@ -175,7 +175,7 @@ static void help() {
/* *************************************************** */
static int setOption(int optkey, char *optargument, edge_conf_t *ec, n2n_edge_t *eee) {
//traceEvent(TRACE_NORMAL, "Option %c = %s", optkey, optargument ? optargument : "");
/* traceEvent(TRACE_NORMAL, "Option %c = %s", optkey, optargument ? optargument : ""); */
switch(optkey) {
case'K':
@ -272,10 +272,10 @@ static int setOption(int optkey, char *optargument, edge_conf_t *ec, n2n_edge_t
{
if(eee->sn_num < N2N_EDGE_NUM_SUPERNODES) {
strncpy((eee->sn_ip_array[eee->sn_num]), optargument, N2N_EDGE_SN_HOST_SIZE);
traceEvent(TRACE_DEBUG, "Adding supernode[%u] = %s\n", (unsigned int)eee->sn_num, (eee->sn_ip_array[eee->sn_num]));
traceEvent(TRACE_NORMAL, "Adding supernode[%u] = %s\n", (unsigned int)eee->sn_num, (eee->sn_ip_array[eee->sn_num]));
++eee->sn_num;
} else {
fprintf(stderr, "Too many supernodes!\n");
traceEvent(TRACE_WARNING, "Too many supernodes!\n");
exit(1);
}
break;

15
edge_utils.c

@ -574,6 +574,8 @@ static void send_register_ack(n2n_edge_t * eee,
* This is frequently called by the main loop.
*/
void update_supernode_reg(n2n_edge_t * eee, time_t nowTime) {
u_int sn_idx;
if(eee->sn_wait && (nowTime > (eee->last_register_req + (eee->register_lifetime/10)))) {
/* fall through */
traceEvent(TRACE_DEBUG, "update_supernode_reg: doing fast retry.");
@ -597,13 +599,16 @@ void update_supernode_reg(n2n_edge_t * eee, time_t nowTime) {
else
--(eee->sup_attempts);
if(eee->re_resolve_supernode_ip || (eee->sn_num > 1))
supernode2addr(&(eee->supernode), eee->sn_ip_array[eee->sn_idx]);
for(sn_idx=0; sn_idx<eee->sn_num; sn_idx++) {
supernode2addr(&(eee->supernode), eee->sn_ip_array[sn_idx]);
traceEvent(TRACE_NORMAL, "Registering with supernode [id: %u/%u][%s][attempts left %u]",
sn_idx+1, eee->sn_num,
supernode_ip(eee), (unsigned int)eee->sup_attempts);
traceEvent(TRACE_DEBUG, "Registering with supernode (%s) (attempts left %u)",
supernode_ip(eee), (unsigned int)eee->sup_attempts);
send_register_super(eee, &(eee->supernode));
}
send_register_super(eee, &(eee->supernode));
register_with_local_peers(eee);
eee->sn_wait=1;

Loading…
Cancel
Save