Better wildcard matching, though we should still split on . before checking

This commit is contained in:
Tyler 2018-08-30 23:03:39 -04:00
parent aae18bc0c9
commit 37c3ebb57e
4 changed files with 14 additions and 6 deletions

View File

@ -2,8 +2,8 @@
Title = "GODNS"
Version = "0.1.3"
Author = "kenshin"
Version = "0.2.0"
Author = "kenshin, tystuyfzand"
Debug = false

View File

@ -1,7 +1,7 @@
#Toml config file
title = "GODNS"
version = "0.2.0"
author = "kenshin, tystuyfzand"
Version = "0.2.1"
Author = "kenshin, tystuyfzand"
debug = false

View File

@ -8,6 +8,7 @@ import (
"os"
"bufio"
"regexp"
"github.com/ryanuber/go-glob"
)
type FileHosts struct {
@ -63,10 +64,13 @@ func (f *FileHosts) Get(domain string) ([]string, bool) {
for host, ip := range f.hosts {
if strings.HasPrefix(host, "*.") {
old, err := publicsuffix.EffectiveTLDPlusOne(host)
if err != nil {
continue
}
if sld == old {
// Don't blindly accept wildcards, match it against string
if sld == old && glob.Glob(host, domain) {
return []string{ip}, true
}
}

View File

@ -5,6 +5,7 @@ import (
"sync"
"strings"
"golang.org/x/net/publicsuffix"
"github.com/ryanuber/go-glob"
)
type RedisHosts struct {
@ -94,10 +95,13 @@ func (r *RedisHosts) Get(domain string) ([]string, bool) {
for host, ip := range r.hosts {
if strings.HasPrefix(host, "*.") {
old, err := publicsuffix.EffectiveTLDPlusOne(host)
if err != nil {
continue
}
if sld == old {
// Don't blindly accept wildcards, match it against string
if sld == old && glob.Glob(host, domain) {
return strings.Split(ip, ","), true
}
}