TheTorProject / bwscanner

Bandwidth authority scanner. This project is deprecated in favour of https://gitlab.torproject.org/tpo/network-health/sbws
GNU General Public License v2.0
38 stars 32 forks source link

Refactor Tor connection and configuration code #67

Closed DonnchaC closed 6 years ago

DonnchaC commented 6 years ago

This PR primarily refactors how connections are made to the Tor control port. The code now uses the Txtorcon high-level interfaces to either run a new Tor daemon or to connect to a running Tor (txtorcon.launch and txtorcon.connect respectively). Both the unit tests and main tool now use the same Tor connection interface.

Tor configuration options are now applied via the Txtorcon TorConfig object which handles marking changed options and applying the changes all at one. There was an issue when setting the UseMicroDescriptors option as this would cause Tor to throw away its descriptors and request new ones. As a result the tests would fail when they were run before all the descriptors were received.

The fix was to wait for a NEWCONSENSUS event after changing an option that required a consensus be loaded.

This PR also fixes some other small issues and renames the self.tor TorState object to self.tor_state to make the code more clear.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+3.5%) to 54.748% when pulling 78b0c8cf7ab472ef08fa7d6f3cfa2429c39e2f7c on tor-conn-fixes into ff86b302ff1c1ef395b9e38f60775be9e9217f94 on develop.

DonnchaC commented 6 years ago

We may be able to simplify some of this configuration update code when meejah/txtorcon#278 is implemented.