|
@@ -100,10 +100,6 @@ func GetNetwork(name string) (*Network, error) {
|
|
|
if govalidator.IsNull(name) {
|
|
if govalidator.IsNull(name) {
|
|
|
return nil, fmt.Errorf("validation error: %s can not be null", name)
|
|
return nil, fmt.Errorf("validation error: %s can not be null", name)
|
|
|
}
|
|
}
|
|
|
- if !govalidator.Matches(name, "[\\w.]+") { // allow alphanumeric + dot
|
|
|
|
|
- return nil, fmt.Errorf("validation error: `%s` can only contain letters, numbers and dots", name)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
var network dbNetworkModel
|
|
var network dbNetworkModel
|
|
|
db.Preload("Users").Where(&dbNetworkModel{Name: name}).First(&network)
|
|
db.Preload("Users").Where(&dbNetworkModel{Name: name}).First(&network)
|
|
@@ -135,8 +131,8 @@ func CreateNewNetwork(name, cidr string, nettype NetworkType, via string) (*Netw
|
|
|
if govalidator.IsNull(name) {
|
|
if govalidator.IsNull(name) {
|
|
|
return nil, fmt.Errorf("validation error: %s can not be null", name)
|
|
return nil, fmt.Errorf("validation error: %s can not be null", name)
|
|
|
}
|
|
}
|
|
|
- if !govalidator.Matches(name, "[\\w.]+") { // allow alphanumeric + dot
|
|
|
|
|
- return nil, fmt.Errorf("validation error: `%s` can only contain letters, numbers and dots", name)
|
|
|
|
|
|
|
+ if !govalidator.Matches(name, "^([\\w\\.]+)$") { // allow alphanumeric, underscore and dot
|
|
|
|
|
+ return nil, fmt.Errorf("validation error: `%s` can only contain letters, numbers, underscores and dots", name)
|
|
|
}
|
|
}
|
|
|
if !govalidator.IsCIDR(cidr) {
|
|
if !govalidator.IsCIDR(cidr) {
|
|
|
return nil, fmt.Errorf("validation error: `%s` must be a network in the CIDR form", cidr)
|
|
return nil, fmt.Errorf("validation error: `%s` must be a network in the CIDR form", cidr)
|