casesensitive fix
All checks were successful
release-tag / release-image (push) Successful in 42s

This commit is contained in:
2025-01-16 01:24:08 +01:00
parent 130411e58f
commit ed93d04d7e

31
main.go
View File

@@ -193,14 +193,19 @@ func handleDNSRequest(w dns.ResponseWriter, r *dns.Msg) {
// Durchlaufe alle Fragen in der Anfrage
for _, q := range r.Question {
if strings.ToLower(q.Name) != q.Name {
if DEBUG {
fmt.Println("!", "handleDNSRequest", "case dns.TypeANY", "strings.ToLower(q.Name) != q.Name", strings.ToLower(q.Name), q.Name)
}
}
switch q.Qtype {
case dns.TypeA: // IPv4-Anfrage
ip, exists := D[q.Name]
ip, exists := D[strings.ToLower(q.Name)]
if exists {
rr, err := dns.NewRR(q.Name + " A " + ip.Ipv4)
rr, err := dns.NewRR(strings.ToLower(q.Name) + " A " + ip.Ipv4)
if err == nil {
if DEBUG {
fmt.Println("~", "handleDNSRequest", "case dns.TypeA", "D[q.Name]", D[q.Name], "q.Name", q.Name)
fmt.Println("~", "handleDNSRequest", "case dns.TypeA", "D[q.Name]", D[strings.ToLower(q.Name)], "q.Name", strings.ToLower(q.Name))
}
msg.Answer = append(msg.Answer, rr)
} else {
@@ -210,18 +215,18 @@ func handleDNSRequest(w dns.ResponseWriter, r *dns.Msg) {
}
} else {
if DEBUG {
fmt.Println("!", "handleDNSRequest", "case dns.TypeA", "not found in D", q.Name)
fmt.Println("!", "handleDNSRequest", "case dns.TypeA", "not found in D", strings.ToLower(q.Name))
}
}
case dns.TypeAAAA: // IPv6-Anfrage
// Beispielhafte IPv6-Adresse für Demonstration
ip, exists := D[q.Name]
ip, exists := D[strings.ToLower(q.Name)]
if exists && !strings.EqualFold(ip.Ipv6, "") {
rr, err := dns.NewRR(q.Name + " AAAA " + ip.Ipv6)
rr, err := dns.NewRR(strings.ToLower(q.Name) + " AAAA " + ip.Ipv6)
if err == nil {
if DEBUG {
fmt.Println("~", "handleDNSRequest", "case dns.TypeAAAA", "D[q.Name]", D[q.Name], "q.Name", q.Name)
fmt.Println("~", "handleDNSRequest", "case dns.TypeAAAA", "D[q.Name]", D[strings.ToLower(q.Name)], "q.Name", strings.ToLower(q.Name))
}
msg.Answer = append(msg.Answer, rr)
} else {
@@ -231,14 +236,14 @@ func handleDNSRequest(w dns.ResponseWriter, r *dns.Msg) {
}
} else {
if DEBUG {
fmt.Println("!", "handleDNSRequest", "case dns.TypeAAAA", "not found in D", q.Name)
fmt.Println("!", "handleDNSRequest", "case dns.TypeAAAA", "not found in D", strings.ToLower(q.Name))
}
}
case dns.TypePTR:
for a, b := range D {
iptocheck := reverseString(b.Ipv4)
if iptocheck+".in-addr.arpa." == q.Name {
rr, err := dns.NewRR(q.Name + " PTR " + a)
if iptocheck+".in-addr.arpa." == strings.ToLower(q.Name) {
rr, err := dns.NewRR(strings.ToLower(q.Name) + " PTR " + a)
if err == nil {
if DEBUG {
fmt.Println("~", "handleDNSRequest", "case dns.TypePTR", "IPv4", "found match", a, b)
@@ -252,8 +257,8 @@ func handleDNSRequest(w dns.ResponseWriter, r *dns.Msg) {
}
ip6tocheck, _ := IPv6ToPTR(b.Ipv6)
if ip6tocheck == q.Name {
rr, err := dns.NewRR(q.Name + " PTR " + a)
if ip6tocheck == strings.ToLower(q.Name) {
rr, err := dns.NewRR(strings.ToLower(q.Name) + " PTR " + a)
if err == nil {
if DEBUG {
fmt.Println("~", "handleDNSRequest", "case dns.TypePTR", "IPv6", "found match", a, b)
@@ -268,7 +273,7 @@ func handleDNSRequest(w dns.ResponseWriter, r *dns.Msg) {
}
default:
if DEBUG {
fmt.Println("+", "unhandledDNSRequest", r.Question, q.Name, q.Qclass, q.Qtype)
fmt.Println("+", "unhandledDNSRequest", r.Question, strings.ToLower(q.Name), q.Qclass, q.Qtype)
}
}
}