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
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion desktop/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
"strings"
"time"

"github.com/joho/godotenv"

"github.com/getlantern/appdir"
"github.com/getlantern/errors"
"github.com/getlantern/flashlight/v7"

Check failure on line 18 in desktop/lib.go

View workflow job for this annotation

GitHub Actions / build

git -c core.autocrlf=input -c core.eol=lf archive --format=zip --prefix=prefix/ f1a94e2598cfb822a9d760fb330f28600b998ed9 in /home/runner/go/pkg/mod/cache/vcs/36e8750ce80f175e2587645e1b9071ded4d6b22314004281134a85302af8af99: exit status 128:
"github.com/getlantern/flashlight/v7/issue"

Check failure on line 19 in desktop/lib.go

View workflow job for this annotation

GitHub Actions / build

git -c core.autocrlf=input -c core.eol=lf archive --format=zip --prefix=prefix/ f1a94e2598cfb822a9d760fb330f28600b998ed9 in /home/runner/go/pkg/mod/cache/vcs/36e8750ce80f175e2587645e1b9071ded4d6b22314004281134a85302af8af99: exit status 128:
"github.com/getlantern/flashlight/v7/logging"

Check failure on line 20 in desktop/lib.go

View workflow job for this annotation

GitHub Actions / build

git -c core.autocrlf=input -c core.eol=lf archive --format=zip --prefix=prefix/ f1a94e2598cfb822a9d760fb330f28600b998ed9 in /home/runner/go/pkg/mod/cache/vcs/36e8750ce80f175e2587645e1b9071ded4d6b22314004281134a85302af8af99: exit status 128:
"github.com/getlantern/flashlight/v7/ops"

Check failure on line 21 in desktop/lib.go

View workflow job for this annotation

GitHub Actions / build

git -c core.autocrlf=input -c core.eol=lf archive --format=zip --prefix=prefix/ f1a94e2598cfb822a9d760fb330f28600b998ed9 in /home/runner/go/pkg/mod/cache/vcs/36e8750ce80f175e2587645e1b9071ded4d6b22314004281134a85302af8af99: exit status 128:
"github.com/getlantern/golog"
"github.com/getlantern/jibber_jabber"
"github.com/getlantern/lantern-client/desktop/app"
Expand All @@ -26,7 +28,6 @@
"github.com/getlantern/lantern-client/internalsdk/common"
"github.com/getlantern/lantern-client/internalsdk/protos"
"github.com/getlantern/osversion"
"github.com/joho/godotenv"
)

import "C"
Expand Down
2 changes: 1 addition & 1 deletion internalsdk/android.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ func run(configDir, locale string, settings Settings, wrappedSession Session) {
config.ForceCountry(forcedCountryCode)
}

userConfig := newUserConfig(session)
userConfig := &userConfig{session}
globalConfigChanged := make(chan interface{})
geoRefreshed := geolookup.OnRefresh()

Expand Down
22 changes: 4 additions & 18 deletions internalsdk/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ package auth

