系统dns替换回退dns
This commit is contained in:
parent
a74711363b
commit
40f50d9c42
@ -223,7 +223,7 @@ cert_refresh_delay = 240
|
|||||||
##
|
##
|
||||||
## If more than one resolver is specified, they will be tried in sequence.
|
## If more than one resolver is specified, they will be tried in sequence.
|
||||||
|
|
||||||
fallback_resolvers = ['9.9.9.9:53', '8.8.8.8:53']
|
fallback_resolvers = []
|
||||||
|
|
||||||
|
|
||||||
## Always use the fallback resolver before the system DNS settings.
|
## Always use the fallback resolver before the system DNS settings.
|
||||||
|
|||||||
@ -1,42 +0,0 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
using System.Net;
|
|
||||||
|
|
||||||
namespace FastGithub.Configuration
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// dns配置
|
|
||||||
/// </summary>
|
|
||||||
public record DnsConfig
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// IP地址
|
|
||||||
/// </summary>
|
|
||||||
[AllowNull]
|
|
||||||
public string IPAddress { get; init; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 端口
|
|
||||||
/// </summary>
|
|
||||||
public int Port { get; init; } = 53;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 转换为IPEndPoint
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
/// <exception cref="FastGithubException"></exception>
|
|
||||||
public IPEndPoint ToIPEndPoint()
|
|
||||||
{
|
|
||||||
if (System.Net.IPAddress.TryParse(this.IPAddress, out var address) == false)
|
|
||||||
{
|
|
||||||
throw new FastGithubException($"无效的ip:{this.IPAddress}");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.Port == 53 && LocalMachine.ContainsIPAddress(address))
|
|
||||||
{
|
|
||||||
throw new FastGithubException($"配置的dns值不能指向{nameof(FastGithub)}自身:{this.IPAddress}:{this.Port}");
|
|
||||||
}
|
|
||||||
|
|
||||||
return new IPEndPoint(address, this.Port);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -5,7 +5,6 @@ using System.Collections.Concurrent;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
|
||||||
|
|
||||||
namespace FastGithub.Configuration
|
namespace FastGithub.Configuration
|
||||||
{
|
{
|
||||||
@ -18,11 +17,6 @@ namespace FastGithub.Configuration
|
|||||||
private SortedDictionary<DomainPattern, DomainConfig> domainConfigs;
|
private SortedDictionary<DomainPattern, DomainConfig> domainConfigs;
|
||||||
private ConcurrentDictionary<string, DomainConfig?> domainConfigCache;
|
private ConcurrentDictionary<string, DomainConfig?> domainConfigCache;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 回退的dns
|
|
||||||
/// </summary>
|
|
||||||
public IPEndPoint[] FallbackDns { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// FastGithub配置
|
/// FastGithub配置
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -35,7 +29,6 @@ namespace FastGithub.Configuration
|
|||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
var opt = options.CurrentValue;
|
var opt = options.CurrentValue;
|
||||||
|
|
||||||
this.FallbackDns = opt.FallbackDns.Select(item => item.ToIPEndPoint()).ToArray();
|
|
||||||
this.domainConfigs = ConvertDomainConfigs(opt.DomainConfigs);
|
this.domainConfigs = ConvertDomainConfigs(opt.DomainConfigs);
|
||||||
this.domainConfigCache = new ConcurrentDictionary<string, DomainConfig?>();
|
this.domainConfigCache = new ConcurrentDictionary<string, DomainConfig?>();
|
||||||
|
|
||||||
@ -50,7 +43,6 @@ namespace FastGithub.Configuration
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.FallbackDns = options.FallbackDns.Select(item => item.ToIPEndPoint()).ToArray();
|
|
||||||
this.domainConfigs = ConvertDomainConfigs(options.DomainConfigs);
|
this.domainConfigs = ConvertDomainConfigs(options.DomainConfigs);
|
||||||
this.domainConfigCache = new ConcurrentDictionary<string, DomainConfig?>();
|
this.domainConfigCache = new ConcurrentDictionary<string, DomainConfig?>();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace FastGithub.Configuration
|
namespace FastGithub.Configuration
|
||||||
{
|
{
|
||||||
@ -13,11 +12,6 @@ namespace FastGithub.Configuration
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int HttpProxyPort { get; set; }
|
public int HttpProxyPort { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 回退的dns
|
|
||||||
/// </summary>
|
|
||||||
public DnsConfig[] FallbackDns { get; set; } = Array.Empty<DnsConfig>();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 代理的域名配置
|
/// 代理的域名配置
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
|
||||||
using System.Net.NetworkInformation;
|
using System.Net.NetworkInformation;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
|
|
||||||
@ -17,50 +16,6 @@ namespace FastGithub.Configuration
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static string Name => Environment.MachineName;
|
public static string Name => Environment.MachineName;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取本机设备所有IP
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static IEnumerable<IPAddress> GetAllIPAddresses()
|
|
||||||
{
|
|
||||||
yield return IPAddress.Loopback;
|
|
||||||
yield return IPAddress.IPv6Loopback;
|
|
||||||
|
|
||||||
foreach (var @interface in NetworkInterface.GetAllNetworkInterfaces())
|
|
||||||
{
|
|
||||||
foreach (var addressInfo in @interface.GetIPProperties().UnicastAddresses)
|
|
||||||
{
|
|
||||||
yield return addressInfo.Address;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取本机设备所有IPv4
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static IEnumerable<IPAddress> GetAllIPv4Addresses()
|
|
||||||
{
|
|
||||||
foreach (var address in GetAllIPAddresses())
|
|
||||||
{
|
|
||||||
if (address.AddressFamily == AddressFamily.InterNetwork)
|
|
||||||
{
|
|
||||||
yield return address;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 返回本机设备是否包含指定IP
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="address"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static bool ContainsIPAddress(IPAddress address)
|
|
||||||
{
|
|
||||||
return GetAllIPAddresses().Contains(address);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取可用的随机Tcp端口
|
/// 获取可用的随机Tcp端口
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -3,7 +3,6 @@ using Microsoft.Extensions.Logging;
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -47,7 +46,6 @@ namespace FastGithub.Dns
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var localAddresses = LocalMachine.GetAllIPv4Addresses().ToArray();
|
|
||||||
var lines = await File.ReadAllLinesAsync(hostsPath);
|
var lines = await File.ReadAllLinesAsync(hostsPath);
|
||||||
foreach (var line in lines)
|
foreach (var line in lines)
|
||||||
{
|
{
|
||||||
@ -55,7 +53,7 @@ namespace FastGithub.Dns
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (localAddresses.Contains(record.Address) == true)
|
if (IPAddress.Loopback.Equals(record.Address) == true)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,8 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -27,22 +29,7 @@ namespace FastGithub.Dns
|
|||||||
/// 验证冲突
|
/// 验证冲突
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Task ValidateAsync()
|
public async Task ValidateAsync()
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
this.ValidateSystemProxy();
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 验证代理
|
|
||||||
/// </summary>
|
|
||||||
private void ValidateSystemProxy()
|
|
||||||
{
|
{
|
||||||
var systemProxy = HttpClient.DefaultProxy;
|
var systemProxy = HttpClient.DefaultProxy;
|
||||||
if (systemProxy == null)
|
if (systemProxy == null)
|
||||||
@ -51,18 +38,50 @@ namespace FastGithub.Dns
|
|||||||
}
|
}
|
||||||
|
|
||||||
var httpProxyPort = this.options.Value.HttpProxyPort;
|
var httpProxyPort = this.options.Value.HttpProxyPort;
|
||||||
var loopbackProxyUri = new Uri($"http://127.0.0.1:{httpProxyPort}");
|
|
||||||
var localhostProxyUri = new Uri($"http://localhost:{httpProxyPort}");
|
|
||||||
|
|
||||||
foreach (var domain in this.options.Value.DomainConfigs.Keys)
|
foreach (var domain in this.options.Value.DomainConfigs.Keys)
|
||||||
{
|
{
|
||||||
var destination = new Uri($"https://{domain.Replace('*', 'a')}");
|
var destination = new Uri($"https://{domain.Replace('*', 'a')}");
|
||||||
var proxyServer = systemProxy.GetProxy(destination);
|
var proxyServer = systemProxy.GetProxy(destination);
|
||||||
if (proxyServer != null && proxyServer != loopbackProxyUri && proxyServer != localhostProxyUri)
|
|
||||||
|
if (proxyServer == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (await IsFastGithubProxyAsync(proxyServer, httpProxyPort) == false)
|
||||||
{
|
{
|
||||||
this.logger.LogError($"由于系统配置了{proxyServer}代理{domain},{nameof(FastGithub)}无法加速相关域名");
|
this.logger.LogError($"由于系统配置了{proxyServer}代理{domain},{nameof(FastGithub)}无法加速相关域名");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否为fastgithub代理
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="proxyServer"></param>
|
||||||
|
/// <param name="httpProxyPort"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private static async Task<bool> IsFastGithubProxyAsync(Uri proxyServer, int httpProxyPort)
|
||||||
|
{
|
||||||
|
if (proxyServer.Port != httpProxyPort)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IPAddress.TryParse(proxyServer.Host, out var address))
|
||||||
|
{
|
||||||
|
return address.Equals(IPAddress.Loopback);
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var addresses = await System.Net.Dns.GetHostAddressesAsync(proxyServer.Host);
|
||||||
|
return addresses.Contains(IPAddress.Loopback);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -112,7 +112,7 @@ namespace FastGithub.DomainResolve
|
|||||||
if (address == null)
|
if (address == null)
|
||||||
{
|
{
|
||||||
expiration = this.fallbackExpiration;
|
expiration = this.fallbackExpiration;
|
||||||
address = await this.LookupByFallbackAsync(domain, cancellationToken);
|
address = await this.LookupAsync(null, domain, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (address == null)
|
if (address == null)
|
||||||
@ -140,11 +140,12 @@ namespace FastGithub.DomainResolve
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private async Task<IPAddress?> LookupByDnscryptAsync(DnsEndPoint domain, CancellationToken cancellationToken, int maxTryCount = 2)
|
private async Task<IPAddress?> LookupByDnscryptAsync(DnsEndPoint domain, CancellationToken cancellationToken, int maxTryCount = 2)
|
||||||
{
|
{
|
||||||
if (this.dnscryptProxy.LocalEndPoint != null)
|
var dns = this.dnscryptProxy.LocalEndPoint;
|
||||||
|
if (dns != null)
|
||||||
{
|
{
|
||||||
for (var i = 0; i < maxTryCount; i++)
|
for (var i = 0; i < maxTryCount; i++)
|
||||||
{
|
{
|
||||||
var address = await this.LookupAsync(this.dnscryptProxy.LocalEndPoint, domain, cancellationToken);
|
var address = await this.LookupAsync(dns, domain, cancellationToken);
|
||||||
if (address != null)
|
if (address != null)
|
||||||
{
|
{
|
||||||
return address;
|
return address;
|
||||||
@ -154,27 +155,6 @@ namespace FastGithub.DomainResolve
|
|||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 回退查找ip
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="domain"></param>
|
|
||||||
/// <param name="cancellationToken"></param>
|
|
||||||
/// <exception cref="OperationCanceledException"></exception>
|
|
||||||
/// <returns></returns>
|
|
||||||
private async Task<IPAddress?> LookupByFallbackAsync(DnsEndPoint domain, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
foreach (var dns in this.fastGithubConfig.FallbackDns)
|
|
||||||
{
|
|
||||||
var address = await this.LookupAsync(dns, domain, cancellationToken);
|
|
||||||
if (address != null)
|
|
||||||
{
|
|
||||||
return address;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return default;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找最快的可用ip
|
/// 查找最快的可用ip
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -183,28 +163,39 @@ namespace FastGithub.DomainResolve
|
|||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <exception cref="OperationCanceledException"></exception>
|
/// <exception cref="OperationCanceledException"></exception>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private async Task<IPAddress?> LookupAsync(IPEndPoint dns, DnsEndPoint domain, CancellationToken cancellationToken)
|
private async Task<IPAddress?> LookupAsync(IPEndPoint? dns, DnsEndPoint domain, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
var dnsName = dns?.ToString() ?? "System";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var dnsClient = new DnsClient(dns);
|
IEnumerable<IPAddress> addresses;
|
||||||
var addresses = await dnsClient.Lookup(domain.Host, RecordType.A, cancellationToken);
|
if (dns != null)
|
||||||
|
{
|
||||||
|
var dnsClient = new DnsClient(dns);
|
||||||
|
addresses = await dnsClient.Lookup(domain.Host, RecordType.A, cancellationToken);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var addrs = await Dns.GetHostAddressesAsync(domain.Host);
|
||||||
|
addresses = addrs.Where(item => item.AddressFamily == AddressFamily.InterNetwork);
|
||||||
|
}
|
||||||
|
|
||||||
addresses = addresses.Where(address => this.disableIPAddressCache.TryGetValue(address, out _) == false).ToList();
|
addresses = addresses.Where(address => this.disableIPAddressCache.TryGetValue(address, out _) == false).ToList();
|
||||||
var address = await this.FindFastValueAsync(addresses, domain.Port, cancellationToken);
|
var address = await this.FindFastValueAsync(addresses, domain.Port, cancellationToken);
|
||||||
if (address == null)
|
if (address == null)
|
||||||
{
|
{
|
||||||
this.logger.LogWarning($"dns({dns})解析不到{domain.Host}可用的ip解析");
|
this.logger.LogWarning($"dns({dnsName})解析不到{domain.Host}可用的ip解析");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.logger.LogInformation($"dns({dns}): {domain.Host}->{address}");
|
this.logger.LogInformation($"dns({dnsName}): {domain.Host}->{address}");
|
||||||
}
|
}
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
this.logger.LogWarning($"dns({dns})无法解析{domain.Host}:{ex.Message}");
|
this.logger.LogWarning($"dns({dnsName})无法解析{domain.Host}:{ex.Message}");
|
||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
|
||||||
namespace FastGithub.ReverseProxy
|
namespace FastGithub.ReverseProxy
|
||||||
@ -182,10 +183,7 @@ namespace FastGithub.ReverseProxy
|
|||||||
}
|
}
|
||||||
|
|
||||||
yield return LocalMachine.Name;
|
yield return LocalMachine.Name;
|
||||||
foreach (var address in LocalMachine.GetAllIPv4Addresses())
|
yield return IPAddress.Loopback.ToString();
|
||||||
{
|
|
||||||
yield return address.ToString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,9 +7,7 @@ using Microsoft.Extensions.DependencyInjection;
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
|
||||||
|
|
||||||
namespace FastGithub
|
namespace FastGithub
|
||||||
{
|
{
|
||||||
@ -44,37 +42,6 @@ namespace FastGithub
|
|||||||
var logger = kestrel.GetLogger();
|
var logger = kestrel.GetLogger();
|
||||||
kestrel.Listen(IPAddress.Loopback, httpProxyPort);
|
kestrel.Listen(IPAddress.Loopback, httpProxyPort);
|
||||||
logger.LogInformation($"已监听http://127.0.0.1:{httpProxyPort},http代理启动完成");
|
logger.LogInformation($"已监听http://127.0.0.1:{httpProxyPort},http代理启动完成");
|
||||||
|
|
||||||
if (SystemHasSetHttpProxy() == false)
|
|
||||||
{
|
|
||||||
logger.LogWarning($"请设置系统或浏览器代理为:http://127.0.0.1:{httpProxyPort},或自动代理为http://127.0.0.1:{httpProxyPort}/proxy.pac");
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SystemHasSetHttpProxy()
|
|
||||||
{
|
|
||||||
var systemProxy = HttpClient.DefaultProxy;
|
|
||||||
if (systemProxy == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var domainPattern = options.DomainConfigs.Keys.FirstOrDefault();
|
|
||||||
if (domainPattern == null)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
var destination = new Uri($"https://{domainPattern.Replace('*', 'a')}");
|
|
||||||
var proxyServer = systemProxy.GetProxy(destination);
|
|
||||||
if (proxyServer == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var loopbackProxyUri = new Uri($"http://127.0.0.1:{httpProxyPort}");
|
|
||||||
var localhostProxyUri = new Uri($"http://localhost:{httpProxyPort}");
|
|
||||||
return proxyServer == loopbackProxyUri || proxyServer == localhostProxyUri;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -2,16 +2,6 @@
|
|||||||
// 新增的子配置文件appsettings.*.json,重启应用程序才生效
|
// 新增的子配置文件appsettings.*.json,重启应用程序才生效
|
||||||
"FastGithub": {
|
"FastGithub": {
|
||||||
"HttpProxyPort": 2222, // http代理端口,非windows才使用
|
"HttpProxyPort": 2222, // http代理端口,非windows才使用
|
||||||
"FallbackDns": [ // 用于解析不在DomainConfigs的域名
|
|
||||||
{
|
|
||||||
"IPAddress": "114.114.114.114",
|
|
||||||
"Port": 53
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"IPAddress": "8.8.8.8",
|
|
||||||
"Port": 53
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"DomainConfigs": {
|
"DomainConfigs": {
|
||||||
"*.fastgithub.com": { // 域名的*表示除.之外0到多个任意字符
|
"*.fastgithub.com": { // 域名的*表示除.之外0到多个任意字符
|
||||||
"TlsSni": false, // 指示tls握手时是否发送SNI
|
"TlsSni": false, // 指示tls握手时是否发送SNI
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user