From 085078a4f3e9010be997d97e1fec2e9a08b3f27d Mon Sep 17 00:00:00 2001 From: atavism Date: Tue, 24 Sep 2024 08:38:46 -0700 Subject: [PATCH] remove all references to staging environment --- common/const.go | 37 +------------------------------------ config/fetcher_test.go | 5 ----- config/initializer.go | 31 ++----------------------------- config/initializer_test.go | 12 ------------ flags.go | 1 - pro/client/client_test.go | 4 ---- pro/user_data_test.go | 2 -- 7 files changed, 3 insertions(+), 89 deletions(-) diff --git a/common/const.go b/common/const.go index e386aa34e..2af19709a 100644 --- a/common/const.go +++ b/common/const.go @@ -16,9 +16,6 @@ const ( // ProxiesURL is the URL for fetching the per user proxy config. ProxiesURL = "http://config.getiantem.org/proxies.yaml.gz" - // ProxiesStagingURL is the URL for fetching the per user proxy config in a staging environment. - ProxiesStagingURL = "http://config-staging.getiantem.org/proxies.yaml.gz" - // Sentry Configurations SentryTimeout = time.Second * 30 SentryMaxMessageChars = 8000 @@ -37,15 +34,6 @@ var ( // GlobalURL URL for fetching the global config. GlobalURL = "https://globalconfig.flashlightproxy.com/global.yaml.gz" - // GlobalStagingURL is the URL for fetching the global config in a staging environment. - GlobalStagingURL = "https://globalconfig.flashlightproxy.com/global.yaml.gz" - - // StagingMode if true, run Lantern against our staging infrastructure. - // This is set by the linker using -ldflags - StagingMode = "false" - - Staging = false - ProAPIHost = "api.getiantem.org" log = golog.LoggerFor("flashlight.common") @@ -58,31 +46,8 @@ var ( Environment = "production" ) -func init() { - initInternal() -} - -// ForceStaging forces staging mode. -func ForceStaging() { - StagingMode = "true" - initInternal() -} - -func initInternal() { - var err error - log.Debugf("****************************** stagingMode: %v", StagingMode) - Staging, err = strconv.ParseBool(StagingMode) - if err != nil { - log.Errorf("Error parsing boolean flag: %v", err) - return - } - if Staging { - ProAPIHost = "api-staging.getiantem.org" - } - forceAds, _ = strconv.ParseBool(os.Getenv("FORCEADS")) -} - // ForceAds indicates whether adswapping should be forced to 100% func ForceAds() bool { + forceAds, _ = strconv.ParseBool(os.Getenv("FORCEADS")) return forceAds } diff --git a/config/fetcher_test.go b/config/fetcher_test.go index 359121319..3f049eab0 100644 --- a/config/fetcher_test.go +++ b/config/fetcher_test.go @@ -46,9 +46,4 @@ func TestStagingSetup(t *testing.T) { fetch = newHttpFetcher(newTestUserConfig(), rt, url).(*fetcher) assert.Equal(t, "http://config.getiantem.org/proxies.yaml.gz", fetch.originURL) - - stagingURL := common.ProxiesStagingURL - flags["staging"] = true - fetch = newHttpFetcher(newTestUserConfig(), rt, stagingURL).(*fetcher) - assert.Equal(t, "http://config-staging.getiantem.org/proxies.yaml.gz", fetch.originURL) } diff --git a/config/initializer.go b/config/initializer.go index 8e69e7dfe..2e625485a 100644 --- a/config/initializer.go +++ b/config/initializer.go @@ -39,9 +39,8 @@ func Init( origGlobalDispatch func(interface{}, Source), onGlobalSaveError func(error), rt http.RoundTripper) (stop func()) { - staging := isStaging(flags) - proxyConfigURL := checkOverrides(flags, getProxyURL(staging), "proxies.yaml.gz") - globalConfigURL := checkOverrides(flags, getGlobalURL(staging), "global.yaml.gz") + proxyConfigURL := checkOverrides(flags, common.ProxiesURL, "proxies.yaml.gz") + globalConfigURL := checkOverrides(flags, common.GlobalURL, "global.yaml.gz") return InitWithURLs( configDir, flags, userConfig, proxiesDispatch, onProxiesSaveError, @@ -192,10 +191,6 @@ func obfuscate(flags map[string]interface{}) bool { return flags["readableconfig"] == nil || !flags["readableconfig"].(bool) } -func isStaging(flags map[string]interface{}) bool { - return checkBool(flags, "staging") -} - func isSticky(flags map[string]interface{}) bool { return checkBool(flags, "stickyconfig") } @@ -217,25 +212,3 @@ func checkOverrides(flags map[string]interface{}, } return url } - -// getProxyURL returns the proxy URL to use depending on whether or not -// we're in staging. -func getProxyURL(staging bool) string { - if staging { - log.Debug("Will obtain proxies.yaml from staging service") - return common.ProxiesStagingURL - } - log.Debug("Will obtain proxies.yaml from production service") - return common.ProxiesURL -} - -// getGlobalURL returns the global URL to use depending on whether or not -// we're in staging. -func getGlobalURL(staging bool) string { - if staging { - log.Debug("Will obtain global.yaml from staging service") - return common.GlobalStagingURL - } - log.Debugf("Will obtain global.yaml from production service at %v", common.GlobalURL) - return common.GlobalURL -} diff --git a/config/initializer_test.go b/config/initializer_test.go index 1bb7199fc..a36f7e87c 100644 --- a/config/initializer_test.go +++ b/config/initializer_test.go @@ -20,7 +20,6 @@ func TestInit(t *testing.T) { defer deleteGlobalConfig() flags := make(map[string]interface{}) - flags["staging"] = true gotProxies := eventual.NewValue() gotGlobal := eventual.NewValue() @@ -104,17 +103,6 @@ func TestInitWithURLs(t *testing.T) { }) } -func TestStaging(t *testing.T) { - flags := make(map[string]interface{}) - flags["staging"] = true - - assert.True(t, isStaging(flags)) - - flags["staging"] = false - - assert.False(t, isStaging(flags)) -} - // TestOverrides tests url override flags func TestOverrides(t *testing.T) { url := "host" diff --git a/flags.go b/flags.go index 9a1aa4cc9..5fe953058 100644 --- a/flags.go +++ b/flags.go @@ -40,7 +40,6 @@ type Flags struct { Initialize bool `flag:"initialize" help:"silently initialize Lantern to a state of having working proxy and exit, typically during installation."` Timeout time.Duration `flag:"timeout" help:"force stop Lantern with an exit status of -1 after the timeout."` ReplicaRustUrl string `flag:"replica-rust-url" help:"use the replica-rust service at the provided endpoint"` - Staging bool `flag:"-"` Experiments []string `flag:"enabled-experiments" help:"comma separated list of experiments to enable"` } diff --git a/pro/client/client_test.go b/pro/client/client_test.go index e9a80776f..9f84d8796 100644 --- a/pro/client/client_test.go +++ b/pro/client/client_test.go @@ -104,10 +104,6 @@ func generateUser() *common.UserConfigData { return common.NewUserConfigData(common.DefaultAppName, generateDeviceId(), int64(rand.Uint64()), fmt.Sprintf("aasfge%d", rand.Uint64()), nil, "en-US") } -func init() { - common.ForceStaging() -} - func createClient(resp *http.Response) *Client { mockedHTTPClient := createMockClient(resp) return NewClient(mockedHTTPClient, func(req *http.Request, uc common.UserConfig) { diff --git a/pro/user_data_test.go b/pro/user_data_test.go index 3938ce6f6..b9399d65a 100644 --- a/pro/user_data_test.go +++ b/pro/user_data_test.go @@ -15,8 +15,6 @@ import ( ) func TestUsers(t *testing.T) { - common.ForceStaging() - deviceID := "77777777" userID := int64(1000) token := uuid.NewString()