|
|
|
|
@ -1148,16 +1148,51 @@ final class CloudAdminHostNetworkService
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** IPv6 pools materialize only addresses that were actually claimed. */
|
|
|
|
|
/**
|
|
|
|
|
* IPv6 pools materialize claimed addresses and the bounded set of
|
|
|
|
|
* control-plane blocked addresses. The latter keeps administrator
|
|
|
|
|
* disabled-address projections exact without expanding the sparse range.
|
|
|
|
|
*/
|
|
|
|
|
private static function refreshSparseIpv6Ledger(CloudPublicIpPool $pool,
|
|
|
|
|
array $config, array $blocked): void
|
|
|
|
|
{
|
|
|
|
|
$network = CloudIpPrefix::network((string) $config['cidr']);
|
|
|
|
|
$start = CloudIpAddress::parse((string) $config['allocation_start']);
|
|
|
|
|
$end = CloudIpAddress::parse((string) $config['allocation_end']);
|
|
|
|
|
$now = time();
|
|
|
|
|
foreach (CloudPublicIp::where(
|
|
|
|
|
$rows = CloudPublicIp::where(
|
|
|
|
|
'public_ip_pool_id', (int) $pool->id
|
|
|
|
|
)->orderBy('id')->lockForUpdate()->get() as $row) {
|
|
|
|
|
)->orderBy('id')->lockForUpdate()->get();
|
|
|
|
|
$byAddress = [];
|
|
|
|
|
foreach ($rows as $row) {
|
|
|
|
|
$byAddress[(string) $row->address] = true;
|
|
|
|
|
}
|
|
|
|
|
foreach (array_keys($blocked) as $blockedText) {
|
|
|
|
|
try {
|
|
|
|
|
$blockedAddress = CloudIpAddress::parse($blockedText);
|
|
|
|
|
} catch (\Throwable) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if ($blockedAddress->family() !== 6
|
|
|
|
|
|| !$network->contains($blockedAddress)
|
|
|
|
|
|| isset($byAddress[$blockedAddress->text()])) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
$row = new CloudPublicIp();
|
|
|
|
|
$row->host_id = (int) $pool->host_id;
|
|
|
|
|
$row->public_ip_pool_id = (int) $pool->id;
|
|
|
|
|
$row->address_family = 6;
|
|
|
|
|
$row->address = $blockedAddress->text();
|
|
|
|
|
$row->address_binary = $blockedAddress->binary();
|
|
|
|
|
$row->prefix_length = (int) $config['guest_prefix_length'];
|
|
|
|
|
$row->state = 'disabled';
|
|
|
|
|
$row->created_at = $now;
|
|
|
|
|
$row->updated_at = $now;
|
|
|
|
|
$row->save();
|
|
|
|
|
$rows->push($row);
|
|
|
|
|
$byAddress[$blockedAddress->text()] = true;
|
|
|
|
|
}
|
|
|
|
|
foreach ($rows as $row) {
|
|
|
|
|
try {
|
|
|
|
|
$address = CloudIpAddress::parse((string) $row->address);
|
|
|
|
|
$inRange = $address->family() === 6
|
|
|
|
|
|