diff options
author | Mike Perry <mikeperry-git@torproject.org> | 2018-10-23 21:02:31 +0000 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2019-01-02 15:25:55 +0200 |
commit | 8ad497bb578b13c66489843905764a60545e6388 (patch) | |
tree | d0ec9e5259c5beb6d882f461f5506c83df009018 /src/core | |
parent | a336d816a68e5eaddd9d80f7179699274b367a1d (diff) | |
download | tor-8ad497bb578b13c66489843905764a60545e6388.tar.gz tor-8ad497bb578b13c66489843905764a60545e6388.zip |
Config option to specify specific MiddleNodes.
Hope is this will make it easier to test on the live tor network.
Does not need to be merged if we don't want to, but will come in handy
for researchers.
Co-authored-by: George Kadianakis <desnacked@riseup.net>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/or/circuitbuild.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/core/or/circuitbuild.c b/src/core/or/circuitbuild.c index 2d8bc4d4ad..22e4cf96d8 100644 --- a/src/core/or/circuitbuild.c +++ b/src/core/or/circuitbuild.c @@ -2610,7 +2610,24 @@ choose_good_middle_server(uint8_t purpose, return choice; } - choice = router_choose_random_node(excluded, options->ExcludeNodes, flags); + if (options->MiddleNodes) { + smartlist_t *sl = smartlist_new(); + routerset_get_all_nodes(sl, options->MiddleNodes, + options->ExcludeNodes, 1); + + smartlist_subtract(sl, excluded); + + choice = node_sl_choose_by_bandwidth(sl, WEIGHT_FOR_MID); + smartlist_free(sl); + if (choice) { + log_fn(LOG_INFO, LD_CIRC, "Chose fixed middle node: %s", + hex_str(choice->identity, DIGEST_LEN)); + } else { + log_fn(LOG_NOTICE, LD_CIRC, "Restricted middle not available"); + } + } else { + choice = router_choose_random_node(excluded, options->ExcludeNodes, flags); + } smartlist_free(excluded); return choice; } |