Quellcode durchsuchen

使用host.port

老九 vor 3 Jahren
Ursprung
Commit
c5aac25a47

+ 4 - 2
FastGithub.HttpServer/HttpProxyMiddleware.cs

@@ -1,4 +1,6 @@
-using Microsoft.AspNetCore.Connections.Features;
+using FastGithub.Configuration;
+using FastGithub.DomainResolve;
+using Microsoft.AspNetCore.Connections.Features;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Http.Features;
 using Microsoft.Extensions.Options;
@@ -97,7 +99,7 @@ namespace FastGithub.HttpServer
         {
             if (host.Host == LOOPBACK || host.Host == LOCALHOST)
             {
-                return host.Port == this.options.Value.HttpProxyPort;
+                return host.Port == null || host.Port == this.options.Value.HttpProxyPort;
             }
             return false;
         }

+ 3 - 3
FastGithub.HttpServer/HttpReverseProxyMiddleware.cs

@@ -38,8 +38,8 @@ namespace FastGithub.HttpServer
         /// <returns></returns>
         public async Task InvokeAsync(HttpContext context, RequestDelegate next)
         {
-            var host = context.Request.Host.Host;
-            if (this.fastGithubConfig.TryGetDomainConfig(host, out var domainConfig) == false)
+            var host = context.Request.Host;
+            if (this.fastGithubConfig.TryGetDomainConfig(host.Host, out var domainConfig) == false)
             {
                 await next(context);
             }
@@ -69,7 +69,7 @@ namespace FastGithub.HttpServer
         /// <param name="host"></param>
         /// <param name="destination"></param>
         /// <returns></returns>
-        private string GetDestinationPrefix(string scheme, string host, Uri? destination)
+        private string GetDestinationPrefix(string scheme, HostString host, Uri? destination)
         {
             var defaultValue = $"{scheme}://{host}/";
             if (destination == null)