Commit 4c6a8f50 authored by Honfika's avatar Honfika

Add property for client local endoint (not the lsitening endpoint, the actual...

Add property for client local endoint  (not the lsitening endpoint, the actual EP for the connection)
parent 9c2bc8bb
......@@ -31,7 +31,7 @@
<GridViewColumn Header="Process" DisplayMemberBinding="{Binding Process}" />
<GridViewColumn Header="SentBytes" DisplayMemberBinding="{Binding SentDataCount}" />
<GridViewColumn Header="ReceivedBytes" DisplayMemberBinding="{Binding ReceivedDataCount}" />
<GridViewColumn Header="ClientEndPoint" DisplayMemberBinding="{Binding ClientEndPoint}" />
<GridViewColumn Header="ClientRemoteEndPoint" DisplayMemberBinding="{Binding ClientRemoteEndPoint}" />
<GridViewColumn Header="ClientConnectionId" DisplayMemberBinding="{Binding ClientConnectionId}" />
<GridViewColumn Header="ServerConnectionId" DisplayMemberBinding="{Binding ServerConnectionId}" />
</GridView>
......
......@@ -229,7 +229,8 @@ namespace Titanium.Web.Proxy.Examples.Wpf
ClientConnectionId = e.ClientConnectionId,
ServerConnectionId = e.ServerConnectionId,
HttpClient = e.HttpClient,
ClientEndPoint = e.ClientEndPoint,
ClientRemoteEndPoint = e.ClientRemoteEndPoint,
ClientLocalEndPoint = e.ClientLocalEndPoint,
IsTunnelConnect = isTunnelConnect
};
......
......@@ -38,7 +38,9 @@ namespace Titanium.Web.Proxy.Examples.Wpf
public HttpWebClient HttpClient { get; set; }
public IPEndPoint ClientEndPoint { get; set; }
public IPEndPoint ClientLocalEndPoint { get; set; }
public IPEndPoint ClientRemoteEndPoint { get; set; }
public bool IsTunnelConnect { get; set; }
......
......@@ -25,7 +25,7 @@ namespace Titanium.Web.Proxy.EventArguments
/// </summary>
private bool reRequest;
private WebSocketDecoder webSocketDecoder;
private WebSocketDecoder? webSocketDecoder;
/// <summary>
/// Is this session a HTTP/2 promise?
......@@ -221,7 +221,7 @@ namespace Titanium.Web.Proxy.EventArguments
var reader = isRequest ? (HttpStream)ClientStream : HttpClient.Connection.Stream;
await reader.CopyBodyAsync(requestResponse, true, new NullWriter(), TransformationMode.None, null, cancellationToken);
await reader.CopyBodyAsync(requestResponse, true, NullWriter.Instance, TransformationMode.None, null, cancellationToken);
}
/// <summary>
......
......@@ -94,9 +94,14 @@ namespace Titanium.Web.Proxy.EventArguments
public bool IsHttps => HttpClient.Request.IsHttps;
/// <summary>
/// Client End Point.
/// Client Local End Point.
/// </summary>
public IPEndPoint ClientEndPoint => (IPEndPoint)ClientConnection.RemoteEndPoint;
public IPEndPoint ClientLocalEndPoint => (IPEndPoint)ClientConnection.LocalEndPoint;
/// <summary>
/// Client Remote End Point.
/// </summary>
public IPEndPoint ClientRemoteEndPoint => (IPEndPoint)ClientConnection.RemoteEndPoint;
/// <summary>
/// The web client used to communicate with server for this session.
......
......@@ -37,7 +37,6 @@ namespace Titanium.Web.Proxy
Task<TcpServerConnection>? prefetchConnectionTask = null;
bool closeServerConnection = false;
bool calledRequestHandler = false;
try
{
......@@ -375,10 +374,11 @@ namespace Titanium.Web.Proxy
}
}
calledRequestHandler = true;
var prefetchTask = prefetchConnectionTask;
prefetchConnectionTask = null;
// Now create the request
await handleHttpSessionRequest(endPoint, clientStream, cancellationTokenSource, connectArgs, prefetchConnectionTask);
await handleHttpSessionRequest(endPoint, clientStream, cancellationTokenSource, connectArgs, prefetchTask);
}
catch (ProxyException e)
{
......@@ -407,10 +407,7 @@ namespace Titanium.Web.Proxy
cancellationTokenSource.Cancel();
}
if (!calledRequestHandler)
{
await tcpConnectionFactory.Release(prefetchConnectionTask, closeServerConnection);
}
await tcpConnectionFactory.Release(prefetchConnectionTask, closeServerConnection);
clientStream.Dispose();
}
......
......@@ -8,6 +8,10 @@ namespace Titanium.Web.Proxy.Helpers
{
public static NullWriter Instance { get; } = new NullWriter();
private NullWriter()
{
}
public void Write(byte[] buffer, int offset, int count)
{
}
......
......@@ -580,20 +580,22 @@ retry:
internal async Task Release(Task<TcpServerConnection>? connectionCreateTask, bool closeServerConnection)
{
if (connectionCreateTask != null)
if (connectionCreateTask == null)
{
TcpServerConnection? connection = null;
try
{
connection = await connectionCreateTask;
}
catch { }
finally
return;
}
TcpServerConnection? connection = null;
try
{
connection = await connectionCreateTask;
}
catch { }
finally
{
if (connection != null)
{
if (connection != null)
{
await Release(connection, closeServerConnection);
}
await Release(connection, closeServerConnection);
}
}
}
......
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