From c5aac25a47137d522b3482db9e404eed7e199af0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=80=81=E4=B9=9D?= <366193849@qq.com>
Date: Sun, 19 Sep 2021 10:22:25 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8host.port?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
FastGithub.HttpServer/HttpProxyMiddleware.cs | 6 ++++--
FastGithub.HttpServer/HttpReverseProxyMiddleware.cs | 6 +++---
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/FastGithub.HttpServer/HttpProxyMiddleware.cs b/FastGithub.HttpServer/HttpProxyMiddleware.cs
index d7ea09b..1cfd231 100644
--- a/FastGithub.HttpServer/HttpProxyMiddleware.cs
+++ b/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;
}
diff --git a/FastGithub.HttpServer/HttpReverseProxyMiddleware.cs b/FastGithub.HttpServer/HttpReverseProxyMiddleware.cs
index 45c2a06..20c7048 100644
--- a/FastGithub.HttpServer/HttpReverseProxyMiddleware.cs
+++ b/FastGithub.HttpServer/HttpReverseProxyMiddleware.cs
@@ -38,8 +38,8 @@ namespace FastGithub.HttpServer
///
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
///
///
///
- 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)