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
a6a60cd0
Commit
a6a60cd0
authored
Jun 25, 2017
by
Honfika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NETStandard releated improvelents + another websocket fix
parent
12d17b77
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
135 additions
and
116 deletions
+135
-116
DataEventArgs.cs
Titanium.Web.Proxy/EventArguments/DataEventArgs.cs
+3
-1
DotNetStandardExtensions.cs
Titanium.Web.Proxy/Extensions/DotNetStandardExtensions.cs
+2
-1
TcpExtensions.cs
Titanium.Web.Proxy/Extensions/TcpExtensions.cs
+2
-0
NativeMethods.SystemProxy.cs
Titanium.Web.Proxy/Helpers/NativeMethods.SystemProxy.cs
+23
-0
NativeMethods.Tcp.cs
Titanium.Web.Proxy/Helpers/NativeMethods.Tcp.cs
+61
-0
SystemProxy.cs
Titanium.Web.Proxy/Helpers/SystemProxy.cs
+0
-19
Tcp.cs
Titanium.Web.Proxy/Helpers/Tcp.cs
+5
-60
Titanium.Web.Proxy.csproj
Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
+39
-35
No files found.
Titanium.Web.Proxy/EventArguments/DataEventArgs.cs
View file @
a6a60cd0
using
System
;
namespace
Titanium.Web.Proxy.EventArguments
{
public
class
DataEventArgs
public
class
DataEventArgs
:
EventArgs
{
public
byte
[]
Buffer
{
get
;
}
...
...
Titanium.Web.Proxy/Extensions/DotNetStandardExtensions.cs
View file @
a6a60cd0
...
...
@@ -10,6 +10,7 @@ namespace Titanium.Web.Proxy.Extensions
{
internal
static
class
DotNetStandardExtensions
{
#if NET45
/// <summary>
/// Disposes the specified client.
/// Int .NET framework 4.5 the TcpClient class has no Dispose method,
...
...
@@ -34,6 +35,6 @@ namespace Titanium.Web.Proxy.Extensions
{
client
.
Close
();
}
#endif
}
}
Titanium.Web.Proxy/Extensions/TcpExtensions.cs
View file @
a6a60cd0
...
...
@@ -34,6 +34,7 @@ namespace Titanium.Web.Proxy.Extensions
}
}
#if NET45
/// <summary>
/// Gets the local port from a native TCP row object.
/// </summary>
...
...
@@ -53,5 +54,6 @@ namespace Titanium.Web.Proxy.Extensions
{
return
(
tcpRow
.
remotePort1
<<
8
)
+
tcpRow
.
remotePort2
+
(
tcpRow
.
remotePort3
<<
24
)
+
(
tcpRow
.
remotePort4
<<
16
);
}
#endif
}
}
Titanium.Web.Proxy/Helpers/NativeMethods.SystemProxy.cs
0 → 100644
View file @
a6a60cd0
using
System
;
using
System.Runtime.InteropServices
;
namespace
Titanium.Web.Proxy.Helpers
{
internal
partial
class
NativeMethods
{
[
DllImport
(
"wininet.dll"
)]
internal
static
extern
bool
InternetSetOption
(
IntPtr
hInternet
,
int
dwOption
,
IntPtr
lpBuffer
,
int
dwBufferLength
);
[
DllImport
(
"kernel32.dll"
)]
internal
static
extern
IntPtr
GetConsoleWindow
();
// Keeps it from getting garbage collected
internal
static
ConsoleEventDelegate
Handler
;
[
DllImport
(
"kernel32.dll"
,
SetLastError
=
true
)]
internal
static
extern
bool
SetConsoleCtrlHandler
(
ConsoleEventDelegate
callback
,
bool
add
);
// Pinvoke
internal
delegate
bool
ConsoleEventDelegate
(
int
eventType
);
}
}
\ No newline at end of file
Titanium.Web.Proxy/Helpers/NativeMethods.Tcp.cs
0 → 100644
View file @
a6a60cd0
using
System
;
using
System.Net.NetworkInformation
;
using
System.Runtime.InteropServices
;
namespace
Titanium.Web.Proxy.Helpers
{
internal
partial
class
NativeMethods
{
internal
const
int
AfInet
=
2
;
internal
const
int
AfInet6
=
23
;
internal
enum
TcpTableType
{
BasicListener
,
BasicConnections
,
BasicAll
,
OwnerPidListener
,
OwnerPidConnections
,
OwnerPidAll
,
OwnerModuleListener
,
OwnerModuleConnections
,
OwnerModuleAll
,
}
/// <summary>
/// <see href="http://msdn2.microsoft.com/en-us/library/aa366921.aspx"/>
/// </summary>
[
StructLayout
(
LayoutKind
.
Sequential
)]
internal
struct
TcpTable
{
public
uint
length
;
public
TcpRow
row
;
}
/// <summary>
/// <see href="http://msdn2.microsoft.com/en-us/library/aa366913.aspx"/>
/// </summary>
[
StructLayout
(
LayoutKind
.
Sequential
)]
internal
struct
TcpRow
{
public
TcpState
state
;
public
uint
localAddr
;
public
byte
localPort1
;
public
byte
localPort2
;
public
byte
localPort3
;
public
byte
localPort4
;
public
uint
remoteAddr
;
public
byte
remotePort1
;
public
byte
remotePort2
;
public
byte
remotePort3
;
public
byte
remotePort4
;
public
int
owningPid
;
}
/// <summary>
/// <see href="http://msdn2.microsoft.com/en-us/library/aa365928.aspx"/>
/// </summary>
[
DllImport
(
"iphlpapi.dll"
,
SetLastError
=
true
)]
internal
static
extern
uint
GetExtendedTcpTable
(
IntPtr
tcpTable
,
ref
int
size
,
bool
sort
,
int
ipVersion
,
int
tableClass
,
int
reserved
);
}
}
\ No newline at end of file
Titanium.Web.Proxy/Helpers/SystemProxy.cs
View file @
a6a60cd0
using
System
;
using
System.Linq
;
using
System.Runtime.InteropServices
;
using
Microsoft.Win32
;
// Helper classes for setting system proxy settings
...
...
@@ -30,24 +29,6 @@ namespace Titanium.Web.Proxy.Helpers
AllHttp
=
Http
|
Https
,
}
internal
partial
class
NativeMethods
{
[
DllImport
(
"wininet.dll"
)]
internal
static
extern
bool
InternetSetOption
(
IntPtr
hInternet
,
int
dwOption
,
IntPtr
lpBuffer
,
int
dwBufferLength
);
[
DllImport
(
"kernel32.dll"
)]
internal
static
extern
IntPtr
GetConsoleWindow
();
// Keeps it from getting garbage collected
internal
static
ConsoleEventDelegate
Handler
;
[
DllImport
(
"kernel32.dll"
,
SetLastError
=
true
)]
internal
static
extern
bool
SetConsoleCtrlHandler
(
ConsoleEventDelegate
callback
,
bool
add
);
// Pinvoke
internal
delegate
bool
ConsoleEventDelegate
(
int
eventType
);
}
internal
class
HttpSystemProxyValue
{
internal
string
HostName
{
get
;
set
;
}
...
...
Titanium.Web.Proxy/Helpers/Tcp.cs
View file @
a6a60cd0
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Net.NetworkInformation
;
using
System.Runtime.InteropServices
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
Titanium.Web.Proxy.Extensions
;
using
Titanium.Web.Proxy.Models
;
...
...
@@ -20,63 +18,9 @@ namespace Titanium.Web.Proxy.Helpers
Ipv6
=
2
,
}
internal
partial
class
NativeMethods
{
internal
const
int
AfInet
=
2
;
internal
const
int
AfInet6
=
23
;
internal
enum
TcpTableType
{
BasicListener
,
BasicConnections
,
BasicAll
,
OwnerPidListener
,
OwnerPidConnections
,
OwnerPidAll
,
OwnerModuleListener
,
OwnerModuleConnections
,
OwnerModuleAll
,
}
/// <summary>
/// <see href="http://msdn2.microsoft.com/en-us/library/aa366921.aspx"/>
/// </summary>
[
StructLayout
(
LayoutKind
.
Sequential
)]
internal
struct
TcpTable
{
public
uint
length
;
public
TcpRow
row
;
}
/// <summary>
/// <see href="http://msdn2.microsoft.com/en-us/library/aa366913.aspx"/>
/// </summary>
[
StructLayout
(
LayoutKind
.
Sequential
)]
internal
struct
TcpRow
{
public
TcpState
state
;
public
uint
localAddr
;
public
byte
localPort1
;
public
byte
localPort2
;
public
byte
localPort3
;
public
byte
localPort4
;
public
uint
remoteAddr
;
public
byte
remotePort1
;
public
byte
remotePort2
;
public
byte
remotePort3
;
public
byte
remotePort4
;
public
int
owningPid
;
}
/// <summary>
/// <see href="http://msdn2.microsoft.com/en-us/library/aa365928.aspx"/>
/// </summary>
[
DllImport
(
"iphlpapi.dll"
,
SetLastError
=
true
)]
internal
static
extern
uint
GetExtendedTcpTable
(
IntPtr
tcpTable
,
ref
int
size
,
bool
sort
,
int
ipVersion
,
int
tableClass
,
int
reserved
);
}
internal
class
TcpHelper
{
#if NET45
/// <summary>
/// Gets the extended TCP table.
/// </summary>
...
...
@@ -165,6 +109,7 @@ namespace Titanium.Web.Proxy.Helpers
return
null
;
}
#endif
/// <summary>
/// relays the input clientStream to the server at the specified host name and port with the given httpCmd and headers as prefix
...
...
@@ -202,7 +147,7 @@ namespace Titanium.Web.Proxy.Helpers
writer
.
Flush
();
var
data
=
ms
.
ToArray
();
await
ms
.
WriteAsync
(
data
,
0
,
data
.
Length
);
await
clientStream
.
WriteAsync
(
data
,
0
,
data
.
Length
);
onDataSend
?.
Invoke
(
data
,
0
,
data
.
Length
);
}
}
...
...
@@ -217,4 +162,4 @@ namespace Titanium.Web.Proxy.Helpers
await
Task
.
WhenAll
(
sendRelay
,
receiveRelay
);
}
}
}
}
\ No newline at end of file
Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
View file @
a6a60cd0
...
...
@@ -51,17 +51,16 @@
<Private>
True
</Private>
</Reference>
<Reference
Include=
"System"
/>
<Reference
Include=
"System.Net"
/>
<Reference
Include=
"System.Configuration"
/>
<Reference
Include=
"System.Core"
/>
<Reference
Include=
"System.Xml.Linq"
/>
<Reference
Include=
"System.Data.DataSetExtensions"
/>
<Reference
Include=
"Microsoft.CSharp"
/>
<Reference
Include=
"System.Data"
/>
<Reference
Include=
"System.Data.DataSetExtensions"
/>
<Reference
Include=
"System.Net"
/>
<Reference
Include=
"System.Xml"
/>
<Reference
Include=
"System.Xml.Linq"
/>
<Reference
Include=
"Microsoft.CSharp"
/>
</ItemGroup>
<ItemGroup>
<Compile
Include=
"CertificateHandler.cs"
/>
<Compile
Include=
"Compression\CompressionFactory.cs"
/>
<Compile
Include=
"Compression\DeflateCompression.cs"
/>
<Compile
Include=
"Compression\GZipCompression.cs"
/>
...
...
@@ -74,18 +73,31 @@
<Compile
Include=
"EventArguments\CertificateSelectionEventArgs.cs"
/>
<Compile
Include=
"EventArguments\CertificateValidationEventArgs.cs"
/>
<Compile
Include=
"EventArguments\DataEventArgs.cs"
/>
<Compile
Include=
"EventArguments\SessionEventArgs.cs"
/>
<Compile
Include=
"EventArguments\TunnelConnectEventArgs.cs"
/>
<Compile
Include=
"Exceptions\BodyNotFoundException.cs"
/>
<Compile
Include=
"Exceptions\ProxyAuthorizationException.cs"
/>
<Compile
Include=
"Exceptions\ProxyException.cs"
/>
<Compile
Include=
"Exceptions\ProxyHttpException.cs"
/>
<Compile
Include=
"Extensions\ByteArrayExtensions.cs"
/>
<Compile
Include=
"Extensions\DotNetStandardExtensions.cs"
/>
<Compile
Include=
"Extensions\FuncExtensions.cs"
/>
<Compile
Include=
"Helpers\HttpHelper.cs"
/>
<Compile
Include=
"Extensions\HttpWebRequestExtensions.cs"
/>
<Compile
Include=
"Extensions\HttpWebResponseExtensions.cs"
/>
<Compile
Include=
"Extensions\StreamExtensions.cs"
/>
<Compile
Include=
"Extensions\StringExtensions.cs"
/>
<Compile
Include=
"Extensions\TcpExtensions.cs"
/>
<Compile
Include=
"Helpers\BufferPool.cs"
/>
<Compile
Include=
"Helpers\CustomBinaryReader.cs"
/>
<Compile
Include=
"Helpers\CustomBufferedStream.cs"
/>
<Compile
Include=
"Helpers\
ProxyInfo
.cs"
/>
<Compile
Include=
"Helpers\
WinHttp\NativeMethods.WinHttp
.cs"
/>
<Compile
Include=
"Helpers\
Firefox
.cs"
/>
<Compile
Include=
"Helpers\
HttpHelper
.cs"
/>
<Compile
Include=
"Helpers\Network.cs"
/>
<Compile
Include=
"Helpers\ProxyInfo.cs"
/>
<Compile
Include=
"Helpers\RunTime.cs"
/>
<Compile
Include=
"Helpers\SystemProxy.cs"
/>
<Compile
Include=
"Helpers\Tcp.cs"
/>
<Compile
Include=
"Helpers\WinHttp\NativeMethods.WinHttp.cs"
/>
<Compile
Include=
"Helpers\WinHttp\WinHttpHandle.cs"
/>
<Compile
Include=
"Helpers\WinHttp\WinHttpWebProxyFinder.cs"
/>
<Compile
Include=
"Http\ConnectRequest.cs"
/>
...
...
@@ -93,51 +105,43 @@
<Compile
Include=
"Http\HeaderCollection.cs"
/>
<Compile
Include=
"Http\HeaderParser.cs"
/>
<Compile
Include=
"Http\HttpsTools.cs"
/>
<Compile
Include=
"Http\HttpWebClient.cs"
/>
<Compile
Include=
"Http\Request.cs"
/>
<Compile
Include=
"Http\Response.cs"
/>
<Compile
Include=
"Http\Responses\GenericResponse.cs"
/>
<Compile
Include=
"Http\Responses\OkResponse.cs"
/>
<Compile
Include=
"Http\Responses\RedirectResponse.cs"
/>
<Compile
Include=
"Models\EndPoint.cs"
/>
<Compile
Include=
"Models\ExternalProxy.cs"
/>
<Compile
Include=
"Models\HttpHeader.cs"
/>
<Compile
Include=
"Network\CachedCertificate.cs"
/>
<Compile
Include=
"Network\Certificate\WinCertificateMaker.cs"
/>
<Compile
Include=
"Network\Certificate\BCCertificateMaker.cs"
/>
<Compile
Include=
"Network\Certificate\ICertificateMaker.cs"
/>
<Compile
Include=
"Network\ProxyClient.cs"
/>
<Compile
Include=
"Exceptions\BodyNotFoundException.cs"
/>
<Compile
Include=
"Exceptions\ProxyAuthorizationException.cs"
/>
<Compile
Include=
"Exceptions\ProxyException.cs"
/>
<Compile
Include=
"Exceptions\ProxyHttpException.cs"
/>
<Compile
Include=
"Extensions\HttpWebResponseExtensions.cs"
/>
<Compile
Include=
"Extensions\HttpWebRequestExtensions.cs"
/>
<Compile
Include=
"Network\Certificate\WinCertificateMaker.cs"
/>
<Compile
Include=
"Network\CertificateManager.cs"
/>
<Compile
Include=
"Helpers\Firefox.cs"
/>
<Compile
Include=
"Helpers\SystemProxy.cs"
/>
<Compile
Include=
"Models\EndPoint.cs"
/>
<Compile
Include=
"Extensions\TcpExtensions.cs"
/>
<Compile
Include=
"Http\Request.cs"
/>
<Compile
Include=
"Http\Response.cs"
/>
<Compile
Include=
"Models\ExternalProxy.cs"
/>
<Compile
Include=
"Network\ProxyClient.cs"
/>
<Compile
Include=
"Network\Tcp\TcpConnection.cs"
/>
<Compile
Include=
"Network\Tcp\TcpConnectionFactory.cs"
/>
<Compile
Include=
"Models\HttpHeader.cs"
/>
<Compile
Include=
"Http\HttpWebClient.cs"
/>
<Compile
Include=
"Network\WinAuth\Security\Common.cs"
/>
<Compile
Include=
"Network\WinAuth\Security\WinAuthEndPoint.cs"
/>
<Compile
Include=
"Network\WinAuth\Security\LittleEndian.cs"
/>
<Compile
Include=
"Network\WinAuth\Security\Message.cs"
/>
<Compile
Include=
"Network\WinAuth\Security\State.cs"
/>
<Compile
Include=
"Network\WinAuth\Security\WinAuthEndPoint.cs"
/>
<Compile
Include=
"Network\WinAuth\WinAuthHandler.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"Shared\ProxyConstants.cs"
/>
<Compile
Include=
"WinAuthHandler.cs"
/>
<Compile
Include=
"CertificateHandler.cs"
/>
<Compile
Include=
"ProxyAuthorizationHandler.cs"
/>
<Compile
Include=
"ProxyServer.cs"
/>
<Compile
Include=
"RequestHandler.cs"
/>
<Compile
Include=
"ResponseHandler.cs"
/>
<Compile
Include=
"Helpers\CustomBinaryReader.cs"
/>
<Compile
Include=
"ProxyServer.cs"
/>
<Compile
Include=
"EventArguments\SessionEventArgs.cs"
/>
<Compile
Include=
"Helpers\Tcp.cs"
/>
<Compile
Include=
"Extensions\StreamExtensions.cs"
/>
<Compile
Include=
"Http\Responses\OkResponse.cs"
/>
<Compile
Include=
"Http\Responses\RedirectResponse.cs"
/>
<Compile
Include=
"Shared\ProxyConstants.cs"
/>
</ItemGroup>
<ItemGroup>
<Compile
Include=
"Helpers\NativeMethods.SystemProxy.cs"
/>
<Compile
Include=
"Helpers\NativeMethods.Tcp.cs"
/>
<Compile
Include=
"Network\Tcp\TcpRow.cs"
/>
<Compile
Include=
"Network\Tcp\TcpTable.cs"
/>
<Compile
Include=
"WinAuthHandler.cs"
/>
</ItemGroup>
<ItemGroup>
<COMReference
Include=
"CERTENROLLLib"
Condition=
"'$(OS)' != 'Unix'"
>
...
...
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