Skip to content

Commit 43786b1

Browse files
committed
Block addition of more than 2000 ports at once, closes pterodactyl#219
1 parent 9231171 commit 43786b1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

app/Repositories/NodeRepository.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,13 @@ public function addAllocations($id, array $allocations)
213213
throw new DisplayException('The mapping for ' . $port . ' is invalid and cannot be processed.');
214214
}
215215
if (preg_match('/^(\d{1,5})-(\d{1,5})$/', $port, $matches)) {
216-
foreach (range($matches[1], $matches[2]) as $assignPort) {
216+
$portBlock = range($matches[1], $matches[2]);
217+
218+
if (count($portBlock) > 2000) {
219+
throw new DisplayException('Adding more than 2000 ports at once is not currently supported. Please consider using a smaller port range.');
220+
}
221+
222+
foreach ($portBlock as $assignPort) {
217223
$alloc = Models\Allocation::firstOrNew([
218224
'node' => $node->id,
219225
'ip' => $ip,
@@ -252,7 +258,6 @@ public function addAllocations($id, array $allocations)
252258
}
253259

254260
DB::commit();
255-
// return true;
256261
} catch (\Exception $ex) {
257262
DB::rollBack();
258263
throw $ex;

0 commit comments

Comments
 (0)