splay_tree_t *config_tree;
FILE *fp;
- char *pubname = NULL, *hcfname = NULL;
+ char *pubname = NULL;
char *p;
- xasprintf(&hcfname, "%s" SLASH "hosts" SLASH "%s", confbase, n->name);
-
init_configuration(&config_tree);
- if(!read_config_file(config_tree, hcfname))
+ if(!read_host_config(config_tree, n->name))
goto exit;
/* First, check for simple ECDSAPublicKey statement */
exit:
exit_configuration(&config_tree);
- free(hcfname);
free(pubname);
return n->ecdsa;
}
char *fname;
char *p;
+ if(!c->config_tree) {
+ init_configuration(&c->config_tree);
+ if(!read_host_config(c->config_tree, c->name))
+ return false;
+ }
+
/* First, check for simple ECDSAPublicKey statement */
if(get_config_string(lookup_config(c->config_tree, "ECDSAPublicKey"), &p)) {
return myself->connection->ecdsa;
}
+static bool read_invitation_key(void) {
+ FILE *fp;
+ char *fname;
+
+ if(invitation_key) {
+ ecdsa_free(invitation_key);
+ invitation_key = NULL;
+ }
+
+ xasprintf(&fname, "%s" SLASH "invitations" SLASH "ecdsa_key.priv", confbase);
+
+ fp = fopen(fname, "r");
+
+ if(fp) {
+ invitation_key = ecdsa_read_pem_private_key(fp);
+ fclose(fp);
+ if(!invitation_key)
+ logger(DEBUG_ALWAYS, LOG_ERR, "Reading ECDSA private key file `%s' failed: %s", fname, strerror(errno));
+ }
+
+ free(fname);
+ return invitation_key;
+}
+
static bool read_rsa_private_key(void) {
FILE *fp;
char *fname;
// continue;
#endif
- char *fname;
- xasprintf(&fname, "%s" SLASH "hosts" SLASH "%s", confbase, ent->d_name);
-
splay_tree_t *config_tree;
init_configuration(&config_tree);
read_config_options(config_tree, ent->d_name);
- read_config_file(config_tree, fname);
- free(fname);
+ read_host_config(config_tree, ent->d_name);
if(!n) {
n = new_node();
get_config_bool(lookup_config(config_tree, "DisableBuggyPeers"), &disablebuggypeers);
+ read_invitation_key();
+
return true;
}
*/
static bool setup_myself(void) {
char *name, *hostname, *cipher, *digest, *type;
- char *fname = NULL;
char *address = NULL;
if(!(name = get_name())) {
myself->connection = new_connection();
myself->name = name;
myself->connection->name = xstrdup(name);
- xasprintf(&fname, "%s" SLASH "hosts" SLASH "%s", confbase, name);
- read_config_options(config_tree, name);
- read_config_file(config_tree, fname);
- free(fname);
+ read_host_config(config_tree, name);
if(!get_config_string(lookup_config(config_tree, "Port"), &myport))
myport = xstrdup("655");