From 4db6aa189781294be719edd771119797fdaeb6ca Mon Sep 17 00:00:00 2001 From: Kieran Date: Wed, 30 Apr 2025 13:54:51 +0100 Subject: [PATCH] fix: allow full range in capacity checks --- lnvps_api/src/provisioner/capacity.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lnvps_api/src/provisioner/capacity.rs b/lnvps_api/src/provisioner/capacity.rs index d45a57e..8aea8bc 100644 --- a/lnvps_api/src/provisioner/capacity.rs +++ b/lnvps_api/src/provisioner/capacity.rs @@ -304,9 +304,6 @@ pub struct IPRangeCapacity { } impl IPRangeCapacity { - // first/last/gw - const RESERVED: u128 = 3; - /// Total number of IPs free pub fn available_capacity(&self) -> u128 { let net: IpNetwork = self.range.cidr.parse().unwrap(); @@ -315,7 +312,11 @@ impl IPRangeCapacity { NetworkSize::V4(s) => (s as u128).saturating_sub(self.usage), NetworkSize::V6(s) => s.saturating_sub(self.usage), } - .saturating_sub(Self::RESERVED) + .saturating_sub(if self.range.use_full_range { + 1 // gw + } else { + 3 // first/last/gw + }) } }