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

Commit 4b4972f

Browse files
committed
disable socket reuse in linux/macOS
1 parent 3b37a98 commit 4b4972f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ private async Task<TcpServerConnection> createServerConnection(string remoteHost
277277
};
278278

279279
//linux has a bug with socket reuse in .net core.
280-
if (proxyServer.ReuseSocket && !RunTime.IsLinux)
280+
if (proxyServer.ReuseSocket && RunTime.IsWindows || RunTime.IsRunningOnMono)
281281
{
282282
tcpClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
283283
}

Titanium.Web.Proxy/ProxyServer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public ProxyServer(string rootCertificateName, string rootCertificateIssuerName,
193193

194194
/// <summary>
195195
/// Should we reuse client/server tcp sockets.
196-
/// Default is true (false for linux due to bug in .Net core).
196+
/// Default is true (disabled for linux/macOS due to bug in .Net core).
197197
/// </summary>
198198
public bool ReuseSocket { get; set; } = true;
199199

@@ -617,8 +617,8 @@ private void listen(ProxyEndPoint endPoint)
617617
{
618618
endPoint.Listener = new TcpListener(endPoint.IpAddress, endPoint.Port);
619619

620-
//linux has a bug with socket reuse in .net core.
621-
if (ReuseSocket && !RunTime.IsLinux)
620+
//linux/macOS has a bug with socket reuse in .net core.
621+
if (ReuseSocket && (RunTime.IsWindows || RunTime.IsRunningOnMono))
622622
{
623623
endPoint.Listener.Server.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
624624
}

0 commit comments

Comments
 (0)