fix: define tenant IP changes as IPv4 only

go
codex 3 weeks ago
parent 82d633e102
commit 0837fd71c6

@ -1466,7 +1466,7 @@ final class CloudApiController
$actor = $this->actor($request);
$instance = CloudAccess::instance($args['id'], $actor);
if ((int) $instance->user_id !== (int) $actor['user_id']) {
throw new CloudError('只能为自己持有的实例更换 IP', 403);
throw new CloudError('只能为自己持有的实例更换公网 IPv4', 403);
}
$this->requireService($instance, $actor);
$options = CloudNetworkChangeOptionsService::tenantQuote($instance);
@ -1485,13 +1485,14 @@ final class CloudApiController
&& $enabled && $balanceSufficient;
$message = (string) ($options['message'] ?? '');
if (!$enabled) {
$message = '管理员尚未启用付费更换 IP。';
$message = '管理员尚未启用付费更换公网 IPv4。';
} elseif (!$balanceSufficient) {
$message = '账户余额不足,请先充值。';
}
return $this->json($response, [
'instance_id' => (string) $instance->id,
'address_family' => (int) ($options['address_family'] ?? 0),
'active_job' => $options['active_job'] ?? null,
'configuration_state' =>
(string) ($options['configuration_state'] ?? 'invalid'),
@ -1564,16 +1565,21 @@ final class CloudApiController
{
$actor = $this->actor($request);
if (!isset($actor['request_idempotency_key'])) {
throw new CloudError('付费更换 IP 必须提供请求幂等标识', 400);
throw new CloudError(
'付费更换公网 IPv4 必须提供请求幂等标识',
400
);
}
$instance = CloudAccess::instance($args['id'], $actor, true);
if ((int) $instance->user_id !== (int) $actor['user_id']) {
throw new CloudError('只能为自己持有的实例更换 IP', 403);
throw new CloudError('只能为自己持有的实例更换公网 IPv4', 403);
}
$body = CloudInput::object($request);
CloudInput::only($body, ['expected_amount', 'confirm_restart']);
if (($body['confirm_restart'] ?? false) !== true) {
throw new CloudError('更换公网 IP 前必须确认虚拟机会短暂重启');
throw new CloudError(
'更换公网 IPv4 前必须确认虚拟机会短暂重启'
);
}
try {
$expectedAmount = CloudIpChangeBillingService::normalizePrice(
@ -1591,7 +1597,7 @@ final class CloudApiController
$expectedAmount
);
} catch (\InvalidArgumentException) {
throw new CloudError('付费更换 IP 请求无效', 422);
throw new CloudError('付费更换公网 IPv4 请求无效', 422);
}
$dispatch = CloudPublicNetworkTransitionWorkflow::begin($command);
return $this->json($response, [

@ -7,7 +7,7 @@ final class CloudBillingPresentationCatalog
{
private const PURPOSES = [
'provision' => '实例开通', 'renewal' => '实例续费',
'upgrade' => '实例升级', 'ip_change' => '更换公网 IP',
'upgrade' => '实例升级', 'ip_change' => '更换公网 IPv4',
'backup_addon' => '自动备份开通', 'recharge' => '余额充值',
];
private const PROVIDERS = [

@ -482,7 +482,7 @@ final class CloudInvoicePresentation
if ($message === '') {
$message = $label !== '' ? $label : match ($purpose) {
'upgrade' => '等待升级',
'ip_change' => '等待更换公网 IP',
'ip_change' => '等待更换公网 IPv4',
default => '等待创建',
};
}
@ -491,12 +491,12 @@ final class CloudInvoicePresentation
'show_fulfillment' => $show,
'fulfillment_title' => match ($purpose) {
'upgrade' => '实例升级进度',
'ip_change' => '公网 IP 更换进度',
'ip_change' => '公网 IPv4 更换进度',
default => '实例创建进度',
},
'fulfillment_description' => match ($purpose) {
'upgrade' => '账单扣款后,系统会在后台升级实例;关闭页面不会取消任务。',
'ip_change' => '账单扣款后,系统会在后台更换公网 IP;关闭页面不会取消任务。',
'ip_change' => '账单扣款后,系统会在后台更换公网 IPv4;公网 IPv6 保持不变,关闭页面不会取消任务。',
default => '账单付款后,系统会在后台创建实例;关闭页面不会取消任务。',
},
'fulfillment_message' => $message,
@ -567,14 +567,15 @@ final class CloudInvoicePresentation
if ($purpose === 'ip_change') {
return match ($taskStatus) {
'succeeded', 'completed' => [
'message' => '公网 IP 已更换。', 'tone' => 'success',
'message' => '公网 IPv4 已更换;公网 IPv6 保持不变。',
'tone' => 'success',
],
'review' => [
'message' => '公网 IP 更换结果待人工核对,请勿重复提交。',
'message' => '公网 IPv4 更换结果待人工核对,请勿重复提交。',
'tone' => 'error',
],
'failed', 'cancelled', 'canceled' => [
'message' => '公网 IP 更换未完成,请在账单详情查看任务状态。',
'message' => '公网 IPv4 更换未完成,请在账单详情查看任务状态。',
'tone' => 'error',
],
default => null,
@ -701,7 +702,7 @@ final class CloudInvoicePresentation
$specification[] = [
'label' => '服务内容',
'value' => $purpose === 'ip_change'
? '更换公网 IP' : '自动备份开通',
? '更换公网 IPv4' : '自动备份开通',
];
}
return $specification;

@ -9,7 +9,7 @@ use App\Models\Configurations;
use App\Models\CloudPublicNetworkTransition;
use App\Models\User;
/** Balance pricing and exactly-once settlement for tenant IP changes. */
/** Balance pricing and exactly-once settlement for tenant IPv4 changes. */
final class CloudIpChangeBillingService
{
public const PRICE_CONFIG_KEY = 'cloud_ip_change_price';
@ -28,7 +28,7 @@ final class CloudIpChangeBillingService
);
} catch (\InvalidArgumentException $error) {
throw new CloudError(
'付费更换 IP 的后台价格配置无效,请联系管理员',
'付费更换公网 IPv4 的后台价格配置无效,请联系管理员',
503
);
}
@ -43,7 +43,7 @@ final class CloudIpChangeBillingService
{
if (is_array($value) || is_object($value)) {
throw new \InvalidArgumentException(
'更换 IP 价格必须是十进制金额'
'更换公网 IPv4 价格必须是十进制金额'
);
}
$raw = trim((string) $value);
@ -51,14 +51,14 @@ final class CloudIpChangeBillingService
$cents = CloudMoney::cents($raw);
} catch (CloudError $error) {
throw new \InvalidArgumentException(
'更换 IP 价格格式无效,仅支持最多两位小数',
'更换公网 IPv4 价格格式无效,仅支持最多两位小数',
0,
$error
);
}
if ($cents > 99999999) {
throw new \InvalidArgumentException(
'更换 IP 价格不能超过 999999.99'
'更换公网 IPv4 价格不能超过 999999.99'
);
}
return CloudMoney::decimal($cents);
@ -131,7 +131,7 @@ final class CloudIpChangeBillingService
|| (int) $job->instance_id !== (int) $instance->id
|| (int) $instance->user_id !== (int) $user->id
|| $priceCents < 1) {
throw new CloudError('付费更换 IP 的账单关联无效', 409);
throw new CloudError('付费更换公网 IPv4 的账单关联无效', 409);
}
$balance = CloudMoney::cents((string) $user->money);
if ($balance < $priceCents) {
@ -177,7 +177,7 @@ final class CloudIpChangeBillingService
): void {
if ($effectResolution !== 'not_applied') {
throw new CloudError(
'更换 IP 只有明确确认未生效时才允许退款',
'更换公网 IPv4 只有明确确认未生效时才允许退款',
409
);
}
@ -186,7 +186,7 @@ final class CloudIpChangeBillingService
}
if ($user === null || (int) $user->id !== (int) $job->user_id
|| (string) $job->kind !== 'network_change') {
throw new CloudError('更换 IP 退款账户关联无效', 409);
throw new CloudError('更换公网 IPv4 退款账户关联无效', 409);
}
$invoice = CloudInvoice::where('id', (int) $job->invoice_id)
->lockForUpdate()->first();
@ -199,7 +199,7 @@ final class CloudIpChangeBillingService
'network-change-' . (int) $job->id,
(string) $invoice->payment_reference
)) {
throw new CloudError('更换 IP 退款账单关联不一致', 409);
throw new CloudError('更换公网 IPv4 退款账单关联不一致', 409);
}
if ((string) $invoice->status === 'refunded') {
return;
@ -207,7 +207,7 @@ final class CloudIpChangeBillingService
if ((string) $invoice->status !== 'paid'
|| (string) $invoice->paid_via !== 'balance'
|| $invoice->paid_at === null) {
throw new CloudError('更换 IP 退款账单状态无效', 409);
throw new CloudError('更换公网 IPv4 退款账单状态无效', 409);
}
$amount = CloudMoney::cents((string) $invoice->amount);
$balance = CloudMoney::cents((string) $user->money);

@ -29,10 +29,11 @@ final class CloudNetworkChangeOptionsService
$state = $catalog['malformed']
? 'invalid'
: ($hasAutomaticIpv4 ? 'ready' : 'not_configured');
$availability = self::availability($instance, $state);
$availability = self::availability($instance, $state, true);
return [
'instance_id' => (string) $instance->id,
'address_family' => 4,
'configuration_state' => $state,
'active_job' => $availability['active_job'],
'can_change' => $availability['can_change'],
@ -379,17 +380,19 @@ final class CloudNetworkChangeOptionsService
}
private static function availability(CloudInstance $instance,
string $configurationState): array
string $configurationState, bool $tenant = false): array
{
$decision = CloudPublicNetworkMutationAdmission::inspect($instance);
$canChange = $decision->allowed()
&& $configurationState === 'ready';
$message = match (true) {
$configurationState === 'invalid' =>
'面板公网地址池配置异常,请先修复双栈地址账本。',
$configurationState === 'invalid' => $tenant
? '面板公网 IPv4 地址池配置异常,请联系管理员。'
: '面板公网地址池配置异常,请先修复双栈地址账本。',
!$decision->allowed() => $decision->message,
$configurationState !== 'ready' =>
'当前公网地址池没有可用目标地址。',
$configurationState !== 'ready' => $tenant
? '当前公网 IPv4 地址池没有可用目标地址。'
: '当前公网地址池没有可用目标地址。',
default => '',
};
return [

@ -396,7 +396,7 @@ final class CloudPublicNetworkTransitionWorkflow
&& $command->priceCents() !==
CloudIpChangeBillingService::priceCents()) {
throw new CloudError(
'付费更换 IP 的价格已发生变化,请刷新后重试',
'付费更换公网 IPv4 的价格已发生变化,请刷新后重试',
409
);
}

@ -406,7 +406,7 @@ function bindDetailTabs(vmId) {
const INSTANCE_SETTING_LABELS = Object.freeze({
hostname: '主机名', password: 'root 密码', ssh_key: 'SSH 公钥',
ip_change: '公网 IP', upgrade: '实例升级', automatic_backup: '自动备份', firewall: '防火墙',
ip_change: '公网 IPv4', upgrade: '实例升级', automatic_backup: '自动备份', firewall: '防火墙',
snapshots: '在线快照', rescue: '紧急救援',
});
const INSTANCE_SETTING_TABS = Object.freeze([
@ -1925,8 +1925,8 @@ async function loadIpChangeQuote(vmId, force = false) {
try {
const payload = await api(`/api/v1/vms/${encodeURIComponent(vmId)}/network-options`);
if (!payload || typeof payload !== 'object' || Array.isArray(payload)
|| typeof payload.price !== 'string') {
throw new Error('更换 IP 配置响应无效。');
|| payload.address_family !== 4 || typeof payload.price !== 'string') {
throw new Error('更换公网 IPv4 配置响应无效。');
}
ipChangePayload = payload;
ipChangeLoadedVmId = String(vmId);
@ -1937,14 +1937,14 @@ async function loadIpChangeQuote(vmId, force = false) {
} else {
ipChangeStatus(message || (payload.active_job
? '实例已有任务正在执行,请等待完成后刷新。'
: '当前暂不能更换公网 IP。'), 'warning');
: '当前暂不能更换公网 IPv4。'), 'warning');
}
return payload;
} catch (error) {
ipChangePayload = null;
ipChangeLoadedVmId = null;
renderIpChangeQuote({ price: '0.00' });
ipChangeStatus(error.message || '更换 IP 配置加载失败,请稍后重试。', 'error');
ipChangeStatus(error.message || '更换公网 IPv4 配置加载失败,请稍后重试。', 'error');
throw error;
} finally {
ipChangeRequest = null;
@ -1972,22 +1972,22 @@ function clearPendingIpChangeKey(vmId) {
}
function pollIpChangeJob(vmId, receipt) {
return watchTask(receipt, '更换公网 IP', {
onUpdate: () => ipChangeStatus('更换公网 IP 任务正在后台执行;费用已扣除,请勿重复提交。'),
return watchTask(receipt, '更换公网 IPv4', {
onUpdate: () => ipChangeStatus('更换公网 IPv4 任务正在后台执行;费用已扣除,请勿重复提交。'),
onTerminal: task => {
void (async () => {
await refreshMetadataAndStatus(vmId, false, true, true);
await loadIpChangeQuote(vmId, true).catch(() => null);
if (taskSucceededWithoutRecovery(task)) {
ipChangeStatus('公网 IP 已更换,实例详情已刷新。', 'success');
toast('公网 IP 更换完成。', 'success');
ipChangeStatus('公网 IPv4 已更换,公网 IPv6 保持不变;实例详情已刷新。', 'success');
toast('公网 IPv4 更换完成。', 'success');
return;
}
const base = taskFailureMessage(task, '更换公网 IP 任务失败。');
const base = taskFailureMessage(task, '更换公网 IPv4 任务失败。');
if (task.effect_resolution === 'not_applied') {
ipChangeStatus(`${base} 系统已确认未生效,本次费用已自动退回余额。`, 'error');
} else if (task.effect_resolution === 'applied') {
ipChangeStatus(`${base} 系统已确认新 IP 实际生效,本次费用不会退回。`, 'warning');
ipChangeStatus(`${base} 系统已确认新公网 IPv4 实际生效,本次费用不会退回。`, 'warning');
} else {
ipChangeStatus(`${base} 操作结果仍在核对,本次费用暂不退回,请勿再次提交。`, 'warning');
}
@ -2021,8 +2021,8 @@ function bindIpChange(vmId) {
return;
}
const confirmed = await requestUserConfirmation({
title: '确认付费更换公网 IP',
message: `系统将自动分配一个可用公网 IP,并从余额扣除 ${ipChangeMoney(expectedAmount, ipChangePayload.currency)}。实例可能短暂重启。`,
title: '确认付费更换公网 IPv4',
message: `系统将自动分配一个可用公网 IPv4,并从余额扣除 ${ipChangeMoney(expectedAmount, ipChangePayload.currency)}。公网 IPv6 保持不变,实例可能短暂重启。`,
confirmText: '确认扣费并更换',
tone: 'danger',
});
@ -2052,13 +2052,13 @@ function bindIpChange(vmId) {
};
renderIpChangeQuote(ipChangePayload);
ipChangeStatus(`任务已接收,已扣除 ${ipChangeMoney(expectedAmount, ipChangePayload.currency)};正在等待宿主机确认结果。`);
toast('付费更换 IP 任务已接收。', 'success');
toast('付费更换公网 IPv4 任务已接收。', 'success');
if (!pollIpChangeJob(vmId, receipt)) {
ipChangeStatus('任务已接收,但自动观察协议无效。请勿重复提交,并在任务中心核查结果。', 'error');
}
} catch (error) {
const uncertain = firewallTransportUncertain(error);
const message = error.message || '更换 IP 提交失败,请稍后重试。';
const message = error.message || '更换公网 IPv4 提交失败,请稍后重试。';
if (uncertain) {
ipChangeError(message);
ipChangeStatus('请求结果暂时无法确认;页面已保留同一请求标识。请勿发起其他更换,重新点击提交只会核对原请求。', 'warning');
@ -2066,7 +2066,7 @@ function bindIpChange(vmId) {
clearPendingIpChangeKey(vmId);
await loadIpChangeQuote(vmId, true).catch(() => null);
ipChangeError(message);
ipChangeStatus('更换 IP 未提交,请按提示修正后重试。', 'error');
ipChangeStatus('更换公网 IPv4 未提交,请按提示修正后重试。', 'error');
}
} finally {
ipChangeSubmitting = false;

@ -54,7 +54,7 @@
<button id="vm-settings-nav-hostname" class="vm-settings-navigation-button active" type="button" role="tab" aria-selected="true" aria-controls="vm-settings-section-hostname" data-instance-setting-tab="hostname">修改主机名</button>
<button id="vm-settings-nav-password" class="vm-settings-navigation-button" type="button" role="tab" aria-selected="false" aria-controls="vm-settings-section-password" data-instance-setting-tab="password" tabindex="-1">重置密码</button>
<button id="vm-settings-nav-ssh-key" class="vm-settings-navigation-button" type="button" role="tab" aria-selected="false" aria-controls="vm-settings-section-ssh-key" data-instance-setting-tab="ssh_key" tabindex="-1">更新 SSH 公钥</button>
<button id="vm-settings-nav-ip-change" class="vm-settings-navigation-button" type="button" role="tab" aria-selected="false" aria-controls="vm-settings-section-ip-change" data-instance-setting-tab="ip_change" tabindex="-1">付费更换 IP</button>
<button id="vm-settings-nav-ip-change" class="vm-settings-navigation-button" type="button" role="tab" aria-selected="false" aria-controls="vm-settings-section-ip-change" data-instance-setting-tab="ip_change" tabindex="-1">付费更换公网 IPv4</button>
<button id="vm-settings-nav-upgrade" class="vm-settings-navigation-button" type="button" role="tab" aria-selected="false" aria-controls="vm-settings-section-upgrade" data-instance-setting-tab="upgrade" tabindex="-1">实例升级</button>
<button id="vm-settings-nav-automatic-backup" class="vm-settings-navigation-button" type="button" role="tab" aria-selected="false" aria-controls="vm-settings-section-automatic-backup" data-instance-setting-tab="automatic_backup" tabindex="-1">自动备份</button>
<button id="vm-settings-nav-firewall" class="vm-settings-navigation-button" type="button" role="tab" aria-selected="false" aria-controls="vm-settings-section-firewall" data-instance-setting-tab="firewall" tabindex="-1">防火墙</button>
@ -95,14 +95,14 @@
</form>
</section>
<section id="vm-settings-section-ip-change" class="vm-settings-section" role="tabpanel" aria-labelledby="vm-settings-nav-ip-change" data-instance-setting-panel="ip_change" hidden>
<header class="vm-settings-section-heading"><span class="eyebrow">PUBLIC IPV4</span><h3>付费更换公网 IP</h3><p>系统会从当前宿主机同一网络线路的可用地址池中自动分配新地址,费用从账户余额扣除。</p></header>
<div class="vm-settings-notice warning"><strong>扣费与重启提示</strong><span>提交后会立即冻结系统分配的 IP 并扣除页面显示的金额,运行中的实例会短暂重启。只有系统明确确认变更未生效时才会自动退回余额;结果暂不确定时不会重复执行或提前退款。</span></div>
<p id="vm-ip-change-status" class="vm-settings-status" role="status" aria-live="polite">打开“付费更换 IP”后加载更换费用。</p>
<dl class="vm-ip-change-facts" aria-label="更换 IP 计费信息">
<header class="vm-settings-section-heading"><span class="eyebrow">PUBLIC IPV4</span><h3>付费更换公网 IPv4</h3><p>系统会从当前宿主机同一网络线路的可用 IPv4 地址池中自动分配新地址,公网 IPv6 保持不变,费用从账户余额扣除。</p></header>
<div class="vm-settings-notice warning"><strong>扣费与重启提示</strong><span>提交后会立即冻结系统分配的公网 IPv4 并扣除页面显示的金额,运行中的实例会短暂重启;公网 IPv6 保持不变。只有系统明确确认变更未生效时才会自动退回余额;结果暂不确定时不会重复执行或提前退款。</span></div>
<p id="vm-ip-change-status" class="vm-settings-status" role="status" aria-live="polite">打开“付费更换公网 IPv4”后加载更换费用。</p>
<dl class="vm-ip-change-facts" aria-label="更换公网 IPv4 计费信息">
<div><dt>本次费用</dt><dd id="vm-ip-change-price">—</dd></div>
</dl>
<form id="vm-ip-change-form" class="vm-settings-form" novalidate>
<label class="checkbox-row vm-settings-restart-confirm"><input type="checkbox" name="confirm_purchase" value="1" required disabled/><span><strong>确认扣费并更换 IP</strong><small>我确认按页面显示价格从余额扣款,并知道实例会短暂重启。</small></span></label>
<label class="checkbox-row vm-settings-restart-confirm"><input type="checkbox" name="confirm_purchase" value="1" required disabled/><span><strong>确认扣费并更换公网 IPv4</strong><small>我确认按页面显示价格从余额扣款,公网 IPv6 保持不变,并知道实例会短暂重启。</small></span></label>
<div class="vm-settings-actions"><button id="vm-ip-change-submit" class="button button-primary" type="submit" disabled>确认付费更换</button></div>
<p id="vm-ip-change-error" class="form-error" role="alert" hidden></p>
</form>

@ -16,7 +16,7 @@
<option value="renewal"{if $cloud_invoice_filter == 'renewal'} selected{/if}>续费账单</option>
<option value="provision"{if $cloud_invoice_filter == 'provision'} selected{/if}>开通账单</option>
<option value="upgrade"{if $cloud_invoice_filter == 'upgrade'} selected{/if}>升级账单</option>
<option value="ip_change"{if $cloud_invoice_filter == 'ip_change'} selected{/if}>更换 IP</option>
<option value="ip_change"{if $cloud_invoice_filter == 'ip_change'} selected{/if}>更换公网 IPv4</option>
<option value="backup_addon"{if $cloud_invoice_filter == 'backup_addon'} selected{/if}>自动备份开通</option>
</select>
</label>

@ -17,6 +17,8 @@ date_default_timezone_set('Asia/Shanghai');
try {
$assert(CloudBillingPresentationCatalog::purposeLabel('backup_addon')
=== '自动备份开通'
&& CloudBillingPresentationCatalog::purposeLabel('ip_change')
=== '更换公网 IPv4'
&& CloudBillingPresentationCatalog::providerLabel('paytaro')
=== 'Paytaro · 支付宝'
&& CloudBillingPresentationCatalog::money('12.5', 'USD') === '$12.50'

@ -109,7 +109,7 @@ $assert($switchable['show_payment'] === true
$ipChange = [
'id' => '81',
'purpose' => 'ip_change',
'title' => '更换公网 IP',
'title' => '更换公网 IPv4',
'currency' => 'USD',
'created_at' => 2_000_000_000,
'amount' => '5.00',
@ -127,7 +127,8 @@ $ipChange = [
$ipView = CloudInvoicePresentation::detail(['invoice' => $ipChange]);
$ipRow = CloudInvoicePresentation::summaries([$ipChange])[0];
$assert($ipView['show_fulfillment'] === true
&& $ipView['fulfillment_title'] === '公网 IP 更换进度'
&& $ipView['title'] === '更换公网 IPv4'
&& $ipView['fulfillment_title'] === '公网 IPv4 更换进度'
&& $ipView['fulfillment_label'] === '待人工核对'
&& $ipView['fulfillment_class'] === 'warning'
&& $ipView['instance_id'] === '41'
@ -135,7 +136,7 @@ $assert($ipView['show_fulfillment'] === true
&& $ipRow['fulfillment_label'] === '待人工核对'
&& $ipRow['context_display'] === '目标实例 vm-audit'
&& ($ipView['completion_notice']['message'] ?? null)
=== '公网 IP 更换结果待人工核对,请勿重复提交。',
=== '公网 IPv4 更换结果待人工核对,请勿重复提交。',
'IP-change presentation lost its target or review-only fulfillment state.');
$unknown = CloudInvoicePresentation::summaries([[

@ -98,7 +98,7 @@ $ipChangePayload = [
'invoice' => [
'id' => '81',
'purpose' => 'ip_change',
'title' => '更换公网 IP',
'title' => '更换公网 IPv4',
'created_at' => 2_000_000_000,
'amount' => '5.00',
'status' => 'paid',
@ -120,7 +120,8 @@ $ipChangeRow = CloudInvoicePresentation::summaries([
$ipChangePayload['invoice'],
])[0];
$assert(($ipChangeView['show_fulfillment'] ?? false) === true
&& ($ipChangeView['fulfillment_title'] ?? null) === '公网 IP 更换进度'
&& ($ipChangeView['title'] ?? null) === '更换公网 IPv4'
&& ($ipChangeView['fulfillment_title'] ?? null) === '公网 IPv4 更换进度'
&& ($ipChangeView['fulfillment_label'] ?? null) === '待人工核对'
&& ($ipChangeView['fulfillment_class'] ?? null) === 'warning'
&& ($ipChangeView['instance_id'] ?? null) === '41'

@ -320,9 +320,10 @@ namespace {
$instance = CloudInstance::findOrFail(30);
$tenant = CloudNetworkChangeOptionsService::tenantQuote($instance);
$assert(($tenant['can_change'] ?? null) === true
$assert(($tenant['address_family'] ?? null) === 4
&& ($tenant['can_change'] ?? null) === true
&& ($tenant['configuration_state'] ?? null) === 'ready',
'Current-attachment automatic IPv4 availability was not projected.');
'Tenant quote lost its IPv4-only contract or current availability.');
foreach ([
'host_id', 'host_name', 'region', 'current_public_network',
'current_attachment_id', 'attachments', 'available_ip_options',

@ -60,6 +60,8 @@ $assert($optionsMethod !== ''
'(int) $instance->user_id !== (int) $actor[\'user_id\']')
&& str_contains($optionsMethod,
'CloudNetworkChangeOptionsService::tenantQuote($instance)')
&& str_contains($optionsMethod,
"'address_family' => (int) (\$options['address_family'] ?? 0)")
&& str_contains($optionsMethod, 'CloudIpChangeBillingService::price()')
&& !str_contains($optionsMethod, "'available_ip_options'")
&& !str_contains($optionsMethod, "'available_count'")
@ -92,6 +94,7 @@ $assert($networkMethod !== ''
'Paid IP submission lost its quote check, idempotency, or strict task receipt.');
$assert(str_contains($options, "->where('state', 'available')")
&& str_contains($options, "'address_family' => 4")
&& str_contains($options, "->whereNull('reservation_id')")
&& str_contains($options, "->whereNull('instance_id')")
&& str_contains($options, "->whereNull('operation_id')")
@ -186,7 +189,8 @@ $ipChangeUi = $ipChangeUiStart !== false && $ipChangeUiEnd !== false
$assert(str_contains($detailView, 'data-instance-setting-tab="ip_change"')
&& str_contains($detailView, 'id="vm-ip-change-form"')
&& str_contains($detailView, 'id="vm-ip-change-price"')
&& str_contains($detailView, '系统会从当前宿主机同一网络线路的可用地址池中自动分配新地址')
&& str_contains($detailView, '系统会从当前宿主机同一网络线路的可用 IPv4 地址池中自动分配新地址')
&& str_contains($detailView, '公网 IPv6 保持不变')
&& str_contains($detailView, '只有系统明确确认变更未生效时才会自动退回余额')
&& !str_contains($detailView, 'id="vm-ip-change-target"')
&& !str_contains($detailView, 'id="vm-ip-change-current"')
@ -196,7 +200,9 @@ $assert(str_contains($detailView, 'data-instance-setting-tab="ip_change"')
&& str_contains($ipChangeUi, 'expected_amount: expectedAmount')
&& str_contains($ipChangeUi, 'sessionStorage.setItem')
&& str_contains($ipChangeUi, 'automatic|${expectedAmount}')
&& str_contains($ipChangeUi, '系统将自动分配一个可用公网 IP')
&& str_contains($ipChangeUi, 'payload.address_family !== 4')
&& str_contains($ipChangeUi, '系统将自动分配一个可用公网 IPv4')
&& str_contains($ipChangeUi, '公网 IPv6 保持不变')
&& str_contains($ipChangeUi, '页面已保留同一请求标识')
&& !str_contains($ipChangeUi, 'available_ip_options')
&& !str_contains($ipChangeUi, 'available_count')
@ -207,12 +213,12 @@ $assert(str_contains($detailView, 'data-instance-setting-tab="ip_change"')
&& str_contains($ipChangeUi, "task.effect_resolution === 'applied'"),
'Tenant settings UI exposed targets or lost pricing, durable retry, or outcome guidance.');
$assert(str_contains($billingCatalog, "'ip_change' => '更换公网 IP'")
$assert(str_contains($billingCatalog, "'ip_change' => '更换公网 IPv4'")
&& substr_count($invoiceService,
'CloudBillingPresentationCatalog::knownPurposeLabel($purpose)') >= 2
&& str_contains($adminBilling,
"'provision', 'renewal', 'upgrade', 'ip_change'")
&& str_contains($documentation, '## 用户付费更换 IP')
&& str_contains($documentation, '## 用户付费更换公网 IPv4')
&& str_contains($documentation, '用户页面只显示单次更换费用')
&& str_contains($documentation, '也不接受用户指定目标地址')
&& str_contains($documentation, '钱包 → 实例 → 网络账本'),

Loading…
Cancel
Save