From ae5154402ac6c1bd6fe8af3593e21246da2c0a78 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=80=81=E4=B9=9D?= <366193849@qq.com>
Date: Sat, 18 Sep 2021 21:32:16 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dpac=E4=B8=A2=E5=A4=B1?=
=?UTF-8?q?=E7=AB=AF=E5=8F=A3=E7=9A=84=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
FastGithub.HttpServer/HttpProxyMiddleware.cs | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/FastGithub.HttpServer/HttpProxyMiddleware.cs b/FastGithub.HttpServer/HttpProxyMiddleware.cs
index 5ed2365..d7ea09b 100644
--- a/FastGithub.HttpServer/HttpProxyMiddleware.cs
+++ b/FastGithub.HttpServer/HttpProxyMiddleware.cs
@@ -1,6 +1,4 @@
-using FastGithub.Configuration;
-using FastGithub.DomainResolve;
-using Microsoft.AspNetCore.Connections.Features;
+using Microsoft.AspNetCore.Connections.Features;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.Options;
@@ -58,7 +56,7 @@ namespace FastGithub.HttpServer
var host = context.Request.Host;
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.Headers.Add("Content-Disposition", $"attachment;filename=proxy.pac");
await context.Response.WriteAsync(proxyPac);
@@ -105,15 +103,15 @@ namespace FastGithub.HttpServer
}
///
- /// 获取proxypac脚本
+ /// 创建proxypac脚本
///
///
///
- private string GetProxyPacString(HostString host)
+ private string CreateProxyPac(HostString host)
{
var buidler = new StringBuilder();
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())
{
buidler.AppendLine($" if (shExpMatch(host, '{domain}')) return proxy;");