/*
net_setup.c -- Setup.
Copyright (C) 1998-2005 Ivo Timmermans,
- 2000-2017 Guus Sliepen <guus@tinc-vpn.org>
+ 2000-2021 Guus Sliepen <guus@tinc-vpn.org>
2006 Scott Lamb <slamb@slamb.org>
2010 Brandon Black <blblack@gmail.com>
init_configuration(&config_tree);
- if(!read_host_config(config_tree, n->name)) {
+ if(!read_host_config(config_tree, n->name, true)) {
goto exit;
}
if(!c->config_tree) {
init_configuration(&c->config_tree);
- if(!read_host_config(c->config_tree, c->name)) {
+ if(!read_host_config(c->config_tree, c->name, true)) {
return false;
}
}
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)) {
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)) {
}
#endif
+#ifndef DISABLE_LEGACY
static timeout_t keyexpire_timeout;
static void keyexpire_handler(void *data) {
keylifetime, rand() % 100000
});
}
+#endif
void regenerate_key(void) {
logger(DEBUG_STATUS, LOG_INFO, "Expiring symmetric keys");
splay_tree_t *config_tree;
init_configuration(&config_tree);
read_config_options(config_tree, ent->d_name);
- read_host_config(config_tree, ent->d_name);
+ read_host_config(config_tree, ent->d_name, true);
if(!n) {
n = new_node();
free(fmode);
}
- choice = true;
+ choice = !(myself->options & OPTION_TCPONLY);
get_config_bool(lookup_config(config_tree, "PMTUDiscovery"), &choice);
if(choice) {
subnet_add(NULL, s);
}
-#if !defined(IPPROTO_IP) || !defined(IP_TOS)
+#if !defined(IP_TOS)
if(priorityinheritance) {
logger(DEBUG_ALWAYS, LOG_WARNING, "%s not supported on this platform for IPv4 connections", "PriorityInheritance");
#endif
-#if !defined(IPPROTO_IPV6) || !defined(IPV6_TCLASS)
+#if !defined(IPV6_TCLASS)
if(priorityinheritance) {
logger(DEBUG_ALWAYS, LOG_WARNING, "%s not supported on this platform for IPv6 connections", "PriorityInheritance");
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);
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;
myself->connection = new_connection();
myself->name = name;
myself->connection->name = xstrdup(name);
- read_host_config(config_tree, name);
+ read_host_config(config_tree, name, true);
if(!get_config_string(lookup_config(config_tree, "Port"), &myport)) {
myport = xstrdup("655");
free(myport);
memcpy(&sa, ai->ai_addr, ai->ai_addrlen);
+ freeaddrinfo(ai);
sockaddr2str(&sa, NULL, &myport);
}
}
}
+ get_config_int(lookup_config(config_tree, "FWMark"), &fwmark);
+#ifndef SO_MARK
+
+ if(fwmark) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "FWMark not supported on this platform!");
+ return false;
+ }
+
+#endif
+
int replaywin_int;
if(get_config_int(lookup_config(config_tree, "ReplayWindow"), &replaywin_int)) {
#ifndef DISABLE_LEGACY
/* Generate packet encryption key */
+ char *cipher;
+
if(!get_config_string(lookup_config(config_tree, "Cipher"), &cipher)) {
cipher = xstrdup("aes-256-cbc");
}
myself->incipher = NULL;
} else if(!(myself->incipher = cipher_open_by_name(cipher))) {
logger(DEBUG_ALWAYS, LOG_ERR, "Unrecognized cipher type!");
+ free(cipher);
return false;
}
return false;
}
+ char *digest;
+
if(!get_config_string(lookup_config(config_tree, "Digest"), &digest)) {
digest = xstrdup("sha256");
}
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;
}
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;