[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [tor-talk] How does Tor REALLY work?
On Sat, Mar 5, 2011 at 7:29 AM, <hikki@xxxxxxxxxxxxx> wrote:
> I mean _really_ work.
> (I already know how it protects your anonymity.)
> What happens from the moment you start the Tor program? What's the first
> thing it does, the next thing, and so forth? I've never seen a detailed
> technical illustration of how it works on a technical level.
You mean, which parts of the code call what, and how they all fit
together? I'm afraid we haven't written anything like that. I'd love
for somebody to start writing one, but for now, learning how the code
all fits together will require you to read some C.
If you're still interested, here are some good points to start with:
- The tor program does most of its work in the main thread. The
main thread is written launches operations in response to events,
which include network IO, timers, and signals. Tor uses libevent to
notice these events. The starting point for handling network IO
events (in 0.2.2) is conn_read_callback and conn_write_callback. The
starting point for handling signals is signal_callback. The starting
point for invoking periodic timers is second_elapsed_callback. These
are all in src/or/main.c.
- There are also subthreads to handle CPU-intensive tasks. Right
now, they only handle onionskins.
- To see how the program starts up, start with the function
tor_main() in src/or/main.c. When Tor is run, it invokes
do_main_loop(), which sets up more of the global state, and then
spends most of its time in a loop. The loop's main job is to call
event_base_loop(): this is where Tor spends most of its time.
Again, this is just a sketch of interesting points to start reading a
top-down tour of the program, and isn't a "tor internals guide" by any
means. If somebody has time to write one someday, that would rock.
tor-talk mailing list