Skip to content

Commit

Permalink
dotnet7
Browse files Browse the repository at this point in the history
  • Loading branch information
xljiulang committed Sep 17, 2022
1 parent 0ddc22a commit 2a6289e
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 44 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<Version>2.1.4</Version>
<Nullable>enable</Nullable>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<IsWebConfigTransformDisabled>true</IsWebConfigTransformDisabled>
<Description>github加速神器</Description>
<Copyright>https://github.com/dotnetcore/FastGithub</Copyright>
Expand Down
2 changes: 1 addition & 1 deletion FastGithub.Configuration/FastGithub.Configuration.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.2" />
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
</ItemGroup>

Expand Down
10 changes: 5 additions & 5 deletions FastGithub.DomainResolve/FastGithub.DomainResolve.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="PInvoke.AdvApi32" Version="0.7.104" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.0" />
<PackageReference Include="DNS" Version="6.1.0" />
<PackageReference Include="Tommy" Version="3.0.1" />
<PackageReference Include="PInvoke.AdvApi32" Version="0.7.124" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
<PackageReference Include="DNS" Version="7.0.0" />
<PackageReference Include="Tommy" Version="3.1.2" />
<ProjectReference Include="..\FastGithub.Configuration\FastGithub.Configuration.csproj" />
</ItemGroup>

Expand Down
3 changes: 1 addition & 2 deletions FastGithub.Http/FastGithub.Http.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0" />
<ItemGroup>
<ProjectReference Include="..\FastGithub.DomainResolve\FastGithub.DomainResolve.csproj" />
</ItemGroup>

Expand Down
28 changes: 5 additions & 23 deletions FastGithub.Http/HttpClientHandler.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using FastGithub.Configuration;
using FastGithub.DomainResolve;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -200,32 +199,15 @@ private async IAsyncEnumerable<IPEndPoint> GetIPEndPointsAsync(DnsEndPoint dnsEn
/// <returns></returns>
private static IEnumerable<string> ReadDnsNames(X509Certificate? cert)
{
if (cert == null)
if (cert is X509Certificate2 x509)
{
yield break;
}
var parser = new Org.BouncyCastle.X509.X509CertificateParser();
var x509Cert = parser.ReadCertificate(cert.GetRawCertData());
var subjects = x509Cert.GetSubjectAlternativeNames();
if (subjects == null)
{
yield break;
}

foreach (var subject in subjects)
{
if (subject is IList list)
var extension = x509.Extensions.OfType<X509SubjectAlternativeNameExtension>().FirstOrDefault();
if (extension != null)
{
if (list.Count >= 2 && list[0] is int nameType && nameType == 2)
{
var dnsName = list[1]?.ToString();
if (dnsName != null)
{
yield return dnsName;
}
}
return extension.EnumerateDnsNames();
}
}
return Array.Empty<string>();
}

/// <summary>
Expand Down
6 changes: 2 additions & 4 deletions FastGithub.HttpServer/Certs/CertService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,10 @@ public bool CreateCaCertIfNotExists()
var subjectName = new X500DistinguishedName($"CN={nameof(FastGithub)}");
this.caCert = CertGenerator.CreateCACertificate(subjectName, notBefore, notAfter);

var privateKey = this.caCert.GetRSAPrivateKey()?.ExportRSAPrivateKey();
var privateKeyPem = PemEncoding.Write("RSA PRIVATE KEY", privateKey);
var privateKeyPem = this.caCert.GetRSAPrivateKey()?.ExportRSAPrivateKeyPem();
File.WriteAllText(this.CaKeyFilePath, new string(privateKeyPem), Encoding.ASCII);

var cert = this.caCert.Export(X509ContentType.Cert);
var certPem = PemEncoding.Write("CERTIFICATE", cert);
var certPem = this.caCert.ExportCertificatePem();
File.WriteAllText(this.CaCerFilePath, new string(certPem), Encoding.ASCII);

return true;
Expand Down
2 changes: 1 addition & 1 deletion FastGithub.HttpServer/FastGithub.HttpServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Yarp.ReverseProxy" Version="1.1.0" />
<PackageReference Include="Yarp.ReverseProxy" Version="1.1.1" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 1 addition & 2 deletions FastGithub.PacketIntercept/FastGithub.PacketIntercept.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="DNS" Version="6.1.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.0" />
<PackageReference Include="DNS" Version="7.0.0" />
<PackageReference Include="FastGithub.WinDiverts" Version="1.4.1" />
</ItemGroup>

Expand Down
10 changes: 5 additions & 5 deletions FastGithub/FastGithub.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="7.0.0-rc*" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="7.0.0-rc*" />
<PackageReference Include="Serilog.Sinks.Network" Version="2.0.2.68" />
<ProjectReference Include="..\FastGithub.DomainResolve\FastGithub.DomainResolve.csproj" />
<ProjectReference Include="..\FastGithub.HttpServer\FastGithub.HttpServer.csproj" />
<ProjectReference Include="..\FastGithub.PacketIntercept\FastGithub.PacketIntercept.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Serilog.Extensions.Hosting" Version="4.2.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.0" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="5.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.3.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 2a6289e

Please sign in to comment.