check if the ip range is valid
This commit is contained in:
parent
24544a6260
commit
657f92a3df
11
ldap.go
11
ldap.go
|
@ -34,11 +34,12 @@ func (l *ldapConfig) addIPRange(s string) error {
|
||||||
if len(ips) != 2 {
|
if len(ips) != 2 {
|
||||||
return errors.New("invalid IPs")
|
return errors.New("invalid IPs")
|
||||||
}
|
}
|
||||||
if ip := net.ParseIP(ips[0]); ip != nil {
|
for k, v := range []*net.IP{&(l.ipMin), &(l.ipMax)} {
|
||||||
l.ipMin = ip
|
if ip := net.ParseIP(strings.Trim(ips[k], " ")); ip == nil {
|
||||||
}
|
return errors.New(fmt.Sprintf("invalid IP '%s'", ips[k]))
|
||||||
if ip := net.ParseIP(ips[1]); ip != nil {
|
} else {
|
||||||
l.ipMax = ip
|
*v = ip
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
5
main.go
5
main.go
|
@ -76,7 +76,10 @@ func main() {
|
||||||
certAuth: config.GetString(profile+".cert", "optionnal"),
|
certAuth: config.GetString(profile+".cert", "optionnal"),
|
||||||
upgradeFrom: config.GetString(profile+".upgradeFrom", ""),
|
upgradeFrom: config.GetString(profile+".upgradeFrom", ""),
|
||||||
}
|
}
|
||||||
ldapConf.addIPRange(config.GetString(profile+".IPRange", ""))
|
if err := ldapConf.addIPRange(config.GetString(profile+".IPRange", "")); err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
if len(ldapConf.servers) > 0 && len(ldapConf.attributes) < 2 {
|
if len(ldapConf.servers) > 0 && len(ldapConf.attributes) < 2 {
|
||||||
log.Println("valud ldap configuration must have 2 attributes")
|
log.Println("valud ldap configuration must have 2 attributes")
|
||||||
|
|
Loading…
Reference in New Issue