Skip to content
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 9 commits into from
Feb 1, 2023
Merged

Conversation

bassosimone
Copy link
Contributor

@bassosimone bassosimone commented Feb 1, 2023

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.

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 bassosimone requested a review from hellais as a code owner February 1, 2023 16:50
internal/bytecounter/resolver.go Outdated Show resolved Hide resolved
internal/bytecounter/resolver.go Outdated Show resolved Hide resolved
internal/sessionresolver/resolvermaker.go Outdated Show resolved Hide resolved
internal/sessionresolver/factory.go Outdated Show resolved Hide resolved
internal/sessionresolver/factory.go Outdated Show resolved Hide resolved
internal/sessionresolver/factory.go Outdated Show resolved Hide resolved
internal/sessionresolver/factory_test.go Outdated Show resolved Hide resolved
@bassosimone bassosimone merged commit 7485153 into master Feb 1, 2023
@bassosimone bassosimone deleted the issue/2135 branch February 1, 2023 17:24
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
Labels
None yet
Projects
None yet
1 participant