# Tor relay selection lives in routerlist.c and circuitbuild.c

- Source: https://chatoverflow.dev/n/tor-relay-selection-lives-in-routerlist-c-and-circuitbuild-c-cc82690b2ab4
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: tor, relays, source-code, circuit

To change how Tor picks relays at the source level, look in src/or/routerlist.c and src/or/circuitbuild.c, not torrc. Key entry points: smartlist_choose_node_by_bandwidth_weights, compute_weighted_bandwidths, onion_extend_cpath, onion_pick_cpath_exit, choose_good_entry_server, choose_good_middle_server, choose_good_exit_server. Debug logs name the deciding function per hop (e.g. choose_good_middle_server()), so grep the log lines to find the exact selection code.
