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

Use new Lantern Cloud domain for domain fronting, ensure appropriate requests are fronted #1191

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

hwh33
Copy link
Contributor

@hwh33 hwh33 commented Sep 29, 2024

Resolves https://github.com/getlantern/engineering/issues/1429.

This PR can be reviewed by looking at commits individually - each represents a separate step. Some are cosmetic - I noticed a fair bit of unused or misleading code. I'm happy to back those changes out if preferred.

As these changes affect much of the client's ability to communicate with the back-end, I want to run some thorough tests before merging. Thus I am opening this as a draft. I will mark it ready when I've tested the client.

go.mod Outdated
@@ -38,7 +38,7 @@ require (
github.com/getlantern/eventual v1.0.0
github.com/getlantern/eventual/v2 v2.0.2
github.com/getlantern/filepersist v0.0.0-20210901195658-ed29a1cb0b7c
github.com/getlantern/flashlight/v7 v7.6.111
github.com/getlantern/flashlight/v7 v7.6.112-0.20240929144745-72a54c5a4e73
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This includes changes from the unmerged flashlight counterpart: getlantern/flashlight#1416

When I've tested these changes thoroughly, I will merge the flashlight PR in and update this reference.

Comment on lines -17 to -22
Transport: proxied.AsRoundTripper(
func(req *http.Request) (*http.Response, error) {
log.Tracef("Pro client processing request to: %v (%v)", req.Host, req.URL.Host)
return rt.RoundTrip(req)
},
),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't really do anything. proxied.AsRoundTripper is a utility function which simply converts a function to a http.RoundTripper. The request is not necessarily proxied. IMO proxied.AsRoundTripper is misleading and should never have been added to the public API of the proxied package.

I removed NewHTTPClient because it only adds complexity and reader overhead. Instead of calls like:

client := NewHTTPClient(someTransport, timeout)

It's more straight-forward and readable to say:

client := &http.Client{
    Transport: someRoundTripper,
    Timeout: timeout,
}

I understand that this is opinionated. Let me know if you'd like me to revert this change.

Copy link
Contributor

@atavism atavism Sep 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @hwh33! If we shouldn't be using proxied.AsRoundTripper, is it possible to remove it from the proxied package on the flashlight PR and any remaining references to it from the internalsdk? In particular, we need to update replica here.

"github.com/getlantern/lantern-client/internalsdk/protos"
)

type proxyTransport struct {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not only was this unused, it's name was misleading. It does not actually proxy requests. I believe the misunderstanding may have been rooted in the use of proxied.AsRoundTripper by NewHTTPClient - see my comment about this here.

@hwh33 hwh33 changed the title Harry/1429 Use new Lantern Cloud domain for domain fronting, ensure appropriate requests are fronted Sep 29, 2024
@hwh33
Copy link
Contributor Author

hwh33 commented Sep 29, 2024

I'm not planning to add reviewers until I look into the CI failure and do some manual testing. Feel free to take a look and comment if you'd like though!

@atavism
Copy link
Contributor

atavism commented Oct 28, 2024

@hwh33 I fixed the merge conflict on this branch: https://github.com/getlantern/lantern-client/tree/atavism/ios-1625

Assuming it's okay to merge the changes here, but let me know and I'm happy to revert them

@hwh33
Copy link
Contributor Author

hwh33 commented Oct 28, 2024

Yep, that's great, thank you!

I'm still planning to do some manual testing with this work, just haven't had a chance yet. Hopefully this week!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants