Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when requesting IP (first_free) dont provide IP when 'IP request is disabled' (allowRequests==0) #3635

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion api/controllers/Addresses.php
Expand Up @@ -122,6 +122,7 @@ public function GET () {
$subnet = $this->Tools->fetch_object ("subnets", "id", $this->_params->id2);
}
if($subnet->isFull==1) { $this->Response->throw_exception(404, 'No free addresses found'); }
if ($subnet->allowRequests==0) { $this->Response->throw_exception(404, 'Subnet not enabled for IP Requests'); }

$this->_params->ip_addr = $this->Addresses->get_first_available_address ($subnet->id);
// null
Expand Down Expand Up @@ -304,6 +305,8 @@ public function POST () {
}
if($subnet===false) { $this->Response->throw_exception(400, "Invalid subnet identifier"); }
if($subnet->isFull==1) { $this->Response->throw_exception(404, "No free addresses found (subnet is full)"); }
if($subnet->allowRequests==0) { $this->Response->throw_exception(404, 'Subnet not enabled for IP Requests'); }


// Obtain exclusive MySQL lock so parallel API requests on the same object are thread safe.
$Lock = new LockForUpdate($this->Database, 'subnets', $subnet->id);
Expand Down Expand Up @@ -612,4 +615,4 @@ private function validate_create_update_common () {
$this->_params->state = 2;
}
}
}
}
2 changes: 2 additions & 0 deletions api/controllers/Subnets.php
Expand Up @@ -600,6 +600,8 @@ public function subnet_first_free_address () {
// check for isFull
$subnet = $this->read_subnet ();
if($subnet->isFull==1) { $this->Response->throw_exception(404, "No free addresses found"); }
if($subnet->allowRequests==0) { $this->Response->throw_exception(404, 'Subnet not enabled for IP Requests'); }

// slaves
if($this->Subnets->has_slaves ($this->_params->id)) { $this->Response->throw_exception(409, "Subnet contains subnets"); }
// fetch
Expand Down