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

Commit c83769b

Browse files
authored
Merge pull request #628 from justcoding121/master
beta
2 parents 1abc6e5 + bac300f commit c83769b

File tree

6 files changed

+169
-28
lines changed

6 files changed

+169
-28
lines changed

docs/api/Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.html

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ <h3 id="properties">Properties
185185
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_EventArguments_TunnelConnectSessionEventArgs_DecryptSsl.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.DecryptSsl%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
186186
</span>
187187
<span class="small pull-right mobile-hide">
188-
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/EventArguments/TunnelConnectEventArgs.cs/#L26">View Source</a>
188+
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/EventArguments/TunnelConnectEventArgs.cs/#L27">View Source</a>
189189
</span>
190190
<a id="Titanium_Web_Proxy_EventArguments_TunnelConnectSessionEventArgs_DecryptSsl_" data-uid="Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.DecryptSsl*"></a>
191191
<h4 id="Titanium_Web_Proxy_EventArguments_TunnelConnectSessionEventArgs_DecryptSsl" data-uid="Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.DecryptSsl">DecryptSsl</h4>
@@ -217,7 +217,7 @@ <h5 class="propertyValue">Property Value</h5>
217217
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_EventArguments_TunnelConnectSessionEventArgs_DenyConnect.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.DenyConnect%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
218218
</span>
219219
<span class="small pull-right mobile-hide">
220-
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/EventArguments/TunnelConnectEventArgs.cs/#L31">View Source</a>
220+
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/EventArguments/TunnelConnectEventArgs.cs/#L32">View Source</a>
221221
</span>
222222
<a id="Titanium_Web_Proxy_EventArguments_TunnelConnectSessionEventArgs_DenyConnect_" data-uid="Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.DenyConnect*"></a>
223223
<h4 id="Titanium_Web_Proxy_EventArguments_TunnelConnectSessionEventArgs_DenyConnect" data-uid="Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.DenyConnect">DenyConnect</h4>
@@ -248,7 +248,7 @@ <h5 class="propertyValue">Property Value</h5>
248248
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_EventArguments_TunnelConnectSessionEventArgs_IsHttpsConnect.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.IsHttpsConnect%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
249249
</span>
250250
<span class="small pull-right mobile-hide">
251-
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/EventArguments/TunnelConnectEventArgs.cs/#L36">View Source</a>
251+
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/EventArguments/TunnelConnectEventArgs.cs/#L37">View Source</a>
252252
</span>
253253
<a id="Titanium_Web_Proxy_EventArguments_TunnelConnectSessionEventArgs_IsHttpsConnect_" data-uid="Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.IsHttpsConnect*"></a>
254254
<h4 id="Titanium_Web_Proxy_EventArguments_TunnelConnectSessionEventArgs_IsHttpsConnect" data-uid="Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.IsHttpsConnect">IsHttpsConnect</h4>
@@ -274,6 +274,68 @@ <h5 class="propertyValue">Property Value</h5>
274274
</tr>
275275
</tbody>
276276
</table>
277+
<h3 id="events">Events
278+
</h3>
279+
<span class="small pull-right mobile-hide">
280+
<span class="divider">|</span>
281+
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_EventArguments_TunnelConnectSessionEventArgs_DecryptedDataReceived.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.DecryptedDataReceived%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
282+
</span>
283+
<span class="small pull-right mobile-hide">
284+
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/EventArguments/TunnelConnectEventArgs.cs/#L53">View Source</a>
285+
</span>
286+
<h4 id="Titanium_Web_Proxy_EventArguments_TunnelConnectSessionEventArgs_DecryptedDataReceived" data-uid="Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.DecryptedDataReceived">DecryptedDataReceived</h4>
287+
<div class="markdown level1 summary"><p>Fired when decrypted data is received within this session from client/server.</p>
288+
</div>
289+
<div class="markdown level1 conceptual"></div>
290+
<h5 class="decalaration">Declaration</h5>
291+
<div class="codewrapper">
292+
<pre><code class="lang-csharp hljs">public event EventHandler&lt;DataEventArgs&gt; DecryptedDataReceived</code></pre>
293+
</div>
294+
<h5 class="eventType">Event Type</h5>
295+
<table class="table table-bordered table-striped table-condensed">
296+
<thead>
297+
<tr>
298+
<th>Type</th>
299+
<th>Description</th>
300+
</tr>
301+
</thead>
302+
<tbody>
303+
<tr>
304+
<td><a class="xref" href="https://docs.microsoft.com/dotnet/api/system.eventhandler-1">EventHandler</a>&lt;<span class="xref">DataEventArgs</span>&gt;</td>
305+
<td></td>
306+
</tr>
307+
</tbody>
308+
</table>
309+
<span class="small pull-right mobile-hide">
310+
<span class="divider">|</span>
311+
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_EventArguments_TunnelConnectSessionEventArgs_DecryptedDataSent.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.DecryptedDataSent%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
312+
</span>
313+
<span class="small pull-right mobile-hide">
314+
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/EventArguments/TunnelConnectEventArgs.cs/#L48">View Source</a>
315+
</span>
316+
<h4 id="Titanium_Web_Proxy_EventArguments_TunnelConnectSessionEventArgs_DecryptedDataSent" data-uid="Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.DecryptedDataSent">DecryptedDataSent</h4>
317+
<div class="markdown level1 summary"><p>Fired when decrypted data is sent within this session to server/client.</p>
318+
</div>
319+
<div class="markdown level1 conceptual"></div>
320+
<h5 class="decalaration">Declaration</h5>
321+
<div class="codewrapper">
322+
<pre><code class="lang-csharp hljs">public event EventHandler&lt;DataEventArgs&gt; DecryptedDataSent</code></pre>
323+
</div>
324+
<h5 class="eventType">Event Type</h5>
325+
<table class="table table-bordered table-striped table-condensed">
326+
<thead>
327+
<tr>
328+
<th>Type</th>
329+
<th>Description</th>
330+
</tr>
331+
</thead>
332+
<tbody>
333+
<tr>
334+
<td><a class="xref" href="https://docs.microsoft.com/dotnet/api/system.eventhandler-1">EventHandler</a>&lt;<span class="xref">DataEventArgs</span>&gt;</td>
335+
<td></td>
336+
</tr>
337+
</tbody>
338+
</table>
277339
<h3 id="implements">Implements</h3>
278340
<div>
279341
<a class="xref" href="https://docs.microsoft.com/dotnet/api/system.idisposable">System.IDisposable</a>
@@ -289,7 +351,7 @@ <h3 id="implements">Implements</h3>
289351
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_EventArguments_TunnelConnectSessionEventArgs.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A" class="contribution-link">Improve this Doc</a>
290352
</li>
291353
<li>
292-
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/EventArguments/TunnelConnectEventArgs.cs/#L11" class="contribution-link">View Source</a>
354+
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/EventArguments/TunnelConnectEventArgs.cs/#L12" class="contribution-link">View Source</a>
293355
</li>
294356
</ul>
295357
</div>

docs/index.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"api/Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.html": {
4343
"href": "api/Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.html",
4444
"title": "Class TunnelConnectSessionEventArgs | Titanium Web Proxy",
45-
"keywords": "Class TunnelConnectSessionEventArgs A class that wraps the state when a tunnel connect event happen for Explicit endpoints. Inheritance Object EventArgs SessionEventArgsBase TunnelConnectSessionEventArgs Implements IDisposable Inherited Members SessionEventArgsBase.BufferPool SessionEventArgsBase.ExceptionFunc SessionEventArgsBase.TimeLine SessionEventArgsBase.UserData SessionEventArgsBase.IsHttps SessionEventArgsBase.ClientEndPoint SessionEventArgsBase.HttpClient SessionEventArgsBase.WebSession SessionEventArgsBase.CustomUpStreamProxyUsed SessionEventArgsBase.LocalEndPoint SessionEventArgsBase.IsTransparent SessionEventArgsBase.Exception SessionEventArgsBase.Dispose() SessionEventArgsBase.DataSent SessionEventArgsBase.DataReceived SessionEventArgsBase.TerminateSession() EventArgs.Empty Object.Equals(Object) Object.Equals(Object, Object) Object.GetHashCode() Object.GetType() Object.MemberwiseClone() Object.ReferenceEquals(Object, Object) Object.ToString() Namespace : Titanium.Web.Proxy.EventArguments Assembly : Titanium.Web.Proxy.dll Syntax public class TunnelConnectSessionEventArgs : SessionEventArgsBase, IDisposable Properties | Improve this Doc View Source DecryptSsl Should we decrypt the Ssl or relay it to server? Default is true. Declaration public bool DecryptSsl { get; set; } Property Value Type Description Boolean | Improve this Doc View Source DenyConnect When set to true it denies the connect request with a Forbidden status. Declaration public bool DenyConnect { get; set; } Property Value Type Description Boolean | Improve this Doc View Source IsHttpsConnect Is this a connect request to secure HTTP server? Or is it to some other protocol. Declaration public bool IsHttpsConnect { get; } Property Value Type Description Boolean Implements System.IDisposable"
45+
"keywords": "Class TunnelConnectSessionEventArgs A class that wraps the state when a tunnel connect event happen for Explicit endpoints. Inheritance Object EventArgs SessionEventArgsBase TunnelConnectSessionEventArgs Implements IDisposable Inherited Members SessionEventArgsBase.BufferPool SessionEventArgsBase.ExceptionFunc SessionEventArgsBase.TimeLine SessionEventArgsBase.UserData SessionEventArgsBase.IsHttps SessionEventArgsBase.ClientEndPoint SessionEventArgsBase.HttpClient SessionEventArgsBase.WebSession SessionEventArgsBase.CustomUpStreamProxyUsed SessionEventArgsBase.LocalEndPoint SessionEventArgsBase.IsTransparent SessionEventArgsBase.Exception SessionEventArgsBase.Dispose() SessionEventArgsBase.DataSent SessionEventArgsBase.DataReceived SessionEventArgsBase.TerminateSession() EventArgs.Empty Object.Equals(Object) Object.Equals(Object, Object) Object.GetHashCode() Object.GetType() Object.MemberwiseClone() Object.ReferenceEquals(Object, Object) Object.ToString() Namespace : Titanium.Web.Proxy.EventArguments Assembly : Titanium.Web.Proxy.dll Syntax public class TunnelConnectSessionEventArgs : SessionEventArgsBase, IDisposable Properties | Improve this Doc View Source DecryptSsl Should we decrypt the Ssl or relay it to server? Default is true. Declaration public bool DecryptSsl { get; set; } Property Value Type Description Boolean | Improve this Doc View Source DenyConnect When set to true it denies the connect request with a Forbidden status. Declaration public bool DenyConnect { get; set; } Property Value Type Description Boolean | Improve this Doc View Source IsHttpsConnect Is this a connect request to secure HTTP server? Or is it to some other protocol. Declaration public bool IsHttpsConnect { get; } Property Value Type Description Boolean Events | Improve this Doc View Source DecryptedDataReceived Fired when decrypted data is received within this session from client/server. Declaration public event EventHandler<DataEventArgs> DecryptedDataReceived Event Type Type Description EventHandler < DataEventArgs > | Improve this Doc View Source DecryptedDataSent Fired when decrypted data is sent within this session to server/client. Declaration public event EventHandler<DataEventArgs> DecryptedDataSent Event Type Type Description EventHandler < DataEventArgs > Implements System.IDisposable"
4646
},
4747
"api/Titanium.Web.Proxy.ExceptionHandler.html": {
4848
"href": "api/Titanium.Web.Proxy.ExceptionHandler.html",

docs/xrefmap.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,18 @@ references:
709709
commentId: T:Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs
710710
fullName: Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs
711711
nameWithType: TunnelConnectSessionEventArgs
712+
- uid: Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.DecryptedDataReceived
713+
name: DecryptedDataReceived
714+
href: api/Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.html#Titanium_Web_Proxy_EventArguments_TunnelConnectSessionEventArgs_DecryptedDataReceived
715+
commentId: E:Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.DecryptedDataReceived
716+
fullName: Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.DecryptedDataReceived
717+
nameWithType: TunnelConnectSessionEventArgs.DecryptedDataReceived
718+
- uid: Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.DecryptedDataSent
719+
name: DecryptedDataSent
720+
href: api/Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.html#Titanium_Web_Proxy_EventArguments_TunnelConnectSessionEventArgs_DecryptedDataSent
721+
commentId: E:Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.DecryptedDataSent
722+
fullName: Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.DecryptedDataSent
723+
nameWithType: TunnelConnectSessionEventArgs.DecryptedDataSent
712724
- uid: Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.DecryptSsl
713725
name: DecryptSsl
714726
href: api/Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.html#Titanium_Web_Proxy_EventArguments_TunnelConnectSessionEventArgs_DecryptSsl

examples/Titanium.Web.Proxy.Examples.Wpf/MainWindow.xaml.cs

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -231,42 +231,71 @@ private SessionListItem createSessionListItem(SessionEventArgsBase e)
231231
};
232232

233233
//if (isTunnelConnect || e.HttpClient.Request.UpgradeToWebSocket)
234+
e.DataReceived += (sender, args) =>
234235
{
235-
e.DataReceived += (sender, args) =>
236+
var session = (SessionEventArgsBase)sender;
237+
if (sessionDictionary.TryGetValue(session.HttpClient, out var li))
236238
{
237-
var session = (SessionEventArgsBase)sender;
238-
if (sessionDictionary.TryGetValue(session.HttpClient, out var li))
239+
var tunnelType = session.HttpClient.ConnectRequest?.TunnelType ?? TunnelType.Unknown;
240+
if (tunnelType != TunnelType.Unknown)
239241
{
240-
var tunnelType = session.HttpClient.ConnectRequest?.TunnelType ?? TunnelType.Unknown;
241-
if (tunnelType != TunnelType.Unknown)
242-
{
243-
li.Protocol = TunnelTypeToString(tunnelType);
244-
}
242+
li.Protocol = TunnelTypeToString(tunnelType);
243+
}
244+
245+
li.ReceivedDataCount += args.Count;
246+
247+
AppendTransferLog(session.GetHashCode() + (isTunnelConnect ? "_tunnel" : "") + "_received",
248+
args.Buffer, args.Offset, args.Count);
249+
}
250+
};
245251

246-
li.ReceivedDataCount += args.Count;
252+
e.DataSent += (sender, args) =>
253+
{
254+
var session = (SessionEventArgsBase)sender;
255+
if (sessionDictionary.TryGetValue(session.HttpClient, out var li))
256+
{
257+
var tunnelType = session.HttpClient.ConnectRequest?.TunnelType ?? TunnelType.Unknown;
258+
if (tunnelType != TunnelType.Unknown)
259+
{
260+
li.Protocol = TunnelTypeToString(tunnelType);
247261
}
248-
};
249262

250-
e.DataSent += (sender, args) =>
263+
li.SentDataCount += args.Count;
264+
265+
AppendTransferLog(session.GetHashCode() + (isTunnelConnect ? "_tunnel" : "") + "_sent",
266+
args.Buffer, args.Offset, args.Count);
267+
}
268+
};
269+
270+
if (e is TunnelConnectSessionEventArgs te)
271+
{
272+
te.DecryptedDataReceived += (sender, args) =>
251273
{
252274
var session = (SessionEventArgsBase)sender;
253-
if (sessionDictionary.TryGetValue(session.HttpClient, out var li))
254-
{
255-
var tunnelType = session.HttpClient.ConnectRequest?.TunnelType ?? TunnelType.Unknown;
256-
if (tunnelType != TunnelType.Unknown)
257-
{
258-
li.Protocol = TunnelTypeToString(tunnelType);
259-
}
275+
AppendTransferLog(session.GetHashCode() + "_decrypted_received", args.Buffer, args.Offset,
276+
args.Count);
277+
};
260278

261-
li.SentDataCount += args.Count;
262-
}
279+
te.DecryptedDataSent += (sender, args) =>
280+
{
281+
var session = (SessionEventArgsBase)sender;
282+
AppendTransferLog(session.GetHashCode() + "_decrypted_sent", args.Buffer, args.Offset, args.Count);
263283
};
264284
}
265285

266286
item.Update();
267287
return item;
268288
}
269289

290+
private void AppendTransferLog(string fileName, byte[] buffer, int offset, int count)
291+
{
292+
//string basePath = @"c:\!titanium\";
293+
//using (var fs = new FileStream(basePath + fileName, FileMode.Append, FileAccess.Write, FileShare.Read))
294+
//{
295+
// fs.Write(buffer, offset, count);
296+
//}
297+
}
298+
270299
private string TunnelTypeToString(TunnelType tunnelType)
271300
{
272301
switch (tunnelType)

0 commit comments

Comments
 (0)