X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fnet_setup.c;h=7b4c741f0fe55ce1bd5daefcf39e2d990fa8867e;hb=ddabda536acf33abbfef28bc199d2b3ae7219b46;hp=455f66c68d78ee55ddded5e5d9f1b59b3a9aedba;hpb=7ee885a1f6776be85e5397eda04f75d98ff0b631;p=tinc diff --git a/src/net_setup.c b/src/net_setup.c index 455f66c6..7b4c741f 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -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 keypair 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 keypair 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"); @@ -687,15 +689,8 @@ bool setup_myself_reloadable(void) { keylifetime = 3600; } - config_t *cfg = lookup_config(config_tree, "AutoConnect"); - - if(cfg) { - if(!get_config_bool(cfg, &autoconnect)) { - // Some backwards compatibility with when this option was an int - int val = 0; - get_config_int(cfg, &val); - autoconnect = val; - } + if(!get_config_bool(lookup_config(config_tree, "AutoConnect"), &autoconnect)) { + autoconnect = true; } get_config_bool(lookup_config(config_tree, "DisableBuggyPeers"), &disablebuggypeers); @@ -829,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; @@ -974,6 +969,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"); } @@ -982,6 +979,7 @@ static bool setup_myself(void) { myself->incipher = NULL; } else if(!(myself->incipher = cipher_open_by_name(cipher))) { logger(DEBUG_ALWAYS, LOG_ERR, "Unrecognized cipher type!"); + free(cipher); return false; } @@ -1001,6 +999,8 @@ static bool setup_myself(void) { return false; } + char *digest; + if(!get_config_string(lookup_config(config_tree, "Digest"), &digest)) { digest = xstrdup("sha256"); } @@ -1009,6 +1009,7 @@ static bool setup_myself(void) { myself->indigest = NULL; } else if(!(myself->indigest = digest_open_by_name(digest, maclength))) { logger(DEBUG_ALWAYS, LOG_ERR, "Unrecognized digest type!"); + free(digest); return false; }