From e4ae4dd0bebdb01a23e0c061a356d0762ebd0105 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Sat, 5 Nov 2022 14:30:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9F=9F=E5=90=8D=E8=B7=B3=E8=BD=AC=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=98=AF=E5=90=A6=E5=BF=BD=E7=95=A5=E7=AB=AF=E5=8F=A3?= =?UTF-8?q?=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/nodes/http_request_host_redirect.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/internal/nodes/http_request_host_redirect.go b/internal/nodes/http_request_host_redirect.go index 7e11ad3..c396f31 100644 --- a/internal/nodes/http_request_host_redirect.go +++ b/internal/nodes/http_request_host_redirect.go @@ -117,8 +117,18 @@ func (this *HTTPRequest) doHostRedirect() (blocked bool) { continue } + var reqHost = this.ReqHost + + // 忽略跳转前端口 + if u.DomainBeforeIgnorePorts { + h, _, err := net.SplitHostPort(reqHost) + if err == nil && len(h) > 0 { + reqHost = h + } + } + // 如果跳转前后域名一致,则终止 - if u.DomainAfter == this.ReqHost { + if u.DomainAfter == reqHost { return false } @@ -126,7 +136,7 @@ func (this *HTTPRequest) doHostRedirect() (blocked bool) { if len(scheme) == 0 { scheme = this.requestScheme() } - if u.DomainsAll || configutils.MatchDomains(u.DomainsBefore, this.ReqHost) { + if u.DomainsAll || configutils.MatchDomains(u.DomainsBefore, reqHost) { var afterURL = scheme + "://" + u.DomainAfter + urlPath if fullURL == afterURL { // 终止匹配