|
|
@ -81,6 +81,8 @@ static void deinit_sn(n2n_sn_t * sss) |
|
|
|
|
|
|
|
HASH_ITER(hh, sss->communities, community, tmp) { |
|
|
|
clear_peer_list(&community->edges); |
|
|
|
if (NULL != community->header_encryption_ctx) |
|
|
|
free (community->header_encryption_ctx); |
|
|
|
HASH_DEL(sss->communities, community); |
|
|
|
free(community); |
|
|
|
} |
|
|
@ -390,6 +392,8 @@ static int load_allowed_sn_community(n2n_sn_t *sss, char *path) { |
|
|
|
|
|
|
|
HASH_ITER(hh, sss->communities, s, tmp) { |
|
|
|
HASH_DEL(sss->communities, s); |
|
|
|
if (NULL != s->header_encryption_ctx) |
|
|
|
free (s->header_encryption_ctx); |
|
|
|
free(s); |
|
|
|
} |
|
|
|
|
|
|
@ -413,7 +417,12 @@ static int load_allowed_sn_community(n2n_sn_t *sss, char *path) { |
|
|
|
if(s != NULL) { |
|
|
|
strncpy((char*)s->community, line, N2N_COMMUNITY_SIZE-1); |
|
|
|
s->community[N2N_COMMUNITY_SIZE-1] = '\0'; |
|
|
|
/* we do not know if header encryption is used in this community,
|
|
|
|
* first packet will show. just in case, setup the key. */ |
|
|
|
s->header_encryption = HEADER_ENCRYPTION_UNKNOWN; |
|
|
|
packet_header_setup_key (s->community, s->header_encryption_ctx); |
|
|
|
HASH_ADD_STR(sss->communities, community, s); |
|
|
|
|
|
|
|
num_communities++; |
|
|
|
traceEvent(TRACE_INFO, "Added allowed community '%s' [total: %u]", |
|
|
|
(char*)s->community, num_communities); |
|
|
@ -630,6 +639,7 @@ static int process_udp(n2n_sn_t * sss, |
|
|
|
comm->community[N2N_COMMUNITY_SIZE-1] = '\0'; |
|
|
|
/* new communities introduced by REGISTERs could not have had encrypted header */ |
|
|
|
comm->header_encryption = HEADER_ENCRYPTION_NONE; |
|
|
|
comm->header_encryption_ctx = NULL; |
|
|
|
|
|
|
|
HASH_ADD_STR(sss->communities, community, comm); |
|
|
|
|
|
|
@ -1122,6 +1132,9 @@ static int run_loop(n2n_sn_t * sss) { |
|
|
|
|
|
|
|
if((comm->edges == NULL) && (!sss->lock_communities)) { |
|
|
|
traceEvent(TRACE_INFO, "Purging idle community %s", comm->community); |
|
|
|
if (NULL != comm->header_encryption_ctx) |
|
|
|
/* this should not happen as no 'locked' and thus only communities w/o encrypted header here */ |
|
|
|
free (comm->header_encryption_ctx); |
|
|
|
HASH_DEL(sss->communities, comm); |
|
|
|
free(comm); |
|
|
|
} |
|
|
|