Skip to content

Commit

Permalink
feat: client name in clientGroupsBlock should not be case-sensitive (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
0xERR0R committed Mar 7, 2023
1 parent 3315873 commit b079d27
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion resolver/blocking_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func NewBlockingResolver(
cgb := make(map[string][]string, len(cfg.ClientGroupsBlock))

for identifier, cfgGroups := range cfg.ClientGroupsBlock {
for _, ipart := range strings.Split(identifier, ",") {
for _, ipart := range strings.Split(strings.ToLower(identifier), ",") {
existingGroups, found := cgb[ipart]
if found {
cgb[ipart] = append(existingGroups, cfgGroups...)
Expand Down
4 changes: 2 additions & 2 deletions resolver/blocking_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ var _ = Describe("BlockingResolver", Label("blockingResolver"), func() {
"defaultGroup": {defaultGroupFile.Path},
},
ClientGroupsBlock: map[string][]string{
"client1": {"gr1"},
"Client1": {"gr1"},
"client2,client3": {"gr1"},
"client3": {"gr2"},
"192.168.178.55": {"gr1"},
Expand Down Expand Up @@ -324,7 +324,7 @@ var _ = Describe("BlockingResolver", Label("blockingResolver"), func() {

When("Client has multiple names and for each name a client group block definition exists", func() {
It("should block query if domain is in one group", func() {
Expect(sut.Resolve(newRequestWithClient("domain1.com.", A, "1.2.1.2", "client1", "altName"))).
Expect(sut.Resolve(newRequestWithClient("domain1.com.", A, "1.2.1.2", "client1", "altname"))).
Should(
SatisfyAll(
BeDNSRecord("domain1.com.", A, "0.0.0.0"),
Expand Down
2 changes: 1 addition & 1 deletion util/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func CidrContainsIP(cidr string, ip net.IP) bool {

// ClientNameMatchesGroupName checks if a group with optional wildcards contains a client name
func ClientNameMatchesGroupName(group, clientName string) bool {
match, _ := filepath.Match(group, clientName)
match, _ := filepath.Match(strings.ToLower(group), strings.ToLower(clientName))

return match
}

0 comments on commit b079d27

Please sign in to comment.