godns/utils.go

18 lines
304 B
Go
Raw Normal View History

2018-02-01 09:09:02 +00:00
package main
import (
"net"
"regexp"
2018-09-01 01:27:26 +00:00
)
2018-02-01 09:09:02 +00:00
func isDomain(domain string) bool {
if isIP(domain) {
return false
}
match, _ := regexp.MatchString(`^([a-zA-Z0-9\*]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$`, domain)
return match
}
func isIP(ip string) bool {
2018-09-01 01:27:26 +00:00
return net.ParseIP(ip) != nil
}