Skip to content

Commit 58ffb77

Browse files
committed
Small fixes
1 parent d84416e commit 58ffb77

File tree

5 files changed

+45
-47
lines changed

5 files changed

+45
-47
lines changed

build.cake

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,6 @@ Task("TestLoadBalanced")
229229
Task("TestLoadBalancedNetStandard21").IsDependentOn("TestLoadBalanced");
230230
Task("TestLoadBalancedNet60").IsDependentOn("TestLoadBalanced");
231231

232-
Task("TestSocks5Proxy")
233-
.IsDependentOn("TestLibMongoCrypt")
234-
.DoesForEach(
235-
items: GetFiles("./**/*.Tests.csproj"),
236-
action: (BuildConfig buildConfig, Path testProject) =>
237-
RunTests(buildConfig, testProject, filter: "Category=\"Socks5Proxy\""));
238-
239232
Task("TestSocks5ProxyNet472").IsDependentOn("TestSocks5Proxy");
240233
Task("TestSocks5ProxyNetStandard21").IsDependentOn("TestSocks5Proxy");
241234
Task("TestSocks5ProxyNet60").IsDependentOn("TestSocks5Proxy");
@@ -276,6 +269,13 @@ Task("TestCsfleWithGcpKms")
276269
action: (BuildConfig buildConfig, Path testProject) =>
277270
RunTests(buildConfig, testProject, filter: "Category=\"CsfleGCPKMS\""));
278271

272+
Task("TestSocks5Proxy")
273+
.IsDependentOn("Build")
274+
.DoesForEach(
275+
items: GetFiles("./**/*.Tests.csproj"),
276+
action: (BuildConfig buildConfig, Path testProject) =>
277+
RunTests(buildConfig, testProject, filter: "Category=\"Socks5Proxy\""));
278+
279279
Task("Package")
280280
.IsDependentOn("PackageNugetPackages");
281281

evergreen/evergreen.yml

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -26,42 +26,6 @@ timeout:
2626
2727
functions:
2828

29-
setup-socks5-proxy:
30-
- command: shell.exec
31-
params:
32-
background: true
33-
script: |
34-
${PREPARE_SHELL}
35-
MONGODB_URI="${MONGODB_URI}"
36-
# Read the MongoDB URI connection string and extract an arbitrary member's host:port
37-
HOST_PORT=$(echo "$MONGODB_URI" | sed 's|mongodb://||' | cut -d',' -f1)
38-
39-
export MAP_ARG="localhost:12345 to $HOST_PORT"
40-
python3 $DRIVERS_TOOLS/.evergreen/socks5srv.py --map "$MAP_ARG" --port 1080 --auth username:p4ssw0rd &
41-
python3 $DRIVERS_TOOLS/.evergreen/socks5srv.py --map "$MAP_ARG" --port 1081
42-
43-
#//TODO Check if we need all those parameters...
44-
run-socks5-proxy-tests:
45-
- command: shell.exec
46-
type: test
47-
params:
48-
working_dir: "mongo-csharp-driver"
49-
shell: "bash"
50-
script: |
51-
export SOCKS5_PROXY_SERVERS_ENABLED=true
52-
${PREPARE_SHELL}
53-
OS=${OS} \
54-
evergreen/add-ca-certs.sh
55-
SSL=${SSL} \
56-
MONGODB_URI="${MONGODB_URI}" \
57-
TOPOLOGY=${TOPOLOGY} \
58-
OS=${OS} \
59-
FRAMEWORK=${FRAMEWORK} \
60-
TARGET="TestSocks5Proxy" \
61-
evergreen/run-tests.sh
62-
OS=${OS} \
63-
evergreen/cleanup-test-resources.sh
64-
6529
fetch-source:
6630
# Executes git clone and applies the submitted patch, if any
6731
- command: git.get_project
@@ -1077,6 +1041,40 @@ functions:
10771041
bash $DRIVERS_TOOLS/.evergreen/auth_oidc/k8s/run-driver-test.sh
10781042
bash $DRIVERS_TOOLS/.evergreen/auth_oidc/k8s/teardown-pod.sh
10791043
1044+
setup-socks5-proxy:
1045+
- command: shell.exec
1046+
params:
1047+
background: true
1048+
script: |
1049+
${PREPARE_SHELL}
1050+
MONGODB_URI="${MONGODB_URI}"
1051+
# Read the MongoDB URI connection string and extract an arbitrary member's host:port
1052+
HOST_PORT=$(echo "$MONGODB_URI" | sed 's|mongodb://||' | cut -d',' -f1)
1053+
1054+
export MAP_ARG="localhost:12345 to $HOST_PORT"
1055+
python3 $DRIVERS_TOOLS/.evergreen/socks5srv.py --map "$MAP_ARG" --port 1080 --auth username:p4ssw0rd &
1056+
python3 $DRIVERS_TOOLS/.evergreen/socks5srv.py --map "$MAP_ARG" --port 1081
1057+
1058+
run-socks5-proxy-tests:
1059+
- command: shell.exec
1060+
type: test
1061+
params:
1062+
working_dir: "mongo-csharp-driver"
1063+
shell: "bash"
1064+
script: |
1065+
export SOCKS5_PROXY_SERVERS_ENABLED=true
1066+
${PREPARE_SHELL}
1067+
OS=${OS} \
1068+
evergreen/add-ca-certs.sh
1069+
SSL=${SSL} \
1070+
MONGODB_URI="${MONGODB_URI}" \
1071+
TOPOLOGY=${TOPOLOGY} \
1072+
OS=${OS} \
1073+
FRAMEWORK=${FRAMEWORK} \
1074+
TARGET="TestSocks5Proxy" \
1075+
evergreen/run-tests.sh
1076+
OS=${OS} \
1077+
evergreen/cleanup-test-resources.sh
10801078
pre:
10811079
- func: fetch-source
10821080
- func: prepare-resources

