Skip to content
This repository has been archived by the owner on Jul 9, 2023. It is now read-only.

Commit

Permalink
Merge branch 'develop' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
justcoding121 committed Nov 18, 2021
2 parents a07bc3d + 400ca56 commit 9d759b1
Show file tree
Hide file tree
Showing 21 changed files with 39 additions and 177 deletions.
61 changes: 0 additions & 61 deletions src/Titanium.Web.Proxy.Mono.sln

This file was deleted.

2 changes: 1 addition & 1 deletion src/Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ public void Redirect(string url, bool closeServerConnection = false)
var response = new RedirectResponse();
response.HttpVersion = HttpClient.Request.HttpVersion;
response.Headers.AddHeader(KnownHeaders.Location, url);
#if NET45
#if NET451
response.Body = Net45Compatibility.EmptyArray;
#else
response.Body = Array.Empty<byte>();
Expand Down
2 changes: 1 addition & 1 deletion src/Titanium.Web.Proxy/Helpers/Net45Compatibility.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NET45
#if NET451
using System;
using System.Threading.Tasks;

Expand Down
2 changes: 1 addition & 1 deletion src/Titanium.Web.Proxy/Helpers/RunTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class RunTime
{
private static readonly Lazy<bool> isRunningOnMono = new Lazy<bool>(() => Type.GetType("Mono.Runtime") != null);

#if NET45 || NET461
#if NET451 || NET461
/// <summary>
/// cache for Windows platform check
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@ public void LoadFromIE()
proxy = new WebProxy(new Uri("http://localhost"), BypassOnLocal, pi.BypassList);
}

internal void UsePacFile(Uri upstreamProxyConfigurationScript)
{
AutomaticallyDetectSettings = true;
AutomaticConfigurationScript = upstreamProxyConfigurationScript;
BypassLoopback = true;
BypassOnLocal = false;
proxy = new WebProxy(new Uri("http://localhost"), BypassOnLocal);
}

