diff --git a/modules/hostmatcher/hostmatcher.go b/modules/hostmatcher/hostmatcher.go index a95557def1a4..f8a787c575e3 100644 --- a/modules/hostmatcher/hostmatcher.go +++ b/modules/hostmatcher/hostmatcher.go @@ -35,7 +35,7 @@ const MatchBuiltinLoopback = "loopback" func ParseHostMatchList(hostList string) *HostMatchList { hl := &HostMatchList{} for _, s := range strings.Split(hostList, ",") { - s = strings.TrimSpace(s) + s = strings.ToLower(strings.TrimSpace(s)) if s == "" { continue } @@ -52,6 +52,7 @@ func ParseHostMatchList(hostList string) *HostMatchList { // MatchesHostOrIP checks if the host or IP matches an allow/deny(block) list func (hl *HostMatchList) MatchesHostOrIP(host string, ip net.IP) bool { var matched bool + host = strings.ToLower(host) ipStr := ip.String() loop: for _, hostInList := range hl.hosts { diff --git a/modules/hostmatcher/hostmatcher_test.go b/modules/hostmatcher/hostmatcher_test.go index e9c8f68dc6f6..8eaafbdbc809 100644 --- a/modules/hostmatcher/hostmatcher_test.go +++ b/modules/hostmatcher/hostmatcher_test.go @@ -20,7 +20,7 @@ func TestHostOrIPMatchesList(t *testing.T) { // for IPv6: "::1" is loopback, "fd00::/8" is private - hl := ParseHostMatchList("private, external, *.mydomain.com, 169.254.1.0/24") + hl := ParseHostMatchList("private, External, *.myDomain.com, 169.254.1.0/24") cases := []tc{ {"", net.IPv4zero, false}, {"", net.IPv6zero, false},