-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
…parsing it and check if the list of SNIs is empty, use the default list
…sni config as expected
config/client_config.go
Outdated
|
||
providers := make(map[string]*fronted.Provider) | ||
for pid, p := range c.Fronted.Providers { | ||
sniConfig := p.FrontingSNIs[sniRegion] | ||
if sniConfig != nil && sniConfig.UseArbitrarySNIs && len(sniConfig.ArbitrarySNIs) == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to fall back to the default SNI config if sniRegion
does not appear in p.FrontingSNIs
. Currently, if there is no entry in p.FrontingSNIs
for sniRegion
, then sniConfig
will never be populated (sniConfig.UseArbitrarySNIs
will be ignored because sniConfig != nil
will fail).
I think we instead want something like:
sniConfig, ok := p.FrontingSNIs[sniRegion]
if !ok {
sniConfig = p.FrontingSNIs["default"]
}
Or am I misunderstanding something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aaaa I have misunderstood, I thought we only want to use the default arbitrary list when the region has an empty arbitrary list, will fix that soon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait I didn't misunderstood, the provided example does mention that, if there are no arbitrary sni provided and we want to use it, we will use it from the default section (see cn example and comment):
fronting-snis:
default:
use-arbitrary-snis: false
arbitrary-snis:
- example.com
- example2.com
- ... etc ...
ir:
use-arbitrary-snis: true
arbirtary-snis:
- iran-example.com
- iran-example2.com
- ... etc ...
cn:
use-abritrary-snis: true
# no abritrary-snis list; use list from default section
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example looks good and your updated code implements it correctly!
…t region we want to use the default SNI list if it's empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Nice work @WendelHime!
This PR allow flashlight to load FrontingSNIs from the global configuration and send them to the fronted library so we can fill SNIs when sending requests. This PR requires getlantern/fronted#40 to be merged before, so we can update the
go.mod
reference