Unverified Commit 34e533c1 authored by Jehonathan Thomas's avatar Jehonathan Thomas Committed by GitHub

Merge pull request #582 from honfika/master

prepare for basic http/2 support and another small fixes (typo, version numbers)
parents 578fd98c b3a486fb
...@@ -103,7 +103,7 @@ namespace Titanium.Web.Proxy ...@@ -103,7 +103,7 @@ namespace Titanium.Web.Proxy
if (await checkAuthorization(connectArgs) == false) if (await checkAuthorization(connectArgs) == false)
{ {
await endPoint.InvokeBeforeTunnectConnectResponse(this, connectArgs, ExceptionFunc); await endPoint.InvokeBeforeTunnelConnectResponse(this, connectArgs, ExceptionFunc);
// send the response // send the response
await clientStreamWriter.WriteResponseAsync(connectArgs.HttpClient.Response, await clientStreamWriter.WriteResponseAsync(connectArgs.HttpClient.Response,
...@@ -129,7 +129,7 @@ namespace Titanium.Web.Proxy ...@@ -129,7 +129,7 @@ namespace Titanium.Web.Proxy
connectRequest.ClientHelloInfo = clientHelloInfo; connectRequest.ClientHelloInfo = clientHelloInfo;
} }
await endPoint.InvokeBeforeTunnectConnectResponse(this, connectArgs, ExceptionFunc, isClientHello); await endPoint.InvokeBeforeTunnelConnectResponse(this, connectArgs, ExceptionFunc, isClientHello);
if (decryptSsl && isClientHello) if (decryptSsl && isClientHello)
{ {
...@@ -183,7 +183,7 @@ namespace Titanium.Web.Proxy ...@@ -183,7 +183,7 @@ namespace Titanium.Web.Proxy
// Successfully managed to authenticate the client using the fake certificate // Successfully managed to authenticate the client using the fake certificate
var options = new SslServerAuthenticationOptions(); var options = new SslServerAuthenticationOptions();
if (http2Supported) if (EnableHttp2 && http2Supported)
{ {
options.ApplicationProtocols = clientHelloInfo.GetAlpn(); options.ApplicationProtocols = clientHelloInfo.GetAlpn();
if (options.ApplicationProtocols == null || options.ApplicationProtocols.Count == 0) if (options.ApplicationProtocols == null || options.ApplicationProtocols.Count == 0)
......
...@@ -63,6 +63,7 @@ namespace Titanium.Web.Proxy.Http2 ...@@ -63,6 +63,7 @@ namespace Titanium.Web.Proxy.Http2
while (true) while (true)
{ {
int read = await ForceRead(input, headerBuffer, 0, 9, cancellationToken); int read = await ForceRead(input, headerBuffer, 0, 9, cancellationToken);
onCopy(headerBuffer, 0, read);
if (read != 9) if (read != 9)
{ {
return; return;
...@@ -75,6 +76,7 @@ namespace Titanium.Web.Proxy.Http2 ...@@ -75,6 +76,7 @@ namespace Titanium.Web.Proxy.Http2
headerBuffer[8]; headerBuffer[8];
read = await ForceRead(input, buffer, 0, length, cancellationToken); read = await ForceRead(input, buffer, 0, length, cancellationToken);
onCopy(buffer, 0, read);
if (read != length) if (read != length)
{ {
return; return;
...@@ -138,7 +140,7 @@ namespace Titanium.Web.Proxy.Http2 ...@@ -138,7 +140,7 @@ namespace Titanium.Web.Proxy.Http2
while (bytesToRead > 0) while (bytesToRead > 0)
{ {
int read = await input.ReadAsync(buffer, offset, bytesToRead, cancellationToken); int read = await input.ReadAsync(buffer, offset, bytesToRead, cancellationToken);
if (read == -1) if (read == 0)
{ {
break; break;
} }
......
...@@ -50,7 +50,7 @@ namespace Titanium.Web.Proxy.Models ...@@ -50,7 +50,7 @@ namespace Titanium.Web.Proxy.Models
} }
} }
internal async Task InvokeBeforeTunnectConnectResponse(ProxyServer proxyServer, internal async Task InvokeBeforeTunnelConnectResponse(ProxyServer proxyServer,
TunnelConnectSessionEventArgs connectArgs, ExceptionHandler exceptionFunc, bool isClientHello = false) TunnelConnectSessionEventArgs connectArgs, ExceptionHandler exceptionFunc, bool isClientHello = false)
{ {
if (BeforeTunnelConnectResponse != null) if (BeforeTunnelConnectResponse != null)
......
...@@ -144,6 +144,12 @@ namespace Titanium.Web.Proxy ...@@ -144,6 +144,12 @@ namespace Titanium.Web.Proxy
/// Defaults to false. /// Defaults to false.
/// </summary> /// </summary>
public bool EnableWinAuth { get; set; } public bool EnableWinAuth { get; set; }
/// <summary>
/// Enable disable HTTP/2 support. This setting is internal,
/// because the implementation is not finished
/// </summary>
internal bool EnableHttp2 { get; set; } = false;
/// <summary> /// <summary>
/// Should we check for certificate revocation during SSL authentication to servers /// Should we check for certificate revocation during SSL authentication to servers
......
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="BrotliSharpLib" Version="0.3.1" /> <PackageReference Include="BrotliSharpLib" Version="0.3.3" />
<PackageReference Include="Portable.BouncyCastle" Version="1.8.3" /> <PackageReference Include="Portable.BouncyCastle" Version="1.8.5" />
<PackageReference Include="StreamExtended" Version="1.0.188-beta" /> <PackageReference Include="StreamExtended" Version="1.0.209-beta" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'"> <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
......
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net45;netstandard2.0</TargetFrameworks> <TargetFrameworks>net45;netstandard2.0;netcoreapp2.1</TargetFrameworks>
<RootNamespace>Titanium.Web.Proxy</RootNamespace> <RootNamespace>Titanium.Web.Proxy</RootNamespace>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<SignAssembly>True</SignAssembly> <SignAssembly>True</SignAssembly>
......
...@@ -26,6 +26,13 @@ ...@@ -26,6 +26,13 @@
<dependency id="Microsoft.Win32.Registry" version="4.4.0" /> <dependency id="Microsoft.Win32.Registry" version="4.4.0" />
<dependency id="System.Security.Principal.Windows" version="4.4.1" /> <dependency id="System.Security.Principal.Windows" version="4.4.1" />
</group> </group>
<group targetFramework="netcoreapp2.1">
<dependency id="StreamExtended" version="1.0.209-beta" />
<dependency id="Portable.BouncyCastle" version="1.8.5" />
<dependency id="BrotliSharpLib" version="0.3.3" />
<dependency id="Microsoft.Win32.Registry" version="4.4.0" />
<dependency id="System.Security.Principal.Windows" version="4.4.1" />
</group>
</dependencies> </dependencies>
</metadata> </metadata>
<files> <files>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment