Better wildcard matching, though we should still split on . before checking
This commit is contained in:
parent
aae18bc0c9
commit
37c3ebb57e
|
@ -2,8 +2,8 @@
|
|||
|
||||
|
||||
Title = "GODNS"
|
||||
Version = "0.1.3"
|
||||
Author = "kenshin"
|
||||
Version = "0.2.0"
|
||||
Author = "kenshin, tystuyfzand"
|
||||
|
||||
Debug = false
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue