Browse Source

new communities have no header encryption

pull/265/head
Logan007 4 years ago
parent
commit
2ce891748d
  1. 11
      sn.c
  2. 5
      sn_utils.c

11
sn.c

@ -19,6 +19,7 @@
/* Supernode for n2n-2.x */ /* Supernode for n2n-2.x */
#include "n2n.h" #include "n2n.h"
#include "header_encryption.h"
#ifdef WIN32 #ifdef WIN32
#include <signal.h> #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, static int process_udp(n2n_sn_t * sss,
const struct sockaddr_in * sender_sock, const struct sockaddr_in * sender_sock,
const uint8_t * udp_buf, uint8_t * udp_buf,
size_t udp_size, size_t udp_size,
time_t now) time_t now)
{ {
n2n_common_t cmn; /* common fields in the packet header */ n2n_common_t cmn; /* common fields in the packet header */
size_t rem; size_t rem;
size_t idx; size_t idx;
int8_t he = HEADER_ENCRYPTION_UNKNOWN;
size_t msg_type; size_t msg_type;
uint8_t from_supernode; uint8_t from_supernode;
macstr_t mac_buf; 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)), udp_size, intoa(ntohl(sender_sock->sin_addr.s_addr), buf, sizeof(buf)),
ntohs(sender_sock->sin_port)); 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: /* Use decode_common() to determine the kind of packet then process it:
* *
* REGISTER_SUPER adds an edge and generate a return REGISTER_SUPER_ACK * 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) { if(comm) {
strncpy(comm->community, (char*)cmn.community, N2N_COMMUNITY_SIZE-1); strncpy(comm->community, (char*)cmn.community, N2N_COMMUNITY_SIZE-1);
comm->community[N2N_COMMUNITY_SIZE-1] = '\0'; 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); HASH_ADD_STR(sss->communities, community, comm);
traceEvent(TRACE_INFO, "New community: %s", comm->community); traceEvent(TRACE_INFO, "New community: %s", comm->community);

5
sn_utils.c

@ -394,7 +394,7 @@ static int process_udp(n2n_sn_t *sss,
he = packet_header_decrypt_if_required (udp_buf, udp_size, sss->communities); he = packet_header_decrypt_if_required (udp_buf, udp_size, sss->communities);
if (he < 0) 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: /* 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); strncpy(comm->community, (char *)cmn.community, N2N_COMMUNITY_SIZE - 1);
comm->community[N2N_COMMUNITY_SIZE - 1] = '\0'; 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); HASH_ADD_STR(sss->communities, community, comm);
traceEvent(TRACE_INFO, "New community: %s", comm->community); traceEvent(TRACE_INFO, "New community: %s", comm->community);

Loading…
Cancel
Save