From 3cbe2ff3473a0cf01cdd77f26485095dc6b77006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=9B=BD=E4=BC=9F?= <366193849@qq.com> Date: Mon, 11 Oct 2021 16:57:38 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=8D=E4=BD=8Elog=E7=AD=89=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FastGithub.DomainResolve/DnsClient.cs | 6 +++--- FastGithub.HttpServer/HttpReverseProxyMiddleware.cs | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/FastGithub.DomainResolve/DnsClient.cs b/FastGithub.DomainResolve/DnsClient.cs index 9bc6290..589294f 100644 --- a/FastGithub.DomainResolve/DnsClient.cs +++ b/FastGithub.DomainResolve/DnsClient.cs @@ -119,18 +119,18 @@ namespace FastGithub.DomainResolve this.dnsCache.Set(key, result.Addresses, result.TimeToLive); 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; } catch (OperationCanceledException) { - this.logger.LogInformation($"dns://{dns}无法解析{endPoint}:请求超时"); + this.logger.LogInformation($"dns://{dns}无法解析{endPoint.Host}:请求超时"); return Array.Empty(); } catch (Exception ex) { - this.logger.LogWarning($"dns://{dns}无法解析{endPoint}:{ex.Message}"); + this.logger.LogInformation($"dns://{dns}无法解析{endPoint.Host}:{ex.Message}"); return Array.Empty(); } finally diff --git a/FastGithub.HttpServer/HttpReverseProxyMiddleware.cs b/FastGithub.HttpServer/HttpReverseProxyMiddleware.cs index a1d03f0..854315a 100644 --- a/FastGithub.HttpServer/HttpReverseProxyMiddleware.cs +++ b/FastGithub.HttpServer/HttpReverseProxyMiddleware.cs @@ -19,7 +19,7 @@ namespace FastGithub.HttpServer private const int HTTP_PORT = 80; 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 IHttpClientFactory httpClientFactory; @@ -95,7 +95,8 @@ namespace FastGithub.HttpServer } // 未配置的域名,但dns污染解析为127.0.0.1的域名 - domainConfig = sniDomainConfig; + this.logger.LogWarning($"检测到{host.Host}可能遭遇了dns污染"); + domainConfig = defaultDomainConfig; return true; }