diff --git a/doh/dns.go b/doh/dns.go index 77b2c08..c3527ff 100644 --- a/doh/dns.go +++ b/doh/dns.go @@ -4,6 +4,7 @@ import ( "errors" "sync" + "regexp" "github.com/babolivier/go-doh-client" ) @@ -15,6 +16,13 @@ func Init(dns string) { } func Lookup(domain string) (string, error) { + ipRegex := "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$" + + if r, _ := regexp.MatchString(ipRegex, domain); r { + return domain, nil + } + + a, _, err := resolver.LookupA(domain) if err != nil { return "", err