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
fc7e798c
Commit
fc7e798c
authored
Nov 27, 2016
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#151 #154
Fix reported issues
parent
a974578a
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
71 additions
and
67 deletions
+71
-67
Tcp.cs
Titanium.Web.Proxy/Helpers/Tcp.cs
+5
-5
HttpWebClient.cs
Titanium.Web.Proxy/Http/HttpWebClient.cs
+3
-2
TcpConnection.cs
Titanium.Web.Proxy/Network/Tcp/TcpConnection.cs
+1
-1
TcpConnectionFactory.cs
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
+3
-2
TcpRow.cs
Titanium.Web.Proxy/Network/Tcp/TcpRow.cs
+43
-43
TcpTable.cs
Titanium.Web.Proxy/Network/Tcp/TcpTable.cs
+2
-2
ProxyServer.cs
Titanium.Web.Proxy/ProxyServer.cs
+1
-0
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+5
-5
ProxyConstants.cs
Titanium.Web.Proxy/Shared/ProxyConstants.cs
+4
-3
Titanium.Web.Proxy.csproj
Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
+4
-4
No files found.
Titanium.Web.Proxy/Helpers/Tcp.cs
View file @
fc7e798c
...
@@ -10,8 +10,8 @@ using System.Text;
...
@@ -10,8 +10,8 @@ using System.Text;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Titanium.Web.Proxy.Extensions
;
using
Titanium.Web.Proxy.Extensions
;
using
Titanium.Web.Proxy.Models
;
using
Titanium.Web.Proxy.Models
;
using
Titanium.Web.Proxy.Network
;
using
Titanium.Web.Proxy.Network
.Tcp
;
using
Titanium.Web.Proxy.
Tcp
;
using
Titanium.Web.Proxy.
Shared
;
namespace
Titanium.Web.Proxy.Helpers
namespace
Titanium.Web.Proxy.Helpers
{
{
...
@@ -154,7 +154,7 @@ namespace Titanium.Web.Proxy.Helpers
...
@@ -154,7 +154,7 @@ namespace Titanium.Web.Proxy.Helpers
if
(
httpCmd
!=
null
)
if
(
httpCmd
!=
null
)
{
{
sb
.
Append
(
httpCmd
);
sb
.
Append
(
httpCmd
);
sb
.
Append
(
Environment
.
NewLine
);
sb
.
Append
(
ProxyConstants
.
NewLine
);
}
}
if
(
requestHeaders
!=
null
)
if
(
requestHeaders
!=
null
)
...
@@ -162,11 +162,11 @@ namespace Titanium.Web.Proxy.Helpers
...
@@ -162,11 +162,11 @@ namespace Titanium.Web.Proxy.Helpers
foreach
(
var
header
in
requestHeaders
.
Select
(
t
=>
t
.
Value
.
ToString
()))
foreach
(
var
header
in
requestHeaders
.
Select
(
t
=>
t
.
Value
.
ToString
()))
{
{
sb
.
Append
(
header
);
sb
.
Append
(
header
);
sb
.
Append
(
Environment
.
NewLine
);
sb
.
Append
(
ProxyConstants
.
NewLine
);
}
}
}
}
sb
.
Append
(
Environment
.
NewLine
);
sb
.
Append
(
ProxyConstants
.
NewLine
);
}
}
var
tcpConnection
=
await
tcpConnectionFactory
.
CreateClient
(
bufferSize
,
connectionTimeOutSeconds
,
var
tcpConnection
=
await
tcpConnectionFactory
.
CreateClient
(
bufferSize
,
connectionTimeOutSeconds
,
...
...
Titanium.Web.Proxy/Http/HttpWebClient.cs
View file @
fc7e798c
...
@@ -5,6 +5,7 @@ using System.Text;
...
@@ -5,6 +5,7 @@ using System.Text;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Titanium.Web.Proxy.Models
;
using
Titanium.Web.Proxy.Models
;
using
Titanium.Web.Proxy.Network
;
using
Titanium.Web.Proxy.Network
;
using
Titanium.Web.Proxy.Network.Tcp
;
using
Titanium.Web.Proxy.Shared
;
using
Titanium.Web.Proxy.Shared
;
namespace
Titanium.Web.Proxy.Http
namespace
Titanium.Web.Proxy.Http
...
@@ -90,7 +91,7 @@ namespace Titanium.Web.Proxy.Http
...
@@ -90,7 +91,7 @@ namespace Titanium.Web.Proxy.Http
var
header
=
headerItem
.
Value
;
var
header
=
headerItem
.
Value
;
if
(
headerItem
.
Key
!=
"Proxy-Authorization"
)
if
(
headerItem
.
Key
!=
"Proxy-Authorization"
)
{
{
requestLines
.
AppendLine
(
header
.
Name
+
':'
+
header
.
Value
);
requestLines
.
AppendLine
(
header
.
Name
+
":"
+
header
.
Value
);
}
}
}
}
...
@@ -102,7 +103,7 @@ namespace Titanium.Web.Proxy.Http
...
@@ -102,7 +103,7 @@ namespace Titanium.Web.Proxy.Http
{
{
if
(
headerItem
.
Key
!=
"Proxy-Authorization"
)
if
(
headerItem
.
Key
!=
"Proxy-Authorization"
)
{
{
requestLines
.
AppendLine
(
header
.
Name
+
':'
+
header
.
Value
);
requestLines
.
AppendLine
(
header
.
Name
+
":"
+
header
.
Value
);
}
}
}
}
}
}
...
...
Titanium.Web.Proxy/Network/TcpConnection.cs
→
Titanium.Web.Proxy/Network/Tcp
/Tcp
Connection.cs
View file @
fc7e798c
...
@@ -4,7 +4,7 @@ using System.Net.Sockets;
...
@@ -4,7 +4,7 @@ using System.Net.Sockets;
using
Titanium.Web.Proxy.Helpers
;
using
Titanium.Web.Proxy.Helpers
;
using
Titanium.Web.Proxy.Models
;
using
Titanium.Web.Proxy.Models
;
namespace
Titanium.Web.Proxy.Network
namespace
Titanium.Web.Proxy.Network
.Tcp
{
{
/// <summary>
/// <summary>
/// An object that holds TcpConnection to a particular server & port
/// An object that holds TcpConnection to a particular server & port
...
...
Titanium.Web.Proxy/Network/TcpConnectionFactory.cs
→
Titanium.Web.Proxy/Network/Tcp
/Tcp
ConnectionFactory.cs
View file @
fc7e798c
...
@@ -8,8 +8,9 @@ using Titanium.Web.Proxy.Helpers;
...
@@ -8,8 +8,9 @@ using Titanium.Web.Proxy.Helpers;
using
Titanium.Web.Proxy.Models
;
using
Titanium.Web.Proxy.Models
;
using
System.Security.Authentication
;
using
System.Security.Authentication
;
using
System.Linq
;
using
System.Linq
;
using
Titanium.Web.Proxy.Shared
;
namespace
Titanium.Web.Proxy.Network
namespace
Titanium.Web.Proxy.Network
.Tcp
{
{
/// <summary>
/// <summary>
/// A class that manages Tcp Connection to server used by this proxy server
/// A class that manages Tcp Connection to server used by this proxy server
...
@@ -54,7 +55,7 @@ namespace Titanium.Web.Proxy.Network
...
@@ -54,7 +55,7 @@ namespace Titanium.Web.Proxy.Network
client
=
new
TcpClient
(
externalHttpsProxy
.
HostName
,
externalHttpsProxy
.
Port
);
client
=
new
TcpClient
(
externalHttpsProxy
.
HostName
,
externalHttpsProxy
.
Port
);
stream
=
client
.
GetStream
();
stream
=
client
.
GetStream
();
using
(
var
writer
=
new
StreamWriter
(
stream
,
Encoding
.
ASCII
,
bufferSize
,
true
)
{
NewLine
=
"\r\n"
})
using
(
var
writer
=
new
StreamWriter
(
stream
,
Encoding
.
ASCII
,
bufferSize
,
true
)
{
NewLine
=
ProxyConstants
.
NewLine
})
{
{
await
writer
.
WriteLineAsync
(
$"CONNECT
{
remoteHostName
}
:
{
remotePort
}
HTTP/
{
httpVersion
}
"
);
await
writer
.
WriteLineAsync
(
$"CONNECT
{
remoteHostName
}
:
{
remotePort
}
HTTP/
{
httpVersion
}
"
);
await
writer
.
WriteLineAsync
(
$"Host:
{
remoteHostName
}
:
{
remotePort
}
"
);
await
writer
.
WriteLineAsync
(
$"Host:
{
remoteHostName
}
:
{
remotePort
}
"
);
...
...
Titanium.Web.Proxy/Tcp/TcpRow.cs
→
Titanium.Web.Proxy/
Network/
Tcp/TcpRow.cs
View file @
fc7e798c
using
System.Net
;
using
System.Net
;
using
Titanium.Web.Proxy.Helpers
;
using
Titanium.Web.Proxy.Helpers
;
namespace
Titanium.Web.Proxy.
Tcp
namespace
Titanium.Web.Proxy.
Network.Tcp
{
{
/// <summary>
/// <summary>
/// Represents a managed interface of IP Helper API TcpRow struct
/// Represents a managed interface of IP Helper API TcpRow struct
/// <see cref="http://msdn2.microsoft.com/en-us/library/aa366913.aspx"/>
/// <see cref="http://msdn2.microsoft.com/en-us/library/aa366913.aspx"/>
/// </summary>
/// </summary>
internal
class
TcpRow
internal
class
TcpRow
{
{
/// <summary>
/// <summary>
/// Initializes a new instance of the <see cref="TcpRow"/> class.
/// Initializes a new instance of the <see cref="TcpRow"/> class.
/// </summary>
/// </summary>
/// <param name="tcpRow">TcpRow struct.</param>
/// <param name="tcpRow">TcpRow struct.</param>
public
TcpRow
(
NativeMethods
.
TcpRow
tcpRow
)
public
TcpRow
(
NativeMethods
.
TcpRow
tcpRow
)
{
{
ProcessId
=
tcpRow
.
owningPid
;
ProcessId
=
tcpRow
.
owningPid
;
int
localPort
=
(
tcpRow
.
localPort1
<<
8
)
+
(
tcpRow
.
localPort2
)
+
(
tcpRow
.
localPort3
<<
24
)
+
(
tcpRow
.
localPort4
<<
16
);
int
localPort
=
(
tcpRow
.
localPort1
<<
8
)
+
(
tcpRow
.
localPort2
)
+
(
tcpRow
.
localPort3
<<
24
)
+
(
tcpRow
.
localPort4
<<
16
);
long
localAddress
=
tcpRow
.
localAddr
;
long
localAddress
=
tcpRow
.
localAddr
;
LocalEndPoint
=
new
IPEndPoint
(
localAddress
,
localPort
);
LocalEndPoint
=
new
IPEndPoint
(
localAddress
,
localPort
);
int
remotePort
=
(
tcpRow
.
remotePort1
<<
8
)
+
(
tcpRow
.
remotePort2
)
+
(
tcpRow
.
remotePort3
<<
24
)
+
(
tcpRow
.
remotePort4
<<
16
);
int
remotePort
=
(
tcpRow
.
remotePort1
<<
8
)
+
(
tcpRow
.
remotePort2
)
+
(
tcpRow
.
remotePort3
<<
24
)
+
(
tcpRow
.
remotePort4
<<
16
);
long
remoteAddress
=
tcpRow
.
remoteAddr
;
long
remoteAddress
=
tcpRow
.
remoteAddr
;
RemoteEndPoint
=
new
IPEndPoint
(
remoteAddress
,
remotePort
);
RemoteEndPoint
=
new
IPEndPoint
(
remoteAddress
,
remotePort
);
}
}
/// <summary>
/// <summary>
/// Gets the local end point.
/// Gets the local end point.
/// </summary>
/// </summary>
public
IPEndPoint
LocalEndPoint
{
get
;
private
set
;
}
public
IPEndPoint
LocalEndPoint
{
get
;
private
set
;
}
/// <summary>
/// <summary>
/// Gets the remote end point.
/// Gets the remote end point.
/// </summary>
/// </summary>
public
IPEndPoint
RemoteEndPoint
{
get
;
private
set
;
}
public
IPEndPoint
RemoteEndPoint
{
get
;
private
set
;
}
/// <summary>
/// <summary>
/// Gets the process identifier.
/// Gets the process identifier.
/// </summary>
/// </summary>
public
int
ProcessId
{
get
;
private
set
;
}
public
int
ProcessId
{
get
;
private
set
;
}
}
}
}
}
\ No newline at end of file
Titanium.Web.Proxy/Tcp/TcpTable.cs
→
Titanium.Web.Proxy/
Network/
Tcp/TcpTable.cs
View file @
fc7e798c
using
System.Collections
;
using
System.Collections
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
namespace
Titanium.Web.Proxy.Tcp
namespace
Titanium.Web.Proxy.
Network.
Tcp
{
{
/// <summary>
/// <summary>
/// Represents collection of TcpRows
/// Represents collection of TcpRows
/// </summary>
/// </summary>
/// <seealso cref="System.Collections.Generic.IEnumerable{
Titanium.Web.
Proxy.Tcp.TcpRow}" />
/// <seealso cref="System.Collections.Generic.IEnumerable{Proxy.Tcp.TcpRow}" />
internal
class
TcpTable
:
IEnumerable
<
TcpRow
>
internal
class
TcpTable
:
IEnumerable
<
TcpRow
>
{
{
private
readonly
IEnumerable
<
TcpRow
>
tcpRows
;
private
readonly
IEnumerable
<
TcpRow
>
tcpRows
;
...
...
Titanium.Web.Proxy/ProxyServer.cs
View file @
fc7e798c
...
@@ -9,6 +9,7 @@ using Titanium.Web.Proxy.Models;
...
@@ -9,6 +9,7 @@ using Titanium.Web.Proxy.Models;
using
Titanium.Web.Proxy.Network
;
using
Titanium.Web.Proxy.Network
;
using
System.Linq
;
using
System.Linq
;
using
System.Security.Authentication
;
using
System.Security.Authentication
;
using
Titanium.Web.Proxy.Network.Tcp
;
namespace
Titanium.Web.Proxy
namespace
Titanium.Web.Proxy
{
{
...
...
Titanium.Web.Proxy/RequestHandler.cs
View file @
fc7e798c
...
@@ -10,13 +10,13 @@ using System.Text.RegularExpressions;
...
@@ -10,13 +10,13 @@ using System.Text.RegularExpressions;
using
Titanium.Web.Proxy.Exceptions
;
using
Titanium.Web.Proxy.Exceptions
;
using
Titanium.Web.Proxy.EventArguments
;
using
Titanium.Web.Proxy.EventArguments
;
using
Titanium.Web.Proxy.Helpers
;
using
Titanium.Web.Proxy.Helpers
;
using
Titanium.Web.Proxy.Network
;
using
Titanium.Web.Proxy.Models
;
using
Titanium.Web.Proxy.Models
;
using
System.Security.Cryptography.X509Certificates
;
using
System.Security.Cryptography.X509Certificates
;
using
Titanium.Web.Proxy.Shared
;
using
Titanium.Web.Proxy.Shared
;
using
Titanium.Web.Proxy.Http
;
using
Titanium.Web.Proxy.Http
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Titanium.Web.Proxy.Extensions
;
using
Titanium.Web.Proxy.Extensions
;
using
Titanium.Web.Proxy.Network.Tcp
;
namespace
Titanium.Web.Proxy
namespace
Titanium.Web.Proxy
{
{
...
@@ -38,7 +38,7 @@ namespace Titanium.Web.Proxy
...
@@ -38,7 +38,7 @@ namespace Titanium.Web.Proxy
clientStream
.
WriteTimeout
=
ConnectionTimeOutSeconds
*
1000
;
clientStream
.
WriteTimeout
=
ConnectionTimeOutSeconds
*
1000
;
var
clientStreamReader
=
new
CustomBinaryReader
(
clientStream
);
var
clientStreamReader
=
new
CustomBinaryReader
(
clientStream
);
var
clientStreamWriter
=
new
StreamWriter
(
clientStream
)
{
NewLine
=
"\r\n"
};
var
clientStreamWriter
=
new
StreamWriter
(
clientStream
)
{
NewLine
=
ProxyConstants
.
NewLine
};
Uri
httpRemoteUri
;
Uri
httpRemoteUri
;
try
try
...
@@ -121,7 +121,7 @@ namespace Titanium.Web.Proxy
...
@@ -121,7 +121,7 @@ namespace Titanium.Web.Proxy
clientStream
=
sslStream
;
clientStream
=
sslStream
;
clientStreamReader
=
new
CustomBinaryReader
(
sslStream
);
clientStreamReader
=
new
CustomBinaryReader
(
sslStream
);
clientStreamWriter
=
new
StreamWriter
(
sslStream
)
{
NewLine
=
"\r\n"
};
clientStreamWriter
=
new
StreamWriter
(
sslStream
)
{
NewLine
=
ProxyConstants
.
NewLine
};
}
}
catch
catch
...
@@ -195,7 +195,7 @@ namespace Titanium.Web.Proxy
...
@@ -195,7 +195,7 @@ namespace Titanium.Web.Proxy
SslProtocols
.
Tls
,
false
);
SslProtocols
.
Tls
,
false
);
clientStreamReader
=
new
CustomBinaryReader
(
sslStream
);
clientStreamReader
=
new
CustomBinaryReader
(
sslStream
);
clientStreamWriter
=
new
StreamWriter
(
sslStream
)
{
NewLine
=
"\r\n"
};
clientStreamWriter
=
new
StreamWriter
(
sslStream
)
{
NewLine
=
ProxyConstants
.
NewLine
};
//HTTPS server created - we can now decrypt the client's traffic
//HTTPS server created - we can now decrypt the client's traffic
}
}
...
@@ -211,7 +211,7 @@ namespace Titanium.Web.Proxy
...
@@ -211,7 +211,7 @@ namespace Titanium.Web.Proxy
else
else
{
{
clientStreamReader
=
new
CustomBinaryReader
(
clientStream
);
clientStreamReader
=
new
CustomBinaryReader
(
clientStream
);
clientStreamWriter
=
new
StreamWriter
(
clientStream
)
{
NewLine
=
"\r\n"
};
clientStreamWriter
=
new
StreamWriter
(
clientStream
)
{
NewLine
=
ProxyConstants
.
NewLine
};
}
}
//now read the request line
//now read the request line
...
...
Titanium.Web.Proxy/Shared/ProxyConstants.cs
View file @
fc7e798c
...
@@ -8,14 +8,15 @@ namespace Titanium.Web.Proxy.Shared
...
@@ -8,14 +8,15 @@ namespace Titanium.Web.Proxy.Shared
/// </summary>
/// </summary>
internal
class
ProxyConstants
internal
class
ProxyConstants
{
{
internal
static
readonly
char
[]
SpaceSplit
=
{
' '
};
internal
static
readonly
char
[]
SpaceSplit
=
{
' '
};
internal
static
readonly
char
[]
ColonSplit
=
{
':'
};
internal
static
readonly
char
[]
ColonSplit
=
{
':'
};
internal
static
readonly
char
[]
SemiColonSplit
=
{
';'
};
internal
static
readonly
char
[]
SemiColonSplit
=
{
';'
};
internal
static
readonly
byte
[]
NewLineBytes
=
Encoding
.
ASCII
.
GetBytes
(
Environment
.
NewLine
);
internal
static
readonly
byte
[]
NewLineBytes
=
Encoding
.
ASCII
.
GetBytes
(
NewLine
);
internal
static
readonly
byte
[]
ChunkEnd
=
internal
static
readonly
byte
[]
ChunkEnd
=
Encoding
.
ASCII
.
GetBytes
(
0.
ToString
(
"x2"
)
+
Environment
.
NewLine
+
Environment
.
NewLine
);
Encoding
.
ASCII
.
GetBytes
(
0.
ToString
(
"x2"
)
+
NewLine
+
NewLine
);
internal
const
string
NewLine
=
"\r\n"
;
}
}
}
}
Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
View file @
fc7e798c
...
@@ -84,8 +84,8 @@
...
@@ -84,8 +84,8 @@
<Compile
Include=
"Http\Request.cs"
/>
<Compile
Include=
"Http\Request.cs"
/>
<Compile
Include=
"Http\Response.cs"
/>
<Compile
Include=
"Http\Response.cs"
/>
<Compile
Include=
"Models\ExternalProxy.cs"
/>
<Compile
Include=
"Models\ExternalProxy.cs"
/>
<Compile
Include=
"Network\TcpConnection.cs"
/>
<Compile
Include=
"Network\Tcp
\Tcp
Connection.cs"
/>
<Compile
Include=
"Network\TcpConnectionFactory.cs"
/>
<Compile
Include=
"Network\Tcp
\Tcp
ConnectionFactory.cs"
/>
<Compile
Include=
"Models\HttpHeader.cs"
/>
<Compile
Include=
"Models\HttpHeader.cs"
/>
<Compile
Include=
"Http\HttpWebClient.cs"
/>
<Compile
Include=
"Http\HttpWebClient.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
...
@@ -100,8 +100,8 @@
...
@@ -100,8 +100,8 @@
<Compile
Include=
"Http\Responses\OkResponse.cs"
/>
<Compile
Include=
"Http\Responses\OkResponse.cs"
/>
<Compile
Include=
"Http\Responses\RedirectResponse.cs"
/>
<Compile
Include=
"Http\Responses\RedirectResponse.cs"
/>
<Compile
Include=
"Shared\ProxyConstants.cs"
/>
<Compile
Include=
"Shared\ProxyConstants.cs"
/>
<Compile
Include=
"Tcp\TcpRow.cs"
/>
<Compile
Include=
"
Network\
Tcp\TcpRow.cs"
/>
<Compile
Include=
"Tcp\TcpTable.cs"
/>
<Compile
Include=
"
Network\
Tcp\TcpTable.cs"
/>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<COMReference
Include=
"CERTENROLLLib"
>
<COMReference
Include=
"CERTENROLLLib"
>
...
...
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