迁移ValidateIpPort函数的位置

This commit is contained in:
lanrenwo
2022-06-06 21:34:51 +08:00
parent b06c035cce
commit f46a30488a
2 changed files with 9 additions and 7 deletions

View File

@@ -1,6 +1,9 @@
package dbdata
import "reflect"
import (
"reflect"
"regexp"
)
var authRegistry = make(map[string]reflect.Type)
@@ -13,3 +16,8 @@ func makeInstance(name string) interface{} {
v := reflect.New(authRegistry[name]).Elem()
return v.Interface()
}
func ValidateIpPort(addr string) bool {
RegExp := regexp.MustCompile(`^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\:([0-9]|[1-9]\d{1,3}|[1-5]\d{4}|6[0-5]{2}[0-3][0-5])$$`)
return RegExp.MatchString(addr)
}