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

Adding SNI config support #1396

merged 13 commits into from
Aug 5, 2024

Conversation

WendelHime
Copy link
Contributor

@WendelHime WendelHime commented Jul 17, 2024

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

embeddedconfig/global.yaml Outdated Show resolved Hide resolved

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 {
Copy link
Contributor

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?

Copy link
Contributor Author

@WendelHime WendelHime Jul 30, 2024

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

Copy link
Contributor Author

@WendelHime WendelHime Jul 30, 2024

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

Copy link
Contributor

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!

@WendelHime WendelHime marked this pull request as ready for review July 30, 2024 14:23
Copy link
Contributor

@hwh33 hwh33 left a 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!

@WendelHime WendelHime merged commit 45fabba into main Aug 5, 2024
3 checks passed
@WendelHime WendelHime deleted the feat/154 branch August 5, 2024 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants