降低log等级

This commit is contained in:
陈国伟 2021-10-11 16:57:38 +08:00
parent c9a2ea3dda
commit 3cbe2ff347
2 changed files with 6 additions and 5 deletions

View File

@ -119,18 +119,18 @@ namespace FastGithub.DomainResolve
this.dnsCache.Set(key, result.Addresses, result.TimeToLive); this.dnsCache.Set(key, result.Addresses, result.TimeToLive);
var items = string.Join(", ", result.Addresses.Select(item => item.ToString())); var items = string.Join(", ", result.Addresses.Select(item => item.ToString()));
this.logger.LogInformation($"dns://{dns}{endPoint}->[{items}]"); this.logger.LogInformation($"dns://{dns}{endPoint.Host}->[{items}]");
return result.Addresses; return result.Addresses;
} }
catch (OperationCanceledException) catch (OperationCanceledException)
{ {
this.logger.LogInformation($"dns://{dns}无法解析{endPoint}:请求超时"); this.logger.LogInformation($"dns://{dns}无法解析{endPoint.Host}:请求超时");
return Array.Empty<IPAddress>(); return Array.Empty<IPAddress>();
} }
catch (Exception ex) catch (Exception ex)
{ {
this.logger.LogWarning($"dns://{dns}无法解析{endPoint}{ex.Message}"); this.logger.LogInformation($"dns://{dns}无法解析{endPoint.Host}{ex.Message}");
return Array.Empty<IPAddress>(); return Array.Empty<IPAddress>();
} }
finally finally

View File

@ -19,7 +19,7 @@ namespace FastGithub.HttpServer
private const int HTTP_PORT = 80; private const int HTTP_PORT = 80;
private const int HTTPS_PORT = 443; private const int HTTPS_PORT = 443;
private static readonly DomainConfig sniDomainConfig = new() { TlsSni = true }; private static readonly DomainConfig defaultDomainConfig = new() { TlsSni = true };
private readonly IHttpForwarder httpForwarder; private readonly IHttpForwarder httpForwarder;
private readonly IHttpClientFactory httpClientFactory; private readonly IHttpClientFactory httpClientFactory;
@ -95,7 +95,8 @@ namespace FastGithub.HttpServer
} }
// 未配置的域名但dns污染解析为127.0.0.1的域名 // 未配置的域名但dns污染解析为127.0.0.1的域名
domainConfig = sniDomainConfig; this.logger.LogWarning($"检测到{host.Host}可能遭遇了dns污染");
domainConfig = defaultDomainConfig;
return true; return true;
} }