I'm modifying tor source code for research purposes and I want to modify concept of getting tor nodes list. Now, tor client is getting tor nodes from directory servers and I want to change it.

My question is, where can I find piece of code where this process is done? My current version of tor is cloned from git repository.

1 Answer 1


Three important files you'll want to look at are:

  • feature/dirclient/dirclient.c
  • feature/nodelist/networkstatus.c
  • feature/nodelist/routerlist.c

You might want to start at fetch_networkstatus_callback() which is the callback triggered by the eventloop to download new directory documents. Without knowing more about what you want to do, I can't suggest specific parts of the code to look at.

  • I want to build new system of getting nodes. Nowadays, clients are getting tor nodes only from directory servers. I want to build blockchain protocol to distribute available tor nodes with consensus protocol. Mar 4, 2021 at 22:36
  • Okay, the existing network status code isn't very flexible, so you'll probably want to re-write a lot of the existing network status code.
    – Steve
    Mar 4, 2021 at 22:58
  • Method fetch_networkstatus_callback() is periodically invoking, and is also invoking when new client wants to join tor network and create circuit? Mar 4, 2021 at 23:17
  • That function is run once per second when tor is bootstrapping. Other than on a HUP signal, I'm not sure if there are any other places that trigger a directory download.
    – Steve
    Mar 4, 2021 at 23:40
  • And where I can find these downloaded relays from directory authorities? Mar 5, 2021 at 13:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .