diff options
Diffstat (limited to 'src/feature/rend')
-rw-r--r-- | src/feature/rend/rendservice.c | 24 | ||||
-rw-r--r-- | src/feature/rend/rendservice.h | 1 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/feature/rend/rendservice.c b/src/feature/rend/rendservice.c index da4a98b3d1..1af9117aaf 100644 --- a/src/feature/rend/rendservice.c +++ b/src/feature/rend/rendservice.c @@ -37,6 +37,7 @@ #include "feature/nodelist/routerparse.h" #include "feature/nodelist/routerset.h" #include "lib/encoding/confline.h" +#include "lib/net/resolve.h" #include "core/or/cpath_build_state_st.h" #include "core/or/crypt_path_st.h" @@ -1340,6 +1341,29 @@ rend_service_poison_new_single_onion_dir(const rend_service_t *s, return 0; } +/* Return true iff the given service identity key is present on disk. This is + * used to try to learn the service version during configuration time. */ +int +rend_service_key_on_disk(const char *directory_path) +{ + int ret = 0; + char *fname; + crypto_pk_t *pk = NULL; + + tor_assert(directory_path); + + /* Load key */ + fname = hs_path_from_filename(directory_path, private_key_fname); + pk = init_key_from_file(fname, 0, LOG_DEBUG, 0); + if (pk) { + ret = 1; + } + + crypto_pk_free(pk); + tor_free(fname); + return ret; +} + /** Load and/or generate private keys for all hidden services, possibly * including keys for client authorization. * If a <b>service_list</b> is provided, treat it as the list of hidden diff --git a/src/feature/rend/rendservice.h b/src/feature/rend/rendservice.h index 7096789629..7186289fc7 100644 --- a/src/feature/rend/rendservice.h +++ b/src/feature/rend/rendservice.h @@ -145,6 +145,7 @@ int rend_config_service(const struct config_line_t *line_, void rend_service_prune_list(void); void rend_service_free_staging_list(void); int rend_service_load_all_keys(const smartlist_t *service_list); +int rend_service_key_on_disk(const char *directory_path); void rend_services_add_filenames_to_lists(smartlist_t *open_lst, smartlist_t *stat_lst); void rend_consider_services_intro_points(time_t now); |