X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fnet_setup.c;h=125715180b7ffa941f40798610e68c7256a629f9;hb=f71ab70351e8d5dfdc91c9808d142cf93d2a5d61;hp=d48c229990f45b7a205c2296de2a5ff670afd27e;hpb=953f5b4231bbbb8269bb0c55b96a1c8c4bb34a59;p=tinc diff --git a/src/net_setup.c b/src/net_setup.c index d48c2299..12571518 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -1,7 +1,7 @@ /* net_setup.c -- Setup. Copyright (C) 1998-2005 Ivo Timmermans, - 2000-2017 Guus Sliepen + 2000-2021 Guus Sliepen 2006 Scott Lamb 2010 Brandon Black @@ -215,14 +215,14 @@ static bool read_ecdsa_private_key(void) { logger(DEBUG_ALWAYS, LOG_ERR, "Error reading Ed25519 private key file `%s': %s", fname, strerror(errno)); if(errno == ENOENT) { - logger(DEBUG_ALWAYS, LOG_INFO, "Create an Ed25519 keypair with `tinc -n %s generate-ed25519-keys'.", netname ? : "."); + logger(DEBUG_ALWAYS, LOG_INFO, "Create an Ed25519 key pair with `tinc -n %s generate-ed25519-keys'.", netname ? netname : "."); } free(fname); return false; } -#if !defined(HAVE_MINGW) && !defined(HAVE_CYGWIN) +#ifndef HAVE_MINGW struct stat s; if(fstat(fileno(fp), &s)) { @@ -307,14 +307,14 @@ static bool read_rsa_private_key(void) { fname, strerror(errno)); if(errno == ENOENT) { - logger(DEBUG_ALWAYS, LOG_INFO, "Create an RSA keypair with `tinc -n %s generate-rsa-keys'.", netname ? : "."); + logger(DEBUG_ALWAYS, LOG_INFO, "Create an RSA key pair with `tinc -n %s generate-rsa-keys'.", netname ? netname : "."); } free(fname); return false; } -#if !defined(HAVE_MINGW) && !defined(HAVE_CYGWIN) +#ifndef HAVE_MINGW struct stat s; if(fstat(fileno(fp), &s)) { @@ -341,6 +341,7 @@ static bool read_rsa_private_key(void) { } #endif +#ifndef DISABLE_LEGACY static timeout_t keyexpire_timeout; static void keyexpire_handler(void *data) { @@ -349,6 +350,7 @@ static void keyexpire_handler(void *data) { keylifetime, rand() % 100000 }); } +#endif void regenerate_key(void) { logger(DEBUG_STATUS, LOG_INFO, "Expiring symmetric keys"); @@ -822,7 +824,7 @@ void device_disable(void) { Configure node_t myself and set up the local sockets (listen only) */ static bool setup_myself(void) { - char *name, *hostname, *cipher, *digest, *type; + char *name, *hostname, *type; char *address = NULL; bool port_specified = false; @@ -933,6 +935,8 @@ static bool setup_myself(void) { logger(DEBUG_ALWAYS, LOG_ERR, "UDPRcvBuf cannot be negative!"); return false; } + + udp_rcvbuf_warnings = true; } if(get_config_int(lookup_config(config_tree, "UDPSndBuf"), &udp_sndbuf)) { @@ -940,6 +944,8 @@ static bool setup_myself(void) { logger(DEBUG_ALWAYS, LOG_ERR, "UDPSndBuf cannot be negative!"); return false; } + + udp_sndbuf_warnings = true; } get_config_int(lookup_config(config_tree, "FWMark"), &fwmark); @@ -967,6 +973,8 @@ static bool setup_myself(void) { #ifndef DISABLE_LEGACY /* Generate packet encryption key */ + char *cipher; + if(!get_config_string(lookup_config(config_tree, "Cipher"), &cipher)) { cipher = xstrdup("aes-256-cbc"); } @@ -995,6 +1003,8 @@ static bool setup_myself(void) { return false; } + char *digest; + if(!get_config_string(lookup_config(config_tree, "Digest"), &digest)) { digest = xstrdup("sha256"); } @@ -1013,8 +1023,49 @@ static bool setup_myself(void) { /* Compression */ if(get_config_int(lookup_config(config_tree, "Compression"), &myself->incompression)) { - if(myself->incompression < 0 || myself->incompression > 11) { + switch(myself->incompression) { + case 12: +#ifdef HAVE_LZ4 + break; +#else + logger(DEBUG_ALWAYS, LOG_ERR, "Bogus compression level!"); + logger(DEBUG_ALWAYS, LOG_ERR, "LZ4 compression is unavailable on this node."); + return false; +#endif + + case 11: + case 10: +#ifdef HAVE_LZO + break; +#else + logger(DEBUG_ALWAYS, LOG_ERR, "Bogus compression level!"); + logger(DEBUG_ALWAYS, LOG_ERR, "LZO compression is unavailable on this node."); + return false; +#endif + + case 9: + case 8: + case 7: + case 6: + case 5: + case 4: + case 3: + case 2: + case 1: +#ifdef HAVE_ZLIB + break; +#else logger(DEBUG_ALWAYS, LOG_ERR, "Bogus compression level!"); + logger(DEBUG_ALWAYS, LOG_ERR, "ZLIB compression is unavailable on this node."); + return false; +#endif + + case 0: + break; + + default: + logger(DEBUG_ALWAYS, LOG_ERR, "Bogus compression level!"); + logger(DEBUG_ALWAYS, LOG_ERR, "Compression level %i is unrecognized by this node.", myself->incompression); return false; } } else { @@ -1047,10 +1098,14 @@ static bool setup_myself(void) { devops = raw_socket_devops; } else if(!strcasecmp(type, "multicast")) { devops = multicast_devops; - } else if(!strcasecmp(type, "fd")) { + } + +#ifdef HAVE_SYS_UN_H + else if(!strcasecmp(type, "fd")) { devops = fd_devops; } +#endif #ifdef ENABLE_UML else if(!strcasecmp(type, "uml")) { devops = uml_devops; @@ -1275,7 +1330,7 @@ void close_network_connections(void) { if(myself && myself->connection) { subnet_update(myself, NULL, false); - connection_del(myself->connection); + free_connection(myself->connection); } for(int i = 0; i < listen_sockets; i++) {