|
|
|
|
@ -13,6 +13,7 @@ final class CloudActivePublicNetworkClaimSet
|
|
|
|
|
{
|
|
|
|
|
private function __construct(
|
|
|
|
|
private readonly int $reservationId,
|
|
|
|
|
private readonly int $hostId,
|
|
|
|
|
private readonly array $claims,
|
|
|
|
|
private readonly CloudPublicNetworkSnapshot $publicNetwork,
|
|
|
|
|
private readonly string $digest
|
|
|
|
|
@ -27,10 +28,11 @@ final class CloudActivePublicNetworkClaimSet
|
|
|
|
|
* @param array<int, object> $claims
|
|
|
|
|
* @param array<int, object> $addresses keyed by public IP id
|
|
|
|
|
*/
|
|
|
|
|
public static function fromLedger(int $reservationId, array $claims,
|
|
|
|
|
array $addresses, CloudPublicNetworkSnapshot $publicNetwork): self
|
|
|
|
|
public static function fromLedger(int $reservationId, int $hostId,
|
|
|
|
|
array $claims, array $addresses,
|
|
|
|
|
CloudPublicNetworkSnapshot $publicNetwork): self
|
|
|
|
|
{
|
|
|
|
|
if ($reservationId < 1 || count($claims) !== 2) {
|
|
|
|
|
if ($reservationId < 1 || $hostId < 1 || count($claims) !== 2) {
|
|
|
|
|
throw new CloudError('活动双栈公网地址账本不完整', 409);
|
|
|
|
|
}
|
|
|
|
|
$canonical = [];
|
|
|
|
|
@ -60,6 +62,7 @@ final class CloudActivePublicNetworkClaimSet
|
|
|
|
|
|| preg_match('/^[a-f0-9]{32}$/D', $operationId) !== 1
|
|
|
|
|
|| !is_object($ip)
|
|
|
|
|
|| (int) ($ip->id ?? 0) !== $publicIpId
|
|
|
|
|
|| (int) ($ip->host_id ?? 0) !== $hostId
|
|
|
|
|
|| (int) ($ip->address_family ?? 0) !== $family
|
|
|
|
|
|| (int) ($ip->reservation_id ?? 0) !== $reservationId
|
|
|
|
|
|| (int) ($ip->reservation_ip_claim_id ?? 0) !== $claimId
|
|
|
|
|
@ -101,7 +104,13 @@ final class CloudActivePublicNetworkClaimSet
|
|
|
|
|
$addresses,
|
|
|
|
|
$publicNetwork
|
|
|
|
|
)->digest();
|
|
|
|
|
return new self($reservationId, $canonical, $publicNetwork, $digest);
|
|
|
|
|
return new self(
|
|
|
|
|
$reservationId,
|
|
|
|
|
$hostId,
|
|
|
|
|
$canonical,
|
|
|
|
|
$publicNetwork,
|
|
|
|
|
$digest
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function reservationId(): int
|
|
|
|
|
@ -109,6 +118,11 @@ final class CloudActivePublicNetworkClaimSet
|
|
|
|
|
return $this->reservationId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function hostId(): int
|
|
|
|
|
{
|
|
|
|
|
return $this->hostId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function claimId(int $family): int
|
|
|
|
|
{
|
|
|
|
|
if (!isset($this->claims[$family])) {
|
|
|
|
|
|