aboutsummaryrefslogtreecommitdiff
path: root/src/or/routerlist.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/or/routerlist.c')
-rw-r--r--src/or/routerlist.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 2db72722d..6382248e4 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -5046,6 +5046,47 @@ hid_serv_get_responsible_directories(smartlist_t *responsible_dirs,
return smartlist_len(responsible_dirs) ? 0 : -1;
}
+int
+hid_serv_get_introduction_points(smartlist_t *introduction_points,
+ int number,
+ smartlist_t *excludedsmartlist,
+ const char *id)
+{
+ int start, found, i;
+
+ networkstatus_t *c = networkstatus_get_latest_consensus();
+ if (!c || !smartlist_len(c->routerstatus_list)) {
+ log_warn(LD_REND, "We don't have a consensus, so determine introduction "
+ "points");
+ return -1;
+ }
+ tor_assert(id);
+ start = networkstatus_vote_find_entry_idx(c, id, &found);
+ if (start == smartlist_len(c->routerstatus_list)) start = 0;
+ i = start;
+ do {
+ routerstatus_t *r = smartlist_get(c->routerstatus_list, i);
+
+ node_t *node = node_get_by_id(r->identity_digest);
+
+ if (!excludedsmartlist || !smartlist_contains(excludedsmartlist, node)) {
+ smartlist_add(introduction_points, node);
+ if (--number <= 0)
+ return 0;
+ } else {
+ log_warn(LD_REND, "Ignoring node %s ",
+ safe_str_client(node_describe(node)));
+ }
+
+ if (++i == smartlist_len(c->routerstatus_list))
+ i = 0;
+ } while (i != start);
+
+ /* Even though we don't have the desired number of hidden service
+ * directories, be happy if we got any. */
+ return smartlist_len(introduction_points) ? 0 : -1;
+}
+
/** Return true if this node is currently acting as hidden service
* directory, false otherwise. */
int