import (
"context"
"time"

"fmt"
"net/http"
"strings"
"time"

"github.com/getlantern/flashlight/v7/proxied"
"github.com/getlantern/golog"
"github.com/getlantern/lantern-client/internalsdk/common"
"github.com/getlantern/lantern-client/internalsdk/pro"
"github.com/getlantern/lantern-client/internalsdk/protos"
"github.com/getlantern/lantern-client/internalsdk/webclient"

Expand Down Expand Up @@ -52,21 +50,9 @@ type AuthClient interface {

// NewClient creates a new instance of AuthClient
func NewClient(baseURL string, userConfig func() common.UserConfig) AuthClient {
// The default http.RoundTripper is ChainedNonPersistent which proxies requests through chained servers
// and does not use keep alive connections. Since no root CA is specified, we do not need to check for an error.

var httpClient *http.Client

if baseURL == fmt.Sprintf("https://%s", common.APIBaseUrl) {
log.Debug("using proxied.Fronted")
//this is ios version
httpClient = &http.Client{
Transport: proxied.Fronted(30 * time.Second),
}
} else {
log.Debug("using proxied.ChainedNonPersistent")
rt, _ := proxied.ChainedNonPersistent("")
httpClient = pro.NewHTTPClient(rt, 30*time.Second)
atavism marked this conversation as resolved.
Show resolved Hide resolved
httpClient := &http.Client{
Transport: proxied.ChainedThenFronted(),
atavism marked this conversation as resolved.
Show resolved Hide resolved
Timeout: 30 * time.Second,
}

rc := webclient.NewRESTClient(&webclient.Opts{
Expand Down
14 changes: 8 additions & 6 deletions internalsdk/common/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,15 @@ var (
// GlobalStagingURL is the URL for fetching the global config in a staging environment.
GlobalStagingURL = "https://globalconfig.flashlightproxy.com/global.yaml.gz"

ProAPIHost = "api.getiantem.org"
// ProAPIBaseURL is the URL for all requests to the back-end pro server. Paths at this URL can
// be hit directly (not recommended due to censorship), through proxies, or through domain
// fronting.
ProAPIBaseURL = "df.iantem.io/api/pro-server"

DFBaseUrl = "df.iantem.io/api/v1"
APIBaseUrl = "iantem.io/api/v1"
// APIBaseURL is the URL for all requests to the back-end "API service". Paths at this URL can
// be hit directly (not recommended due to censorship), through proxies, or through domain
// fronting.
APIBaseURL = "df.iantem.io/api/v1"

log = golog.LoggerFor("flashlight.common")

Expand All @@ -63,9 +68,6 @@ func ForceStaging() {
func initInternal() {
isStaging := IsStagingEnvironment()
log.Debugf("****************************** stagingMode: %v", isStaging)
if isStaging {
ProAPIHost = "api-staging.getiantem.org"
}
forceAds, _ = strconv.ParseBool(os.Getenv("FORCEADS"))
}

Expand Down
3 changes: 2 additions & 1 deletion internalsdk/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ func SendIssueReport(
if err != nil {
return err
}
userConfig := &userConfig{&panickingSessionImpl{session}}
return issue.SendReport(
newUserConfig(&panickingSessionImpl{session}),
userConfig,
issueTypeInt,
description,
subscriptionLevel,
Expand Down
25 changes: 0 additions & 25 deletions internalsdk/pro/http.go

This file was deleted.

26 changes: 18 additions & 8 deletions internalsdk/pro/pro.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ import (
"fmt"
"net/http"
"strings"
"time"

"github.com/go-resty/resty/v2"

"github.com/getlantern/errors"
"github.com/getlantern/flashlight/v7/proxied"
"github.com/getlantern/golog"
"github.com/getlantern/lantern-client/internalsdk/common"
"github.com/getlantern/lantern-client/internalsdk/protos"
"github.com/getlantern/lantern-client/internalsdk/webclient"
"github.com/go-resty/resty/v2"

"github.com/leekchan/accounting"
"github.com/shopspring/decimal"
Expand Down Expand Up @@ -57,29 +59,37 @@ type ProClient interface {
// NewClient creates a new instance of ProClient
func NewClient(baseURL string, opts *webclient.Opts) ProClient {
if opts.HttpClient == nil {
// The default http.RoundTripper used by the ProClient is ParallelForIdempotent which
// attempts to send requests through both chained and direct fronted routes in parallel
// for HEAD and GET requests and ChainedThenFronted for all others.
opts.HttpClient = NewHTTPClient(proxied.ParallelForIdempotent(), opts.Timeout)
opts.HttpClient = &http.Client{
// The default http.RoundTripper used by the ProClient is ParallelForIdempotent which
// attempts to send requests through both chained and direct fronted routes in parallel
// for HEAD and GET requests and ChainedThenFronted for all others.
Transport: proxied.ParallelForIdempotent(),
Timeout: 30 * time.Second,
}
}

if opts.OnBeforeRequest == nil {
opts.OnBeforeRequest = func(client *resty.Client, req *http.Request) error {
prepareProRequest(req, common.ProAPIHost, opts.UserConfig())
prepareProRequest(req, opts.UserConfig())
return nil
}
}

if opts.BaseURL == "" {
opts.BaseURL = baseURL
}
atavism marked this conversation as resolved.
Show resolved Hide resolved

return &proClient{
userConfig: opts.UserConfig,
RESTClient: webclient.NewRESTClient(opts),
}
}

// prepareProRequest normalizes requests to the pro server with device ID, user ID, etc set.
func prepareProRequest(r *http.Request, proAPIHost string, userConfig common.UserConfig) {
func prepareProRequest(r *http.Request, userConfig common.UserConfig) {
if r.URL.Scheme == "" {
r.URL.Scheme = "http"
}
r.URL.Host = proAPIHost
r.RequestURI = "" // http: Request.RequestURI can't be set in client requests.
r.Header.Set("Access-Control-Allow-Headers", strings.Join([]string{
common.DeviceIdHeader,
Expand Down
2 changes: 1 addition & 1 deletion internalsdk/pro/pro_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ package pro
// },
// }

// proClient := NewClient(fmt.Sprintf("https://%s", common.ProAPIHost), webclientOpts)
// proClient := NewClient(common.ProAPIBaseURL, webclientOpts)

// puchaseData := map[string]interface{}{
// "idempotencyKey": strconv.FormatInt(time.Now().UnixNano(), 10),
Expand Down
115 changes: 0 additions & 115 deletions internalsdk/pro/proxy.go

This file was deleted.

64 changes: 0 additions & 64 deletions internalsdk/pro/proxy_test.go

This file was deleted.

Loading
Loading