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

Add optional method ProxyTLSConnection (closes #779) #782

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

sleeyax
Copy link

@sleeyax sleeyax commented May 12, 2022

Previously, it was impossible to specify both Proxy and NetDialTLSContext on the websocket Dialer without experiencing connection issues. This commit brings a change to the proxy CONNECT flow so that the initial connection is always a normal proxy CONNECT over TCP, while allowing TLS customizations on the existing connection at a later point in time via the new ProxyTLSConnection method.

Fixes #779

Summary of Changes

Please see my comment on the relevant issue for a detailed explanation and my thought process: #779 (comment)

Tests are not included, I'd appreciate some help or guidance on that front because I'm unsure what to test, thanks!

Removed the call to NetDialTLSContext from the HTTP proxy CONNECT step and replaced it with a regular net.Dial in order to prevent connection issues. Custom TLS connections can now be made via the new optional ProxyTLSConnection method, after the proxy connection has been successfully established.
client.go Outdated Show resolved Hide resolved
@jaitaiwan
Copy link
Member

Thanks for the commit. I know it's been a long time but it would be good to see a test to go with this PR. I'm not fully confident in merging without associated tests.

@jaitaiwan
Copy link
Member

It also looks like this PR does something similar: https://github.com/gorilla/websocket/pull/740/files maybe consider using that PR to bolster your own.

@sleeyax
Copy link
Author

sleeyax commented Jun 19, 2024

It also looks like this PR does something similar: https://github.com/gorilla/websocket/pull/740/files maybe consider using that PR to bolster your own.

Not sure if this fixes the issue completely. The PR you mention adds support for HTTPS proxies whereas this PR fixes a bug where NetDialTLSContext and Proxy fields on the websocket.Dialer don't work together. See the referenced issues for more details.

@sleeyax
Copy link
Author

sleeyax commented Jun 19, 2024

Thanks for the commit. I know it's been a long time but it would be good to see a test to go with this PR. I'm not fully confident in merging without associated tests.

It's been so long. Can't say when/if I'll be able to find the time to look into this again and add tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

[bug] Can't establish websocket connection when using NetDialTLSContext and Proxy together
5 participants