diff options
author | George Kadianakis <desnacked@riseup.net> | 2021-05-05 10:21:48 +0300 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2021-05-05 10:21:48 +0300 |
commit | d6e7fc00f3c3f3d77b0f3257e7bb0d83e35b3e2a (patch) | |
tree | 31c6d157294bd515ac3a0cb3f3445155e7426b7f /src/feature | |
parent | 1d18ecbc5f74e8aba8096e9bfd851ff775bbce0d (diff) | |
parent | cf6e72b7020c47ba20677dc19602663723bd8491 (diff) | |
download | tor-d6e7fc00f3c3f3d77b0f3257e7bb0d83e35b3e2a.tar.gz tor-d6e7fc00f3c3f3d77b0f3257e7bb0d83e35b3e2a.zip |
Merge branch 'maint-0.4.6'
Diffstat (limited to 'src/feature')
-rw-r--r-- | src/feature/hs/hs_service.c | 18 | ||||
-rw-r--r-- | src/feature/hs/hs_service.h | 3 |
2 files changed, 11 insertions, 10 deletions
diff --git a/src/feature/hs/hs_service.c b/src/feature/hs/hs_service.c index a232377221..9b7b590140 100644 --- a/src/feature/hs/hs_service.c +++ b/src/feature/hs/hs_service.c @@ -160,6 +160,15 @@ HT_GENERATE2(hs_service_ht, hs_service_t, hs_service_node, hs_service_ht_hash, hs_service_ht_eq, 0.6, tor_reallocarray, tor_free_); +/** Return true iff the given service has client authorization configured that + * is the client list is non empty. */ +static inline bool +is_client_auth_enabled(const hs_service_t *service) +{ + return (service->config.clients != NULL && + smartlist_len(service->config.clients) > 0); +} + /** Query the given service map with a public key and return a service object * if found else NULL. It is also possible to set a directory path in the * search query. If pk is NULL, then it will be set to zero indicating the @@ -1302,11 +1311,6 @@ load_client_keys(hs_service_t *service) } SMARTLIST_FOREACH_END(filename); - /* If the number of clients is greater than zero, set the flag to be true. */ - if (smartlist_len(config->clients) > 0) { - config->is_client_auth_enabled = 1; - } - /* Success. */ ret = 0; end: @@ -1816,7 +1820,7 @@ build_service_desc_superencrypted(const hs_service_t *service, /* We do not need to build the desc authorized client if the client * authorization is disabled */ - if (config->is_client_auth_enabled) { + if (is_client_auth_enabled(service)) { SMARTLIST_FOREACH_BEGIN(config->clients, hs_service_authorized_client_t *, client) { hs_desc_authorized_client_t *desc_client; @@ -3588,7 +3592,7 @@ service_encode_descriptor(const hs_service_t *service, /* If the client authorization is enabled, send the descriptor cookie to * hs_desc_encode_descriptor. Otherwise, send NULL */ - if (service->config.is_client_auth_enabled) { + if (is_client_auth_enabled(service)) { descriptor_cookie = desc->descriptor_cookie; } diff --git a/src/feature/hs/hs_service.h b/src/feature/hs/hs_service.h index f5be37b410..c48f470245 100644 --- a/src/feature/hs/hs_service.h +++ b/src/feature/hs/hs_service.h @@ -230,9 +230,6 @@ typedef struct hs_service_config_t { * HiddenServiceNumIntroductionPoints option. */ unsigned int num_intro_points; - /** True iff the client auth is enabled. */ - unsigned int is_client_auth_enabled : 1; - /** List of hs_service_authorized_client_t's of clients that may access this * service. Specified by HiddenServiceAuthorizeClient option. */ smartlist_t *clients; |