diff --git a/hosts.go b/hosts.go index 360efe8..c234ef7 100644 --- a/hosts.go +++ b/hosts.go @@ -4,7 +4,6 @@ import ( "bufio" "net" "os" - "regexp" "strings" "sync" "time" @@ -240,15 +239,3 @@ func (f *FileHosts) Refresh() { func (f *FileHosts) clear() { f.hosts = make(map[string]string) } - -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 { - return (net.ParseIP(ip) != nil) -} diff --git a/utils.go b/utils.go new file mode 100644 index 0000000..1993d59 --- /dev/null +++ b/utils.go @@ -0,0 +1,18 @@ +package main + +import ( + "net" + "regexp" +) + +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 { + return (net.ParseIP(ip) != nil) +} diff --git a/hosts_test.go b/utils_test.go similarity index 100% rename from hosts_test.go rename to utils_test.go