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