修复pac丢失端口的问题
This commit is contained in:
parent
a2b6fcc1ab
commit
ae5154402a
@ -1,6 +1,4 @@
|
|||||||
using FastGithub.Configuration;
|
using Microsoft.AspNetCore.Connections.Features;
|
||||||
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;
|
||||||
@ -58,7 +56,7 @@ namespace FastGithub.HttpServer
|
|||||||
var host = context.Request.Host;
|
var host = context.Request.Host;
|
||||||
if (this.IsFastGithubServer(host) == true)
|
if (this.IsFastGithubServer(host) == true)
|
||||||
{
|
{
|
||||||
var proxyPac = this.GetProxyPacString(host);
|
var proxyPac = this.CreateProxyPac(host);
|
||||||
context.Response.ContentType = "application/x-ns-proxy-autoconfig";
|
context.Response.ContentType = "application/x-ns-proxy-autoconfig";
|
||||||
context.Response.Headers.Add("Content-Disposition", $"attachment;filename=proxy.pac");
|
context.Response.Headers.Add("Content-Disposition", $"attachment;filename=proxy.pac");
|
||||||
await context.Response.WriteAsync(proxyPac);
|
await context.Response.WriteAsync(proxyPac);
|
||||||
@ -105,15 +103,15 @@ namespace FastGithub.HttpServer
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取proxypac脚本
|
/// 创建proxypac脚本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="host"></param>
|
/// <param name="host"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private string GetProxyPacString(HostString host)
|
private string CreateProxyPac(HostString host)
|
||||||
{
|
{
|
||||||
var buidler = new StringBuilder();
|
var buidler = new StringBuilder();
|
||||||
buidler.AppendLine("function FindProxyForURL(url, host){");
|
buidler.AppendLine("function FindProxyForURL(url, host){");
|
||||||
buidler.AppendLine($" var proxy = 'PROXY {host.Host}';");
|
buidler.AppendLine($" var proxy = 'PROXY {host}';");
|
||||||
foreach (var domain in this.fastGithubConfig.GetDomainPatterns())
|
foreach (var domain in this.fastGithubConfig.GetDomainPatterns())
|
||||||
{
|
{
|
||||||
buidler.AppendLine($" if (shExpMatch(host, '{domain}')) return proxy;");
|
buidler.AppendLine($" if (shExpMatch(host, '{domain}')) return proxy;");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user