src/MongoDB.Driver/Core/Connections/TcpStreamFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public Stream CreateStream(EndPoint endPoint, CancellationToken cancellationToke
5050
{
5151
var socks5ProxySettings = _settings.Socks5ProxySettings;
5252
var useProxy = socks5ProxySettings != null;
53-
var targetEndpoint = socks5ProxySettings != null ? new DnsEndPoint(socks5ProxySettings.Host, socks5ProxySettings.Port) : endPoint;
53+
var targetEndpoint = useProxy ? new DnsEndPoint(socks5ProxySettings.Host, socks5ProxySettings.Port) : endPoint;
5454

5555
#if NET472
5656
var socket = CreateSocket(targetEndpoint);
@@ -99,7 +99,7 @@ public async Task<Stream> CreateStreamAsync(EndPoint endPoint, CancellationToken
9999
{
100100
var socks5ProxySettings = _settings.Socks5ProxySettings;
101101
var useProxy = socks5ProxySettings != null;
102-
var targetEndpoint = socks5ProxySettings != null ? new DnsEndPoint(socks5ProxySettings.Host, socks5ProxySettings.Port) : endPoint;
102+
var targetEndpoint = useProxy ? new DnsEndPoint(socks5ProxySettings.Host, socks5ProxySettings.Port) : endPoint;
103103

104104
#if NET472
105105
var socket = CreateSocket(targetEndpoint);

src/MongoDB.Driver/MongoUrlBuilder.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,6 @@ public MongoUrl ToMongoUrl()
821821
/// <returns>The canonical URL.</returns>
822822
public override string ToString()
823823
{
824-
//TODO Need to add options here too
825824
StringBuilder url = new StringBuilder();
826825
if (_scheme == ConnectionStringScheme.MongoDB)
827826
{

tests/MongoDB.Driver.Tests/Specifications/socks5-support/Socks5SupportProseTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ public static IEnumerable<object[]> GetTestCombinations()
6666
* - check if apiCompat is ok
6767
* - need to run the tests on .net framework as well
6868
* - cleanup tests
69-
*
69+
* - Drivers MUST verify for at least one of the connection strings marked (succeeds)
70+
* that command monitoring events do not reference the SOCKS5 proxy host where the MongoDB service server/port are referenced.
7071
*
7172
*/
7273

0 commit comments

Comments
 (0)