Skip to content

Commit

Permalink
chore(NET-1245): remove check for private network address (#2934)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aceix authored May 14, 2024
1 parent 4a355ee commit faf50c8
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions controllers/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,36 +442,22 @@ func createNetwork(w http.ResponseWriter, r *http.Request) {

// validate address ranges: must be private
if network.AddressRange != "" {
_, ipNet, err := net.ParseCIDR(network.AddressRange)
_, _, err := net.ParseCIDR(network.AddressRange)
if err != nil {
logger.Log(0, r.Header.Get("user"), "failed to create network: ",
err.Error())
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "badrequest"))
return
}
if !ipNet.IP.IsPrivate() {
err := errors.New("address range must be private")
logger.Log(0, r.Header.Get("user"), "failed to create network: ",
err.Error())
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "badrequest"))
return
}
}
if network.AddressRange6 != "" {
_, ipNet, err := net.ParseCIDR(network.AddressRange6)
_, _, err := net.ParseCIDR(network.AddressRange6)
if err != nil {
logger.Log(0, r.Header.Get("user"), "failed to create network: ",
err.Error())
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "badrequest"))
return
}
if !ipNet.IP.IsPrivate() {
err := errors.New("address range must be private")
logger.Log(0, r.Header.Get("user"), "failed to create network: ",
err.Error())
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "badrequest"))
return
}
}

network, err = logic.CreateNetwork(network)
Expand Down

0 comments on commit faf50c8

Please sign in to comment.