Looking at the tor daemon source code

coderman coderman at protonmail.com
Tue Oct 13 14:42:28 PDT 2020


‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Monday, October 12, 2020 10:36 PM, Karl <gmkarl at gmail.com> wrote:
...
>     `tor_main` appears to be in tor_api.c .  If you want to memorize the
>     basics of how tor works, that's the next file to look in.  That's all
>     for now, folks!


for Unix like systems, you will enter tor here:
  https://github.com/torproject/tor/blob/master/src/app/main/main.c#L538

note that here you setup environment, signal handling, read configs, setup services (like hs, tracing, etc.) and then begin the main loop.

tor's main loop enters here:
  https://github.com/torproject/tor/blob/master/src/core/mainloop/mainloop.c#L2340

you can see how the first time through, various one-time tasks are done, then afterward all threads in the event thread pool just process read/write events, again and again :)


if you're thinking of circuit padding, consider the client-edge padding capability already built:
  https://github.com/torproject/tor/blob/master/src/core/or/circuitpadding.c#L10

you could monitor sockets and streams for activity, then queue chaff traffic if needed to fill in toward target rate, or some time-delayed logarithmic fall-off...


have fun!

best regards,


More information about the cypherpunks mailing list