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