-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Introduce SOCKS5 proxy support #1180
Merged
Merged
Changes from 23 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
311515e
Introduce SOCKS5 proxy support, allowing seamless connections to Mong…
vbabanin 07a567d
Include CSFLE test suites to run via Socks5 proxy.
vbabanin 0231ae6
Remove extra MONGODB_URI variable.
vbabanin 53c7973
Remove unused imports.
vbabanin 81020fb
Update driver-core/src/main/com/mongodb/connection/SocketSettings.java
vbabanin 1313753
Update driver-core/src/main/com/mongodb/ClientEncryptionSettings.java
vbabanin 37e0874
Update driver-core/src/main/com/mongodb/AutoEncryptionSettings.java
vbabanin 3790094
Update driver-core/src/main/com/mongodb/connection/ProxySettings.java
vbabanin 494e293
Apply suggestions from code review
vbabanin de7697d
Update driver-core/src/main/com/mongodb/internal/connection/SocksSock…
vbabanin 3e84f5c
Revert proxy settings for key Management Service.
vbabanin 08d3e30
Remove KMIP config.
vbabanin ba111ca
Restructuring testing:
vbabanin db8d91b
Fix checkstyle errors.
vbabanin ea1060c
Update driver-reactive-streams/src/main/com/mongodb/reactivestreams/c…
vbabanin 7b93565
Update driver-core/src/main/com/mongodb/connection/ProxySettings.java
vbabanin e7218a8
Update driver-core/src/main/com/mongodb/connection/ProxySettings.java
vbabanin a56d56c
Update driver-core/src/main/com/mongodb/connection/ProxySettings.java
vbabanin dcac4f6
Apply suggestions from code review
vbabanin 7eb1c11
- Change javadoc.
vbabanin 19f2dca
Add javadoc.
vbabanin 735e81e
Remove redundant code.
vbabanin 34a26ce
Add @EnabledIf annotation for tests to remove skipped tests from a re…
vbabanin ede85de
Apply suggestions from code review
vbabanin 840d12b
Remove redundant code.
vbabanin 7d461a0
Add size check in domain regex.
vbabanin 42aca98
Address checkstyle warnings.
vbabanin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#!/bin/bash | ||
|
||
set -o xtrace # Write all commands first to stderr | ||
set -o errexit # Exit the script with error if any of the commands fail | ||
|
||
SSL=${SSL:-nossl} | ||
SOCKS_AUTH=${SOCKS_AUTH:-noauth} | ||
MONGODB_URI=${MONGODB_URI:-} | ||
SOCKS5_SERVER_SCRIPT="$DRIVERS_TOOLS/.evergreen/socks5srv.py" | ||
PYTHON_BINARY=${PYTHON_BINARY:-python3} | ||
# Grab a connection string that only refers to *one* of the hosts in MONGODB_URI | ||
FIRST_HOST=$(echo "$MONGODB_URI" | awk -F[/:,] '{print $4":"$5}') | ||
# Use 127.0.0.1:12345 as the URL for the single host that we connect to, | ||
# we configure the Socks5 proxy server script to redirect from this to FIRST_HOST | ||
export MONGODB_URI_SINGLEHOST="mongodb://127.0.0.1:12345" | ||
|
||
if [ "${SSL}" = "ssl" ]; then | ||
MONGODB_URI="${MONGODB_URI}&ssl=true&sslInvalidHostNameAllowed=true" | ||
MONGODB_URI_SINGLEHOST="${MONGODB_URI_SINGLEHOST}/?ssl=true&sslInvalidHostNameAllowed=true" | ||
fi | ||
|
||
# Compute path to socks5 fake server script in a way that works on Windows | ||
if [ "Windows_NT" == "$OS" ]; then | ||
SOCKS5_SERVER_SCRIPT=$(cygpath -m $DRIVERS_TOOLS) | ||
fi | ||
|
||
RELATIVE_DIR_PATH="$(dirname "${BASH_SOURCE:-$0}")" | ||
. "${RELATIVE_DIR_PATH}/javaConfig.bash" | ||
|
||
############################################ | ||
# Functions # | ||
############################################ | ||
|
||
provision_ssl () { | ||
# We generate the keystore and truststore on every run with the certs in the drivers-tools repo | ||
if [ ! -f client.pkc ]; then | ||
openssl pkcs12 -CAfile ${DRIVERS_TOOLS}/.evergreen/x509gen/ca.pem -export -in ${DRIVERS_TOOLS}/.evergreen/x509gen/client.pem -out client.pkc -password pass:bithere | ||
fi | ||
|
||
cp ${JAVA_HOME}/lib/security/cacerts mongo-truststore | ||
${JAVA_HOME}/bin/keytool -importcert -trustcacerts -file ${DRIVERS_TOOLS}/.evergreen/x509gen/ca.pem -keystore mongo-truststore -storepass changeit -storetype JKS -noprompt | ||
|
||
# We add extra gradle arguments for SSL | ||
export GRADLE_SSL_VARS="-Pssl.enabled=true -Pssl.keyStoreType=pkcs12 -Pssl.keyStore=`pwd`/client.pkc -Pssl.keyStorePassword=bithere -Pssl.trustStoreType=jks -Pssl.trustStore=`pwd`/mongo-truststore -Pssl.trustStorePassword=changeit" | ||
} | ||
|
||
|
||
run_socks5_proxy () { | ||
if [ "$SOCKS_AUTH" == "auth" ]; then | ||
"$PYTHON_BINARY" "$SOCKS5_SERVER_SCRIPT" --port 1080 --auth username:p4ssw0rd --map "127.0.0.1:12345 to $FIRST_HOST" & | ||
SOCKS5_SERVER_PID_1=$! | ||
trap "kill $SOCKS5_SERVER_PID_1" EXIT | ||
else | ||
"$PYTHON_BINARY" "$SOCKS5_SERVER_SCRIPT" --port 1080 --map "127.0.0.1:12345 to $FIRST_HOST" & | ||
SOCKS5_SERVER_PID_1=$! | ||
trap "kill $SOCKS5_SERVER_PID_1" EXIT | ||
fi | ||
} | ||
|
||
run_socks5_prose_tests () { | ||
if [ "$SOCKS_AUTH" == "auth" ]; then | ||
local AUTH_ENABLED="true" | ||
else | ||
local AUTH_ENABLED="false" | ||
fi | ||
|
||
echo "Running Socks5 tests with Java ${JAVA_VERSION} over $SSL for $TOPOLOGY and connecting to $MONGODB_URI with socks auth enabled: $AUTH_ENABLED" | ||
./gradlew -PjavaVersion=${JAVA_VERSION} -Dorg.mongodb.test.uri=${MONGODB_URI} \ | ||
-Dorg.mongodb.test.uri.singleHost=${MONGODB_URI_SINGLEHOST} \ | ||
-Dorg.mongodb.test.uri.proxyHost="127.0.0.1" \ | ||
-Dorg.mongodb.test.uri.proxyPort="1080" \ | ||
-Dorg.mongodb.test.uri.socks.auth.enabled=${AUTH_ENABLED} \ | ||
${GRADLE_SSL_VARS} \ | ||
--stacktrace --info --continue \ | ||
driver-sync:test \ | ||
--tests "com.mongodb.client.Socks5ProseTest*" | ||
} | ||
|
||
############################################ | ||
# Main Program # | ||
############################################ | ||
|
||
# Set up keystore/truststore | ||
provision_ssl | ||
./gradlew -version | ||
run_socks5_proxy | ||
run_socks5_prose_tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stIncMale marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stIncMale marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move
socks_auth
afterSOCKS5 proxy
so that they sort together in the display