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
0bfe7a74
Commit
0bfe7a74
authored
Sep 28, 2019
by
Honfika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
netstandard 2.1 added
parent
bac300f3
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
52 additions
and
68 deletions
+52
-68
Titanium.Web.Proxy.Examples.Wpf.csproj
...Proxy.Examples.Wpf/Titanium.Web.Proxy.Examples.Wpf.csproj
+3
-30
ExplicitClientHandler.cs
src/Titanium.Web.Proxy/ExplicitClientHandler.cs
+4
-7
SslExtensions.cs
src/Titanium.Web.Proxy/Extensions/SslExtensions.cs
+2
-2
Http2Helper.cs
src/Titanium.Web.Proxy/Http2/Http2Helper.cs
+19
-14
TcpClientConnection.cs
src/Titanium.Web.Proxy/Network/Tcp/TcpClientConnection.cs
+1
-1
TcpConnectionFactory.cs
src/Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
+1
-1
TcpServerConnection.cs
src/Titanium.Web.Proxy/Network/Tcp/TcpServerConnection.cs
+1
-1
RequestHandler.cs
src/Titanium.Web.Proxy/RequestHandler.cs
+7
-7
ResponseHandler.cs
src/Titanium.Web.Proxy/ResponseHandler.cs
+3
-3
Titanium.Web.Proxy.csproj
src/Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
+10
-1
WebSocketHandler.cs
src/Titanium.Web.Proxy/WebSocketHandler.cs
+1
-1
No files found.
examples/Titanium.Web.Proxy.Examples.Wpf/Titanium.Web.Proxy.Examples.Wpf.csproj
View file @
0bfe7a74
...
...
@@ -6,11 +6,11 @@
<UseWPF>true</UseWPF>
</PropertyGroup>
<
!--<ItemGroup
>
<
ItemGroup Condition="'$(TargetFramework)' == 'net461'"
>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="WindowsBase" />
</ItemGroup>
-->
</ItemGroup>
<ItemGroup>
<Compile Remove="Properties\AssemblyInfo.cs" />
...
...
@@ -20,23 +20,6 @@
<ProjectReference Include="..\..\src\Titanium.Web.Proxy\Titanium.Web.Proxy.csproj" />
</ItemGroup>
<!--<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Update="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Update="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
...
...
@@ -52,16 +35,6 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Update="App.xaml">
<Generator>MSBuild:Compile</Generator>
</None>
<None Update="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
</None>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>-->
</ItemGroup>
</Project>
\ No newline at end of file
src/Titanium.Web.Proxy/ExplicitClientHandler.cs
View file @
0bfe7a74
...
...
@@ -288,8 +288,7 @@ namespace Titanium.Web.Proxy
if
(!
clientStream
.
IsClosed
&&
!
connection
.
Stream
.
IsClosed
)
{
await
TcpHelper
.
SendRaw
(
clientStream
,
connection
.
Stream
,
BufferPool
,
null
,
null
,
connectArgs
.
CancellationTokenSource
,
ExceptionFunc
);
null
,
null
,
connectArgs
.
CancellationTokenSource
,
ExceptionFunc
);
}
}
finally
...
...
@@ -338,17 +337,15 @@ namespace Titanium.Web.Proxy
await
connection
.
StreamWriter
.
WriteLineAsync
(
"SM"
,
cancellationToken
);
await
connection
.
StreamWriter
.
WriteLineAsync
(
cancellationToken
);
#if NETCOREAPP2_1
await
Http2Helper
.
SendHttp2
(
clientStream
,
connection
.
Stream
,
BufferPool
.
BufferSize
,
(
buffer
,
offset
,
count
)
=>
{
connectArgs
.
OnDecryptedDataSent
(
buffer
,
offset
,
count
);
},
(
buffer
,
offset
,
count
)
=>
{
connectArgs
.
OnDecryptedDataReceived
(
buffer
,
offset
,
count
);
},
await
Http2Helper
.
SendHttp2
(
clientStream
,
connection
.
Stream
,
()
=>
new
SessionEventArgs
(
this
,
endPoint
,
cancellationTokenSource
)
{
ProxyClient
=
{
Connection
=
clientConnection
},
HttpClient
=
{
ConnectRequest
=
connectArgs
?.
HttpClient
.
ConnectRequest
},
UserData
=
connectArgs
?.
UserData
},
async
args
=>
{
await
invoke
BeforeRequest
(
args
);
},
async
args
=>
{
await
invoke
BeforeResponse
(
args
);
},
async
args
=>
{
await
on
BeforeRequest
(
args
);
},
async
args
=>
{
await
on
BeforeResponse
(
args
);
},
connectArgs
.
CancellationTokenSource
,
clientConnection
.
Id
,
ExceptionFunc
);
#endif
}
...
...
src/Titanium.Web.Proxy/Extensions/SslExtensions.cs
View file @
0bfe7a74
...
...
@@ -28,7 +28,7 @@ namespace Titanium.Web.Proxy.Extensions
return
null
;
}
#if NETCOREAPP2_1
#if NETCOREAPP2_1
|| NETSTANDARD2_1
internal
static
List
<
SslApplicationProtocol
>
GetAlpn
(
this
ClientHelloInfo
clientHelloInfo
)
{
if
(
clientHelloInfo
.
Extensions
!=
null
&&
clientHelloInfo
.
Extensions
.
TryGetValue
(
"ALPN"
,
out
var
alpnExtension
))
...
...
@@ -78,7 +78,7 @@ namespace Titanium.Web.Proxy.Extensions
#endif
}
#if !NETCOREAPP2_1
#if !NETCOREAPP2_1
&& !NETSTANDARD2_1
internal
enum
SslApplicationProtocol
{
Http11
,
...
...
src/Titanium.Web.Proxy/Http2/Http2Helper.cs
View file @
0bfe7a74
#
if
NETCOREAPP2_1
#
if
NETCOREAPP2_1
||
NETSTANDARD2_1
using
System
;
using
System.Collections.Concurrent
;
using
System.Collections.Generic
;
...
...
@@ -24,8 +24,7 @@ namespace Titanium.Web.Proxy.Http2
/// Task-based Asynchronous Pattern
/// </summary>
/// <returns></returns>
internal
static
async
Task
SendHttp2
(
Stream
clientStream
,
Stream
serverStream
,
int
bufferSize
,
Action
<
byte
[],
int
,
int
>
onDataSend
,
Action
<
byte
[],
int
,
int
>
onDataReceive
,
internal
static
async
Task
SendHttp2
(
Stream
clientStream
,
Stream
serverStream
,
Func
<
SessionEventArgs
>
sessionFactory
,
Func
<
SessionEventArgs
,
Task
>
onBeforeRequest
,
Func
<
SessionEventArgs
,
Task
>
onBeforeResponse
,
CancellationTokenSource
cancellationTokenSource
,
Guid
connectionId
,
...
...
@@ -38,13 +37,13 @@ namespace Titanium.Web.Proxy.Http2
// Now async relay all server=>client & client=>server data
var
sendRelay
=
copyHttp2FrameAsync
(
clientStream
,
serverStream
,
onDataSend
,
clientSettings
,
serverSettings
,
copyHttp2FrameAsync
(
clientStream
,
serverStream
,
clientSettings
,
serverSettings
,
sessionFactory
,
sessions
,
onBeforeRequest
,
bufferSize
,
connectionId
,
true
,
cancellationTokenSource
.
Token
,
exceptionFunc
);
connectionId
,
true
,
cancellationTokenSource
.
Token
,
exceptionFunc
);
var
receiveRelay
=
copyHttp2FrameAsync
(
serverStream
,
clientStream
,
onDataReceive
,
serverSettings
,
clientSettings
,
copyHttp2FrameAsync
(
serverStream
,
clientStream
,
serverSettings
,
clientSettings
,
sessionFactory
,
sessions
,
onBeforeResponse
,
bufferSize
,
connectionId
,
false
,
cancellationTokenSource
.
Token
,
exceptionFunc
);
connectionId
,
false
,
cancellationTokenSource
.
Token
,
exceptionFunc
);
await
Task
.
WhenAny
(
sendRelay
,
receiveRelay
);
cancellationTokenSource
.
Cancel
();
...
...
@@ -52,11 +51,11 @@ namespace Titanium.Web.Proxy.Http2
await
Task
.
WhenAll
(
sendRelay
,
receiveRelay
);
}
private
static
async
Task
copyHttp2FrameAsync
(
Stream
input
,
Stream
output
,
Action
<
byte
[],
int
,
int
>
onCopy
,
private
static
async
Task
copyHttp2FrameAsync
(
Stream
input
,
Stream
output
,
Http2Settings
localSettings
,
Http2Settings
remoteSettings
,
Func
<
SessionEventArgs
>
sessionFactory
,
ConcurrentDictionary
<
int
,
SessionEventArgs
>
sessions
,
Func
<
SessionEventArgs
,
Task
>
onBeforeRequestResponse
,
int
bufferSize
,
Guid
connectionId
,
bool
isClient
,
CancellationToken
cancellationToken
,
Guid
connectionId
,
bool
isClient
,
CancellationToken
cancellationToken
,
ExceptionHandler
exceptionFunc
)
{
int
headerTableSize
=
0
;
...
...
@@ -69,7 +68,6 @@ namespace Titanium.Web.Proxy.Http2
{
var
frameHeaderBuffer
=
frameHeader
.
Buffer
;
int
read
=
await
forceRead
(
input
,
frameHeaderBuffer
,
0
,
9
,
cancellationToken
);
onCopy
(
frameHeaderBuffer
,
0
,
read
);
if
(
read
!=
9
)
{
return
;
...
...
@@ -92,7 +90,6 @@ namespace Titanium.Web.Proxy.Http2
}
read
=
await
forceRead
(
input
,
buffer
,
0
,
length
,
cancellationToken
);
onCopy
(
buffer
,
0
,
read
);
if
(
read
!=
length
)
{
return
;
...
...
@@ -127,6 +124,11 @@ namespace Titanium.Web.Proxy.Http2
//System.Diagnostics.Debug.WriteLine("CONN: " + connectionId + ", CLIENT: " + isClient + ", STREAM: " + streamId + ", TYPE: " + type);
if
(
type
==
Http2FrameType
.
Data
&&
args
!=
null
)
{
if
(
isClient
)
args
.
OnDataSent
(
buffer
,
0
,
read
);
else
args
.
OnDataReceived
(
buffer
,
0
,
read
);
rr
=
isClient
?
(
RequestResponseBase
)
args
.
HttpClient
.
Request
:
args
.
HttpClient
.
Response
;
bool
padded
=
(
flags
&
Http2FrameFlag
.
Padded
)
!=
0
;
...
...
@@ -182,8 +184,10 @@ namespace Titanium.Web.Proxy.Http2
{
args
=
sessionFactory
();
args
.
IsPromise
=
true
;
sessions
.
TryAdd
(
streamId
,
args
);
sessions
.
TryAdd
(
promisedStreamId
,
args
);
if
(!
sessions
.
TryAdd
(
streamId
,
args
))
;
if
(!
sessions
.
TryAdd
(
promisedStreamId
,
args
))
;
}
System
.
Diagnostics
.
Debug
.
WriteLine
(
"PROMISE STREAM: "
+
streamId
+
", "
+
promisedStreamId
+
...
...
@@ -201,7 +205,8 @@ namespace Titanium.Web.Proxy.Http2
if
(!
sessions
.
TryGetValue
(
streamId
,
out
args
))
{
args
=
sessionFactory
();
sessions
.
TryAdd
(
streamId
,
args
);
if
(!
sessions
.
TryAdd
(
streamId
,
args
))
;
}
rr
=
isClient
?
(
RequestResponseBase
)
args
.
HttpClient
.
Request
:
args
.
HttpClient
.
Response
;
...
...
src/Titanium.Web.Proxy/Network/Tcp/TcpClientConnection.cs
View file @
0bfe7a74
using
System
;
using
System.IO
;
using
System.Net
;
#if NETCOREAPP2_1
#if NETCOREAPP2_1
|| NETSTANDARD2_1
using
System.Net.Security
;
#endif
using
System.Net.Sockets
;
...
...
src/Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
View file @
0bfe7a74
...
...
@@ -391,7 +391,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
CertificateRevocationCheckMode
=
proxyServer
.
CheckCertificateRevocation
};
await
sslStream
.
AuthenticateAsClientAsync
(
options
,
cancellationToken
);
#if NETCOREAPP2_1
#if NETCOREAPP2_1
|| NETSTANDARD2_1
negotiatedApplicationProtocol
=
sslStream
.
NegotiatedApplicationProtocol
;
#endif
...
...
src/Titanium.Web.Proxy/Network/Tcp/TcpServerConnection.cs
View file @
0bfe7a74
using
System
;
using
System.Net
;
#if NETCOREAPP2_1
#if NETCOREAPP2_1
|| NETSTANDARD2_1
using
System.Net.Security
;
#endif
using
System.Net.Sockets
;
...
...
src/Titanium.Web.Proxy/RequestHandler.cs
View file @
0bfe7a74
...
...
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using
System.Linq
;
using
System.Net
;
using
System.Net.Sockets
;
#if NETCOREAPP2_1
#if NETCOREAPP2_1
|| NETSTANDARD2_1
using
System.Net.Security
;
#endif
using
System.Text.RegularExpressions
;
...
...
@@ -143,7 +143,7 @@ namespace Titanium.Web.Proxy
// proxy authorization check
if
(
httpsConnectHostname
==
null
&&
await
checkAuthorization
(
args
)
==
false
)
{
await
invoke
BeforeResponse
(
args
);
await
on
BeforeResponse
(
args
);
// send the response
await
clientStreamWriter
.
WriteResponseAsync
(
args
.
HttpClient
.
Response
,
...
...
@@ -166,10 +166,8 @@ namespace Titanium.Web.Proxy
// we need this to syphon out data from connection if API user changes them.
request
.
SetOriginalHeaders
();
args
.
TimeLine
[
"Request Received"
]
=
DateTime
.
Now
;
// If user requested interception do it
await
invoke
BeforeRequest
(
args
);
await
on
BeforeRequest
(
args
);
var
response
=
args
.
HttpClient
.
Response
;
...
...
@@ -286,7 +284,7 @@ namespace Titanium.Web.Proxy
}
finally
{
await
invoke
AfterResponse
(
args
);
await
on
AfterResponse
(
args
);
args
.
Dispose
();
}
}
...
...
@@ -410,8 +408,10 @@ namespace Titanium.Web.Proxy
/// </summary>
/// <param name="args">The session event arguments.</param>
/// <returns></returns>
private
async
Task
invoke
BeforeRequest
(
SessionEventArgs
args
)
private
async
Task
on
BeforeRequest
(
SessionEventArgs
args
)
{
args
.
TimeLine
[
"Request Received"
]
=
DateTime
.
Now
;
if
(
BeforeRequest
!=
null
)
{
await
BeforeRequest
.
InvokeAsync
(
this
,
args
,
ExceptionFunc
);
...
...
src/Titanium.Web.Proxy/ResponseHandler.cs
View file @
0bfe7a74
...
...
@@ -58,7 +58,7 @@ namespace Titanium.Web.Proxy
// if user requested call back then do it
if
(!
response
.
Locked
)
{
await
invoke
BeforeResponse
(
args
);
await
on
BeforeResponse
(
args
);
}
// it may changed in the user event
...
...
@@ -132,7 +132,7 @@ namespace Titanium.Web.Proxy
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
private
async
Task
invoke
BeforeResponse
(
SessionEventArgs
args
)
private
async
Task
on
BeforeResponse
(
SessionEventArgs
args
)
{
if
(
BeforeResponse
!=
null
)
{
...
...
@@ -145,7 +145,7 @@ namespace Titanium.Web.Proxy
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
private
async
Task
invoke
AfterResponse
(
SessionEventArgs
args
)
private
async
Task
on
AfterResponse
(
SessionEventArgs
args
)
{
if
(
AfterResponse
!=
null
)
{
...
...
src/Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
View file @
0bfe7a74
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net
standard2.1;net
coreapp2.1</TargetFrameworks>
<RootNamespace>Titanium.Web.Proxy</RootNamespace>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<SignAssembly>True</SignAssembly>
...
...
@@ -26,6 +26,15 @@
</PackageReference>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
<PackageReference Include="Microsoft.Win32.Registry">
<Version>4.5.0</Version>
</PackageReference>
<PackageReference Include="System.Security.Principal.Windows">
<Version>4.5.1</Version>
</PackageReference>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<PackageReference Include="Microsoft.Win32.Registry">
<Version>4.5.0</Version>
...
...
src/Titanium.Web.Proxy/WebSocketHandler.cs
View file @
0bfe7a74
...
...
@@ -60,7 +60,7 @@ namespace Titanium.Web.Proxy
// If user requested call back then do it
if
(!
args
.
HttpClient
.
Response
.
Locked
)
{
await
invoke
BeforeResponse
(
args
);
await
on
BeforeResponse
(
args
);
}
await
TcpHelper
.
SendRaw
(
clientStream
,
serverConnection
.
Stream
,
BufferPool
,
...
...
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