char *proxyuser;
char *proxypass;
proxytype_t proxytype;
+int autoconnect;
char *scriptinterpreter;
char *scriptextension;
timeout_set(&keyexpire_event, keyexpire_handler, NULL);
}
- event_add(&keyexpire_event, &(struct timeval){keylifetime, 0});
+ event_add(&keyexpire_event, &(struct timeval){keylifetime, rand() % 100000});
}
/*
closedir(dir);
}
+void load_all_nodes(void) {
+ DIR *dir;
+ struct dirent *ent;
+ char *dname;
+
+ xasprintf(&dname, "%s" SLASH "hosts", confbase);
+ dir = opendir(dname);
+ if(!dir) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "Could not open %s: %s", dname, strerror(errno));
+ free(dname);
+ return;
+ }
+
+ while((ent = readdir(dir))) {
+ if(!check_id(ent->d_name))
+ continue;
+
+ node_t *n = lookup_node(ent->d_name);
+ if(n)
+ continue;
+
+ n = new_node();
+ n->name = xstrdup(ent->d_name);
+ node_add(n);
+ }
+
+ closedir(dir);
+}
+
+
char *get_name(void) {
char *name = NULL;
char *envname = getenv(name + 1);
if(!envname) {
if(strcmp(name + 1, "HOST")) {
- fprintf(stderr, "Invalid Name: environment variable %s does not exist\n", name + 1);
+ logger(DEBUG_ALWAYS, LOG_ERR, "Invalid Name: environment variable %s does not exist\n", name + 1);
return false;
}
- envname = alloca(32);
+ char envname[32];
if(gethostname(envname, 32)) {
- fprintf(stderr, "Could not get hostname: %s\n", strerror(errno));
+ logger(DEBUG_ALWAYS, LOG_ERR, "Could not get hostname: %s\n", strerror(errno));
return false;
}
envname[31] = 0;
if(!get_config_int(lookup_config(config_tree, "KeyExpire"), &keylifetime))
keylifetime = 3600;
+ get_config_int(lookup_config(config_tree, "AutoConnect"), &autoconnect);
+
return true;
}
return false;
}
replaywin = (unsigned)replaywin_int;
+ sptps_replaywin = replaywin;
}
/* Generate packet encryption key */
if(strictsubnets)
load_all_subnets();
+ else if(autoconnect)
+ load_all_nodes();
/* Open device */