Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleanup(sessionresolver): don't depend on netx
This diff closes ooni/probe#2121 because it removes the last unnecessary netx usage. All the other packages that currently use netx are network experiments. We will eventually convert them to not use netx as part of other tracked issues. This diff closes ooni/probe#2135 because now the sessionresolver does not depend on netx anymore. We refactor the way in which we conditionally configure byte counting for HTTP such that we use a free function rather than a method (we can use methods with nil receiver in Go, but the free function seems to be a better choice in this case). We introduce and use a new bytecounter specifically for the system resolver. This byte counter is very imprecise but seems still better than using the system resolver doesn't use any network I/O. We stop printing the sessionresolver stats when we close a session, since this component has been in production for years now. We improve the model.UnderlyingNetwork model to add support for changing the root cert pool, which helps with writing some integration tests. We modify the protocol to use and modify the netxlite tproxy (a singleton instance of UnderlyingNetwork) to make it goroutine safe. We introduce a new file inside sessionresolver, factory.go, which creates and properly wraps the resolvers. This code replaces code for which we previously used netx, and is the core change introduced here. While there, we refactor how we log in the session resolver to use the operation logger as we do in some experiments. We write some additional tests that take advantage of the new netxlite tproxy mocking functionality to ensure the sessionresolver continues to work in two extreme use cases: no resolver is available and just the system resolver is available. I introduced these new tests because I originally broke the system resolver when I introduced factory.go and I felt like it was useful to have more robustness here.
- Loading branch information