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

This commit is contained in:
Dimitri Herzog 2023-03-07 14:23:02 +01:00 committed by GitHub
parent 3315873b35
commit 120e32c1eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View File

@ -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...)

View File

@ -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"},
@ -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"),

View File

@ -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
}