mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-25 23:21:38 +01:00
Improve how we access or_state_t.
* Use get_or_state()->VirtualOption instead of relying on config_find_option(), STRUCT_VAR_P and voodoo.
This commit is contained in:
parent
0dcf327248
commit
2703e41d8b
1 changed files with 10 additions and 20 deletions
|
@ -5513,16 +5513,11 @@ static int
|
||||||
validate_transports_in_state(or_state_t *state)
|
validate_transports_in_state(or_state_t *state)
|
||||||
{
|
{
|
||||||
int broken = 0;
|
int broken = 0;
|
||||||
|
config_line_t *line;
|
||||||
|
|
||||||
config_var_t *var = config_find_option(&state_format,"TransportProxies");
|
for (line = state->TransportProxies ; line ; line = line->next) {
|
||||||
if (!var)
|
tor_assert(!strcmp(line->key, "TransportProxy"));
|
||||||
return 0;
|
if (!state_transport_line_is_valid(line->value)<0)
|
||||||
|
|
||||||
config_line_t **value = STRUCT_VAR_P(state, var->var_offset);
|
|
||||||
config_line_t *search = NULL;
|
|
||||||
|
|
||||||
for (search = *value ; search ; search = search->next) {
|
|
||||||
if (!state_transport_line_is_valid(search->value)<0)
|
|
||||||
broken = 1;
|
broken = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5790,18 +5785,13 @@ or_state_save(time_t now)
|
||||||
static config_line_t *
|
static config_line_t *
|
||||||
get_transport_in_state_by_name(const char *transport)
|
get_transport_in_state_by_name(const char *transport)
|
||||||
{
|
{
|
||||||
config_var_t *var = config_find_option(&state_format,"TransportProxies");
|
or_state_t *or_state = get_or_state();
|
||||||
if (!var)
|
config_line_t *line;
|
||||||
return NULL;
|
|
||||||
|
|
||||||
config_line_t **value = STRUCT_VAR_P(get_or_state(), var->var_offset);
|
for (line = or_state->TransportProxies ; line ; line = line->next) {
|
||||||
config_line_t *search = *value;
|
tor_assert(!strcmp(line->key, "TransportProxy"));
|
||||||
|
if (!strcmpstart(line->value, transport))
|
||||||
while (search) {
|
return line;
|
||||||
if (!strcmpstart(search->value, transport))
|
|
||||||
return search;
|
|
||||||
|
|
||||||
search = search->next;
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue