Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Titanium-Web-Proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Titanium-Web-Proxy
Commits
ead81899
Commit
ead81899
authored
Nov 14, 2017
by
Honfika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some property setter visibility changed, wpf demo project simplified
parent
b6829121
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
28 additions
and
28 deletions
+28
-28
MainWindow.xaml.cs
Examples/Titanium.Web.Proxy.Examples.Wpf/MainWindow.xaml.cs
+10
-9
SessionListItem.cs
Examples/Titanium.Web.Proxy.Examples.Wpf/SessionListItem.cs
+7
-7
SessionEventArgs.cs
Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
+3
-3
TunnelConnectEventArgs.cs
Titanium.Web.Proxy/EventArguments/TunnelConnectEventArgs.cs
+3
-2
HttpWebClient.cs
Titanium.Web.Proxy/Http/HttpWebClient.cs
+4
-5
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+1
-2
No files found.
Examples/Titanium.Web.Proxy.Examples.Wpf/MainWindow.xaml.cs
View file @
ead81899
...
@@ -56,7 +56,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
...
@@ -56,7 +56,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
set
{
SetValue
(
ServerConnectionCountProperty
,
value
);
}
set
{
SetValue
(
ServerConnectionCountProperty
,
value
);
}
}
}
private
readonly
Dictionary
<
SessionEventArgs
,
SessionListItem
>
sessionDictionary
=
new
Dictionary
<
SessionEventArgs
,
SessionListItem
>();
private
readonly
Dictionary
<
HttpWebClient
,
SessionListItem
>
sessionDictionary
=
new
Dictionary
<
HttpWebClient
,
SessionListItem
>();
private
SessionListItem
selectedSession
;
private
SessionListItem
selectedSession
;
public
MainWindow
()
public
MainWindow
()
...
@@ -105,7 +105,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
...
@@ -105,7 +105,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
await
Dispatcher
.
InvokeAsync
(()
=>
await
Dispatcher
.
InvokeAsync
(()
=>
{
{
SessionListItem
item
;
SessionListItem
item
;
if
(
sessionDictionary
.
TryGetValue
(
e
,
out
item
))
if
(
sessionDictionary
.
TryGetValue
(
e
.
WebSession
,
out
item
))
{
{
item
.
Update
();
item
.
Update
();
}
}
...
@@ -133,7 +133,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
...
@@ -133,7 +133,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
await
Dispatcher
.
InvokeAsync
(()
=>
await
Dispatcher
.
InvokeAsync
(()
=>
{
{
SessionListItem
item2
;
SessionListItem
item2
;
if
(
sessionDictionary
.
TryGetValue
(
e
,
out
item2
))
if
(
sessionDictionary
.
TryGetValue
(
e
.
WebSession
,
out
item2
))
{
{
item2
.
Update
();
item2
.
Update
();
item
=
item2
;
item
=
item2
;
...
@@ -154,27 +154,28 @@ namespace Titanium.Web.Proxy.Examples.Wpf
...
@@ -154,27 +154,28 @@ namespace Titanium.Web.Proxy.Examples.Wpf
{
{
var
item
=
CreateSessionListItem
(
e
);
var
item
=
CreateSessionListItem
(
e
);
Sessions
.
Add
(
item
);
Sessions
.
Add
(
item
);
sessionDictionary
.
Add
(
e
,
item
);
sessionDictionary
.
Add
(
e
.
WebSession
,
item
);
return
item
;
return
item
;
}
}
private
SessionListItem
CreateSessionListItem
(
SessionEventArgs
e
)
private
SessionListItem
CreateSessionListItem
(
SessionEventArgs
e
)
{
{
lastSessionNumber
++;
lastSessionNumber
++;
bool
isTunnelConnect
=
e
is
TunnelConnectSessionEventArgs
;
var
item
=
new
SessionListItem
var
item
=
new
SessionListItem
{
{
Number
=
lastSessionNumber
,
Number
=
lastSessionNumber
,
SessionArgs
=
e
,
WebSession
=
e
.
WebSession
,
WebSession
=
e
.
WebSession
,
IsTunnelConnect
=
isTunnelConnect
,
};
};
if
(
e
is
TunnelConnectSessionEventArgs
||
e
.
WebSession
.
Request
.
UpgradeToWebSocket
)
if
(
isTunnelConnect
||
e
.
WebSession
.
Request
.
UpgradeToWebSocket
)
{
{
e
.
DataReceived
+=
(
sender
,
args
)
=>
e
.
DataReceived
+=
(
sender
,
args
)
=>
{
{
var
session
=
(
SessionEventArgs
)
sender
;
var
session
=
(
SessionEventArgs
)
sender
;
SessionListItem
li
;
SessionListItem
li
;
if
(
sessionDictionary
.
TryGetValue
(
session
,
out
li
))
if
(
sessionDictionary
.
TryGetValue
(
session
.
WebSession
,
out
li
))
{
{
li
.
ReceivedDataCount
+=
args
.
Count
;
li
.
ReceivedDataCount
+=
args
.
Count
;
}
}
...
@@ -184,7 +185,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
...
@@ -184,7 +185,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
{
{
var
session
=
(
SessionEventArgs
)
sender
;
var
session
=
(
SessionEventArgs
)
sender
;
SessionListItem
li
;
SessionListItem
li
;
if
(
sessionDictionary
.
TryGetValue
(
session
,
out
li
))
if
(
sessionDictionary
.
TryGetValue
(
session
.
WebSession
,
out
li
))
{
{
li
.
SentDataCount
+=
args
.
Count
;
li
.
SentDataCount
+=
args
.
Count
;
}
}
...
@@ -203,7 +204,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
...
@@ -203,7 +204,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
foreach
(
var
item
in
selectedItems
.
Cast
<
SessionListItem
>().
ToArray
())
foreach
(
var
item
in
selectedItems
.
Cast
<
SessionListItem
>().
ToArray
())
{
{
Sessions
.
Remove
(
item
);
Sessions
.
Remove
(
item
);
sessionDictionary
.
Remove
(
item
.
SessionArgs
);
sessionDictionary
.
Remove
(
item
.
WebSession
);
}
}
}
}
}
}
...
...
Examples/Titanium.Web.Proxy.Examples.Wpf/SessionListItem.cs
View file @
ead81899
...
@@ -20,7 +20,9 @@ namespace Titanium.Web.Proxy.Examples.Wpf
...
@@ -20,7 +20,9 @@ namespace Titanium.Web.Proxy.Examples.Wpf
public
int
Number
{
get
;
set
;
}
public
int
Number
{
get
;
set
;
}
public
SessionEventArgs
SessionArgs
{
get
;
set
;
}
public
HttpWebClient
WebSession
{
get
;
set
;
}
public
bool
IsTunnelConnect
{
get
;
set
;
}
public
string
StatusCode
public
string
StatusCode
{
{
...
@@ -70,8 +72,6 @@ namespace Titanium.Web.Proxy.Examples.Wpf
...
@@ -70,8 +72,6 @@ namespace Titanium.Web.Proxy.Examples.Wpf
set
{
SetField
(
ref
sentDataCount
,
value
);
}
set
{
SetField
(
ref
sentDataCount
,
value
);
}
}
}
public
HttpWebClient
WebSession
{
get
;
set
;
}
public
event
PropertyChangedEventHandler
PropertyChanged
;
public
event
PropertyChangedEventHandler
PropertyChanged
;
protected
void
SetField
<
T
>(
ref
T
field
,
T
value
,[
CallerMemberName
]
string
propertyName
=
null
)
protected
void
SetField
<
T
>(
ref
T
field
,
T
value
,[
CallerMemberName
]
string
propertyName
=
null
)
...
@@ -88,13 +88,13 @@ namespace Titanium.Web.Proxy.Examples.Wpf
...
@@ -88,13 +88,13 @@ namespace Titanium.Web.Proxy.Examples.Wpf
public
void
Update
()
public
void
Update
()
{
{
var
request
=
SessionArgs
.
WebSession
.
Request
;
var
request
=
WebSession
.
Request
;
var
response
=
SessionArgs
.
WebSession
.
Response
;
var
response
=
WebSession
.
Response
;
int
statusCode
=
response
?.
ResponseStatusCode
??
0
;
int
statusCode
=
response
?.
ResponseStatusCode
??
0
;
StatusCode
=
statusCode
==
0
?
"-"
:
statusCode
.
ToString
();
StatusCode
=
statusCode
==
0
?
"-"
:
statusCode
.
ToString
();
Protocol
=
request
.
RequestUri
.
Scheme
;
Protocol
=
request
.
RequestUri
.
Scheme
;
if
(
SessionArgs
is
TunnelConnectSessionEventArgs
)
if
(
IsTunnelConnect
)
{
{
Host
=
"Tunnel to"
;
Host
=
"Tunnel to"
;
Url
=
request
.
RequestUri
.
Host
+
":"
+
request
.
RequestUri
.
Port
;
Url
=
request
.
RequestUri
.
Host
+
":"
+
request
.
RequestUri
.
Port
;
...
@@ -106,7 +106,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
...
@@ -106,7 +106,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
}
}
BodySize
=
response
?.
ContentLength
??
-
1
;
BodySize
=
response
?.
ContentLength
??
-
1
;
Process
=
GetProcessDescription
(
SessionArgs
.
WebSession
.
ProcessId
.
Value
);
Process
=
GetProcessDescription
(
WebSession
.
ProcessId
.
Value
);
}
}
private
string
GetProcessDescription
(
int
processId
)
private
string
GetProcessDescription
(
int
processId
)
...
...
Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
View file @
ead81899
...
@@ -79,17 +79,17 @@ namespace Titanium.Web.Proxy.EventArguments
...
@@ -79,17 +79,17 @@ namespace Titanium.Web.Proxy.EventArguments
/// A web session corresponding to a single request/response sequence
/// A web session corresponding to a single request/response sequence
/// within a proxy connection
/// within a proxy connection
/// </summary>
/// </summary>
public
HttpWebClient
WebSession
{
get
;
set
;
}
public
HttpWebClient
WebSession
{
get
;
}
/// <summary>
/// <summary>
/// Are we using a custom upstream HTTP proxy?
/// Are we using a custom upstream HTTP proxy?
/// </summary>
/// </summary>
public
ExternalProxy
CustomUpStreamHttpProxyUsed
{
get
;
set
;
}
public
ExternalProxy
CustomUpStreamHttpProxyUsed
{
get
;
internal
set
;
}
/// <summary>
/// <summary>
/// Are we using a custom upstream HTTPS proxy?
/// Are we using a custom upstream HTTPS proxy?
/// </summary>
/// </summary>
public
ExternalProxy
CustomUpStreamHttpsProxyUsed
{
get
;
set
;
}
public
ExternalProxy
CustomUpStreamHttpsProxyUsed
{
get
;
internal
set
;
}
public
event
EventHandler
<
DataEventArgs
>
DataSent
;
public
event
EventHandler
<
DataEventArgs
>
DataSent
;
...
...
Titanium.Web.Proxy/EventArguments/TunnelConnectEventArgs.cs
View file @
ead81899
using
System.Net
;
using
System.Net
;
using
Titanium.Web.Proxy.Http
;
using
Titanium.Web.Proxy.Models
;
using
Titanium.Web.Proxy.Models
;
namespace
Titanium.Web.Proxy.EventArguments
namespace
Titanium.Web.Proxy.EventArguments
...
@@ -7,10 +8,10 @@ namespace Titanium.Web.Proxy.EventArguments
...
@@ -7,10 +8,10 @@ namespace Titanium.Web.Proxy.EventArguments
{
{
public
bool
IsHttpsConnect
{
get
;
set
;
}
public
bool
IsHttpsConnect
{
get
;
set
;
}
public
TunnelConnectSessionEventArgs
(
int
bufferSize
,
ProxyEndPoint
endPoin
t
)
internal
TunnelConnectSessionEventArgs
(
int
bufferSize
,
ProxyEndPoint
endPoint
,
ConnectRequest
connectReques
t
)
:
base
(
bufferSize
,
endPoint
,
null
)
:
base
(
bufferSize
,
endPoint
,
null
)
{
{
WebSession
.
Request
=
connectRequest
;
}
}
}
}
}
}
Titanium.Web.Proxy/Http/HttpWebClient.cs
View file @
ead81899
...
@@ -33,17 +33,17 @@ namespace Titanium.Web.Proxy.Http
...
@@ -33,17 +33,17 @@ namespace Titanium.Web.Proxy.Http
/// <summary>
/// <summary>
/// Headers passed with Connect.
/// Headers passed with Connect.
/// </summary>
/// </summary>
public
ConnectRequest
ConnectRequest
{
get
;
set
;
}
public
ConnectRequest
ConnectRequest
{
get
;
internal
set
;
}
/// <summary>
/// <summary>
/// Web Request.
/// Web Request.
/// </summary>
/// </summary>
public
Request
Request
{
get
;
set
;
}
public
Request
Request
{
get
;
internal
set
;
}
/// <summary>
/// <summary>
/// Web Response.
/// Web Response.
/// </summary>
/// </summary>
public
Response
Response
{
get
;
set
;
}
public
Response
Response
{
get
;
internal
set
;
}
/// <summary>
/// <summary>
/// PID of the process that is created the current session when client is running in this machine
/// PID of the process that is created the current session when client is running in this machine
...
@@ -74,8 +74,7 @@ namespace Titanium.Web.Proxy.Http
...
@@ -74,8 +74,7 @@ namespace Titanium.Web.Proxy.Http
connection
.
LastAccess
=
DateTime
.
Now
;
connection
.
LastAccess
=
DateTime
.
Now
;
ServerConnection
=
connection
;
ServerConnection
=
connection
;
}
}
/// <summary>
/// <summary>
/// Prepare and send the http(s) request
/// Prepare and send the http(s) request
/// </summary>
/// </summary>
...
...
Titanium.Web.Proxy/RequestHandler.cs
View file @
ead81899
...
@@ -88,8 +88,7 @@ namespace Titanium.Web.Proxy
...
@@ -88,8 +88,7 @@ namespace Titanium.Web.Proxy
await
HeaderParser
.
ReadHeaders
(
clientStreamReader
,
connectRequest
.
RequestHeaders
);
await
HeaderParser
.
ReadHeaders
(
clientStreamReader
,
connectRequest
.
RequestHeaders
);
var
connectArgs
=
new
TunnelConnectSessionEventArgs
(
BufferSize
,
endPoint
);
var
connectArgs
=
new
TunnelConnectSessionEventArgs
(
BufferSize
,
endPoint
,
connectRequest
);
connectArgs
.
WebSession
.
Request
=
connectRequest
;
connectArgs
.
ProxyClient
.
TcpClient
=
tcpClient
;
connectArgs
.
ProxyClient
.
TcpClient
=
tcpClient
;
connectArgs
.
ProxyClient
.
ClientStream
=
clientStream
;
connectArgs
.
ProxyClient
.
ClientStream
=
clientStream
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment