Browse Source

Add option to disable p2p

pull/169/head
emanuele-f 5 years ago
parent
commit
eea0c9b46b
  1. 9
      edge.c
  2. 13
      edge_utils.c
  3. 1
      n2n.h

9
edge.c

@ -167,6 +167,7 @@ static void help() {
printf("-A | Use AES CBC for encryption (default=use twofish).\n");
#endif
printf("-E | Accept multicast MAC addresses (default=drop).\n");
printf("-S | Do not connect P2P. Always use the supernode.\n");
printf("-v | Make more verbose. Repeat as required.\n");
printf("-t <port> | Management UDP Port (for multiple edges on a machine).\n");
@ -321,6 +322,12 @@ static int setOption(int optkey, char *optargument, n2n_priv_config_t *ec, n2n_e
break;
}
case 'S':
{
conf->allow_p2p = 0;
break;
}
case 'h': /* help */
{
help();
@ -361,7 +368,7 @@ static int loadFromCLI(int argc, char *argv[], n2n_edge_conf_t *conf, n2n_priv_c
u_char c;
while((c = getopt_long(argc, argv,
"K:k:a:bc:Eu:g:m:M:s:d:l:p:fvhrt:i:"
"K:k:a:bc:Eu:g:m:M:s:d:l:p:fvhrt:i:S"
#ifdef N2N_HAVE_AES
"A"
#endif

13
edge_utils.c

@ -332,7 +332,7 @@ static void supernode2addr(n2n_sock_t * sn, const n2n_sn_name_t addrIn) {
*/
static void register_with_local_peers(n2n_edge_t * eee) {
#ifndef SKIP_MULTICAST_PEERS_DISCOVERY
if(eee->multicast_joined) {
if(eee->multicast_joined && eee->conf.allow_p2p) {
/* send registration to the local multicast group */
traceEvent(TRACE_DEBUG, "Registering with multicast group %s:%u",
N2N_MULTICAST_GROUP, N2N_MULTICAST_PORT);
@ -677,6 +677,11 @@ static void send_register(n2n_edge_t * eee,
n2n_REGISTER_t reg;
n2n_sock_str_t sockbuf;
if(!eee->conf.allow_p2p) {
traceEvent(TRACE_DEBUG, "Skipping register as P2P is disabled");
return;
}
memset(&cmn, 0, sizeof(cmn));
memset(&reg, 0, sizeof(reg));
cmn.ttl=N2N_DEFAULT_TTL;
@ -717,6 +722,11 @@ static void send_register_ack(n2n_edge_t * eee,
n2n_REGISTER_ACK_t ack;
n2n_sock_str_t sockbuf;
if(!eee->conf.allow_p2p) {
traceEvent(TRACE_DEBUG, "Skipping register ACK as P2P is disabled");
return;
}
memset(&cmn, 0, sizeof(cmn));
memset(&ack, 0, sizeof(reg));
cmn.ttl=N2N_DEFAULT_TTL;
@ -1839,6 +1849,7 @@ void edge_init_conf_defaults(n2n_edge_conf_t *conf) {
conf->mgmt_port = N2N_EDGE_MGMT_PORT; /* 5644 by default */
conf->transop_id = N2N_TRANSFORM_ID_NULL;
conf->drop_multicast = 1;
conf->allow_p2p = 1;
conf->register_interval = REGISTER_SUPER_INTERVAL_DFL;
if(getenv("N2N_KEY")) {

1
n2n.h

@ -209,6 +209,7 @@ typedef struct n2n_edge_conf {
uint8_t dyn_ip_mode; /**< Interface IP address is dynamically allocated, eg. DHCP. */
uint8_t allow_routing; /**< Accept packet no to interface address. */
uint8_t drop_multicast; /**< Multicast ethernet addresses. */
uint8_t allow_p2p; /**< Allow P2P connection */
uint8_t sn_num; /**< Number of supernode addresses defined. */
char *encrypt_key;
int register_interval; /**< Interval for supernode registration, also used for UDP NAT hole punching. */

Loading…
Cancel
Save