使用host.port

This commit is contained in:
老九 2021-09-19 10:22:25 +08:00
parent ae5154402a
commit c5aac25a47
2 changed files with 7 additions and 5 deletions

View File

@ -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;
using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
@ -97,7 +99,7 @@ namespace FastGithub.HttpServer
{ {
if (host.Host == LOOPBACK || host.Host == LOCALHOST) 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; return false;
} }

View File

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