implement complete shutdown when idle
To make the TorService
work even more like a proper Android Service
, TorServices should shut itself down entirely when tor detects all circuits are closed/inactive and goes dormant.
The model is that the app sends TorServices a message when it needs networking, it starts up based on cached info, which is often really fast, like a couple of seconds. Then when nothing is using tor, it should shutdown entirely.
Tor has "dormant" mode, which implements a version of that, but it seems that it does not send an event when it goes into dormant mode. There might be a way to make the TorService
shutdown when tor goes into dormant mode.
These are some useful torrc options that hopefully can also be sent via the control port:
-
DormantClientTimeout
defaults to 24 hours, so it will need to be much shorter for this use case -
DormantCanceledByStartup 1
will be useful to ensure that tor is active the next timeTorService
starts -
DormantTimeoutDisabledByIdleStreams
could prove useful, I'm not yet sure whether TorServices should stay running based on network activity or active connections.