new communities have no header encryption

This commit is contained in:
Logan007 2020-06-16 23:46:52 +05:45
parent 5972f5ddff
commit 2ce891748d
2 changed files with 14 additions and 2 deletions

11
sn.c
View File

@ -19,6 +19,7 @@
/* Supernode for n2n-2.x */
#include "n2n.h"
#include "header_encryption.h"
#ifdef WIN32
#include <signal.h>
@ -435,13 +436,14 @@ static int load_allowed_sn_community(n2n_sn_t *sss, char *path) {
*/
static int process_udp(n2n_sn_t * sss,
const struct sockaddr_in * sender_sock,
const uint8_t * udp_buf,
uint8_t * udp_buf,
size_t udp_size,
time_t now)
{
n2n_common_t cmn; /* common fields in the packet header */
size_t rem;
size_t idx;
int8_t he = HEADER_ENCRYPTION_UNKNOWN;
size_t msg_type;
uint8_t from_supernode;
macstr_t mac_buf;
@ -453,6 +455,10 @@ static int process_udp(n2n_sn_t * sss,
udp_size, intoa(ntohl(sender_sock->sin_addr.s_addr), buf, sizeof(buf)),
ntohs(sender_sock->sin_port));
he = packet_header_decrypt_if_required (udp_buf, udp_size, sss->communities);
if (he < 0)
return -1; /* something wrong during packet decryption */
/* Use decode_common() to determine the kind of packet then process it:
*
* REGISTER_SUPER adds an edge and generate a return REGISTER_SUPER_ACK
@ -622,6 +628,9 @@ static int process_udp(n2n_sn_t * sss,
if(comm) {
strncpy(comm->community, (char*)cmn.community, N2N_COMMUNITY_SIZE-1);
comm->community[N2N_COMMUNITY_SIZE-1] = '\0';
/* new communities introduced by REGISTERs could not have had encrypted header */
comm->header_encryption = HEADER_ENCRYPTION_NONE;
HASH_ADD_STR(sss->communities, community, comm);
traceEvent(TRACE_INFO, "New community: %s", comm->community);

View File

@ -394,7 +394,7 @@ static int process_udp(n2n_sn_t *sss,
he = packet_header_decrypt_if_required (udp_buf, udp_size, sss->communities);
if (he < 0)
return -1; /* something wrong with packet decryption */
return -1; /* something wrong during packet decryption */
/* Use decode_common() to determine the kind of packet then process it:
*
@ -577,6 +577,9 @@ static int process_udp(n2n_sn_t *sss,
{
strncpy(comm->community, (char *)cmn.community, N2N_COMMUNITY_SIZE - 1);
comm->community[N2N_COMMUNITY_SIZE - 1] = '\0';
/* new communities introduced by REGISTERs could not have had encrypted header */
comm->header_encryption = HEADER_ENCRYPTION_NONE;
HASH_ADD_STR(sss->communities, community, comm);
traceEvent(TRACE_INFO, "New community: %s", comm->community);