修复unix平台不能访问带-的域名的bug (#68)
This commit is contained in:
parent
44960eb4fc
commit
f0de9adfc6
@ -3,10 +3,12 @@ using FastGithub.DomainResolve;
|
|||||||
using Microsoft.AspNetCore.Connections.Features;
|
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.AspNetCore.Server.Kestrel.Core.Internal.Http;
|
||||||
using System.IO.Pipelines;
|
using System.IO.Pipelines;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Yarp.ReverseProxy.Forwarder;
|
using Yarp.ReverseProxy.Forwarder;
|
||||||
@ -28,6 +30,20 @@ namespace FastGithub.HttpServer
|
|||||||
|
|
||||||
private readonly HttpMessageInvoker defaultHttpClient;
|
private readonly HttpMessageInvoker defaultHttpClient;
|
||||||
|
|
||||||
|
static HttpProxyMiddleware()
|
||||||
|
{
|
||||||
|
// https://github.com/dotnet/aspnetcore/issues/37421
|
||||||
|
var authority = typeof(HttpParser<>).Assembly
|
||||||
|
.GetType("Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure.HttpCharacters")?
|
||||||
|
.GetField("_authority", BindingFlags.NonPublic | BindingFlags.Static)?
|
||||||
|
.GetValue(null);
|
||||||
|
|
||||||
|
if (authority is bool[] authorityArray)
|
||||||
|
{
|
||||||
|
authorityArray['-'] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// http代理中间件
|
/// http代理中间件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user