Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: client name in clientGroupsBlock should not be case-sensitive #913

Merged
merged 1 commit into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
}