Use 2LD for lookup
This commit is contained in:
parent
9bb3f1ca2a
commit
1950e95d0f
@ -22,10 +22,10 @@ func reverse_lookup(target string) (string, error) {
|
||||
|
||||
func lookup(target string) (string, error) {
|
||||
labels := strings.Split(target, ".")
|
||||
if len(labels) < 3 || strings.HasSuffix(domainZone, target) {
|
||||
if len(labels) < 2 || strings.HasSuffix(domainZone, target) {
|
||||
return "", errors.New("Invalid domain")
|
||||
}
|
||||
subDomain := labels[len(labels) - 3]
|
||||
subDomain := labels[len(labels) - 2]
|
||||
if len(subDomain) != 26 {
|
||||
return "", errors.New("Invalid subdomain length")
|
||||
}
|
||||
|
@ -95,10 +95,10 @@ func handleRequest(w dns.ResponseWriter, r *dns.Msg) {
|
||||
|
||||
for _, q := range r.Question {
|
||||
labels := dns.SplitDomainName(q.Name)
|
||||
if len(labels) < 3 {
|
||||
if len(labels) < 2 {
|
||||
continue
|
||||
}
|
||||
subDomain := labels[len(labels)-3]
|
||||
subDomain := labels[len(labels)-2]
|
||||
|
||||
resolvedAddr, err := lookup(subDomain)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user