private ProxyInfo getProxyInfo()
{
var proxyConfig = new NativeMethods.WinHttp.WINHTTP_CURRENT_USER_IE_PROXY_CONFIG();
Expand Down
4 changes: 2 additions & 2 deletions src/Titanium.Web.Proxy/Http/HeaderBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void Write(string str)

public ArraySegment<byte> GetBuffer()
{
#if NET45
#if NET451
return new ArraySegment<byte>(stream.ToArray());
#else
stream.TryGetBuffer(out var buffer);
Expand All @@ -104,7 +104,7 @@ public ArraySegment<byte> GetBuffer()

public string GetString(Encoding encoding)
{
#if NET45
#if NET451
return encoding.GetString(stream.ToArray());
#else
stream.TryGetBuffer(out var buffer);
Expand Down
4 changes: 2 additions & 2 deletions src/Titanium.Web.Proxy/Http2/Hpack/Decoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public void Decode(BinaryReader input, IHeaderListener headerListener)
if (nameLength + HttpHeader.HttpHeaderOverhead > dynamicTable.Capacity)
{
dynamicTable.Clear();
#if NET45
#if NET451
name = Net45Compatibility.EmptyArray;
#else
name = Array.Empty<byte>();
Expand Down Expand Up @@ -378,7 +378,7 @@ public void Decode(BinaryReader input, IHeaderListener headerListener)

if (valueLength == 0)
{
#if NET45
#if NET451
InsertHeader(headerListener, name, Net45Compatibility.EmptyArray, indexType);
#else
name = Array.Empty<byte>();
Expand Down
2 changes: 1 addition & 1 deletion src/Titanium.Web.Proxy/Http2/Hpack/DynamicTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Titanium.Web.Proxy.Http2.Hpack
public class DynamicTable
{
// a circular queue of header fields
#if NET45
#if NET451
HttpHeader[] headerFields = new HttpHeader[0];
#else
HttpHeader[] headerFields = Array.Empty<HttpHeader>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ internal Task<TcpServerConnection> GetServerConnection(ProxyServer proxyServer,

try
{
#if NET45
#if NET451
tcpServerSocket?.Close();
#else
tcpServerSocket?.Dispose();
Expand All @@ -479,7 +479,7 @@ internal Task<TcpServerConnection> GetServerConnection(ProxyServer proxyServer,
{
// dispose the current TcpClient and try the next address
lastException = e;
#if NET45
#if NET451
tcpServerSocket?.Close();
#else
tcpServerSocket?.Dispose();
Expand Down
2 changes: 1 addition & 1 deletion src/Titanium.Web.Proxy/Network/Writers/NullWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void Write(byte[] buffer, int offset, int count)

public Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
{
#if NET45
#if NET451
return Net45Compatibility.CompletedTask;
#else
return Task.CompletedTask;
Expand Down
17 changes: 15 additions & 2 deletions src/Titanium.Web.Proxy/ProxyServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ public ProxyServer(string? rootCertificateName, string? rootCertificateIssuerNam
/// </summary>
public bool ForwardToUpstreamGateway { get; set; }

/// <summary>
/// If set, the upstream proxy will be detected by a script that will be loaded from the provided Uri
/// </summary>
public Uri UpstreamProxyConfigurationScript { get; set; }

/// <summary>
/// Enable disable Windows Authentication (NTLM/Kerberos).
/// Note: NTLM/Kerberos will always send local credentials of current user
Expand Down Expand Up @@ -628,9 +633,17 @@ public void Start(bool changeSystemProxySettings = true)

if (ForwardToUpstreamGateway && GetCustomUpStreamProxyFunc == null && systemProxySettingsManager != null)
{
// Use WinHttp to handle PAC/WAPD scripts.
systemProxyResolver = new WinHttpWebProxyFinder();
systemProxyResolver.LoadFromIE();
if (UpstreamProxyConfigurationScript != null)
{
//Use the provided proxy configuration script
systemProxyResolver.UsePacFile(UpstreamProxyConfigurationScript);
}
else
{
// Use WinHttp to handle PAC/WAPD scripts.
systemProxyResolver.LoadFromIE();
}

GetCustomUpStreamProxyFunc = getSystemUpStreamProxy;
}
Expand Down
47 changes: 0 additions & 47 deletions src/Titanium.Web.Proxy/Titanium.Web.Proxy.Mono.csproj

This file was deleted.

52 changes: 0 additions & 52 deletions src/Titanium.Web.Proxy/Titanium.Web.Proxy.NetCore.csproj

This file was deleted.

4 changes: 2 additions & 2 deletions src/Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net45;net461;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net451;net461;netstandard2.0;netstandard2.1</TargetFrameworks>
<RootNamespace>Titanium.Web.Proxy</RootNamespace>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<SignAssembly>True</SignAssembly>
Expand All @@ -23,7 +23,7 @@
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net45'">
<ItemGroup Condition="'$(TargetFramework)' != 'net451'">
<PackageReference Include="Microsoft.Win32.Registry">
<Version>5.0.0</Version>
</PackageReference>
Expand Down
4 changes: 2 additions & 2 deletions src/Titanium.Web.Proxy/Titanium.Web.Proxy.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<copyright>Copyright &#x00A9; Titanium. All rights reserved.</copyright>
<tags></tags>
<dependencies>
<group targetFramework="net45">
<group targetFramework="net451">
<dependency id="BrotliSharpLib" version="0.3.3" />
<dependency id="Portable.BouncyCastle" version="1.8.8" />
<dependency id="System.Buffers" version="4.5.1" />
Expand Down Expand Up @@ -48,7 +48,7 @@
</dependencies>
</metadata>
<files>
<file src="bin\$configuration$\net45\Titanium.Web.Proxy.dll" target="lib\net45" />
<file src="bin\$configuration$\net451\Titanium.Web.Proxy.dll" target="lib\net451" />
<file src="bin\$configuration$\net461\Titanium.Web.Proxy.dll" target="lib\net461" />
<file src="bin\$configuration$\netstandard2.0\Titanium.Web.Proxy.dll" target="lib\netstandard2.0" />
<file src="bin\$configuration$\netstandard2.1\Titanium.Web.Proxy.dll" target="lib\netstandard2.1" />
Expand Down

0 comments on commit 9d759b1

Please sign in to comment.