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 SOCKS5 and SOCKS5H schemes #1562

Closed
wants to merge 26 commits into from
Closed

Conversation

ahmedyarub
Copy link

Description of changes:
Added schemes required for proxying connections to socks5 and socks5h (with host resolution) with CURL library.
Proxifying your connections to AWS is a very common requirement when using AWS SDK. unfortunately, since the default client only accepts http and https schemas, we cannot use socks5 and socks5h proxies that are already supported by curl. socks5h is especially useful in my case since I'm running my WebAssembly application on Google Chrome, and the only way to connect to AWS servers with WebAssembly is by proxifying the requests to a SOCKS proxy AND doing the DNS resolution on the proxy itself.
I could create a new client and use the overriding function but I found it too much of a hassle to create a new client and implement the overriding method and then setting as a default client configuration just so that I can add the schema.

Check all that applies:

  • Did a review by yourself.
  • Added proper tests to cover this PR. (If tests are not applicable, explain.)
    Not applicable: it doesn't add anything functional. It just enables prepending socks5 and socks5h to the host name
  • Checked if this PR is a breaking (APIs have been changed) change.
  • Checked if this PR will not introduce cross-platform inconsistent behavior.
  • Checked if this PR would require a ReadMe/Wiki update.

Check which platforms you have built SDK on to verify the correctness of this PR.

  • Linux
  • Windows
  • Android
  • MacOS
  • IOS
  • Other Platforms
    WebAssembly

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

(cherry picked from commit 80b461f)
@ahmedyarub
Copy link
Author

Will this be merged any time in the future?

@sdavtaker
Copy link
Contributor

Hi @ahmedyarub,
We are evaluating the impact of this change to those not using CURL as httpclient.
BTW, if you don't mind to share, what environment/parameters are you using to build websassembly?
Best,
Damian

@ahmedyarub
Copy link
Author

Hi @ahmedyarub,
We are evaluating the impact of this change to those not using CURL as httpclient.
BTW, if you don't mind to share, what environment/parameters are you using to build websassembly?
Best,
Damian

I made this contribution to vcpkg to fix building using Emscripten: microsoft/vcpkg#17348
Before that I used to build like this:

zlib:
emcmake cmake -DBUILD_SHARED_LIBS=FALSE -DBUILD_SHARED_LIBS=FALSE -DCMAKE_INSTALL_PREFIX=/usr/local/wasm32 ~/Documents/cpp/zlib

Build OpenSSL:
git checkout OpenSSL_1_1_1-stable
emconfigure ./config threads no-engine no-dso no-asm no-shared no-sse2 no-srtp --prefix="/usr/local/wasm32" --openssldir="/usr/local/wasm32" --cross-compile-prefix="/"

emmake make install_sw -j4

Build curl:
emcmake cmake -DBUILD_CURL_EXE=FALSE -DHAVE_SELECT=0 -DHAVE_POLL=1 -DHAVE_POLL_FINE=1 -DHAVE_POLL_H=1 -DHAVE_SIGACTION=0 -DENABLE_DEBUG=TRUE -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=FALSE -DCMAKE_PREFIX_PATH=/usr/local/wasm32 -DCMAKE_FIND_ROOT_PATH=/usr/local/wasm32 -DCMAKE_INSTALL_PREFIX=/usr/local/wasm32 ~/Documents/cpp/curl

Build AWS SDK:
emcmake cmake -DBUILD_ONLY="core;ec2;ecr" -DENABLE_TESTING=FALSE -DENABLE_UNITY_BUILD=ON -DAWS_DEPS_INSTALL_DIR=/usr/local/wasm32 -DGEN_PLATFORM_ARG="-DCMAKE_PREFIX_PATH=/usr/local/wasm32 -DCMAKE_FIND_ROOT_PATH=/usr/local/wasm32" -DBUILD_SHARED_LIBS=FALSE -DCMAKE_PREFIX_PATH=/usr/local/wasm32 -DCMAKE_FIND_ROOT_PATH=/usr/local/wasm32 -DCMAKE_INSTALL_PREFIX=/usr/local/wasm32 ~/Documents/cpp/aws-sdk-cpp

nano .deps/build/src/AwsCEventStream-build/CMakeCache.txt
aws-c-common_DIR:PATH=/usr/local/wasm32/lib/aws-c-common/cmake/
aws-checksums_DIR:PATH=/usr/local/wasm32/lib/aws-checksums/cmake/

emcmake cmake -DCMAKE_PREFIX_PATH=/usr/local/wasm32 -DCMAKE_FIND_ROOT_PATH=/usr/local/wasm32 -DBUILD_SHARED_LIBS=FALSE -DCMAKE_FIND_ROOT_PATH="~/Qt/5.15.1/wasm_32;/usr/local/wasm32/" -Wno-dev

emmake make
emmake make install

@sdavtaker
Copy link
Contributor

Hi @ahmedyarub,
Do you happen to have a container with proxy SOCKS5 setup and an integration test to check things work as expected?

@ahmedyarub
Copy link
Author

Hi @ahmedyarub,
Do you happen to have a container with proxy SOCKS5 setup and an integration test to check things work as expected?

I did test it on my machine and it worked. However, I can create a container and an integration test for you in the next few days.

@ahmedyarub
Copy link
Author

@sdavtaker test added with Dockerfile and instructions.

@sdavtaker
Copy link
Contributor

Thanks @ahmedyarub for the contribution
We will review in the next few days.

@github-actions
Copy link

Greetings! Sorry to say but this is a very old issue that is probably not getting as much attention as it deservers. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to open a new one.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Aug 19, 2022
@github-actions github-actions bot closed this Aug 25, 2022
@SergeyRyabinin SergeyRyabinin mentioned this pull request Jan 18, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants