Skip to content

Commit 9ae48ea

Browse files
committed
feat: make domain name to lowercase before doing any query
1 parent b001a93 commit 9ae48ea

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

main.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ func parseQuery(m *dns.Msg, qdns *QuickDNSResolver) {
2727
for _, q := range m.Question {
2828
println("Query: ", q.Name, q.Qtype, q.Qclass)
2929

30-
if !strings.HasSuffix(q.Name, ".swiftwave.xyz.") {
30+
queryName := strings.ToLower(q.Name)
31+
32+
if !strings.HasSuffix(queryName, ".swiftwave.xyz.") {
3133
// Query 1.1.1.1 or another DNS server and add the answer
3234
answers, err := forwardToExternalDNS(q)
3335
if err != nil {
@@ -57,7 +59,7 @@ func parseQuery(m *dns.Msg, qdns *QuickDNSResolver) {
5759
}
5860
case dns.TypeA:
5961
{
60-
isQDNS, ip := qdns.ResolveARecord(q.Name)
62+
isQDNS, ip := qdns.ResolveARecord(queryName)
6163
if isQDNS {
6264
rr, err := dns.NewRR(fmt.Sprintf("%s A %s", q.Name, ip))
6365
if err == nil {

quickdns_resolver.go

-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package main
33
import (
44
"fmt"
55
"regexp"
6-
"strings"
76
)
87

98
/**
@@ -32,7 +31,6 @@ func NewQuickDNSResolver() (*QuickDNSResolver, error) {
3231
// Returns true if the domain name is in the format ip-3-56-23-12.swiftwave.xyz
3332
// Also returns the IP address
3433
func (q *QuickDNSResolver) ResolveARecord(domain string) (bool, string) {
35-
domain = strings.ToLower(domain)
3634
if matches := q.Regex.FindStringSubmatch(domain); len(matches) == 5 {
3735
ip := fmt.Sprintf("%s.%s.%s.%s", matches[1], matches[2], matches[3], matches[4])
3836
return true, ip

0 commit comments

Comments
 (0)