Skip to content

Commit

Permalink
Fix PORT_FLOOR check and CIDR_MAX_BITS in AssignmentService (#491)
Browse files Browse the repository at this point in the history
* fix max cidr

* fix port floor
  • Loading branch information
Boy132 authored Jul 17, 2024
1 parent 8a3d67a commit a04937d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions app/Services/Allocations/AssignmentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class AssignmentService
{
public const CIDR_MAX_BITS = 27;
public const CIDR_MAX_BITS = 25;
public const CIDR_MIN_BITS = 32;
public const PORT_FLOOR = 1024;
public const PORT_CEIL = 65535;
Expand Down Expand Up @@ -74,7 +74,7 @@ public function handle(Node $node, array $data): array
throw new TooManyPortsInRangeException();
}

if ((int) $matches[1] <= self::PORT_FLOOR || (int) $matches[2] > self::PORT_CEIL) {
if ((int) $matches[1] < self::PORT_FLOOR || (int) $matches[2] > self::PORT_CEIL) {
throw new PortOutOfRangeException();
}

Expand All @@ -88,7 +88,7 @@ public function handle(Node $node, array $data): array
];
}
} else {
if ((int) $port <= self::PORT_FLOOR || (int) $port > self::PORT_CEIL) {
if ((int) $port < self::PORT_FLOOR || (int) $port > self::PORT_CEIL) {
throw new PortOutOfRangeException();
}

Expand Down
2 changes: 1 addition & 1 deletion lang/en/exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
'too_many_ports' => 'Adding more than 1000 ports in a single range at once is not supported.',
'invalid_mapping' => 'The mapping provided for :port was invalid and could not be processed.',
'cidr_out_of_range' => 'CIDR notation only allows masks between /25 and /32.',
'port_out_of_range' => 'Ports in an allocation must be greater than 1024 and less than or equal to 65535.',
'port_out_of_range' => 'Ports in an allocation must be greater than or equal to 1024 and less than or equal to 65535.',
],
'egg' => [
'delete_has_servers' => 'An Egg with active servers attached to it cannot be deleted from the Panel.',
Expand Down

0 comments on commit a04937d

Please sign in to comment.