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.
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 184.108.40.206:9001 for Torlol2
[debug] onion_extend_cpath(): Chose router $D12BDD8E7C1C3EDBBDB2FCFF173D8314C8B1E620~Torlol2 at 220.127.116.11 for hop 2 (exit is yahyaoui)