diff options
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/hs_config.c | 15 | ||||
-rw-r--r-- | src/or/hs_service.c | 9 | ||||
-rw-r--r-- | src/or/hs_service.h | 7 |
3 files changed, 17 insertions, 14 deletions
diff --git a/src/or/hs_config.c b/src/or/hs_config.c index 7e0124bb34..5f9282ea79 100644 --- a/src/or/hs_config.c +++ b/src/or/hs_config.c @@ -55,7 +55,7 @@ stage_services(smartlist_t *service_list) * only >= v3 service. And remember, v2 has a different object type which is * shadow copied from an hs_service_t type. */ SMARTLIST_FOREACH_BEGIN(service_list, hs_service_t *, s) { - if (s->version == HS_VERSION_TWO) { + if (s->config.version == HS_VERSION_TWO) { SMARTLIST_DEL_CURRENT(service_list, s); hs_service_free(s); } @@ -157,7 +157,7 @@ config_has_invalid_options(const config_line_t *line_, const config_line_t *line; tor_assert(service); - tor_assert(service->version <= HS_VERSION_MAX); + tor_assert(service->config.version <= HS_VERSION_MAX); /* List of options that a v3 service doesn't support thus must exclude from * its configuration. */ @@ -178,7 +178,7 @@ config_has_invalid_options(const config_line_t *line_, { opts_exclude_v3 }, /* v3. */ }; - optlist = exclude_lists[service->version].list; + optlist = exclude_lists[service->config.version].list; if (optlist == NULL) { /* No exclude options to look at for this version. */ goto end; @@ -193,7 +193,8 @@ config_has_invalid_options(const config_line_t *line_, if (!strcasecmp(line->key, opt)) { log_warn(LD_CONFIG, "Hidden service option %s is incompatible with " "version %" PRIu32 " of service in %s", - opt, service->version, service->config.directory_path); + opt, service->config.version, + service->config.directory_path); ret = 1; /* Continue the loop so we can find all possible options. */ continue; @@ -342,7 +343,7 @@ config_generic_service(const config_line_t *line_, } /* Version of the service. */ if (!strcasecmp(line->key, "HiddenServiceVersion")) { - service->version = + service->config.version = (uint32_t) helper_parse_uint64(line->key, line->value, HS_VERSION_MIN, HS_VERSION_MAX, &ok); if (!ok || have_version) { @@ -462,7 +463,7 @@ config_service(const config_line_t *line, const or_options_t *options, if (config_generic_service(line, options, service) < 0) { goto err; } - tor_assert(service->version <= HS_VERSION_MAX); + tor_assert(service->config.version <= HS_VERSION_MAX); /* Before we configure the service on a per-version basis, we'll make * sure that this set of options for a service are valid that is for * instance an option only for v2 is not used for v3. */ @@ -482,7 +483,7 @@ config_service(const config_line_t *line, const or_options_t *options, /* Different functions are in charge of specific options for a version. We * start just after the service directory line so once we hit another * directory line, the function knows that it has to stop parsing. */ - switch (service->version) { + switch (service->config.version) { case HS_VERSION_TWO: ret = rend_config_service(line->next, options, &service->config); break; diff --git a/src/or/hs_service.c b/src/or/hs_service.c index 97d3288d17..d8b87d1f2c 100644 --- a/src/or/hs_service.c +++ b/src/or/hs_service.c @@ -250,7 +250,7 @@ close_service_circuits(hs_service_t *service) tor_assert(service); /* Only support for version >= 3. */ - if (BUG(service->version < HS_VERSION_THREE)) { + if (BUG(service->config.version < HS_VERSION_THREE)) { return; } /* Close intro points. */ @@ -492,8 +492,9 @@ load_service_keys(hs_service_t *service) ed25519_keypair_free(kp); /* Build onion address from the newly loaded keys. */ - tor_assert(service->version <= UINT8_MAX); - hs_build_address(&service->keys.identity_pk, (uint8_t) service->version, + tor_assert(service->config.version <= UINT8_MAX); + hs_build_address(&service->keys.identity_pk, + (uint8_t) service->config.version, service->onion_address); /* Write onion address to hostname file. */ @@ -572,7 +573,7 @@ hs_service_new(const or_options_t *options) /* Set default configuration value. */ set_service_default_config(&service->config, options); /* Set the default service version. */ - service->version = HS_SERVICE_DEFAULT_VERSION; + service->config.version = HS_SERVICE_DEFAULT_VERSION; return service; } diff --git a/src/or/hs_service.h b/src/or/hs_service.h index a98884f6bc..54b9e69724 100644 --- a/src/or/hs_service.h +++ b/src/or/hs_service.h @@ -112,6 +112,10 @@ typedef struct hs_service_keys_t { * set by the configuration file or by the control port. Nothing else should * change those values. */ typedef struct hs_service_config_t { + /* Protocol version of the service. Specified by HiddenServiceVersion + * option. */ + uint32_t version; + /* List of rend_service_port_config_t */ smartlist_t *ports; @@ -170,9 +174,6 @@ typedef struct hs_service_state_t { /* Representation of a service running on this tor instance. */ typedef struct hs_service_t { - /* Protocol version of the service. Specified by HiddenServiceVersion. */ - uint32_t version; - /* Onion address base32 encoded and NUL terminated. We keep it for logging * purposes so we don't have to build it everytime. */ char onion_address[HS_SERVICE_ADDR_LEN_BASE32 + 1]; |