diff options
author | Roger Dingledine <arma@torproject.org> | 2004-11-28 11:39:53 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2004-11-28 11:39:53 +0000 |
commit | 22727b4edc64b26aed850297dbf274bab7fd6c44 (patch) | |
tree | 1456f14c2cff195e87fc8080a741ae05eb2fbe48 /src/or/router.c | |
parent | f7c6ad065e2c433acb3fcccb1e9c7812c262579d (diff) | |
download | tor-22727b4edc64b26aed850297dbf274bab7fd6c44.tar tor-22727b4edc64b26aed850297dbf274bab7fd6c44.tar.gz |
wrong is ok, and right is fine, but in between is apparently
totally unacceptable to me.
svn:r3005
Diffstat (limited to 'src/or/router.c')
-rw-r--r-- | src/or/router.c | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/src/or/router.c b/src/or/router.c index f24e2bdcc..0ba606b92 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -191,34 +191,34 @@ crypto_pk_env_t *init_key_from_file(const char *fname) } switch (file_status(fname)) { - case FN_DIR: - case FN_ERROR: - log(LOG_ERR, "Can't read key from %s", fname); - goto error; - case FN_NOENT: - log(LOG_INFO, "No key found in %s; generating fresh key.", fname); - if (crypto_pk_generate_key(prkey)) { - log(LOG_ERR, "Error generating onion key"); - goto error; - } - if (crypto_pk_check_key(prkey) <= 0) { - log(LOG_ERR, "Generated key seems invalid"); - goto error; - } - log(LOG_INFO, "Generated key seems valid"); - if (crypto_pk_write_private_key_to_filename(prkey, fname)) { - log(LOG_ERR, "Couldn't write generated key to %s.", fname); - goto error; - } - return prkey; - case FN_FILE: - if (crypto_pk_read_private_key_from_filename(prkey, fname)) { - log(LOG_ERR, "Error loading private key."); + case FN_DIR: + case FN_ERROR: + log(LOG_ERR, "Can't read key from %s", fname); goto error; - } - return prkey; - default: - tor_assert(0); + case FN_NOENT: + log(LOG_INFO, "No key found in %s; generating fresh key.", fname); + if (crypto_pk_generate_key(prkey)) { + log(LOG_ERR, "Error generating onion key"); + goto error; + } + if (crypto_pk_check_key(prkey) <= 0) { + log(LOG_ERR, "Generated key seems invalid"); + goto error; + } + log(LOG_INFO, "Generated key seems valid"); + if (crypto_pk_write_private_key_to_filename(prkey, fname)) { + log(LOG_ERR, "Couldn't write generated key to %s.", fname); + goto error; + } + return prkey; + case FN_FILE: + if (crypto_pk_read_private_key_from_filename(prkey, fname)) { + log(LOG_ERR, "Error loading private key."); + goto error; + } + return prkey; + default: + tor_assert(0); } error: @@ -402,7 +402,7 @@ void router_retry_connections(void) { if (!clique_mode(options) && !router_is_clique_mode(router)) continue; if (!connection_get_by_identity_digest(router->identity_digest, - CONN_TYPE_OR)) { + CONN_TYPE_OR)) { /* not in the list */ log_fn(LOG_DEBUG,"connecting to OR at %s:%u.",router->address,router->or_port); connection_or_connect(router->addr, router->or_port, router->identity_digest); @@ -650,14 +650,14 @@ int router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router, /* PEM-encode the onion key */ if (crypto_pk_write_public_key_to_string(router->onion_pkey, - &onion_pkey,&onion_pkeylen)<0) { + &onion_pkey,&onion_pkeylen)<0) { log_fn(LOG_WARN,"write onion_pkey to string failed!"); return -1; } /* PEM-encode the identity key key */ if (crypto_pk_write_public_key_to_string(router->identity_pkey, - &identity_pkey,&identity_pkeylen)<0) { + &identity_pkey,&identity_pkeylen)<0) { log_fn(LOG_WARN,"write identity_pkey to string failed!"); tor_free(onion_pkey); return -1; |