Use 2LD for lookup

This commit is contained in:
George 2020-02-03 14:57:51 -05:00
parent 9bb3f1ca2a
commit 1950e95d0f
2 changed files with 4 additions and 4 deletions

View File

@ -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")
}

View File

@ -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 {