From bb48f6b76036b9294a07d0b7fde777c8e65be1ff Mon Sep 17 00:00:00 2001 From: xljiulang <366193849@qq.com> Date: Sat, 24 Jul 2021 23:30:47 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=90=88=E5=B9=B6=E4=B8=8E?= =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Directory.Build.props | 2 +- ...nscryptProxyServiceCollectionExtensions.cs | 23 ---------------- .../ControllState.cs | 2 +- .../DnscryptProxyHostedService.cs | 2 +- .../DnscryptProxyService.cs | 2 +- ...omainResolveServiceCollectionExtensions.cs | 26 ++++++++++++++++++ .../DomainResolver.cs | 2 +- .../FastGithub.DomainResolve.csproj | 2 ++ .../IDomainResolver.cs | 2 +- .../TomlUtil.cs | 2 +- .../dnscrypt-proxy | Bin .../dnscrypt-proxy.exe | Bin .../dnscrypt-proxy.toml | 0 FastGithub.Http/FastGithub.Http.csproj | 3 +- FastGithub.Http/HttpClient.cs | 3 +- FastGithub.Http/HttpClientFactory.cs | 3 +- FastGithub.Http/HttpClientHandler.cs | 3 +- .../HttpClientServiceCollectionExtensions.cs | 2 -- ...ReverseProxyServiceCollectionExtensions.cs | 1 - FastGithub.Upgrade/UpgradeService.cs | 3 +- FastGithub.sln | 12 ++++---- FastGithub/FastGithub.csproj | 2 +- FastGithub/Program.cs | 3 +- 23 files changed, 53 insertions(+), 47 deletions(-) delete mode 100644 FastGithub.DnscryptProxy/DnscryptProxyServiceCollectionExtensions.cs rename {FastGithub.DnscryptProxy => FastGithub.DomainResolve}/ControllState.cs (90%) rename {FastGithub.DnscryptProxy => FastGithub.DomainResolve}/DnscryptProxyHostedService.cs (98%) rename {FastGithub.DnscryptProxy => FastGithub.DomainResolve}/DnscryptProxyService.cs (98%) create mode 100644 FastGithub.DomainResolve/DomainResolveServiceCollectionExtensions.cs rename {FastGithub.Http => FastGithub.DomainResolve}/DomainResolver.cs (99%) rename FastGithub.DnscryptProxy/FastGithub.DnscryptProxy.csproj => FastGithub.DomainResolve/FastGithub.DomainResolve.csproj (82%) rename {FastGithub.Http => FastGithub.DomainResolve}/IDomainResolver.cs (93%) rename {FastGithub.DnscryptProxy => FastGithub.DomainResolve}/TomlUtil.cs (98%) rename {FastGithub.DnscryptProxy => FastGithub.DomainResolve}/dnscrypt-proxy (100%) rename {FastGithub.DnscryptProxy => FastGithub.DomainResolve}/dnscrypt-proxy.exe (100%) rename {FastGithub.DnscryptProxy => FastGithub.DomainResolve}/dnscrypt-proxy.toml (100%) diff --git a/Directory.Build.props b/Directory.Build.props index ee4d06f..2b5face 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@ - 1.0.9 + 1.1.0 enable github加速神器 https://github.com/xljiulang/FastGithub diff --git a/FastGithub.DnscryptProxy/DnscryptProxyServiceCollectionExtensions.cs b/FastGithub.DnscryptProxy/DnscryptProxyServiceCollectionExtensions.cs deleted file mode 100644 index e883139..0000000 --- a/FastGithub.DnscryptProxy/DnscryptProxyServiceCollectionExtensions.cs +++ /dev/null @@ -1,23 +0,0 @@ -using FastGithub.DnscryptProxy; -using Microsoft.Extensions.DependencyInjection; - -namespace FastGithub -{ - /// - /// DnscryptProxy的服务注册扩展 - /// - public static class DnscryptProxyServiceCollectionExtensions - { - /// - /// 添加DnscryptProxy - /// - /// - /// - public static IServiceCollection AddDnscryptProxy(this IServiceCollection services) - { - return services - .AddSingleton() - .AddHostedService(); - } - } -} diff --git a/FastGithub.DnscryptProxy/ControllState.cs b/FastGithub.DomainResolve/ControllState.cs similarity index 90% rename from FastGithub.DnscryptProxy/ControllState.cs rename to FastGithub.DomainResolve/ControllState.cs index c9b7d5d..877c70e 100644 --- a/FastGithub.DnscryptProxy/ControllState.cs +++ b/FastGithub.DomainResolve/ControllState.cs @@ -1,4 +1,4 @@ -namespace FastGithub.DnscryptProxy +namespace FastGithub.DomainResolve { /// /// 服务控制状态 diff --git a/FastGithub.DnscryptProxy/DnscryptProxyHostedService.cs b/FastGithub.DomainResolve/DnscryptProxyHostedService.cs similarity index 98% rename from FastGithub.DnscryptProxy/DnscryptProxyHostedService.cs rename to FastGithub.DomainResolve/DnscryptProxyHostedService.cs index 94db659..b1e1630 100644 --- a/FastGithub.DnscryptProxy/DnscryptProxyHostedService.cs +++ b/FastGithub.DomainResolve/DnscryptProxyHostedService.cs @@ -4,7 +4,7 @@ using System; using System.Threading; using System.Threading.Tasks; -namespace FastGithub.DnscryptProxy +namespace FastGithub.DomainResolve { /// /// DnscryptProxy后台服务 diff --git a/FastGithub.DnscryptProxy/DnscryptProxyService.cs b/FastGithub.DomainResolve/DnscryptProxyService.cs similarity index 98% rename from FastGithub.DnscryptProxy/DnscryptProxyService.cs rename to FastGithub.DomainResolve/DnscryptProxyService.cs index 886e50a..76c19da 100644 --- a/FastGithub.DnscryptProxy/DnscryptProxyService.cs +++ b/FastGithub.DomainResolve/DnscryptProxyService.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -namespace FastGithub.DnscryptProxy +namespace FastGithub.DomainResolve { /// /// DnscryptProxy服务 diff --git a/FastGithub.DomainResolve/DomainResolveServiceCollectionExtensions.cs b/FastGithub.DomainResolve/DomainResolveServiceCollectionExtensions.cs new file mode 100644 index 0000000..3e7c97f --- /dev/null +++ b/FastGithub.DomainResolve/DomainResolveServiceCollectionExtensions.cs @@ -0,0 +1,26 @@ +using FastGithub.DomainResolve; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; + +namespace FastGithub +{ + /// + /// 域名解析相关服务注册扩展 + /// + public static class DomainResolveServiceCollectionExtensions + { + /// + /// 注册域名解析相关服务 + /// + /// + /// + public static IServiceCollection AddDomainResolve(this IServiceCollection services) + { + services.AddMemoryCache(); + services.TryAddSingleton(); + services.AddSingleton(); + services.AddHostedService(); + return services; + } + } +} diff --git a/FastGithub.Http/DomainResolver.cs b/FastGithub.DomainResolve/DomainResolver.cs similarity index 99% rename from FastGithub.Http/DomainResolver.cs rename to FastGithub.DomainResolve/DomainResolver.cs index 98bb782..d04bfbb 100644 --- a/FastGithub.Http/DomainResolver.cs +++ b/FastGithub.DomainResolve/DomainResolver.cs @@ -8,7 +8,7 @@ using System.Net; using System.Threading; using System.Threading.Tasks; -namespace FastGithub.Http +namespace FastGithub.DomainResolve { /// /// 域名解析器 diff --git a/FastGithub.DnscryptProxy/FastGithub.DnscryptProxy.csproj b/FastGithub.DomainResolve/FastGithub.DomainResolve.csproj similarity index 82% rename from FastGithub.DnscryptProxy/FastGithub.DnscryptProxy.csproj rename to FastGithub.DomainResolve/FastGithub.DomainResolve.csproj index d8cfc6c..9de0a44 100644 --- a/FastGithub.DnscryptProxy/FastGithub.DnscryptProxy.csproj +++ b/FastGithub.DomainResolve/FastGithub.DomainResolve.csproj @@ -5,6 +5,8 @@ + + diff --git a/FastGithub.Http/IDomainResolver.cs b/FastGithub.DomainResolve/IDomainResolver.cs similarity index 93% rename from FastGithub.Http/IDomainResolver.cs rename to FastGithub.DomainResolve/IDomainResolver.cs index 760e6aa..5d7b609 100644 --- a/FastGithub.Http/IDomainResolver.cs +++ b/FastGithub.DomainResolve/IDomainResolver.cs @@ -2,7 +2,7 @@ using System.Threading; using System.Threading.Tasks; -namespace FastGithub.Http +namespace FastGithub.DomainResolve { /// /// 域名解析器 diff --git a/FastGithub.DnscryptProxy/TomlUtil.cs b/FastGithub.DomainResolve/TomlUtil.cs similarity index 98% rename from FastGithub.DnscryptProxy/TomlUtil.cs rename to FastGithub.DomainResolve/TomlUtil.cs index 03b5840..97541b5 100644 --- a/FastGithub.DnscryptProxy/TomlUtil.cs +++ b/FastGithub.DomainResolve/TomlUtil.cs @@ -5,7 +5,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -namespace FastGithub.DnscryptProxy +namespace FastGithub.DomainResolve { /// /// doml配置工具 diff --git a/FastGithub.DnscryptProxy/dnscrypt-proxy b/FastGithub.DomainResolve/dnscrypt-proxy similarity index 100% rename from FastGithub.DnscryptProxy/dnscrypt-proxy rename to FastGithub.DomainResolve/dnscrypt-proxy diff --git a/FastGithub.DnscryptProxy/dnscrypt-proxy.exe b/FastGithub.DomainResolve/dnscrypt-proxy.exe similarity index 100% rename from FastGithub.DnscryptProxy/dnscrypt-proxy.exe rename to FastGithub.DomainResolve/dnscrypt-proxy.exe diff --git a/FastGithub.DnscryptProxy/dnscrypt-proxy.toml b/FastGithub.DomainResolve/dnscrypt-proxy.toml similarity index 100% rename from FastGithub.DnscryptProxy/dnscrypt-proxy.toml rename to FastGithub.DomainResolve/dnscrypt-proxy.toml diff --git a/FastGithub.Http/FastGithub.Http.csproj b/FastGithub.Http/FastGithub.Http.csproj index e5cca58..2c6e886 100644 --- a/FastGithub.Http/FastGithub.Http.csproj +++ b/FastGithub.Http/FastGithub.Http.csproj @@ -5,10 +5,9 @@ - - + diff --git a/FastGithub.Http/HttpClient.cs b/FastGithub.Http/HttpClient.cs index 498063b..f046e64 100644 --- a/FastGithub.Http/HttpClient.cs +++ b/FastGithub.Http/HttpClient.cs @@ -1,4 +1,5 @@ -using System; +using FastGithub.DomainResolve; +using System; using System.Net.Http; using System.Threading; using System.Threading.Tasks; diff --git a/FastGithub.Http/HttpClientFactory.cs b/FastGithub.Http/HttpClientFactory.cs index 387388e..7b80701 100644 --- a/FastGithub.Http/HttpClientFactory.cs +++ b/FastGithub.Http/HttpClientFactory.cs @@ -1,4 +1,5 @@ -using Microsoft.Extensions.Options; +using FastGithub.DomainResolve; +using Microsoft.Extensions.Options; namespace FastGithub.Http { diff --git a/FastGithub.Http/HttpClientHandler.cs b/FastGithub.Http/HttpClientHandler.cs index 7c50373..8c489a4 100644 --- a/FastGithub.Http/HttpClientHandler.cs +++ b/FastGithub.Http/HttpClientHandler.cs @@ -1,4 +1,5 @@ -using System; +using FastGithub.DomainResolve; +using System; using System.Collections; using System.Collections.Generic; using System.Linq; diff --git a/FastGithub.Http/HttpClientServiceCollectionExtensions.cs b/FastGithub.Http/HttpClientServiceCollectionExtensions.cs index 6648b3b..0f86f6e 100644 --- a/FastGithub.Http/HttpClientServiceCollectionExtensions.cs +++ b/FastGithub.Http/HttpClientServiceCollectionExtensions.cs @@ -16,8 +16,6 @@ namespace FastGithub /// public static IServiceCollection AddHttpClient(this IServiceCollection services) { - services.AddMemoryCache(); - services.TryAddSingleton(); services.TryAddSingleton(); return services; } diff --git a/FastGithub.ReverseProxy/ReverseProxyServiceCollectionExtensions.cs b/FastGithub.ReverseProxy/ReverseProxyServiceCollectionExtensions.cs index c65faef..72858a9 100644 --- a/FastGithub.ReverseProxy/ReverseProxyServiceCollectionExtensions.cs +++ b/FastGithub.ReverseProxy/ReverseProxyServiceCollectionExtensions.cs @@ -18,7 +18,6 @@ namespace FastGithub return services .AddMemoryCache() .AddHttpForwarder() - .AddHttpClient() .AddSingleton() .AddSingleton() .AddHostedService(); diff --git a/FastGithub.Upgrade/UpgradeService.cs b/FastGithub.Upgrade/UpgradeService.cs index 35813ff..c7faaf0 100644 --- a/FastGithub.Upgrade/UpgradeService.cs +++ b/FastGithub.Upgrade/UpgradeService.cs @@ -1,4 +1,5 @@ -using FastGithub.Http; +using FastGithub.DomainResolve; +using FastGithub.Http; using Microsoft.Extensions.Logging; using System; using System.Linq; diff --git a/FastGithub.sln b/FastGithub.sln index 24bdbd6..11d0ce0 100644 --- a/FastGithub.sln +++ b/FastGithub.sln @@ -13,10 +13,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FastGithub.Upgrade", "FastG EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FastGithub.ReverseProxy", "FastGithub.ReverseProxy\FastGithub.ReverseProxy.csproj", "{28326D0F-B0FB-4B6B-A65A-C69ACB72CAD8}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FastGithub.DnscryptProxy", "FastGithub.DnscryptProxy\FastGithub.DnscryptProxy.csproj", "{26BB826F-4117-4746-9BD0-C6D8043E2808}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FastGithub.Http", "FastGithub.Http\FastGithub.Http.csproj", "{B5DCB3E4-5094-4170-B844-6F395002CA42}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FastGithub.DomainResolve", "FastGithub.DomainResolve\FastGithub.DomainResolve.csproj", "{5D26ABDD-F341-4EB7-9D08-FCB80F79B4B4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -43,14 +43,14 @@ Global {28326D0F-B0FB-4B6B-A65A-C69ACB72CAD8}.Debug|Any CPU.Build.0 = Debug|Any CPU {28326D0F-B0FB-4B6B-A65A-C69ACB72CAD8}.Release|Any CPU.ActiveCfg = Release|Any CPU {28326D0F-B0FB-4B6B-A65A-C69ACB72CAD8}.Release|Any CPU.Build.0 = Release|Any CPU - {26BB826F-4117-4746-9BD0-C6D8043E2808}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {26BB826F-4117-4746-9BD0-C6D8043E2808}.Debug|Any CPU.Build.0 = Debug|Any CPU - {26BB826F-4117-4746-9BD0-C6D8043E2808}.Release|Any CPU.ActiveCfg = Release|Any CPU - {26BB826F-4117-4746-9BD0-C6D8043E2808}.Release|Any CPU.Build.0 = Release|Any CPU {B5DCB3E4-5094-4170-B844-6F395002CA42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B5DCB3E4-5094-4170-B844-6F395002CA42}.Debug|Any CPU.Build.0 = Debug|Any CPU {B5DCB3E4-5094-4170-B844-6F395002CA42}.Release|Any CPU.ActiveCfg = Release|Any CPU {B5DCB3E4-5094-4170-B844-6F395002CA42}.Release|Any CPU.Build.0 = Release|Any CPU + {5D26ABDD-F341-4EB7-9D08-FCB80F79B4B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5D26ABDD-F341-4EB7-9D08-FCB80F79B4B4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5D26ABDD-F341-4EB7-9D08-FCB80F79B4B4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5D26ABDD-F341-4EB7-9D08-FCB80F79B4B4}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/FastGithub/FastGithub.csproj b/FastGithub/FastGithub.csproj index edd70a6..4560395 100644 --- a/FastGithub/FastGithub.csproj +++ b/FastGithub/FastGithub.csproj @@ -16,8 +16,8 @@ - + diff --git a/FastGithub/Program.cs b/FastGithub/Program.cs index 794216a..12ffe2a 100644 --- a/FastGithub/Program.cs +++ b/FastGithub/Program.cs @@ -42,7 +42,8 @@ namespace FastGithub .ConfigureServices((ctx, services) => { services.AddDnsServer(); - services.AddDnscryptProxy(); + services.AddDomainResolve(); + services.AddHttpClient(); services.AddAppUpgrade(); services.AddReverseProxy(); services.AddSingleton();