[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Finish most pre2 items: make running-routers list work righ...
- To: or-cvs@freehaven.net
- Subject: [or-cvs] Finish most pre2 items: make running-routers list work righ...
- From: nickm@seul.org (Nick Mathewson)
- Date: Tue, 13 Jul 2004 14:23:42 -0400 (EDT)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Tue, 13 Jul 2004 14:24:05 -0400
- Reply-to: or-dev@freehaven.net
- Sender: owner-or-cvs@freehaven.net
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv6910/src/or
Modified Files:
circuitbuild.c config.c connection.c connection_or.c
cpuworker.c dirserv.c rephist.c router.c
Log Message:
Finish most pre2 items: make running-routers list work right; rename secret key files; make even more lookup-by-nickname use lookup-by-id; default nicknames to hostname.
Index: circuitbuild.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuitbuild.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- circuitbuild.c 13 Jul 2004 01:25:39 -0000 1.10
+++ circuitbuild.c 13 Jul 2004 18:23:40 -0000 1.11
@@ -102,7 +102,7 @@
*/
void circuit_rep_hist_note_result(circuit_t *circ) {
struct crypt_path_t *hop;
- char *prev_nickname = NULL;
+ char *prev_digest = NULL;
routerinfo_t *router;
hop = circ->cpath;
if(!hop) {
@@ -114,22 +114,22 @@
return;
}
if (options.ORPort) {
- prev_nickname = options.Nickname;
+ prev_digest = router_get_my_routerinfo()->identity_digest;
}
do {
router = router_get_by_digest(hop->identity_digest);
if (router) {
- if (prev_nickname) {
+ if (prev_digest) {
if (hop->state == CPATH_STATE_OPEN)
- rep_hist_note_extend_succeeded(prev_nickname, router->nickname);
+ rep_hist_note_extend_succeeded(prev_digest, router->identity_digest);
else {
- rep_hist_note_extend_failed(prev_nickname, router->nickname);
+ rep_hist_note_extend_failed(prev_digest, router->identity_digest);
break;
}
}
- prev_nickname = router->nickname;
+ prev_digest = router->identity_digest;
} else {
- prev_nickname = NULL;
+ prev_digest = NULL;
}
hop=hop->next;
} while (hop!=circ->cpath);
@@ -445,6 +445,8 @@
relay_header_unpack(&rh, cell->payload);
if (rh.length == 4+2+ONIONSKIN_CHALLENGE_LEN) {
+ /* Once this format is no longer supported, nobody will use
+ * connection_*_get_by_addr_port. */
old_format = 1;
} else if (rh.length == 4+2+DIGEST_LEN+ONIONSKIN_CHALLENGE_LEN) {
old_format = 0;
Index: config.c
===================================================================
RCS file: /home/or/cvsroot/src/or/config.c,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -d -r1.124 -r1.125
--- config.c 13 Jul 2004 07:42:20 -0000 1.124
+++ config.c 13 Jul 2004 18:23:40 -0000 1.125
@@ -467,6 +467,40 @@
return 0;
}
+static char *get_default_nickname(void)
+{
+ char localhostname[256];
+ char *cp, *out, *outp;
+
+ if(gethostname(localhostname,sizeof(localhostname)) < 0) {
+ log_fn(LOG_WARN,"Error obtaining local hostname");
+ return NULL;
+ }
+ /* Put it in lowercase; stop at the first dot. */
+ for(cp = localhostname; *cp; ++cp) {
+ if (*cp == '.') {
+ *cp = '\0';
+ break;
+ }
+ *cp = tolower(*cp);
+ }
+ /* Strip invalid characters. */
+ cp = localhostname;
+ out = outp = tor_malloc(strlen(localhostname)+1);
+ while (*cp) {
+ if (strchr(LEGAL_NICKNAME_CHARACTERS, *cp))
+ *outp++ = *cp++;
+ else
+ cp++;
+ }
+ *outp = '\0';
+ /* Enforce length. */
+ if (strlen(out) > MAX_NICKNAME_LEN)
+ out[MAX_NICKNAME_LEN]='\0';
+
+ return out;
+}
+
/** Release storage held by <b>options</b> */
static void free_options(or_options_t *options) {
config_free_lines(options->LogOptions);
@@ -633,8 +667,9 @@
if (options->ORPort) {
if (options->Nickname == NULL) {
- log_fn(LOG_WARN,"Nickname required if ORPort is set, but not found.");
- result = -1;
+ if (!(options->Nickname = get_default_nickname()))
+ return -1;
+ log_fn(LOG_INFO, "Choosing default nickname %s", options->Nickname);
} else {
if (strspn(options->Nickname, LEGAL_NICKNAME_CHARACTERS) !=
strlen(options->Nickname)) {
Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.239
retrieving revision 1.240
diff -u -d -r1.239 -r1.240
--- connection.c 13 Jul 2004 16:58:01 -0000 1.239
+++ connection.c 13 Jul 2004 18:23:40 -0000 1.240
@@ -192,13 +192,13 @@
if (conn->state != OR_CONN_STATE_OPEN) {
/* XXX Nick: this still isn't right, because it might be
* dying even though we didn't initiate the connect. Can
- * you look at this more? -RD */
+ * you look at this more? -RD XXXX008 -NM*/
if(conn->nickname)
- rep_hist_note_connect_failed(conn->nickname, time(NULL));
+ rep_hist_note_connect_failed(conn->identity_digest, time(NULL));
} else if (0) { // XXX reason == CLOSE_REASON_UNUSED_OR_CONN) {
- rep_hist_note_disconnect(conn->nickname, time(NULL));
+ rep_hist_note_disconnect(conn->identity_digest, time(NULL));
} else {
- rep_hist_note_connection_died(conn->nickname, time(NULL));
+ rep_hist_note_connection_died(conn->identity_digest, time(NULL));
}
break;
case CONN_TYPE_AP:
Index: connection_or.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_or.c,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -d -r1.114 -r1.115
--- connection_or.c 12 Jul 2004 18:19:55 -0000 1.114
+++ connection_or.c 13 Jul 2004 18:23:40 -0000 1.115
@@ -329,7 +329,7 @@
directory_set_dirty();
circuit_n_conn_done(conn, 1); /* send the pending creates, if any. */
/* Note the success */
- rep_hist_note_connect_succeeded(nickname, time(NULL));
+ rep_hist_note_connect_succeeded(conn->identity_digest, time(NULL));
return 0;
}
Index: cpuworker.c
===================================================================
RCS file: /home/or/cvsroot/src/or/cpuworker.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- cpuworker.c 1 Jul 2004 23:13:04 -0000 1.45
+++ cpuworker.c 13 Jul 2004 18:23:40 -0000 1.46
@@ -19,7 +19,7 @@
#define MIN_CPUWORKERS 1
/** The tag specifies which circuit this onionskin was from. */
-#define TAG_LEN 8
+#define TAG_LEN (DIGEST_LEN+2)
/** How many bytes are sent from tor to the cpuworker? */
#define LEN_ONION_QUESTION (1+TAG_LEN+ONIONSKIN_CHALLENGE_LEN)
/** How many bytes are sent from the cpuworker back to tor? */
@@ -55,23 +55,17 @@
/** Pack addr,port,and circ_id; set *tag to the result. (See note on
* cpuworker_main for wire format.) */
-static void tag_pack(char *tag, uint32_t addr, uint16_t port, uint16_t circ_id) {
- *(uint32_t *)tag = addr;
- *(uint16_t *)(tag+4) = port;
- *(uint16_t *)(tag+6) = circ_id;
+static void tag_pack(char *tag, uint16_t circ_id, const char *identity_digest){
+ *(uint16_t *)(tag) = circ_id;
+ memcpy(tag+2, identity_digest, DIGEST_LEN);
}
/** Unpack <b>tag</b> into addr, port, and circ_id.
*/
-static void tag_unpack(const char *tag, uint32_t *addr, uint16_t *port, uint16_t *circ_id) {
- struct in_addr in;
-
- *addr = *(const uint32_t *)tag;
- *port = *(const uint16_t *)(tag+4);
- *circ_id = *(const uint16_t *)(tag+6);
-
- in.s_addr = htonl(*addr);
- log_fn(LOG_DEBUG,"onion was from %s:%d, circ_id %d.", inet_ntoa(in), *port, *circ_id);
+static void tag_unpack(const char *tag, uint16_t *circ_id,
+ char *identity_digest) {
+ *circ_id = *(const uint16_t *)(tag);
+ memcpy(identity_digest, tag+2, DIGEST_LEN);
}
/** Called when the onion key has changed and we need to spawn new
@@ -98,11 +92,10 @@
int connection_cpu_process_inbuf(connection_t *conn) {
char success;
unsigned char buf[LEN_ONION_RESPONSE];
- uint32_t addr;
- uint16_t port;
uint16_t circ_id;
connection_t *p_conn;
circuit_t *circ;
+ char identity_digest[DIGEST_LEN];
tor_assert(conn && conn->type == CONN_TYPE_CPUWORKER);
@@ -130,11 +123,11 @@
connection_fetch_from_buf(buf,LEN_ONION_RESPONSE-1,conn);
/* parse out the circ it was talking about */
- tag_unpack(buf, &addr, &port, &circ_id);
+ tag_unpack(buf, &circ_id, identity_digest);
circ = NULL;
/* XXXX This is actually right: we want a specific port here in
* case there are multiple connections. */
- p_conn = connection_exact_get_by_addr_port(addr,port);
+ p_conn = connection_get_by_identity_digest(identity_digest,CONN_TYPE_OR);
if(p_conn)
circ = circuit_get_by_circ_id_conn(circ_id, p_conn);
@@ -358,7 +351,7 @@
log_fn(LOG_INFO,"circ->p_conn gone. Failing circ.");
return -1;
}
- tag_pack(tag, circ->p_conn->addr, circ->p_conn->port, circ->p_circ_id);
+ tag_pack(tag, circ->p_circ_id, circ->p_conn->identity_digest);
cpuworker->state = CPUWORKER_STATE_BUSY_ONION;
num_cpuworkers_busy++;
Index: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dirserv.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- dirserv.c 1 Jul 2004 11:32:25 -0000 1.58
+++ dirserv.c 13 Jul 2004 18:23:40 -0000 1.59
@@ -181,16 +181,25 @@
/** Return true iff any router named <b>nickname</b> is in the fingerprint
* list. */
static int
-router_nickname_is_approved(const char *nickname)
+router_nickname_is_approved(const char *nickname, const char *digest)
{
- int i;
+ int i,j;
fingerprint_entry_t *ent;
+ char fp[FINGERPRINT_LEN+1];
if (!fingerprint_list)
return 0;
+ for (i=j=0;i<DIGEST_LEN;++i,++j) {
+ fp[i]=digest[j];
+ if ((j%4)==3 && j != 19)
+ fp[++i]=' ';
+ }
+ fp[i]='\0';
+
for (i=0;i<smartlist_len(fingerprint_list);++i) {
ent = smartlist_get(fingerprint_list, i);
- if (!strcasecmp(nickname,ent->nickname)) {
+ if (!strcasecmp(nickname,ent->nickname) &&
+ !strcasecmp(fp,ent->fingerprint)) {
return 1;
}
}
@@ -227,6 +236,7 @@
time_t published;
size_t desc_len;
char *descriptor;
+ int verified;
routerinfo_t *router;
} descriptor_entry_t;
@@ -368,6 +378,7 @@
strncpy(ent->descriptor, start, desc_len);
ent->descriptor[desc_len] = '\0';
ent->router = ri;
+ ent->verified = 1; /* XXXX008 support other possibilities. */
smartlist_add(descriptor_list, ent);
*desc = end;
@@ -447,19 +458,25 @@
*nicknames_out = NULL;
nicknames_up = smartlist_create();
nicknames_down = smartlist_create();
- smartlist_add(nicknames_up, options.Nickname);
+ smartlist_add(nicknames_up, tor_strdup(options.Nickname));
get_connection_array(&connection_array, &n_conns);
for (i = 0; i<n_conns; ++i) {
+ char *name;
conn = connection_array[i];
if (conn->type != CONN_TYPE_OR || !conn->nickname)
continue; /* only list ORs. */
- if (!router_nickname_is_approved(conn->nickname))
- continue; /* If we removed them from the approved list, don't list it.*/
+ if (router_nickname_is_approved(conn->nickname, conn->identity_digest)) {
+ name = tor_strdup(conn->nickname);
+ } else {
+ name = tor_malloc(HEX_DIGEST_LEN+1);
+ base16_encode(name, HEX_DIGEST_LEN, conn->identity_digest, DIGEST_LEN);
+ }
+
if(conn->state == OR_CONN_STATE_OPEN)
- smartlist_add(nicknames_up, conn->nickname);
+ smartlist_add(nicknames_up, name);
else
- smartlist_add(nicknames_down, conn->nickname);
+ smartlist_add(nicknames_down, name);
}
length = smartlist_len(nicknames_up) +
2*smartlist_len(nicknames_down) + 1;
@@ -481,6 +498,8 @@
while (*cp)
++cp;
}
+ SMARTLIST_FOREACH(nicknames_up, char *, victim, tor_free(victim));
+ SMARTLIST_FOREACH(nicknames_down, char *, victim, tor_free(victim));
smartlist_free(nicknames_up);
smartlist_free(nicknames_down);
return 0;
Index: rephist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rephist.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- rephist.c 13 Jul 2004 16:58:01 -0000 1.12
+++ rephist.c 13 Jul 2004 18:23:40 -0000 1.13
@@ -7,6 +7,8 @@
* \brief Basic history functionality for reputation module.
**/
+/* DOCDOC references to 'nicknames' in docs here are mostly wrong. */
+
#include "or.h"
/** History of an OR-\>OR link. */
@@ -47,15 +49,18 @@
/** Return the or_history_t for the named OR, creating it if necessary.
*/
-static or_history_t *get_or_history(const char* nickname)
+static or_history_t *get_or_history(const char* id)
{
or_history_t *hist;
- hist = (or_history_t*) strmap_get(history_map, nickname);
+ char hexid[HEX_DIGEST_LEN+1];
+ base16_encode(hexid, HEX_DIGEST_LEN+1, id, DIGEST_LEN);
+
+ hist = (or_history_t*) strmap_get(history_map, hexid);
if (!hist) {
hist = tor_malloc_zero(sizeof(or_history_t));
hist->link_history_map = strmap_new();
hist->since = time(NULL);
- strmap_set(history_map, nickname, hist);
+ strmap_set(history_map, hexid, hist);
}
return hist;
}
@@ -63,17 +68,19 @@
/** Return the link_history_t for the link from the first named OR to
* the second, creating it if necessary.
*/
-static link_history_t *get_link_history(const char *from_name,
- const char *to_name)
+static link_history_t *get_link_history(const char *from_id,
+ const char *to_id)
{
or_history_t *orhist;
link_history_t *lhist;
- orhist = get_or_history(from_name);
- lhist = (link_history_t*) strmap_get(orhist->link_history_map, to_name);
+ char to_hexid[HEX_DIGEST_LEN+1];
+ orhist = get_or_history(from_id);
+ base16_encode(to_hexid, HEX_DIGEST_LEN+1, to_id, DIGEST_LEN);
+ lhist = (link_history_t*) strmap_get(orhist->link_history_map, to_hexid);
if (!lhist) {
lhist = tor_malloc_zero(sizeof(link_history_t));
lhist->since = time(NULL);
- strmap_set(orhist->link_history_map, to_name, lhist);
+ strmap_set(orhist->link_history_map, to_hexid, lhist);
}
return lhist;
}
@@ -104,10 +111,10 @@
/** Remember that an attempt to connect to the OR <b>nickname</b> failed at
* <b>when</b>.
*/
-void rep_hist_note_connect_failed(const char* nickname, time_t when)
+void rep_hist_note_connect_failed(const char* id, time_t when)
{
or_history_t *hist;
- hist = get_or_history(nickname);
+ hist = get_or_history(id);
++hist->n_conn_fail;
if (hist->up_since) {
hist->uptime += (when - hist->up_since);
@@ -120,10 +127,10 @@
/** Remember that an attempt to connect to the OR <b>nickname</b> succeeded
* at <b>when</b>.
*/
-void rep_hist_note_connect_succeeded(const char* nickname, time_t when)
+void rep_hist_note_connect_succeeded(const char* id, time_t when)
{
or_history_t *hist;
- hist = get_or_history(nickname);
+ hist = get_or_history(id);
++hist->n_conn_ok;
if (hist->down_since) {
hist->downtime += (when - hist->down_since);
@@ -136,10 +143,10 @@
/** Remember that we intentionally closed our connection to the OR
* <b>nickname</b> at <b>when</b>.
*/
-void rep_hist_note_disconnect(const char* nickname, time_t when)
+void rep_hist_note_disconnect(const char* id, time_t when)
{
or_history_t *hist;
- hist = get_or_history(nickname);
+ hist = get_or_history(id);
++hist->n_conn_ok;
if (hist->up_since) {
hist->uptime += (when - hist->up_since);
@@ -147,20 +154,21 @@
}
}
-/** Remember that our connection to the OR <b>nickname</b> had an error and
+/** Remember that our connection to the OR <b>id</b> had an error and
* stopped working at <b>when</b>.
*/
-void rep_hist_note_connection_died(const char* nickname, time_t when)
+void rep_hist_note_connection_died(const char* id, time_t when)
{
or_history_t *hist;
- if(!nickname) {
+ if(!id) {
+ /* XXXX008 not so. */
/* If conn has no nickname, it's either an OP, or it is an OR
* which didn't complete its handshake (or did and was unapproved).
* Ignore it.
*/
return;
}
- hist = get_or_history(nickname);
+ hist = get_or_history(id);
if (hist->up_since) {
hist->uptime += (when - hist->up_since);
hist->up_since = 0;
@@ -172,23 +180,23 @@
/** Remember that we successfully extended from the OR <b>from_name</b> to
* the OR <b>to_name</b>.
*/
-void rep_hist_note_extend_succeeded(const char *from_name,
- const char *to_name)
+void rep_hist_note_extend_succeeded(const char *from_id,
+ const char *to_id)
{
link_history_t *hist;
/* log_fn(LOG_WARN, "EXTEND SUCCEEDED: %s->%s",from_name,to_name); */
- hist = get_link_history(from_name, to_name);
+ hist = get_link_history(from_id, to_id);
++hist->n_extend_ok;
}
/** Remember that we tried to extend from the OR <b>from_name</b> to the OR
* <b>to_name</b>, but failed.
*/
-void rep_hist_note_extend_failed(const char *from_name, const char *to_name)
+void rep_hist_note_extend_failed(const char *from_id, const char *to_id)
{
link_history_t *hist;
/* log_fn(LOG_WARN, "EXTEND FAILED: %s->%s",from_name,to_name); */
- hist = get_link_history(from_name, to_name);
+ hist = get_link_history(from_id, to_id);
++hist->n_extend_fail;
}
@@ -199,7 +207,7 @@
{
strmap_iter_t *lhist_it;
strmap_iter_t *orhist_it;
- const char *name1, *name2;
+ const char *name1, *name2, *hexdigest1, *hexdigest2;
or_history_t *or_history;
link_history_t *link_history;
void *or_history_p, *link_history_p;
@@ -207,14 +215,20 @@
char buffer[2048];
int len;
unsigned long upt, downt;
+ routerinfo_t *r;
log(severity, "--------------- Dumping history information:");
for (orhist_it = strmap_iter_init(history_map); !strmap_iter_done(orhist_it);
orhist_it = strmap_iter_next(history_map,orhist_it)) {
- strmap_iter_get(orhist_it, &name1, &or_history_p);
+ strmap_iter_get(orhist_it, &hexdigest1, &or_history_p);
or_history = (or_history_t*) or_history_p;
+ if ((r = router_get_by_hexdigest(hexdigest1)))
+ name1 = r->nickname;
+ else
+ name1 = "(unknown)";
+
update_or_history(or_history, now);
upt = or_history->uptime;
downt = or_history->downtime;
@@ -224,8 +238,8 @@
uptime=1.0;
}
log(severity,
- "OR %s: %ld/%ld good connections; uptime %ld/%ld sec (%.2f%%)",
- name1,
+ "OR %s [%s]: %ld/%ld good connections; uptime %ld/%ld sec (%.2f%%)",
+ name1, hexdigest1,
or_history->n_conn_ok, or_history->n_conn_fail+or_history->n_conn_ok,
upt, upt+downt, uptime*100.0);
@@ -234,7 +248,12 @@
for (lhist_it = strmap_iter_init(or_history->link_history_map);
!strmap_iter_done(lhist_it);
lhist_it = strmap_iter_next(or_history->link_history_map, lhist_it)) {
- strmap_iter_get(lhist_it, &name2, &link_history_p);
+ strmap_iter_get(lhist_it, &hexdigest2, &link_history_p);
+ if ((r = router_get_by_hexdigest(hexdigest2)))
+ name2 = r->nickname;
+ else
+ name2 = "(unknown)";
+
link_history = (link_history_t*) link_history_p;
len += snprintf(buffer+len, 2048-len, "%s(%ld/%ld); ", name2,
link_history->n_extend_ok,
@@ -275,7 +294,6 @@
name1, or_history->since1,
}
-
done:
if (f)
fclose(f);
Index: router.c
===================================================================
RCS file: /home/or/cvsroot/src/or/router.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- router.c 12 Jul 2004 18:02:54 -0000 1.62
+++ router.c 13 Jul 2004 18:23:40 -0000 1.63
@@ -124,6 +124,32 @@
log_fn(LOG_WARN, "Couldn't rotate onion key.");
}
+/* Read an RSA secret key key from a file that was once named fname_old,
+ * but is now named fname_new. Rename the file from old to new as needed.
+ */
+crypto_pk_env_t *init_key_from_file_name_changed(const char *fname_old,
+ const char *fname_new)
+{
+ int fs;
+
+ fs = file_status(fname_new);
+ if (fs == FN_FILE)
+ /* The new filename is there. */
+ return init_key_from_file(fname_new);
+ fs = file_status(fname_old);
+ if (fs != FN_FILE)
+ /* There is no key under either name. */
+ return init_key_from_file(fname_new);
+
+ /* The old filename exists, and the new one doesn't. Rename and load. */
+ if (rename(fname_old, fname_new) < 0) {
+ log_fn(LOG_ERR, "Couldn't rename %s to %s: %s", fname_old, fname_new,
+ strerror(errno));
+ return NULL;
+ }
+ return init_key_from_file(fname_new);
+}
+
/** Try to read an RSA key from <b>fname</b>. If <b>fname</b> doesn't exist,
* create a new RSA key and save it in <b>fname</b>. Return the read/created
* key, or NULL on error.
@@ -182,6 +208,7 @@
*/
int init_keys(void) {
char keydir[512];
+ char keydir2[512];
char fingerprint[FINGERPRINT_LEN+MAX_NICKNAME_LEN+3];
char *cp;
const char *tmp, *mydesc, *datadir;
@@ -217,15 +244,17 @@
cp = keydir + strlen(keydir); /* End of string. */
/* 1. Read identity key. Make it if none is found. */
- strcpy(cp, "/identity.key");
- log_fn(LOG_INFO,"Reading/making identity key %s...",keydir);
- prkey = init_key_from_file(keydir);
+ sprintf(keydir,"%s/keys/identity.key",datadir);
+ sprintf(keydir2,"%s/keys/secret_id_key",datadir);
+ log_fn(LOG_INFO,"Reading/making identity key %s...",keydir2);
+ prkey = init_key_from_file_name_changed(keydir,keydir2);
if (!prkey) return -1;
set_identity_key(prkey);
/* 2. Read onion key. Make it if none is found. */
- strcpy(cp, "/onion.key");
- log_fn(LOG_INFO,"Reading/making onion key %s...",keydir);
- prkey = init_key_from_file(keydir);
+ sprintf(keydir,"%s/keys/onion.key",datadir);
+ sprintf(keydir2,"%s/keys/secret_onion_key",datadir);
+ log_fn(LOG_INFO,"Reading/making onion key %s...",keydir2);
+ prkey = init_key_from_file_name_changed(keydir,keydir2);
if (!prkey) return -1;
set_onion_key(prkey);