-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cleanup(sessionresolver): don't depend on netx #1068
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
bassosimone
commented
Feb 1, 2023
bassosimone
added a commit
that referenced
this pull request
Feb 1, 2023
This diff tweaks #1068 to make sure overriding the default cert pool works. In #1068 we introduced code to add this functionality but we never tested it was working as intended. It turns out it was not! Because this diff amends the previous diff, we'll consider it part of ooni/probe#2135.
bassosimone
added a commit
that referenced
this pull request
Feb 1, 2023
This diff tweaks #1068 to make sure overriding the default cert pool works. In #1068 we introduced code to add this functionality but we never tested it was working as intended. It turns out it was not! Because this diff amends the previous diff, we'll consider it part of ooni/probe#2135.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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. (I did not manage to write a test for this but it felt good code to include anyway.)
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.