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

Commit c525dda

Browse files
committed
let users change timeout minutes
1 parent e4dfa44 commit c525dda

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

Titanium.Web.Proxy/Helpers/CertificateManager.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ internal async void ClearIdleCertificates()
235235

236236
try
237237
{
238-
var cutOff = DateTime.Now.AddSeconds(-60);
238+
var cutOff = DateTime.Now.AddMinutes(-1 * ProxyServer.CertificateCacheTimeOutMinutes);
239239

240240
var outdated = certificateCache
241241
.Where(x => x.Value.LastAccess < cutOff)

Titanium.Web.Proxy/Network/TcpConnectionManager.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ internal async static void ClearIdleConnections()
206206
await connectionAccessLock.WaitAsync();
207207
try
208208
{
209-
var cutOff = DateTime.Now.AddSeconds(-60);
209+
var cutOff = DateTime.Now.AddMinutes(-1 * ProxyServer.ConnectionCacheTimeOutMinutes);
210210

211211
connectionCache
212212
.SelectMany(x => x.Value)

Titanium.Web.Proxy/ProxyServer.cs

+13-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ public partial class ProxyServer
2121

2222
static ProxyServer()
2323
{
24-
ProxyEndPoints = new List<ProxyEndPoint>();
24+
ProxyEndPoints = new List<ProxyEndPoint>();
25+
ConnectionCacheTimeOutMinutes = 3;
26+
CertificateCacheTimeOutMinutes = 60;
2527
}
2628

2729
private static CertificateManager CertManager { get; set; }
@@ -32,6 +34,16 @@ static ProxyServer()
3234
public static string RootCertificateIssuerName { get; set; }
3335
public static string RootCertificateName { get; set; }
3436
public static bool Enable100ContinueBehaviour { get; set; }
37+
38+
/// <summary>
39+
/// Minutes TCP connection cache to servers to be kept alive when in idle state
40+
/// </summary>
41+
public static int ConnectionCacheTimeOutMinutes { get; set; }
42+
43+
/// <summary>
44+
/// Minutes certificates should be kept in cache when not used
45+
/// </summary>
46+
public static int CertificateCacheTimeOutMinutes { get; set; }
3547

3648
public static event Func<object, SessionEventArgs, Task> BeforeRequest;
3749
public static event Func<object, SessionEventArgs, Task> BeforeResponse;

0 commit comments

Comments
 (0)