File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -4,13 +4,40 @@ import (
44 "fmt"
55 "log"
66 "os"
7+ "strings"
78
89 "github.com/miekg/dns"
910)
1011
12+ func forwardToExternalDNS (q dns.Question ) ([]dns.RR , error ) {
13+ // Query the external DNS server (e.g., 1.1.1.1)
14+ client := new (dns.Client )
15+ message := new (dns.Msg )
16+ message .SetQuestion (q .Name , q .Qtype )
17+
18+ // Using 1.1.1.1 as an external resolver
19+ resp , _ , err := client .Exchange (message , "1.1.1.1:53" )
20+ if err != nil {
21+ return nil , err
22+ }
23+ return resp .Answer , nil
24+ }
25+
1126func parseQuery (m * dns.Msg , qdns * QuickDNSResolver ) {
1227 for _ , q := range m .Question {
1328 println ("Query: " , q .Name , q .Qtype , q .Qclass )
29+
30+ if ! strings .HasSuffix (q .Name , ".swiftwave.xyz" ) {
31+ // Query 1.1.1.1 or another DNS server and add the answer
32+ answers , err := forwardToExternalDNS (q )
33+ if err != nil {
34+ log .Printf ("Failed to forward query: %v" , err )
35+ return
36+ }
37+ m .Answer = append (m .Answer , answers ... )
38+ return
39+ }
40+
1441 switch q .Qtype {
1542 case dns .TypeNone :
1643 fallthrough
You can’t perform that action at this time.
0 commit comments