This commit is contained in:
31
main.go
31
main.go
@@ -193,14 +193,19 @@ func handleDNSRequest(w dns.ResponseWriter, r *dns.Msg) {
|
|||||||
|
|
||||||
// Durchlaufe alle Fragen in der Anfrage
|
// Durchlaufe alle Fragen in der Anfrage
|
||||||
for _, q := range r.Question {
|
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 {
|
switch q.Qtype {
|
||||||
case dns.TypeA: // IPv4-Anfrage
|
case dns.TypeA: // IPv4-Anfrage
|
||||||
ip, exists := D[q.Name]
|
ip, exists := D[strings.ToLower(q.Name)]
|
||||||
if exists {
|
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 err == nil {
|
||||||
if DEBUG {
|
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)
|
msg.Answer = append(msg.Answer, rr)
|
||||||
} else {
|
} else {
|
||||||
@@ -210,18 +215,18 @@ func handleDNSRequest(w dns.ResponseWriter, r *dns.Msg) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if DEBUG {
|
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
|
case dns.TypeAAAA: // IPv6-Anfrage
|
||||||
// Beispielhafte IPv6-Adresse für Demonstration
|
// Beispielhafte IPv6-Adresse für Demonstration
|
||||||
ip, exists := D[q.Name]
|
ip, exists := D[strings.ToLower(q.Name)]
|
||||||
if exists && !strings.EqualFold(ip.Ipv6, "") {
|
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 err == nil {
|
||||||
if DEBUG {
|
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)
|
msg.Answer = append(msg.Answer, rr)
|
||||||
} else {
|
} else {
|
||||||
@@ -231,14 +236,14 @@ func handleDNSRequest(w dns.ResponseWriter, r *dns.Msg) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if DEBUG {
|
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:
|
case dns.TypePTR:
|
||||||
for a, b := range D {
|
for a, b := range D {
|
||||||
iptocheck := reverseString(b.Ipv4)
|
iptocheck := reverseString(b.Ipv4)
|
||||||
if iptocheck+".in-addr.arpa." == q.Name {
|
if iptocheck+".in-addr.arpa." == strings.ToLower(q.Name) {
|
||||||
rr, err := dns.NewRR(q.Name + " PTR " + a)
|
rr, err := dns.NewRR(strings.ToLower(q.Name) + " PTR " + a)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if DEBUG {
|
if DEBUG {
|
||||||
fmt.Println("~", "handleDNSRequest", "case dns.TypePTR", "IPv4", "found match", a, b)
|
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)
|
ip6tocheck, _ := IPv6ToPTR(b.Ipv6)
|
||||||
if ip6tocheck == q.Name {
|
if ip6tocheck == strings.ToLower(q.Name) {
|
||||||
rr, err := dns.NewRR(q.Name + " PTR " + a)
|
rr, err := dns.NewRR(strings.ToLower(q.Name) + " PTR " + a)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if DEBUG {
|
if DEBUG {
|
||||||
fmt.Println("~", "handleDNSRequest", "case dns.TypePTR", "IPv6", "found match", a, b)
|
fmt.Println("~", "handleDNSRequest", "case dns.TypePTR", "IPv6", "found match", a, b)
|
||||||
@@ -268,7 +273,7 @@ func handleDNSRequest(w dns.ResponseWriter, r *dns.Msg) {
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
if DEBUG {
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user