Skip to content

Commit

Permalink
use lowercase
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang committed Nov 1, 2021
1 parent d1d5ff0 commit e134bf2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion modules/hostmatcher/hostmatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion modules/hostmatcher/hostmatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down

0 comments on commit e134bf2

Please sign in to comment.