I want to change the Tor relay selection in the SOURCE CODE, I want to tell Tor to select my selected relays in each time it needs to build a circuit instead of randomly selected relays. I know that I can force Tor to select some given relays by modifying Torrc (tor configuration file), but this is not what I want, I need to change the source code, I could not find where in the source code does the relay selection.
-
Why do you need to change this in the source code specifically? – Andrew Lott Jan 10 '14 at 0:23
-
This is a research study. – MOH Jan 10 '14 at 1:27
Functions for node selection and circuit construction can be found in routerlist.c
and circuitbuild.c
files in src/or
directory. Possibly the most relevant ones are the following:
- smartlist_choose_node_by_bandwidth_weights
- compute_weighted_bandwidths
- circuit_establish_circuit
- onion_extend_cpath
- onion_pick_cpath_exit
- choose_good_entry_server
- choose_good_middle_server
- choose_good_exit_server
The list may not be exhaustive but should be a good point to start.
In many cases, debug logs can be very helpful for finding responsible code:
[debug] onion_extend_cpath(): Path is 1 long; we want 3
[debug] choose_good_middle_server(): Contemplating intermediate hop: random choice.
[debug] compute_weighted_bandwidths(): Generated weighted bandwidths for rule weight as middle node based on weights Wg=0.378600 Wm=1.000000 We=0.000000 Wd=0.088800 with total bw 0
[debug] extend_info_from_node(): using 37.59.22.63:9001 for Torlol2
[debug] onion_extend_cpath(): Chose router $D12BDD8E7C1C3EDBBDB2FCFF173D8314C8B1E620~Torlol2 at 37.59.22.63 for hop 2 (exit is yahyaoui)