diff --git a/etc/godns.conf b/etc/godns.conf index 213e631..ca863a1 100644 --- a/etc/godns.conf +++ b/etc/godns.conf @@ -2,8 +2,8 @@ Title = "GODNS" -Version = "0.1.3" -Author = "kenshin" +Version = "0.2.0" +Author = "kenshin, tystuyfzand" Debug = false diff --git a/etc/godns.example.conf b/etc/godns.example.conf index ef46fe5..6827fd5 100644 --- a/etc/godns.example.conf +++ b/etc/godns.example.conf @@ -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 diff --git a/hosts_file.go b/hosts_file.go index 31f9e42..71ae464 100644 --- a/hosts_file.go +++ b/hosts_file.go @@ -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 } } diff --git a/hosts_redis.go b/hosts_redis.go index b26d42b..effaf27 100644 --- a/hosts_redis.go +++ b/hosts_redis.go @@ -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 } }