Skip to content
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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ providers:
hostaliases:
api.example.com: api.dsa.akamai.example.com
testurl: https://fronted-ping.dsa.akamai.example.com/ping
fronting_snis:
frontingsnis:
default:
use_arbitrary_snis: false
usearbitrarysnis: false
br:
use_arbitrary_snis: true
arbitrary_snis:
usearbitrarysnis: true
arbitrarysnis:
- mercadopago.com
- amazon.com.br
masquerades:
Expand Down
11 changes: 8 additions & 3 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,18 @@ type Provider struct {
TestURL string `yaml:"testurl"`
Masquerades []*Masquerade `yaml:"masquerades"`
VerifyHostname *string `yaml:"verifyhostname"`
FrontingSNIs map[string]*SNIConfig `yaml:"fronting_snis"`
// Pipeline-emitted YAML keys are lowercase-concatenated, not
// snake_case (the upstream generator uses lowercased Go field
// names with no yaml tag); the tag here must match the wire
// format exactly or yaml.Unmarshal silently leaves the field
// zero-valued.
FrontingSNIs map[string]*SNIConfig `yaml:"frontingsnis"`
Comment thread
myleshorton marked this conversation as resolved.
}

// SNIConfig controls SNI generation for a specific country or "default".
type SNIConfig struct {
UseArbitrarySNIs bool `yaml:"use_arbitrary_snis"`
ArbitrarySNIs []string `yaml:"arbitrary_snis"`
UseArbitrarySNIs bool `yaml:"usearbitrarysnis"`
ArbitrarySNIs []string `yaml:"arbitrarysnis"`
Comment thread
myleshorton marked this conversation as resolved.
}

// Masquerade contains the data for a single domain front.
Expand Down
19 changes: 19 additions & 0 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ func TestExpandedProvider(t *testing.T) {
}

func TestParseConfigYAML(t *testing.T) {
// Keys are the lowercase-concatenated form the upstream generator
// emits (frontingsnis / usearbitrarysnis / arbitrarysnis), NOT
// snake_case — a tag-spelling mismatch silently parses these as zero
// values, so this fixture guards against that regressing.
yml := `
trustedcas:
- commonname: "Test CA"
Expand All @@ -88,6 +92,14 @@ providers:
hostaliases:
example.com: cdn.example.com
testurl: https://test.example.com/ping
frontingsnis:
default:
usearbitrarysnis: false
ir:
usearbitrarysnis: true
arbitrarysnis:
- python.org
- snapp.ir
masquerades:
- domain: cdn.example.com
ipaddress: "1.2.3.4"
Expand All @@ -101,4 +113,11 @@ providers:
assert.Equal(t, "cdn.example.com", p.HostAliases["example.com"])
require.Len(t, p.Masquerades, 1)
assert.Equal(t, "1.2.3.4", p.Masquerades[0].IpAddress)

require.Contains(t, p.FrontingSNIs, "default")
require.Contains(t, p.FrontingSNIs, "ir")
assert.False(t, p.FrontingSNIs["default"].UseArbitrarySNIs)
ir := p.FrontingSNIs["ir"]
assert.True(t, ir.UseArbitrarySNIs)
assert.Equal(t, []string{"python.org", "snapp.ir"}, ir.ArbitrarySNIs)
}
Loading