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 #40

Merged
merged 17 commits into from
Jul 30, 2024
Merged

Adding SNI config #40

merged 17 commits into from
Jul 30, 2024

Conversation

WendelHime
Copy link
Contributor

@WendelHime WendelHime commented Jul 17, 2024

This pull request implements the SNI aribitrary configuration which allows flashlight to send a SNI on requests depending on the provider SNI configuration (and country at flashlight). Currently our requests doesn't send a SNI domain when making TLS connections (if you open wireshark sudo wireshark -i <interface> -k , scan and filter for ClientHellos - _ws.col.info contains "Client Hello" - , you should be able to see our requests without specifying the SNI domain. e.g. image with empty client hello below.
e.g. image with empty client hello below

Here's a example of how it should look like now when sending requests with the SNI config.
image

Testing

  1. Run wireshark for capturing your local traffic:
$ sudo wireshark -i <interface> -k
  1. At the wireshark interface filter the content by the ClientHello info, you can use the following filter:
_ws.col.info contains "Client Hello"
  1. Execute the test:
$ go test -run=TestDirectDomainFrontingWithSNIConfig ./...
  1. You should be able to see requests with SNIs at wireshark (with random domains)

Note

This pull request is required to be merged before getlantern/flashlight#1396

Copy link

Coverage Status

coverage: 79.495% (-2.8%) from 82.323%
when pulling 4b8fdd6 on feat/154
into 7fec719 on main.

Copy link

Coverage Status

coverage: 79.811% (-2.5%) from 82.323%
when pulling 4b8fdd6 on feat/154
into 7fec719 on main.

@WendelHime WendelHime marked this pull request as ready for review July 23, 2024 20:29
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.

@WendelHime this is really great work. Clean, minimal, easy to follow. I appreciate the updates to modernize this code as well!

I left a few minor comments, plus one new requirement - sorry about that 😬. Let me know if you have any questions!

.github/workflows/test.yaml Show resolved Hide resolved
README.md Show resolved Hide resolved
direct.go Show resolved Hide resolved
masquerade.go Outdated Show resolved Hide resolved
direct.go Outdated
Comment on lines 429 to 431
// selecting a random SNI
randomSNIIndex := rand.IntN(len(provider.SNIConfig.ArbitrarySNIs))
sniDomain := provider.SNIConfig.ArbitrarySNIs[randomSNIIndex]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we actually want this to be deterministic - and deterministic across clients too. The ideal scenario IMO is if any two clients in region R both send requests to IP X, they both use the same SNI. So perhaps we hash the masquerade IP and use the result modulo the set of SNIs to choose an SNI. Does that make sense?

A couple of minor points with my scheme: (1) If two clients have different lists, they will not end up with the same SNI. That is okay though; I think clients should only end up with different lists if they're in different regions. In that case, we don't need them to use the same SNI. (2) If the SNI list changes, then SNI-to-IP mappings will change. This is okay too; I don't expect us to change the SNI often.

Sorry, I know this is a new requirement added after the fact. I realize that can be frustrating. This didn't occur to me earlier =/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a crc32.ChecksumIEEE func call for hashing and made some changes for distributing SNIs per masquerade.

@WendelHime WendelHime requested a review from hwh33 July 26, 2024 15:14
Copy link
Contributor

@garmr-ulfr garmr-ulfr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of things. Otherwise it's good.

direct.go Outdated Show resolved Hide resolved
direct.go Outdated Show resolved Hide resolved
direct.go Outdated Show resolved Hide resolved
direct.go Outdated Show resolved Hide resolved
direct_test.go Outdated Show resolved Hide resolved
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.

One minor request, but otherwise this looks great! Awesome work 😁

masquerade.go Outdated Show resolved Hide resolved
…ashing for consistently retrieving a SNI for the masquerade IP address
@WendelHime WendelHime merged commit 9369ca3 into main Jul 30, 2024
2 checks passed
@WendelHime WendelHime deleted the feat/154 branch July 30, 2024 14:07
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.

3 participants