amogus
This commit is contained in:
parent
ffd7369ab9
commit
063c19d526
68
main.go
68
main.go
@ -6,6 +6,7 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
)
|
)
|
||||||
@ -20,8 +21,46 @@ func (h *dnsHandler) ServeDNS(w dns.ResponseWriter, r *dns.Msg) {
|
|||||||
for _, question := range r.Question {
|
for _, question := range r.Question {
|
||||||
fmt.Printf("Received query: %s (%d)\n", question.Name, question.Qtype)
|
fmt.Printf("Received query: %s (%d)\n", question.Name, question.Qtype)
|
||||||
|
|
||||||
if question.Qtype == dns.TypeCNAME || question.Qtype == dns.TypeA {
|
if question.Qtype == dns.TypeCNAME || question.Qtype == dns.TypeA || question.Qtype == dns.TypeAAAA {
|
||||||
if question.Name == "random-number.dynamic.cringe-studios.com." {
|
if question.Name == "google.com." {
|
||||||
|
msg.Answer = append(msg.Answer, &dns.CNAME{
|
||||||
|
Hdr: dns.RR_Header{
|
||||||
|
Name: question.Name,
|
||||||
|
Rrtype: dns.TypeCNAME,
|
||||||
|
Class: dns.ClassINET,
|
||||||
|
Ttl: 30,
|
||||||
|
},
|
||||||
|
Target: "test0.imposter.cringe-studios.com.",
|
||||||
|
})
|
||||||
|
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if strings.HasPrefix(question.Name, "test") && strings.HasSuffix(question.Name, ".imposter.cringe-studios.com.") {
|
||||||
|
num := question.Name[4:strings.Index(question.Name, ".imposter.cringe-studios.com.")]
|
||||||
|
|
||||||
|
number, err := strconv.ParseUint(num, 10, 64)
|
||||||
|
number++
|
||||||
|
|
||||||
|
log.Println(num)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("sus", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg.Answer = append(msg.Answer, &dns.CNAME{
|
||||||
|
Hdr: dns.RR_Header{
|
||||||
|
Name: question.Name,
|
||||||
|
Rrtype: dns.TypeCNAME,
|
||||||
|
Class: dns.ClassINET,
|
||||||
|
Ttl: 30,
|
||||||
|
},
|
||||||
|
Target: "test" + strconv.Itoa(int(number)) + ".imposter.cringe-studios.com.",
|
||||||
|
})
|
||||||
|
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if question.Name == "random-number.imposter.cringe-studios.com." {
|
||||||
theNumber := rand.Intn(10000)
|
theNumber := rand.Intn(10000)
|
||||||
|
|
||||||
msg.Answer = append(msg.Answer, &dns.CNAME{
|
msg.Answer = append(msg.Answer, &dns.CNAME{
|
||||||
@ -31,13 +70,13 @@ func (h *dnsHandler) ServeDNS(w dns.ResponseWriter, r *dns.Msg) {
|
|||||||
Class: dns.ClassINET,
|
Class: dns.ClassINET,
|
||||||
Ttl: 30,
|
Ttl: 30,
|
||||||
},
|
},
|
||||||
Target: "number-" + strconv.Itoa(theNumber) + ".dynamic.cringe-studios.com.",
|
Target: "number-" + strconv.Itoa(theNumber) + ".imposter.cringe-studios.com.",
|
||||||
})
|
})
|
||||||
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if question.Name == "amogus.dynamic.cringe-studios.com." {
|
if question.Name == "amogus.imposter.cringe-studios.com." {
|
||||||
msg.Answer = append(msg.Answer, &dns.CNAME{
|
msg.Answer = append(msg.Answer, &dns.CNAME{
|
||||||
Hdr: dns.RR_Header{
|
Hdr: dns.RR_Header{
|
||||||
Name: question.Name,
|
Name: question.Name,
|
||||||
@ -45,21 +84,20 @@ func (h *dnsHandler) ServeDNS(w dns.ResponseWriter, r *dns.Msg) {
|
|||||||
Class: dns.ClassINET,
|
Class: dns.ClassINET,
|
||||||
Ttl: 30,
|
Ttl: 30,
|
||||||
},
|
},
|
||||||
Target: "test(test.dynamic.cringe-studios.com.",
|
Target: "test(test.imposter.cringe-studios.com.",
|
||||||
})
|
})
|
||||||
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.Answer = append(msg.Answer, &dns.CNAME{
|
// msg.Answer = append(msg.Answer, &dns.NXNAME{
|
||||||
Hdr: dns.RR_Header{
|
// Hdr: dns.RR_Header{
|
||||||
Name: question.Name,
|
// Name: question.Name,
|
||||||
Rrtype: dns.TypeCNAME,
|
// Rrtype: dns.TypeNXNAME,
|
||||||
Class: dns.ClassINET,
|
// Class: dns.ClassINET,
|
||||||
Ttl: 30,
|
// Ttl: 30,
|
||||||
},
|
// },
|
||||||
Target: "homeipv4.graphite-official.com.",
|
// })
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +112,7 @@ func main() {
|
|||||||
handler := new(dnsHandler)
|
handler := new(dnsHandler)
|
||||||
|
|
||||||
server := &dns.Server{
|
server := &dns.Server{
|
||||||
Addr: ":6953",
|
Addr: ":53",
|
||||||
Net: "udp",
|
Net: "udp",
|
||||||
Handler: handler,
|
Handler: handler,
|
||||||
UDPSize: 65535,
|
UDPSize: 65535,
|
||||||
|
Loading…
Reference in New Issue
Block a user