22 #define OB_OPTIONS_MAGIC 0x631DE7EA
25 #define VAR(varname, conftype, member, initvalue) \
26 CONFIG_VAR_ETYPE(ob_options_t, varname, conftype, member, 0, initvalue)
27 #define V(member,conftype,initvalue) \
28 VAR(#member, conftype, member, initvalue)
32 DUMMY_TYPECHECK_INSTANCE(ob_options_t);
36 V(MasterOnionAddress, LINELIST, NULL),
46 .offset = offsetof(ob_options_t, ExtraLines),
51 .
size =
sizeof(ob_options_t),
55 offsetof(ob_options_t, magic_),
58 .extra = &config_extra_vars,
66 get_config_options_mgr(
void)
68 if (PREDICT_UNLIKELY(config_options_mgr == NULL)) {
72 return config_options_mgr;
75 #define ob_option_free(val) \
76 FREE_AND_NULL(ob_options_t, ob_option_free_, (val))
85 config_free(get_config_options_mgr(), opts);
92 ob_options_t *opts =
config_new(get_config_options_mgr());
125 strlcpy(address, value, strlen(value) -
sizeof(
".onion") + 2);
148 for (line = opts->MasterOnionAddress; line; line = line->next) {
156 log_warn(
LD_REND,
"OnionBalance: MasterOnionAddress %s is invalid",
162 log_notice(
LD_REND,
"OnionBalance: MasterOnionAddress %s registered",
203 if (BUG(service == NULL)) {
223 static const char *fname =
"ob_config";
225 char *content = NULL, *errmsg = NULL, *config_file_path = NULL;
226 ob_options_t *options = NULL;
233 content = read_file_to_str(config_file_path, 0, NULL);
235 log_warn(
LD_FS,
"OnionBalance: Unable to read config file %s",
246 config_assign(get_config_options_mgr(), options, lines, 0, &errmsg);
248 log_warn(
LD_REND,
"OnionBalance: Unable to parse config file: %s",
258 config_free_lines(lines);
259 ob_option_free(options);
281 unsigned int num_pkeys, idx = 0;
283 const int steps[3] = {0, -1, 1};
296 *subcredentials_out = NULL;
331 for (
unsigned int i = 0; i < num_steps; i++) {
336 } SMARTLIST_FOREACH_END(pkey);
346 log_info(
LD_REND,
"Refreshing %u onionbalance keys (TP #%d).",
349 *subcredentials_out = subcreds;
391 if (BUG(!num_subcreds)) {
396 if (service->
state.ob_subcreds) {
400 service->
state.ob_subcreds = ob_subcreds;
401 service->
state.n_ob_subcreds = num_subcreds;
408 config_mgr_free(config_options_mgr);
int config_get_lines(const char *string, config_line_t **result, int extended)
#define END_OF_CONFIG_VARS
void config_init(const config_mgr_t *mgr, void *options)
void config_mgr_freeze(config_mgr_t *mgr)
void * config_new(const config_mgr_t *mgr)
config_mgr_t * config_mgr_new(const config_format_t *toplevel_fmt)
int config_assign(const config_mgr_t *mgr, void *options, config_line_t *list, unsigned config_assign_flags, char **msg)
const char * escaped(const char *s)
void hs_get_subcredential(const ed25519_public_key_t *identity_pk, const ed25519_public_key_t *blinded_pk, hs_subcredential_t *subcred_out)
uint64_t hs_get_time_period_num(time_t now)
void hs_build_blinded_pubkey(const ed25519_public_key_t *pk, const uint8_t *secret, size_t secret_len, uint64_t time_period_num, ed25519_public_key_t *blinded_pk_out)
char * hs_path_from_filename(const char *directory, const char *filename)
int hs_parse_address_no_log(const char *address, ed25519_public_key_t *key_out, uint8_t *checksum_out, uint8_t *version_out, const char **errmsg)
#define HS_SERVICE_ADDR_LEN_BASE32
void hs_ob_free_all(void)
static ob_options_t * ob_option_new(void)
void hs_ob_refresh_keys(hs_service_t *service)
bool hs_ob_service_is_instance(const hs_service_t *service)
static int ob_option_parse(hs_service_config_t *config, const ob_options_t *opts)
static void ob_option_free_(ob_options_t *opts)
static void build_subcredential(const ed25519_public_key_t *pkey, uint64_t tp, hs_subcredential_t *subcredential)
STATIC size_t compute_subcredentials(const hs_service_t *service, hs_subcredential_t **subcredentials_out)
int hs_ob_parse_config_file(hs_service_config_t *config)
static bool get_onion_public_key(const char *value, ed25519_public_key_t *pkey_out)
Header file for the specific code for onion balance.
Header file containing service data for the HS subsystem.
Header file for networkstatus.c.
Networkstatus consensus/vote structure.
smartlist_t * smartlist_new(void)
void smartlist_add(smartlist_t *sl, void *element)
#define SMARTLIST_FOREACH_BEGIN(sl, type, var)
hs_subcredential_t subcredential
smartlist_t * ob_master_pubkeys
hs_service_descriptor_t * desc_current
hs_service_config_t config
hs_service_descriptor_t * desc_next
int strcmpend(const char *s1, const char *s2)