修改pac

This commit is contained in:
老九 2021-09-19 14:53:16 +08:00
parent 1770955d33
commit 19db6388db

View File

@ -99,7 +99,7 @@ namespace FastGithub.HttpServer
{ {
if (host.Host == LOOPBACK || host.Host == LOCALHOST) if (host.Host == LOOPBACK || host.Host == LOCALHOST)
{ {
return host.Port == null || host.Port == this.options.Value.HttpProxyPort; return host.Port == this.options.Value.HttpProxyPort;
} }
return false; return false;
} }
@ -107,16 +107,16 @@ namespace FastGithub.HttpServer
/// <summary> /// <summary>
/// 创建proxypac脚本 /// 创建proxypac脚本
/// </summary> /// </summary>
/// <param name="host"></param> /// <param name="proxyHost"></param>
/// <returns></returns> /// <returns></returns>
private string CreateProxyPac(HostString host) private string CreateProxyPac(HostString proxyHost)
{ {
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}';"); buidler.AppendLine($" var fastgithub = 'PROXY {proxyHost}';");
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 fastgithub;");
} }
buidler.AppendLine(" return 'DIRECT';"); buidler.AppendLine(" return 'DIRECT';");
buidler.AppendLine("}"); buidler.AppendLine("}");