2018-07-10 17:01:07 +02:00
|
|
|
|
|
|
|
TODO: revise this to talk about how things are, rather than how things
|
|
|
|
have changed.
|
|
|
|
|
2019-08-21 16:22:08 +02:00
|
|
|
For quite a while now, the program *tor* has been built from source
|
|
|
|
code in just two directories: **src/common** and **src/or**.
|
2018-07-10 17:01:07 +02:00
|
|
|
|
|
|
|
This has become more-or-less untenable, for a few reasons -- most
|
|
|
|
notably of which is that it has led our code to become more
|
|
|
|
spaghetti-ish than I can endorse with a clean conscience.
|
|
|
|
|
|
|
|
So to fix that, we've gone and done a huge code movement in our git
|
2019-08-21 16:22:08 +02:00
|
|
|
master branch, which will land in a release once Tor `0.3.5.1-alpha` is
|
2018-07-10 17:01:07 +02:00
|
|
|
out.
|
|
|
|
|
|
|
|
Here's what we did:
|
|
|
|
|
2019-08-21 16:22:08 +02:00
|
|
|
* **src/common** has been turned into a set of static libraries. These
|
|
|
|
all live in the **src/lib/*** directories. The dependencies between
|
2018-07-10 17:01:07 +02:00
|
|
|
these libraries should have no cycles. The libraries are:
|
|
|
|
|
2019-08-21 16:22:08 +02:00
|
|
|
- **arch** -- Headers to handle architectural differences
|
|
|
|
- **cc** -- headers to handle differences among compilers
|
|
|
|
- **compress** -- wraps zlib, zstd, lzma
|
|
|
|
- **container** -- high-level container types
|
|
|
|
- **crypt_ops** -- Cryptographic operations. Planning to split this into
|
2018-07-10 17:01:07 +02:00
|
|
|
a higher and lower level library
|
2019-08-21 16:22:08 +02:00
|
|
|
- **ctime** -- Operations that need to run in constant-time. (Properly,
|
2018-07-10 17:01:07 +02:00
|
|
|
data-invariant time)
|
2019-08-21 16:22:08 +02:00
|
|
|
- **defs** -- miscelaneous definitions needed throughout Tor.
|
|
|
|
- **encoding** -- transforming one data type into another, and various
|
2018-07-10 17:01:07 +02:00
|
|
|
data types into strings.
|
2019-08-21 16:22:08 +02:00
|
|
|
- **err** -- lowest-level error handling, in cases where we can't use
|
2018-07-10 17:01:07 +02:00
|
|
|
the logs because something that the logging system needs has broken.
|
2019-08-21 16:22:08 +02:00
|
|
|
- **evloop** -- Generic event-loop handling logic
|
|
|
|
- **fdio** -- Low-level IO wrapper functions for file descriptors.
|
|
|
|
- **fs** -- Operations on the filesystem
|
|
|
|
- **intmath** -- low-level integer math and misc bit-twiddling hacks
|
|
|
|
- **lock** -- low-level locking code
|
|
|
|
- **log** -- Tor's logging module. This library sits roughly halfway up
|
2018-07-10 17:01:07 +02:00
|
|
|
the library dependency diagram, since everything it depends on has to
|
|
|
|
be carefully crafted to *not* log.
|
2019-08-21 16:22:08 +02:00
|
|
|
- **malloc** -- Low-level wrappers for the platform memory allocation functions.
|
|
|
|
- **math** -- Higher-level mathematical functions, and floating-point math
|
|
|
|
- **memarea** -- An arena allocator
|
|
|
|
- **meminfo** -- Functions for querying the current process's memory
|
2018-07-10 17:01:07 +02:00
|
|
|
status and resources
|
2019-08-21 16:22:08 +02:00
|
|
|
- **net** -- Networking compatibility and convenience code
|
|
|
|
- **osinfo** -- Querying information about the operating system
|
|
|
|
- **process** -- Launching and querying the status of other processes
|
|
|
|
- **sandbox** -- Backend for the linux seccomp2 sandbox
|
|
|
|
- **smartlist_core** -- The lowest-level of the smartlist_t data type.
|
2018-07-10 17:01:07 +02:00
|
|
|
Separated from the rest of the containers library because the logging
|
|
|
|
subsystem depends on it.
|
2019-08-21 16:22:08 +02:00
|
|
|
- **string** -- Compatibility and convenience functions for manipulating
|
2018-07-10 17:01:07 +02:00
|
|
|
C strings.
|
2019-08-21 16:22:08 +02:00
|
|
|
- **term** -- Terminal-related functions (currently limited to a getpass
|
2018-07-10 17:01:07 +02:00
|
|
|
function).
|
2019-08-21 16:22:08 +02:00
|
|
|
- **testsupport** -- Macros for mocking, unit tests, etc.
|
|
|
|
- **thread** -- Higher-level thread compatibility code
|
|
|
|
- **time** -- Higher-level time management code, including format
|
2018-07-10 17:01:07 +02:00
|
|
|
conversions and monotonic time
|
2019-08-21 16:22:08 +02:00
|
|
|
- **tls** -- Our wrapper around our TLS library
|
|
|
|
- **trace** -- Formerly src/trace -- a generic event tracing API
|
|
|
|
- **wallclock** -- Low-level time code, used by the log module.
|
2018-07-10 17:01:07 +02:00
|
|
|
|
2019-08-21 16:22:08 +02:00
|
|
|
* To ensure that the dependency graph in **src/common** remains under
|
|
|
|
control, there is a tool that you can run called `make
|
|
|
|
check-includes`. It verifies that each module in Tor only includes
|
2018-07-10 17:01:07 +02:00
|
|
|
the headers that it is permitted to include, using a per-directory
|
2019-08-21 16:22:08 +02:00
|
|
|
*.may_include* file.
|
2018-07-10 17:01:07 +02:00
|
|
|
|
2019-08-21 16:22:08 +02:00
|
|
|
* The **src/or/or.h** header has been split into numerous smaller
|
2018-07-10 17:01:07 +02:00
|
|
|
headers. Notably, many important structures are now declared in a
|
2019-08-21 16:22:08 +02:00
|
|
|
header called *foo_st.h*, where "foo" is the name of the structure.
|
2018-07-10 17:01:07 +02:00
|
|
|
|
2019-08-21 16:22:08 +02:00
|
|
|
* The **src/or** directory, which had most of Tor's code, had been split
|
2018-07-10 17:01:07 +02:00
|
|
|
up into several directories. This is still a work in progress: This
|
|
|
|
code has not itself been refactored, and its dependency graph is still
|
|
|
|
a tangled web. I hope we'll be working on that over the coming
|
|
|
|
releases, but it will take a while to do.
|
|
|
|
|
2019-08-21 16:22:08 +02:00
|
|
|
- The new top-level source directories are:
|
|
|
|
- **src/core** -- Code necessary to actually perform or use onion routing.
|
|
|
|
- **src/feature** -- Code used only by some onion routing
|
2018-07-10 17:01:07 +02:00
|
|
|
configurations, or only for a special purpose.
|
2019-08-21 16:22:08 +02:00
|
|
|
- **src/app** -- Top-level code to run, invoke, and configure the
|
2018-07-10 17:01:07 +02:00
|
|
|
lower-level code
|
|
|
|
|
2019-08-21 16:22:08 +02:00
|
|
|
- The new second-level source directories are:
|
|
|
|
- **src/core/crypto** -- High-level cryptographic protocols used in Tor
|
|
|
|
- **src/core/mainloop** -- Tor's event loop, connection-handling, and
|
2018-07-10 17:01:07 +02:00
|
|
|
traffic-routing code.
|
2019-08-21 16:22:08 +02:00
|
|
|
- **src/core/or** -- Parts related to handling onion routing itself
|
|
|
|
- **src/core/proto** -- support for encoding and decoding different
|
2018-07-10 17:01:07 +02:00
|
|
|
wire protocols
|
2019-08-21 16:22:08 +02:00
|
|
|
- **src/feature/api** -- Support for making Tor embeddable
|
|
|
|
- **src/feature/client** -- Functionality which only Tor clients need
|
|
|
|
- **src/feature/control** -- Controller implementation
|
|
|
|
- **src/feature/dirauth** -- Directory authority
|
|
|
|
- **src/feature/dircache** -- Directory cache
|
|
|
|
- **src/feature/dirclient** -- Directory client
|
|
|
|
- **src/feature/dircommon** -- Shared code between the other directory modules
|
|
|
|
- **src/feature/hibernate** -- Hibernating when Tor is out of bandwidth
|
2018-07-10 17:01:07 +02:00
|
|
|
or shutting down
|
2019-08-21 16:22:08 +02:00
|
|
|
- **src/feature/hs** -- v3 onion service implementation
|
|
|
|
- **src/feature/hs_common** -- shared code between both onion service
|
2018-07-10 17:01:07 +02:00
|
|
|
implementations
|
2019-08-21 16:22:08 +02:00
|
|
|
- **src/feature/nodelist** -- storing and accessing the list of relays on
|
2018-07-10 17:01:07 +02:00
|
|
|
the network.
|
2019-08-21 16:22:08 +02:00
|
|
|
- **src/feature/relay** -- code that only relay servers and exit servers need.
|
|
|
|
- **src/feature/rend** -- v2 onion service implementation
|
|
|
|
- **src/feature/stats** -- statistics and history
|
|
|
|
- **src/app/config** -- configuration and state for Tor
|
|
|
|
- **src/app/main** -- Top-level functions to invoke the rest or Tor.
|
2018-07-10 17:01:07 +02:00
|
|
|
|
2019-08-21 16:22:08 +02:00
|
|
|
* The `tor` executable is now built in **src/app/tor** rather than **src/or/tor**.
|
2018-07-10 17:01:07 +02:00
|
|
|
|
|
|
|
* There are more static libraries than before that you need to build
|
|
|
|
into your application if you want to embed Tor. Rather than
|
2019-08-21 16:22:08 +02:00
|
|
|
maintaining this list yourself, I recommend that you run `make
|
|
|
|
show-libs` to have Tor emit a list of what you need to link.
|