userauth.go 638 B

1234567891011121314151617181920212223
  1. package dbdata
  2. import (
  3. "reflect"
  4. "regexp"
  5. )
  6. var authRegistry = make(map[string]reflect.Type)
  7. type IUserAuth interface {
  8. checkData(authData map[string]interface{}) error
  9. checkUser(name, pwd string, g *Group) error
  10. }
  11. func makeInstance(name string) interface{} {
  12. v := reflect.New(authRegistry[name]).Elem()
  13. return v.Interface()
  14. }
  15. func ValidateIpPort(addr string) bool {
  16. 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])$$`)
  17. return RegExp.MatchString(addr)
  18. }