mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
router_choose_random_node wants a smartlist of routers, not of nicknames.
svn:r1510
This commit is contained in:
parent
2fc106d210
commit
8b371c2aa5
@ -208,6 +208,11 @@ void smartlist_set_capacity(smartlist_t *sl, int n) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Remove all elements from the list. */
|
||||||
|
void smartlist_clear(smartlist_t *sl) {
|
||||||
|
sl->num_used = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* add element to the list, but only if there's room */
|
/* add element to the list, but only if there's room */
|
||||||
void smartlist_add(smartlist_t *sl, void *element) {
|
void smartlist_add(smartlist_t *sl, void *element) {
|
||||||
if (sl->num_used >= sl->capacity) {
|
if (sl->num_used >= sl->capacity) {
|
||||||
|
@ -102,6 +102,7 @@ typedef struct smartlist_t smartlist_t;
|
|||||||
smartlist_t *smartlist_create();
|
smartlist_t *smartlist_create();
|
||||||
void smartlist_free(smartlist_t *sl);
|
void smartlist_free(smartlist_t *sl);
|
||||||
void smartlist_set_capacity(smartlist_t *sl, int n);
|
void smartlist_set_capacity(smartlist_t *sl, int n);
|
||||||
|
void smartlist_clear(smartlist_t *sl);
|
||||||
void smartlist_add(smartlist_t *sl, void *element);
|
void smartlist_add(smartlist_t *sl, void *element);
|
||||||
void smartlist_remove(smartlist_t *sl, void *element);
|
void smartlist_remove(smartlist_t *sl, void *element);
|
||||||
int smartlist_isin(smartlist_t *sl, void *element);
|
int smartlist_isin(smartlist_t *sl, void *element);
|
||||||
|
@ -651,10 +651,13 @@ int rend_services_init(void) {
|
|||||||
rend_service_t *service;
|
rend_service_t *service;
|
||||||
char *desc, *intro;
|
char *desc, *intro;
|
||||||
int changed, prev_intro_nodes, desc_len;
|
int changed, prev_intro_nodes, desc_len;
|
||||||
|
smartlist_t *intro_routers;
|
||||||
|
|
||||||
router_get_routerlist(&rl);
|
router_get_routerlist(&rl);
|
||||||
|
intro_routers = smartlist_create();
|
||||||
|
|
||||||
for (i=0; i< smartlist_len(rend_service_list); ++i) {
|
for (i=0; i< smartlist_len(rend_service_list); ++i) {
|
||||||
|
smartlist_clear(intro_routers);
|
||||||
service = smartlist_get(rend_service_list, i);
|
service = smartlist_get(rend_service_list, i);
|
||||||
|
|
||||||
assert(service);
|
assert(service);
|
||||||
@ -667,6 +670,7 @@ int rend_services_init(void) {
|
|||||||
smartlist_del(service->intro_nodes,j--);
|
smartlist_del(service->intro_nodes,j--);
|
||||||
changed = 1;
|
changed = 1;
|
||||||
}
|
}
|
||||||
|
smartlist_add(intro_routers, router);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We have enough intro points, and the intro points we thought we had were
|
/* We have enough intro points, and the intro points we thought we had were
|
||||||
@ -683,13 +687,14 @@ int rend_services_init(void) {
|
|||||||
router = router_choose_random_node(rl,
|
router = router_choose_random_node(rl,
|
||||||
service->intro_prefer_nodes,
|
service->intro_prefer_nodes,
|
||||||
service->intro_exclude_nodes,
|
service->intro_exclude_nodes,
|
||||||
service->intro_nodes);
|
intro_routers);
|
||||||
if (!router) {
|
if (!router) {
|
||||||
log_fn(LOG_WARN, "Can't establish more than %d introduction points",
|
log_fn(LOG_WARN, "Can't establish more than %d introduction points",
|
||||||
smartlist_len(service->intro_nodes));
|
smartlist_len(service->intro_nodes));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
changed = 1;
|
changed = 1;
|
||||||
|
smartlist_add(intro_routers, router);
|
||||||
smartlist_add(service->intro_nodes, tor_strdup(router->nickname));
|
smartlist_add(service->intro_nodes, tor_strdup(router->nickname));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -719,6 +724,8 @@ int rend_services_init(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
smartlist_free(intro_routers);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user