Skip to content

Commit b9ceea0

Browse files
committed
Removed unused
1 parent 74ade29 commit b9ceea0

File tree

1 file changed

+22
-26
lines changed

1 file changed

+22
-26
lines changed

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

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,23 @@ public static async Task PerformSocks5HandshakeAsync(Stream stream, EndPoint end
145145
}
146146
}
147147

148+
private static void CreateGreetingRequest(byte[] buffer, bool useAuth)
149+
{
150+
buffer[0] = ProtocolVersion5;
151+
152+
if (!useAuth)
153+
{
154+
buffer[1] = 1;
155+
buffer[2] = MethodNoAuth;
156+
}
157+
else
158+
{
159+
buffer[1] = 2;
160+
buffer[2] = MethodNoAuth;
161+
buffer[3] = MethodUsernamePassword;
162+
}
163+
}
164+
148165
private static void ReadGreetingResponse(Stream stream, byte[] buffer, bool useAuth, Socks5AuthenticationSettings authenticationSettings, CancellationToken cancellationToken)
149166
{
150167
stream.ReadBytes(buffer, 0, 2, cancellationToken);
@@ -270,7 +287,11 @@ private static int CreateConnectRequest(byte[] buffer, string targetHost, int ta
270287
private static int ReadConnectResponse(byte[] buffer, CancellationToken cancellationToken)
271288
{
272289
VerifyProtocolVersion(buffer[0]);
273-
VerifySockSuccess(buffer[1]);
290+
291+
if (buffer[1] != Socks5Success)
292+
{
293+
throw new IOException($"SOCKS5 connect failed");
294+
}
274295

275296
return buffer[3] switch
276297
{
@@ -281,23 +302,6 @@ private static int ReadConnectResponse(byte[] buffer, CancellationToken cancella
281302
};
282303
}
283304

284-
private static void CreateGreetingRequest(byte[] buffer, bool useAuth)
285-
{
286-
buffer[0] = ProtocolVersion5;
287-
288-
if (!useAuth)
289-
{
290-
buffer[1] = 1;
291-
buffer[2] = MethodNoAuth;
292-
}
293-
else
294-
{
295-
buffer[1] = 2;
296-
buffer[2] = MethodNoAuth;
297-
buffer[3] = MethodUsernamePassword;
298-
}
299-
}
300-
301305
private static void VerifyProtocolVersion(byte version)
302306
{
303307
if (version != ProtocolVersion5)
@@ -306,14 +310,6 @@ private static void VerifyProtocolVersion(byte version)
306310
}
307311
}
308312

309-
private static void VerifySockSuccess(byte value) //TODO Need to check this
310-
{
311-
if (value != Socks5Success)
312-
{
313-
throw new IOException($"SOCKS5 connect failed");
314-
}
315-
}
316-
317313
private static byte EncodeString(string input, byte[] buffer, int offset, string parameterName)
318314
{
319315
try

0 commit comments

Comments
 (0)