-
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
Conversation
…oDB instances behind firewalls. JAVA-4347
@@ -51,6 +58,27 @@ public static void enableSni(final String host, final SSLParameters sslParameter | |||
} | |||
} | |||
|
|||
public static void configureSslSocket(final Socket socket, final SslSettings sslSettings, final InetSocketAddress inetSocketAddress) throws |
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.
The code of this method has been relocated without any alterations from its original location in SocketStreamHelper.java#L9
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.
Static checks fail. This can be addressed before the whole PR is reviewed.
JAVA-4347
JAVA-4347
All checks are now passing now. @vbabanin can you manually reconfigure to run the new socks tasks? |
Done, I have added |
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.
I have not yet reviewed changes in the following files:
.evergreen/.evg.yml
.evergreen/run-socks5-tests.sh
driver-core/src/main/com/mongodb/internal/connection/SocketStream.java
driver-sync/src/test/functional/com/mongodb/client/Socks5ProseTest.java
driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/MongoClients.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/connection/SocketSettings.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/SocksSocket.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/SocksSocket.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/SocksSocket.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/SocksSocket.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/SocketStream.java
Outdated
Show resolved
Hide resolved
if (socket != null && !socket.isConnected()) { | ||
socket.connect(proxyAddress, remainingMillis(timeout)); | ||
inputStream = socket.getInputStream(); | ||
outputStream = socket.getOutputStream(); | ||
} else { | ||
super.connect(proxyAddress, remainingMillis(timeout)); | ||
inputStream = getInputStream(); | ||
outputStream = getOutputStream(); | ||
} |
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.
When we call Socket.connect
from SocketStream.initializeSocket
for a scenario without a proxy, we try in a loop all InetSocketAddress
es to which ServerAddress
is resolved.
When we call socket.connect
/super.connect
here while connecting to a proxy, we don't do the same. Instead, we pick a single InetSocketAddress
to which ProxySettings.getHost
&getPort
may be resolved, and do only one attempt.
It seems to me that we should try all IP addresses corresponding to the proxy host when connecting to a proxy, similarly to what we do when we connect to MongoDB directly.
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.
It is been decided to handle this in a separate DRIVERS ticket because it requires spec changes. I am going to create one.
UPD: DRIVERS-2719
driver-core/src/main/com/mongodb/internal/connection/SocketStream.java
Outdated
Show resolved
Hide resolved
I have now reviewed all the changes in the PR. |
Co-authored-by: Valentin Kovalenko <[email protected]>
Co-authored-by: Valentin Kovalenko <[email protected]>
Co-authored-by: Valentin Kovalenko <[email protected]>
Co-authored-by: Valentin Kovalenko <[email protected]>
Co-authored-by: Valentin Kovalenko <[email protected]>
…et.java Co-authored-by: Valentin Kovalenko <[email protected]>
PR fixes. JAVA-4347
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.
Sorry for the late review, but I found some things that may need addressing.
driver-core/src/test/functional/com/mongodb/client/model/AggregatesTest.java
Outdated
Show resolved
Hide resolved
JAVA-4347
- Eliminate KMIP server configuration from SOCKS5 tests. - Organize SOCKS5 proxy tests into separate tasks for authenticated and non-authenticated scenarios. - Enhance unit test coverage. JAVA-4347
JAVA-4347
driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/MongoClients.java
Outdated
Show resolved
Hide resolved
driver-scala/src/main/scala/org/mongodb/scala/connection/ProxySettings.scala
Outdated
Show resolved
Hide resolved
driver-scala/src/main/scala/org/mongodb/scala/connection/package.scala
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/connection/SocketSettings.java
Outdated
Show resolved
Hide resolved
…lient/MongoClients.java Co-authored-by: Valentin Kovalenko <[email protected]>
Co-authored-by: Valentin Kovalenko <[email protected]>
Co-authored-by: Valentin Kovalenko <[email protected]>
Co-authored-by: Valentin Kovalenko <[email protected]>
Co-authored-by: Valentin Kovalenko <[email protected]>
JAVA-4347
JAVA-4347
JAVA-4347
…sult report. JAVA-4347
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.
LGTM for all my change requests.
.evergreen/.evg.yml
Outdated
matrix_spec: { os: "linux", ssl: ["nossl", "ssl"], version: [ "latest" ], topology: ["replicaset"] } | ||
display_name: "Socks5: ${version} ${topology} ${ssl} ${jdk} ${os}" | ||
matrix_spec: { os: "linux", ssl: ["nossl", "ssl"], version: [ "latest" ], topology: ["replicaset"], socks_auth: ["auth", "noauth"] } | ||
display_name: "${socks_auth} SOCKS5 proxy: ${version} ${topology} ${ssl} ${jdk} ${os}" |
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
after SOCKS5 proxy
so that they sort together in the display
driver-sync/src/test/functional/com/mongodb/client/Socks5ProseTest.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/SocksSocket.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/SocksSocket.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/SocksSocket.java
Outdated
Show resolved
Hide resolved
JAVA-4347
Summary:
The MongoDB community has expressed the need for SOCKS5 proxy support. This PR introduces support for SOCKS5 proxy configuration for the synchronous version of the driver.
Changes:
Added support for configuring SOCKS5 proxy settings in MongoClientSettings, AutoEncryptionSettings and ClientEncryptionSettings.
Added SocksSocket which implements RFC19128 and RFC1929
Impact:
This feature enhances the driver's versatility and expands its usability in diverse networking scenarios. With this addition, users facing network restrictions, such as those accessing MongoDB deployments behind firewalls, can now seamlessly connect and interact with their databases.
Related links:
Specification
JAVA-4347