From f67a1030b308a24cca13ff788f7b7119f0404580 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 13 Jul 2022 09:07:16 +0800 Subject: Add tests for the host checking logic, clarify the behaviors (#20328) Before, the combination of AllowedDomains/BlockedDomains/AllowLocalNetworks is confusing. This PR adds tests for the logic, clarify the behaviors. --- modules/hostmatcher/hostmatcher.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/hostmatcher/hostmatcher.go b/modules/hostmatcher/hostmatcher.go index 00bbc6cb0a..81c4202fcd 100644 --- a/modules/hostmatcher/hostmatcher.go +++ b/modules/hostmatcher/hostmatcher.go @@ -125,14 +125,14 @@ func (hl *HostMatchList) checkIP(ip net.IP) bool { // MatchHostName checks if the host matches an allow/deny(block) list func (hl *HostMatchList) MatchHostName(host string) bool { + if hl == nil { + return false + } + hostname, _, err := net.SplitHostPort(host) if err != nil { hostname = host } - - if hl == nil { - return false - } if hl.checkPattern(hostname) { return true } -- cgit v1.2.3