little changes
This commit is contained in:
28
echodns.go
28
echodns.go
@@ -2,11 +2,11 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"math/rand"
|
|
||||||
|
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
)
|
)
|
||||||
@@ -23,8 +23,8 @@ func strategyMaker(name string, qtype uint16) uint16 {
|
|||||||
} else if strings.Contains(subdomain, "echo") {
|
} else if strings.Contains(subdomain, "echo") {
|
||||||
return 4 // basic echodns
|
return 4 // basic echodns
|
||||||
} else if strings.Contains(subdomain, "ttl") {
|
} else if strings.Contains(subdomain, "ttl") {
|
||||||
return 5 // ttl test
|
return 5 // ttl test
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@@ -38,9 +38,9 @@ func InttoIPv4(n uint32) net.IP {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TtlParser(domain string) uint32 {
|
func TtlParser(domain string) uint32 {
|
||||||
subdomain := strings.ToLower(strings.Split(domain, ".")[0])
|
subdomain := strings.ToLower(strings.Split(domain, ".")[0])
|
||||||
ttl, _ := strconv.Atoi(strings.Split(subdomain, "-")[0])
|
ttl, _ := strconv.Atoi(strings.Split(subdomain, "-")[0])
|
||||||
return uint32(ttl)
|
return uint32(ttl)
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleReflect(w dns.ResponseWriter, r *dns.Msg) {
|
func handleReflect(w dns.ResponseWriter, r *dns.Msg) {
|
||||||
@@ -52,7 +52,7 @@ func handleReflect(w dns.ResponseWriter, r *dns.Msg) {
|
|||||||
m := new(dns.Msg)
|
m := new(dns.Msg)
|
||||||
m.SetReply(r)
|
m.SetReply(r)
|
||||||
m.Compress = true
|
m.Compress = true
|
||||||
m.Authoritative = true
|
m.Authoritative = true
|
||||||
if addr, ok := w.RemoteAddr().(*net.UDPAddr); ok {
|
if addr, ok := w.RemoteAddr().(*net.UDPAddr); ok {
|
||||||
ip = addr.IP
|
ip = addr.IP
|
||||||
}
|
}
|
||||||
@@ -95,14 +95,14 @@ func handleReflect(w dns.ResponseWriter, r *dns.Msg) {
|
|||||||
A: ip,
|
A: ip,
|
||||||
}
|
}
|
||||||
m.Answer = append(m.Answer, a)
|
m.Answer = append(m.Answer, a)
|
||||||
case 5:
|
case 5:
|
||||||
query_ttl := TtlParser(name)
|
query_ttl := TtlParser(name)
|
||||||
//fmt.Println(query_ttl)
|
//fmt.Println(query_ttl)
|
||||||
a := &dns.A{
|
a := &dns.A{
|
||||||
Hdr: dns.RR_Header{Name: name, Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: query_ttl},
|
Hdr: dns.RR_Header{Name: name, Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: query_ttl},
|
||||||
A: ip,
|
A: ip,
|
||||||
}
|
}
|
||||||
m.Answer = append(m.Answer, a)
|
m.Answer = append(m.Answer, a)
|
||||||
case 0:
|
case 0:
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user