Skip to content
This repository was archived by the owner on Jul 9, 2023. It is now read-only.

Commit abf159f

Browse files
committed
small cleanup
1 parent 2589132 commit abf159f

File tree

5 files changed

+11
-16
lines changed

5 files changed

+11
-16
lines changed

src/Titanium.Web.Proxy/Helpers/TcpHelper.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,10 @@ private static uint toNetworkByteOrder(uint port)
100100
/// <param name="onDataSend"></param>
101101
/// <param name="onDataReceive"></param>
102102
/// <param name="cancellationTokenSource"></param>
103-
/// <param name="exceptionFunc"></param>
104103
/// <returns></returns>
105104
private static async Task sendRawTap(Stream clientStream, Stream serverStream, IBufferPool bufferPool,
106105
Action<byte[], int, int>? onDataSend, Action<byte[], int, int>? onDataReceive,
107-
CancellationTokenSource cancellationTokenSource,
108-
ExceptionHandler exceptionFunc)
106+
CancellationTokenSource cancellationTokenSource)
109107
{
110108
// Now async relay all server=>client & client=>server data
111109
var sendRelay =
@@ -139,8 +137,7 @@ internal static Task SendRaw(Stream clientStream, Stream serverStream, IBufferPo
139137
{
140138
// todo: fix APM mode
141139
return sendRawTap(clientStream, serverStream, bufferPool, onDataSend, onDataReceive,
142-
cancellationTokenSource,
143-
exceptionFunc);
140+
cancellationTokenSource);
144141
}
145142
}
146143
}

src/Titanium.Web.Proxy/Network/Certificate/BCCertificateMaker.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.IO;
33
using System.Security.Cryptography.X509Certificates;
4-
using System.Threading;
54
using Org.BouncyCastle.Asn1;
65
using Org.BouncyCastle.Asn1.Pkcs;
76
using Org.BouncyCastle.Asn1.X509;
@@ -219,11 +218,9 @@ private X509Certificate2 makeCertificateInternal(string hostName, string subject
219218
/// <param name="subject">The s subject cn.</param>
220219
/// <param name="switchToMtaIfNeeded">if set to <c>true</c> [switch to MTA if needed].</param>
221220
/// <param name="signingCert">The signing cert.</param>
222-
/// <param name="cancellationToken">Task cancellation token</param>
223221
/// <returns>X509Certificate2.</returns>
224222
private X509Certificate2 makeCertificateInternal(string subject,
225-
bool switchToMtaIfNeeded, X509Certificate2? signingCert = null,
226-
CancellationToken cancellationToken = default)
223+
bool switchToMtaIfNeeded, X509Certificate2? signingCert = null)
227224
{
228225
return makeCertificateInternal(subject, $"CN={subject}",
229226
DateTime.UtcNow.AddDays(-certificateGraceDays), DateTime.UtcNow.AddDays(certificateValidDays),

src/Titanium.Web.Proxy/RequestHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,13 +291,13 @@ private async Task<RetryResult> handleHttpSessionRequest(SessionEventArgs args,
291291
}
292292

293293
// construct the web request that we are going to issue on behalf of the client.
294-
await handleHttpSessionRequest(connection, args);
294+
await handleHttpSessionRequest(args);
295295
return true;
296296

297297
}, generator, serverConnection);
298298
}
299299

300-
private async Task handleHttpSessionRequest(TcpServerConnection connection, SessionEventArgs args)
300+
private async Task handleHttpSessionRequest(SessionEventArgs args)
301301
{
302302
var cancellationToken = args.CancellationTokenSource.Token;
303303
var request = args.HttpClient.Request;

src/Titanium.Web.Proxy/StreamExtended/SslTools.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ internal class SslTools
154154

155155
if(extensionsStartPosition < recordLength + 5)
156156
{
157-
extensions = await ReadExtensions(majorVersion, minorVersion, peekStream, bufferPool, cancellationToken);
157+
extensions = await ReadExtensions(majorVersion, minorVersion, peekStream, cancellationToken);
158158
}
159159

160160
var clientHelloInfo = new ClientHelloInfo(3, majorVersion, minorVersion, random, sessionId, ciphers, peekStream.Position)
@@ -292,7 +292,7 @@ public static async Task<bool> IsServerHello(IPeekStream stream, IBufferPool buf
292292

293293
if (extensionsStartPosition < recordLength + 5)
294294
{
295-
extensions = await ReadExtensions(majorVersion, minorVersion, peekStream, bufferPool, cancellationToken);
295+
extensions = await ReadExtensions(majorVersion, minorVersion, peekStream, cancellationToken);
296296
}
297297

298298
var serverHelloInfo = new ServerHelloInfo(3, majorVersion, minorVersion, random, sessionId, cipherSuite, peekStream.Position)
@@ -308,7 +308,7 @@ public static async Task<bool> IsServerHello(IPeekStream stream, IBufferPool buf
308308
return null;
309309
}
310310

311-
private static async Task<Dictionary<string, SslExtension>?> ReadExtensions(int majorVersion, int minorVersion, PeekStreamReader peekStreamReader, IBufferPool bufferPool, CancellationToken cancellationToken)
311+
private static async Task<Dictionary<string, SslExtension>?> ReadExtensions(int majorVersion, int minorVersion, PeekStreamReader peekStreamReader, CancellationToken cancellationToken)
312312
{
313313
Dictionary<string, SslExtension>? extensions = null;
314314
if (majorVersion > 3 || majorVersion == 3 && minorVersion >= 1)

src/Titanium.Web.Proxy/TransparentClientHandler.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,15 @@ private async Task handleClient(TransparentProxyEndPoint endPoint, TcpClientConn
7575

7676
// HTTPS server created - we can now decrypt the client's traffic
7777
clientStream = new HttpClientStream(sslStream, BufferPool);
78+
sslStream = null; // clientStream was created, no need to keep SSL stream reference
7879
}
7980
catch (Exception e)
8081
{
81-
var certname = certificate?.GetNameInfo(X509NameType.SimpleName, false);
82+
var certName = certificate?.GetNameInfo(X509NameType.SimpleName, false);
8283
var session = new SessionEventArgs(this, endPoint, clientConnection, clientStream, null,
8384
cancellationTokenSource);
8485
throw new ProxyConnectException(
85-
$"Couldn't authenticate host '{httpsHostName}' with certificate '{certname}'.", e, session);
86+
$"Couldn't authenticate host '{httpsHostName}' with certificate '{certName}'.", e, session);
8687
}
8788

8889
}

0 commit comments

Comments
 (0)