Skip to content
This repository was archived by the owner on Jan 17, 2025. It is now read-only.

Support connecting through a socks proxy#19

Merged
winglot merged 1 commit intobrainly:masterfrom
sworisbreathing:socks-proxy-support
Aug 20, 2021
Merged

Support connecting through a socks proxy#19
winglot merged 1 commit intobrainly:masterfrom
sworisbreathing:socks-proxy-support

Conversation

@sworisbreathing
Copy link
Copy Markdown
Contributor

This PR registers a custom driver name for pq, per lib/pq#470 (comment), and uses it to override the default dialer with one that can transparently handle socks proxy configuration through environment variables.

The environment variable is named ALL_PROXY (all_proxy also works) and has the format socks5[h]://[<socks-user>:<socks-password>@]<socks-host>[:<socks-port>]
There is also support for a NO_PROXY/no_proxy environment variable which lists hostnames, IP addresses, CIDR blocks, and wildcard domain names which should not go through the proxy.

@sworisbreathing
Copy link
Copy Markdown
Contributor Author

sworisbreathing commented Aug 20, 2021

For some weird reason, code coverage isn't being captured, however I can tell this change actually makes a difference. When Redshift is in a VPC and not publicly accessible, and ALL_PROXY points to a valid socks5 proxy into the VPC:

  • when you include this PR, all tests pass
  • When you omit this PR, all tests fail, and report errors connecting to redshift.

@winglot winglot added the enhancement New feature or request label Aug 20, 2021
@winglot winglot merged commit cf50382 into brainly:master Aug 20, 2021
@sworisbreathing sworisbreathing deleted the socks-proxy-support branch August 20, 2021 11:15
Tenzer added a commit to Tenzer/terraform-provider-postgresql that referenced this pull request Mar 30, 2022
This copies the implentation from the Redshift provider:
brainly/terraform-provider-redshift#19.

It allows users to proxy the requests to the database server through a SOCKS
proxy, in case the database server cannot be reached directly.
Tenzer added a commit to Tenzer/terraform-provider-postgresql that referenced this pull request Apr 21, 2022
This copies the implentation from the Redshift provider:
brainly/terraform-provider-redshift#19.

It allows users to proxy the requests to the database server through a SOCKS
proxy, in case the database server cannot be reached directly.
cyrilgdn added a commit to cyrilgdn/terraform-provider-postgresql that referenced this pull request May 4, 2022
* Add SOCKS proxy support

This copies the implentation from the Redshift provider:
brainly/terraform-provider-redshift#19.

It allows users to proxy the requests to the database server through a SOCKS
proxy, in case the database server cannot be reached directly.

* Mention SOCKS5 proxy support to usage documentation

As part of this I found out the format of the values in the environment
variables isn't standardized, so there only place we potentially could link to
about the format of the values would be the source code for
`golang.org/x/net/proxy`. I thought that was a bit much, so I've instead
included a simple example instead.

Co-authored-by: Cyril Gaudin <cyril.gaudin@gmail.com>
StevenKGER referenced this pull request in dbsystel/terraform-provider-redshift Oct 25, 2024
…-go-v2-config-1.x

Update module github.com/aws/aws-sdk-go-v2/config to v1.18.43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants