Skip to content

Commit

Permalink
fix: normalize DNS names to lowercase
Browse files Browse the repository at this point in the history
  • Loading branch information
aschmahmann committed Sep 18, 2024
1 parent f9d8f07 commit d060dac
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions acme/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ func (p acmeReader) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.M
continue
}

subdomain := strings.TrimSuffix(q.Name, "."+p.ForgeDomain+".")
if len(subdomain) == len(q.Name) || len(subdomain) == 0 {
normalizedName := strings.ToLower(q.Name)
subdomain := strings.TrimSuffix(normalizedName, "."+p.ForgeDomain+".")
if len(subdomain) == len(normalizedName) || len(subdomain) == 0 {
continue
}

Expand Down
4 changes: 2 additions & 2 deletions acme/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func parse(c *caddy.Controller) (*acmeReader, *acmeWriter, error) {
case 0:
return nil, nil, c.ArgErr()
case 1:
forgeDomain = args[0]
forgeDomain = strings.ToLower(args[0])
default:
return nil, nil, c.ArgErr()
}
Expand All @@ -82,7 +82,7 @@ func parse(c *caddy.Controller) (*acmeReader, *acmeWriter, error) {
return nil, nil, c.ArgErr()
}

forgeRegistrationDomain = args[0]
forgeRegistrationDomain = strings.ToLower(args[0])
for i := 1; i < len(args); i++ {
nextArg := args[i]
argKV := strings.Split(nextArg, "=")
Expand Down
7 changes: 4 additions & 3 deletions ipparser/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func setup(c *caddy.Controller) error {

// Add the Plugin to CoreDNS, so Servers can use it in their plugin chain.
dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler {
return ipParser{Next: next, ForgeDomain: forgeDomain}
return ipParser{Next: next, ForgeDomain: strings.ToLower(forgeDomain)}
})

return nil
Expand All @@ -52,8 +52,9 @@ func (p ipParser) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg
var answers []dns.RR
containsNODATAResponse := false
for _, q := range r.Question {
subdomain := strings.TrimSuffix(q.Name, "."+p.ForgeDomain+".")
if len(subdomain) == len(q.Name) || len(subdomain) == 0 {
normalizedName := strings.ToLower(q.Name)
subdomain := strings.TrimSuffix(normalizedName, "."+p.ForgeDomain+".")
if len(subdomain) == len(normalizedName) || len(subdomain) == 0 {
continue
}

Expand Down

0 comments on commit d060dac

Please sign in to comment.