+ freeaddrinfo(ai);
+ return true;
+}
+
+void device_enable(void) {
+ if(devops.enable) {
+ devops.enable();
+ }
+
+ /* Run tinc-up script to further initialize the tap interface */
+
+ environment_t env;
+ environment_init(&env);
+ execute_script("tinc-up", &env);
+ environment_exit(&env);
+}
+
+void device_disable(void) {
+ environment_t env;
+ environment_init(&env);
+ execute_script("tinc-down", &env);
+ environment_exit(&env);
+
+ if(devops.disable) {
+ devops.disable();
+ }
+}
+
+/*
+ Configure node_t myself and set up the local sockets (listen only)
+*/
+static bool setup_myself(void) {
+ char *name, *hostname, *type;
+ char *address = NULL;
+ bool port_specified = false;
+
+ if(!(name = get_name())) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "Name for tinc daemon required!");
+ return false;
+ }
+
+ myname = xstrdup(name);
+ myself = new_node();
+ myself->connection = new_connection();
+ myself->name = name;
+ myself->connection->name = xstrdup(name);
+ read_host_config(&config_tree, name, true);
+
+ if(!get_config_string(lookup_config(&config_tree, "Port"), &myport)) {
+ myport = xstrdup("655");
+ } else {
+ port_specified = true;
+ }
+
+ myself->connection->options = 0;
+ myself->connection->protocol_major = PROT_MAJOR;
+ myself->connection->protocol_minor = PROT_MINOR;
+
+ myself->options |= PROT_MINOR << 24;
+
+#ifdef DISABLE_LEGACY
+ myself->connection->ecdsa = read_ecdsa_private_key(&config_tree, NULL);
+ experimental = myself->connection->ecdsa != NULL;
+
+ if(!experimental) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "No private key available, cannot start tinc!");
+ return false;
+ }
+
+#else
+
+ if(!get_config_bool(lookup_config(&config_tree, "ExperimentalProtocol"), &experimental)) {
+ myself->connection->ecdsa = read_ecdsa_private_key(&config_tree, NULL);
+ experimental = myself->connection->ecdsa != NULL;
+
+ if(!experimental) {
+ logger(DEBUG_ALWAYS, LOG_WARNING, "Support for SPTPS disabled.");
+ }
+ } else {
+ if(experimental) {
+ myself->connection->ecdsa = read_ecdsa_private_key(&config_tree, NULL);
+
+ if(!myself->connection->ecdsa) {
+ return false;
+ }
+ }
+ }
+
+ myself->connection->rsa = read_rsa_private_key(&config_tree, NULL);
+
+ if(!myself->connection->rsa) {
+ if(experimental) {
+ logger(DEBUG_ALWAYS, LOG_WARNING, "Support for legacy protocol disabled.");
+ } else {
+ logger(DEBUG_ALWAYS, LOG_ERR, "No private keys available, cannot start tinc!");