Skip to content

Commit

Permalink
feat: adding SNIConfig to provider and load it
Browse files Browse the repository at this point in the history
  • Loading branch information
WendelHime committed Jul 17, 2024
1 parent 7fec719 commit 3062fd0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion context.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (fctx *FrontingContext) ConfigureWithHello(pool *x509.CertPool, providers m

// copy providers
for k, p := range providers {
d.providers[k] = NewProvider(p.HostAliases, p.TestURL, p.Masquerades, p.Validator, p.PassthroughPatterns)
d.providers[k] = NewProvider(p.HostAliases, p.TestURL, p.Masquerades, p.Validator, p.PassthroughPatterns, p.SNIConfig)
}

d.loadCandidates(d.providers)
Expand Down
14 changes: 13 additions & 1 deletion masquerade.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,33 @@ type Provider struct {
// Url used to vet masquerades for this provider
TestURL string
Masquerades []*Masquerade

// SNIConfig is a map of SNIs with configurations per region.
// The key can be a region initial or the default value, used when
// the region wants to use arbitrary SNIs but doesn't provide the SNI list.
SNIConfig *SNIConfig

// Optional response validator used to determine whether
// fronting succeeded for this provider. If the validator
// detects a failure for a given masquerade, it is discarded.
// The default validator is used if nil.
Validator ResponseValidator
}

type SNIConfig struct {
UseArbitrarySNIs bool
ArbitrarySNIs []string
}

// Create a Provider with the given details
func NewProvider(hosts map[string]string, testURL string, masquerades []*Masquerade, validator ResponseValidator, passthrough []string) *Provider {
func NewProvider(hosts map[string]string, testURL string, masquerades []*Masquerade, validator ResponseValidator, passthrough []string, sniConfig *SNIConfig) *Provider {
d := &Provider{
HostAliases: make(map[string]string),
TestURL: testURL,
Masquerades: make([]*Masquerade, 0, len(masquerades)),
Validator: validator,
PassthroughPatterns: make([]string, 0, len(passthrough)),
SNIConfig: sniConfig,
}
for k, v := range hosts {
d.HostAliases[strings.ToLower(k)] = v
Expand Down

0 comments on commit 3062fd0

Please sign in to comment.