tsdns: lowercase the name in parseQuery.

Domains in DNS should be case-insensitive.

Signed-off-by: Dmytro Shynkevych <dmytro@tailscale.com>
This commit is contained in:
Dmytro Shynkevych
2020-08-20 18:05:40 -04:00
parent 309c15dfdd
commit 1886dfdca3
2 changed files with 9 additions and 0 deletions

View File

@@ -293,6 +293,14 @@ func (r *Resolver) parseQuery(query []byte, resp *response) error {
return err
}
// Lowercase the name: DOMAIN.COM. should resolve the same as domain.com.
name := resp.Question.Name.Data[:resp.Question.Name.Length]
for i, b := range name {
if 'A' <= b && b <= 'Z' {
name[i] = b - 'A' + 'a'
}
}
return nil
}