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

Adding SNI config support #1396

Merged
merged 13 commits into from
Aug 5, 2024
Merged
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
17 changes: 16 additions & 1 deletion config/client_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package config
import (
"errors"

"github.com/getlantern/flashlight/v7/geolookup"
"github.com/getlantern/fronted"
)

Expand Down Expand Up @@ -40,6 +41,7 @@ type ProviderConfig struct {
Masquerades []*fronted.Masquerade
Validator *ValidatorConfig
PassthroughPatterns []string
FrontingSNIs map[string]*fronted.SNIConfig
}

// returns a fronted.ResponseValidator specified by the
Expand Down Expand Up @@ -80,15 +82,28 @@ func NewClientConfig() *ClientConfig {

// Builds a list of fronted.Providers to use based on the configuration
func (c *ClientConfig) FrontedProviders() map[string]*fronted.Provider {

sniRegion := geolookup.GetCountry(0)
providers := make(map[string]*fronted.Provider)
for pid, p := range c.Fronted.Providers {
var sniConfig *fronted.SNIConfig
if p.FrontingSNIs != nil {
sniConfig, ok := p.FrontingSNIs[sniRegion]
if !ok {
sniConfig = p.FrontingSNIs["default"]
}

if sniConfig != nil && sniConfig.UseArbitrarySNIs && len(sniConfig.ArbitrarySNIs) == 0 {
sniConfig.ArbitrarySNIs = p.FrontingSNIs["default"].ArbitrarySNIs
}
}

providers[pid] = fronted.NewProvider(
p.HostAliases,
p.TestURL,
p.Masquerades,
p.GetResponseValidator(pid),
p.PassthroughPatterns,
sniConfig,
)
}
return providers
Expand Down
2 changes: 2 additions & 0 deletions config/embedded_global_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ func TestEmbeddedGlobal(t *testing.T) {
assert.NoError(t, err)

gl := global.(*Global)
assert.False(t, gl.Client.Fronted.Providers["akamai"].FrontingSNIs["default"].UseArbitrarySNIs)
assert.NotEmpty(t, gl.Client.Fronted.Providers["akamai"].FrontingSNIs["default"].ArbitrarySNIs)
assert.True(t, len(gl.Client.Fronted.Providers["akamai"].Masquerades) > 20)
assert.True(t, len(gl.Client.Fronted.Providers["cloudfront"].Masquerades) > 20)
assert.Containsf(t, gl.Client.Fronted.Providers["cloudfront"].HostAliases, "replica-search.lantern.io", "embedded global config does not contain replica-search cloudfront fronted provider")
Expand Down
Loading
Loading