mirror of
https://github.com/getnamingo/registry.git
synced 2025-07-03 01:23:22 +02:00
Preparation for better IP whitelisting
This commit is contained in:
parent
b3113da4f4
commit
bb5d34e0f0
3 changed files with 57 additions and 0 deletions
|
@ -47,3 +47,22 @@ function isIpWhitelisted($ip, $pdo) {
|
|||
$count = $stmt->fetchColumn();
|
||||
return $count > 0;
|
||||
}
|
||||
|
||||
// Function to update the permitted IPs from the database
|
||||
function updatePermittedIPs($pool, $permittedIPsTable) {
|
||||
$pdo = $pool->get();
|
||||
$query = "SELECT addr FROM registrar_whitelist";
|
||||
$stmt = $pdo->query($query);
|
||||
$permittedIPs = $stmt->fetchAll(PDO::FETCH_COLUMN, 0);
|
||||
$pool->put($pdo);
|
||||
|
||||
// Manually clear the table by removing each entry
|
||||
foreach ($permittedIPsTable as $key => $value) {
|
||||
$permittedIPsTable->del($key);
|
||||
}
|
||||
|
||||
// Insert new values
|
||||
foreach ($permittedIPs as $ip) {
|
||||
$permittedIPsTable->set($ip, ['addr' => $ip]);
|
||||
}
|
||||
}
|
|
@ -99,3 +99,22 @@ function isIpWhitelisted($ip, $pdo) {
|
|||
$count = $stmt->fetchColumn();
|
||||
return $count > 0;
|
||||
}
|
||||
|
||||
// Function to update the permitted IPs from the database
|
||||
function updatePermittedIPs($pool, $permittedIPsTable) {
|
||||
$pdo = $pool->get();
|
||||
$query = "SELECT addr FROM registrar_whitelist";
|
||||
$stmt = $pdo->query($query);
|
||||
$permittedIPs = $stmt->fetchAll(PDO::FETCH_COLUMN, 0);
|
||||
$pool->put($pdo);
|
||||
|
||||
// Manually clear the table by removing each entry
|
||||
foreach ($permittedIPsTable as $key => $value) {
|
||||
$permittedIPsTable->del($key);
|
||||
}
|
||||
|
||||
// Insert new values
|
||||
foreach ($permittedIPs as $ip) {
|
||||
$permittedIPsTable->set($ip, ['addr' => $ip]);
|
||||
}
|
||||
}
|
|
@ -59,3 +59,22 @@ function isIpWhitelisted($ip, $pdo) {
|
|||
$count = $stmt->fetchColumn();
|
||||
return $count > 0;
|
||||
}
|
||||
|
||||
// Function to update the permitted IPs from the database
|
||||
function updatePermittedIPs($pool, $permittedIPsTable) {
|
||||
$pdo = $pool->get();
|
||||
$query = "SELECT addr FROM registrar_whitelist";
|
||||
$stmt = $pdo->query($query);
|
||||
$permittedIPs = $stmt->fetchAll(PDO::FETCH_COLUMN, 0);
|
||||
$pool->put($pdo);
|
||||
|
||||
// Manually clear the table by removing each entry
|
||||
foreach ($permittedIPsTable as $key => $value) {
|
||||
$permittedIPsTable->del($key);
|
||||
}
|
||||
|
||||
// Insert new values
|
||||
foreach ($permittedIPs as $ip) {
|
||||
$permittedIPsTable->set($ip, ['addr' => $ip]);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue