Commit 1002511c authored by Honfika's avatar Honfika

Include exception data when listener faield to start

parent 09bcfe29
......@@ -26,7 +26,6 @@ namespace Titanium.Web.Proxy.Models
EnableSsl = enableSsl;
}
/// <summary>
/// underlying TCP Listener object
/// </summary>
......@@ -53,7 +52,6 @@ namespace Titanium.Web.Proxy.Models
public bool IpV6Enabled => Equals(IpAddress, IPAddress.IPv6Any)
|| Equals(IpAddress, IPAddress.IPv6Loopback)
|| Equals(IpAddress, IPAddress.IPv6None);
}
/// <summary>
......
......@@ -646,12 +646,23 @@ namespace Titanium.Web.Proxy
private void Listen(ProxyEndPoint endPoint)
{
endPoint.Listener = new TcpListener(endPoint.IpAddress, endPoint.Port);
try
{
endPoint.Listener.Start();
endPoint.Port = ((IPEndPoint)endPoint.Listener.LocalEndpoint).Port;
// accept clients asynchronously
endPoint.Listener.BeginAcceptTcpClient(OnAcceptConnection, endPoint);
}
catch (SocketException ex)
{
var pex = new Exception($"Endpoint {endPoint} failed to start. Check inner exception and exception data for details.", ex);
pex.Data.Add("ipAddress", endPoint.IpAddress);
pex.Data.Add("port", endPoint.Port);
throw pex;
}
}
/// <summary>
/// Verifiy if its safe to set this end point as System proxy
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment