Maybe refactor CircMgr to get NetDir objects directly?
There are several places where CircMgr
's interface takes a NetDir
or DirInfo
object as an argument. This mostly works, but there are a few places where it makes things inconvenient.
Notably, it requires arti-tor-client
to pass messages from the DirMgr
to the CircMgr
when the directory or network parameters change. It also requires arti-tor-client
to periodically invoke launch_timeout_testing_circuit_if_appropriate
. Both of these functions would be better handled as part of tor-circmgr
crate, I think.
But there are some factors that make it hard to let CircMgr
get a NetDir
directly:
-
DirMgr
needs usesCircMgr
to make BEGINDIR circuits, so it has to exist at a higher level thanCircMgr
. That means that you can't easily giveCircMgr
a reference to theDirMgr
that would give it aNetDir
without doing something to break circularity. - The
DirMgr
design is more efficient if nobody ever keeps a reference to aNetDir
longer than they need to. (SeeSharedMutArc::mutate()
andregister_microdescs
inDirMgr
.) - For testing, it's actually pretty convenient for most
CircMgr
APIs to sometimes take aNetDir
as an argument rather than have it stored as a member locally.
This will need some careful thought. Please reach out before hacking here: there are a lot of approaches that won't work, and any approach we do take has architectural implications for the future of Arti.