feat: split rate limits with configurable per-endpoint controls

This commit is contained in:
MengMengCode
2026-06-12 15:53:31 +08:00
parent 01c14ecba6
commit c7742319b2
17 changed files with 746 additions and 141 deletions
+8 -1
View File
@@ -90,7 +90,7 @@ export default function ContainerCard({ container, onRefresh }: ContainerCardPro
</div>
<div className="flex items-center gap-2 text-sm text-gray-600">
<Globe className="w-3.5 h-3.5" />
<span>{container.network_bw_mbps} Mbps</span>
<span>{formatNetworkLimit(container)}</span>
</div>
</div>
@@ -140,3 +140,10 @@ export default function ContainerCard({ container, onRefresh }: ContainerCardPro
</div>
)
}
function formatNetworkLimit(container: { network_bw_mbps?: number; network_down_mbps?: number; network_up_mbps?: number }) {
const down = Math.max(0, Number(container.network_down_mbps || container.network_bw_mbps || 0))
const up = Math.max(0, Number(container.network_up_mbps || container.network_bw_mbps || 0))
if (down === 0 && up === 0) return '不限速'
return `${down || '不限'} / 上 ${up || '不限'} Mbps`
}
@@ -21,11 +21,15 @@ const defaultForm: CreateContainerRequest = {
ram_mb: 512,
disk_gb: 10,
network_bw_mbps: 0,
network_down_mbps: 0,
network_up_mbps: 0,
monthly_traffic_gb: 0,
traffic_mode: 'total',
traffic_in_gb: 0,
traffic_out_gb: 0,
io_speed_mbps: 0,
io_read_mbps: 0,
io_write_mbps: 0,
extra_ports: [],
port_mapping_count: 2,
assign_nat: true,
@@ -498,7 +502,7 @@ export default function CreateContainerModal({ isOpen, onClose, onSuccess, exist
</Field>
</div>
<div className="grid grid-cols-3 gap-3">
<div className="grid grid-cols-1 gap-3 md:grid-cols-3">
<Field label="磁盘 (GB)">
<NumberInput
value={form.disk_gb}
@@ -509,12 +513,20 @@ export default function CreateContainerModal({ isOpen, onClose, onSuccess, exist
/>
{resourceErrors.disk_gb && <p className="mt-1 text-xs text-red-500">{resourceErrors.disk_gb}</p>}
</Field>
<Field label="带宽 (Mbps)">
<NumberInput value={form.network_bw_mbps} min={0} onChange={(value) => setForm({ ...form, network_bw_mbps: value })} />
</Field>
<Field label="IO 速度 (MB/s)">
<NumberInput value={form.io_speed_mbps} min={0} onChange={(value) => setForm({ ...form, io_speed_mbps: value })} />
</Field>
<div className="grid grid-cols-2 gap-3 md:col-span-2">
<Field label="下行带宽 (Mbps)">
<NumberInput value={form.network_down_mbps} min={0} onChange={(value) => setForm({ ...form, network_down_mbps: value, network_bw_mbps: symmetricLimit(value, form.network_up_mbps) })} />
</Field>
<Field label="上行带宽 (Mbps)">
<NumberInput value={form.network_up_mbps} min={0} onChange={(value) => setForm({ ...form, network_up_mbps: value, network_bw_mbps: symmetricLimit(form.network_down_mbps, value) })} />
</Field>
<Field label="读取 IO (MB/s)">
<NumberInput value={form.io_read_mbps} min={0} onChange={(value) => setForm({ ...form, io_read_mbps: value, io_speed_mbps: symmetricLimit(value, form.io_write_mbps) })} />
</Field>
<Field label="写入 IO (MB/s)">
<NumberInput value={form.io_write_mbps} min={0} onChange={(value) => setForm({ ...form, io_write_mbps: value, io_speed_mbps: symmetricLimit(form.io_read_mbps, value) })} />
</Field>
</div>
</div>
<div className="grid grid-cols-1 gap-4 md:grid-cols-2">
@@ -779,5 +791,14 @@ function formatNATPortCount(count: number, language: Language) {
: `将分配 ${count} 个 NAT 端口`
}
function symmetricLimit(a: number, b: number) {
const left = Math.max(0, Number(a) || 0)
const right = Math.max(0, Number(b) || 0)
if (left === right) return left
if (left === 0) return right
if (right === 0) return left
return Math.min(left, right)
}
const inputClass =
'w-full px-3 py-2 border border-gray-300 rounded-md text-sm text-black bg-white focus:outline-none focus:ring-2 focus:ring-black focus:border-black'
+30 -16
View File
@@ -14,6 +14,7 @@ import {
X,
} from 'lucide-react'
import api, { APIResponse, Container } from '../services/api'
import { useLanguage } from '../contexts/LanguageContext'
import { copyToClipboard } from '../utils/clipboard'
interface ApiKeyItem {
@@ -238,6 +239,7 @@ const emptyForm = (): ApiKeyForm => ({
})
export default function ApiIntegration() {
const { t } = useLanguage()
const [keys, setKeys] = useState<ApiKeyItem[]>([])
const [containers, setContainers] = useState<Container[]>([])
const [loading, setLoading] = useState(true)
@@ -329,7 +331,7 @@ export default function ApiIntegration() {
}
const deleteKey = async (id: string) => {
if (!window.confirm('确定删除这个 API Key 吗?')) return
if (!window.confirm(t('确定删除这个 API Key 吗?'))) return
try {
await api.delete(`/api-keys/${id}`)
setKeys(prev => prev.filter(k => k.id !== id))
@@ -730,11 +732,15 @@ const requestBodySamples: Record<string, Record<string, unknown>> = {
ram_mb: 512,
disk_gb: 10,
network_bw_mbps: 0,
network_down_mbps: 100,
network_up_mbps: 20,
monthly_traffic_gb: 0,
traffic_mode: 'total',
traffic_in_gb: 0,
traffic_out_gb: 0,
io_speed_mbps: 0,
io_read_mbps: 80,
io_write_mbps: 30,
extra_ports: [8080],
port_mapping_count: 2,
assign_nat: true,
@@ -765,8 +771,12 @@ const requestBodySamples: Record<string, Record<string, unknown>> = {
'PUT /api/v1/containers/{id}/resource-limit': {
vcpu: 1,
ram_mb: 512,
io_speed_mbps: 0,
network_bw_mbps: 0,
network_down_mbps: 100,
network_up_mbps: 20,
io_read_mbps: 80,
io_write_mbps: 30,
network_bw_mbps: 20,
io_speed_mbps: 30,
},
'PUT /api/v1/containers/{id}/expiry': { expires_at: '2026-12-31 23:59:59' },
'POST /api/v1/containers/{id}/reset-password': { password: 'NewPass123456' },
@@ -1098,11 +1108,11 @@ const responseSamples: Record<string, unknown> = {
'GET /api/v1/security/settings': { success: true, data: { auto_shutdown: false } },
'PUT /api/v1/security/settings': { success: true, data: { auto_shutdown: false } },
'GET /api/v1/swap': { success: true, data: { total_mb: 16383, used_mb: 0, free_mb: 16383, enabled: true, swap_file: '/swapfile' } },
'POST /api/v1/swap': { success: true, message: 'SWAP 已调整为 16384 MB', data: { total_mb: 16383, used_mb: 0, free_mb: 16383, enabled: true, swap_file: '/swapfile' } },
'POST /api/v1/swap': { success: true, message: 'SWAP adjusted to 16384 MB', data: { total_mb: 16383, used_mb: 0, free_mb: 16383, enabled: true, swap_file: '/swapfile' } },
'POST /api/v1/batch-create': { success: true, data: ['task-12'] },
'POST /api/v1/batch-action': { success: true, data: ['task-13'] },
'POST /api/v1/ssh-ticket': { success: true, data: { ticket: '***60秒有效票据***' } },
'POST /api/v1/vnc-ticket': { success: true, data: { ticket: '***60秒有效票据***' } },
'POST /api/v1/ssh-ticket': { success: true, data: { ticket: '***60-second valid ticket***' } },
'POST /api/v1/vnc-ticket': { success: true, data: { ticket: '***60-second valid ticket***' } },
'POST /api/v1/sub-user/create': {
success: true,
message: 'Sub-user created',
@@ -1167,29 +1177,33 @@ function examplePathFor(path: string) {
function endpointNoteFor(key: string) {
const notes: string[] = []
if (key === 'POST /api/v1/containers') {
notes.push('Linux 创建支持 ssh_auth_mode=auto_password|password|key;公网 IPv4IPv6 与 NAT 可通过 assign_natassign_ipv4assign_ipv6 组合使用。')
notes.push('Linux container creation supports ssh_auth_mode=auto_password|password|key. Public IPv4, IPv6, and NAT can be configured with assign_nat, assign_ipv4, and assign_ipv6.')
notes.push('Supports independent upload/download bandwidth limits and read/write I/O limits. network_bw_mbps and io_speed_mbps are deprecated symmetric compatibility aliases. New integrations should use network_down_mbps, network_up_mbps, io_read_mbps, and io_write_mbps.')
}
if (key === 'POST /api/v1/containers/{id}/reinstall') {
notes.push('重装支持 ssh_auth_mode=keep|auto_password|password|keykeep 仅用于重装,未传 SSH 字段时保持原有行为。')
notes.push('Reinstall supports ssh_auth_mode=keep|auto_password|password|key. keep is only for reinstall requests; if SSH fields are omitted, the existing behavior is kept.')
}
if (key === 'POST /api/v1/batch-create') {
notes.push('批量创建的单个 containers[] 项支持与 POST /api/v1/containers 相同的网络和 SSH 认证字段。')
notes.push('Each containers[] item in batch creation supports the same network and SSH authentication fields as POST /api/v1/containers.')
}
if (key === 'PUT /api/v1/containers/{id}/resource-limit') {
notes.push('Supports independent download/upload bandwidth limits and read/write I/O limits. Omitted fields keep their current values, and explicitly passing 0 makes that direction unlimited. network_bw_mbps and io_speed_mbps are deprecated symmetric compatibility aliases.')
}
if (key === 'PUT /api/v1/containers/{id}/firewall') {
notes.push('兼容旧请求:default_action 可不传,不传时保留现有策略;rule.network 可不传,不传按 ipv4 处理。default_action: DROP=未命中规则时拒绝, ACCEPT=未命中规则时放行。network: ipv4=IPv4 NAT/公网 IPv4, ipv6=IPv6, all=同时应用到 IPv4 IPv6。NAT 入站规则的 port 填容器内端口,不是宿主机公网端口。')
notes.push('Backward compatible: default_action is optional; if omitted, the existing policy is kept. rule.network is optional; if omitted, it is treated as ipv4. default_action: DROP=deny unmatched traffic, ACCEPT=allow unmatched traffic. network: ipv4=IPv4 NAT/public IPv4, ipv6=IPv6, all=apply to both IPv4 and IPv6. For NAT inbound rules, port is the container internal port, not the host public port.')
}
if (key === 'POST /api/v1/batch-action') {
notes.push('action=reinstall 时可追加 template_idssh_auth_modessh_passwordssh_public_key;其他 action 会忽略这些重装字段。')
notes.push('When action=reinstall, you can include template_id, ssh_auth_mode, ssh_password, and ssh_public_key. Other actions ignore these reinstall fields.')
}
if (key === 'PUT /api/v1/routing') {
notes.push('更新公网地址池需要 routing:write;已分配给容器的地址不能从池中移除。')
notes.push('Updating public address pools requires routing:write. Addresses already assigned to containers cannot be removed from the pool.')
}
if (key === 'POST /api/v1/routing/ipv4-scan') {
notes.push('扫描公网 IPv4 段需要 routing:writeverify=true 时会尝试校验地址可用性。')
notes.push('Scanning public IPv4 prefixes requires routing:write. When verify=true, the API also attempts to check address availability.')
}
if (key.includes('/vnc-ticket')) notes.push('WebVNC 仅适用于 KVM 虚拟机;LXC 容器会返回 VNC console is only available for KVM VMs')
if (key.includes('/containers/{id}/delete') || key.includes('/batch-action')) notes.push('该接口会进入任务队列,请随后调用 GET /api/v1/tasks 查看执行状态。')
if (key.includes('/reset-password') || key.includes('/api-keys') || key.includes('/sub-user')) notes.push('样例中的密钥、密码和票据已脱敏;创建类接口的完整密钥只在创建响应中出现一次。')
if (key.includes('/vnc-ticket')) notes.push('WebVNC only applies to KVM VMs; LXC containers return "VNC console is only available for KVM VMs".')
if (key.includes('/containers/{id}/delete') || key.includes('/batch-action')) notes.push('This API enters the task queue. Call GET /api/v1/tasks afterward to check execution status.')
if (key.includes('/reset-password') || key.includes('/api-keys') || key.includes('/sub-user')) notes.push('Keys, passwords, and tickets in examples are masked. Full secrets from create APIs appear only once in the creation response.')
return notes.join(' ')
}
+71 -16
View File
@@ -149,7 +149,7 @@ export default function ContainerDetail() {
const [trafficEdit, setTrafficEdit] = useState({ mode: 'total', monthly: 0, inGB: 0, outGB: 0 })
const [savingTraffic, setSavingTraffic] = useState(false)
const [showResourceEdit, setShowResourceEdit] = useState(false)
const [resourceEdit, setResourceEdit] = useState({ vcpu: 1, ramMb: 512, ioMbps: 500, bwMbps: 100 })
const [resourceEdit, setResourceEdit] = useState({ vcpu: 1, ramMb: 512, networkDownMbps: 0, networkUpMbps: 0, ioReadMbps: 0, ioWriteMbps: 0 })
const [savingResource, setSavingResource] = useState(false)
const [showPassword, setShowPassword] = useState(false)
const [showResetPassword, setShowResetPassword] = useState(false)
@@ -395,8 +395,10 @@ export default function ContainerDetail() {
setResourceEdit({
vcpu: container.vcpu,
ramMb: container.ram_mb,
ioMbps: container.io_speed_mbps || 0,
bwMbps: container.network_bw_mbps || 0,
networkDownMbps: resourceLimitValue(container.network_down_mbps, container.network_bw_mbps),
networkUpMbps: resourceLimitValue(container.network_up_mbps, container.network_bw_mbps),
ioReadMbps: resourceLimitValue(container.io_read_mbps, container.io_speed_mbps),
ioWriteMbps: resourceLimitValue(container.io_write_mbps, container.io_speed_mbps),
})
setShowResourceEdit(true)
}
@@ -408,8 +410,12 @@ export default function ContainerDetail() {
await updateResourceLimit(container.id, {
vcpu: resourceEdit.vcpu,
ram_mb: resourceEdit.ramMb,
io_speed_mbps: resourceEdit.ioMbps,
network_bw_mbps: resourceEdit.bwMbps,
network_down_mbps: resourceEdit.networkDownMbps,
network_up_mbps: resourceEdit.networkUpMbps,
network_bw_mbps: symmetricLimit(resourceEdit.networkDownMbps, resourceEdit.networkUpMbps),
io_read_mbps: resourceEdit.ioReadMbps,
io_write_mbps: resourceEdit.ioWriteMbps,
io_speed_mbps: symmetricLimit(resourceEdit.ioReadMbps, resourceEdit.ioWriteMbps),
})
setShowResourceEdit(false)
fetchContainer()
@@ -903,8 +909,19 @@ export default function ContainerDetail() {
const diskPct = container.disk_gb > 0 ? clamp(((usage?.disk_usage_bytes || 0) / (container.disk_gb * 1024 * 1024 * 1024)) * 100) : 0
const networkBps = (usage?.network_rx_bps || 0) + (usage?.network_tx_bps || 0)
const rx = usage?.network_rx_bps || 0
const netPct = Math.min(((usage?.network_rx_bps || 0) + (usage?.network_tx_bps || 0)) / (container.network_bw_mbps > 0 ? container.network_bw_mbps * 125000 : 125000000) * 100, 100)
const networkDownLimit = resourceLimitValue(container.network_down_mbps, container.network_bw_mbps)
const networkUpLimit = resourceLimitValue(container.network_up_mbps, container.network_bw_mbps)
const netPct = Math.max(
directionUsagePercent(usage?.network_rx_bps || 0, networkDownLimit, 125000, 125000000),
directionUsagePercent(usage?.network_tx_bps || 0, networkUpLimit, 125000, 125000000),
)
const diskIOBps = (usage?.disk_read_bps || 0) + (usage?.disk_write_bps || 0)
const ioReadLimit = resourceLimitValue(container.io_read_mbps, container.io_speed_mbps)
const ioWriteLimit = resourceLimitValue(container.io_write_mbps, container.io_speed_mbps)
const diskIOPct = Math.max(
directionUsagePercent(usage?.disk_read_bps || 0, ioReadLimit, 1024 * 1024, 1024 * 1024 * 1024),
directionUsagePercent(usage?.disk_write_bps || 0, ioWriteLimit, 1024 * 1024, 1024 * 1024 * 1024),
)
const mappingCount = container.port_mappings?.length || 0
const mappingLimit = Math.max(container.port_mapping_limit || 0, mappingCount)
const hasNATQuota = mappingLimit > 0
@@ -951,7 +968,7 @@ export default function ContainerDetail() {
current: networkBps,
points: toChartPoints(filtered, 'network'),
formatValue: formatRate,
detail: `${formatRate(usage?.network_rx_bps || 0)} / 出 ${formatRate(usage?.network_tx_bps || 0)},累计 ${formatBytes((usage?.network_rx_bytes || 0) + (usage?.network_tx_bytes || 0))}`,
detail: `${formatRate(usage?.network_rx_bps || 0)} / 出 ${formatRate(usage?.network_tx_bps || 0)}限速占用 ${netPct.toFixed(1)}%累计 ${formatBytes((usage?.network_rx_bytes || 0) + (usage?.network_tx_bytes || 0))}`,
},
{
title: '磁盘IO',
@@ -959,7 +976,7 @@ export default function ContainerDetail() {
current: diskIOBps,
points: toChartPoints(filtered, 'diskIO'),
formatValue: formatRate,
detail: `${formatRate(usage?.disk_read_bps || 0)} / 写 ${formatRate(usage?.disk_write_bps || 0)},累计 ${formatBytes((usage?.disk_read_bytes || 0) + (usage?.disk_write_bytes || 0))},容量 ${diskPct.toFixed(1)}%`,
detail: `${formatRate(usage?.disk_read_bps || 0)} / 写 ${formatRate(usage?.disk_write_bps || 0)}限速占用 ${diskIOPct.toFixed(1)}%累计 ${formatBytes((usage?.disk_read_bytes || 0) + (usage?.disk_write_bytes || 0))},容量 ${diskPct.toFixed(1)}%`,
},
]
@@ -1154,8 +1171,8 @@ export default function ContainerDetail() {
<PlainRow label="vCPU" value={`${container.vcpu}`} />
<PlainRow label="内存" value={`${container.ram_mb} MB`} />
<PlainRow label="磁盘" value={`${container.disk_gb} GB`} />
<PlainRow label="网络速率" value={container.network_bw_mbps > 0 ? `${container.network_bw_mbps} Mbps` : '不限制'} />
<PlainRow label="IO 速度" value={container.io_speed_mbps > 0 ? `${container.io_speed_mbps} MB/s` : '不限制'} />
<PlainRow label="网络速率" value={formatDirectionalLimit('下行', networkDownLimit, '上行', networkUpLimit, 'Mbps')} />
<PlainRow label="IO 速度" value={formatDirectionalLimit('读取', ioReadLimit, '写入', ioWriteLimit, 'MB/s')} />
</Panel>
<Panel title="实时状态">
@@ -1982,15 +1999,27 @@ export default function ContainerDetail() {
className="w-full px-3 py-2 border border-gray-300 rounded-md text-sm" />
</div>
<div>
<label className="block text-xs text-gray-500 mb-1"> (Mbps0=)</label>
<input type="number" min={0} value={resourceEdit.bwMbps}
onChange={(e) => setResourceEdit({ ...resourceEdit, bwMbps: Math.max(0, Number(e.target.value) || 0) })}
<label className="block text-xs text-gray-500 mb-1"> (Mbps0=)</label>
<input type="number" min={0} value={resourceEdit.networkDownMbps}
onChange={(e) => setResourceEdit({ ...resourceEdit, networkDownMbps: Math.max(0, Number(e.target.value) || 0) })}
className="w-full px-3 py-2 border border-gray-300 rounded-md text-sm" />
</div>
<div>
<label className="block text-xs text-gray-500 mb-1">IO (MB/s0=)</label>
<input type="number" min={0} value={resourceEdit.ioMbps}
onChange={(e) => setResourceEdit({ ...resourceEdit, ioMbps: Math.max(0, Number(e.target.value) || 0) })}
<label className="block text-xs text-gray-500 mb-1"> (Mbps0=)</label>
<input type="number" min={0} value={resourceEdit.networkUpMbps}
onChange={(e) => setResourceEdit({ ...resourceEdit, networkUpMbps: Math.max(0, Number(e.target.value) || 0) })}
className="w-full px-3 py-2 border border-gray-300 rounded-md text-sm" />
</div>
<div>
<label className="block text-xs text-gray-500 mb-1"> IO (MB/s0=)</label>
<input type="number" min={0} value={resourceEdit.ioReadMbps}
onChange={(e) => setResourceEdit({ ...resourceEdit, ioReadMbps: Math.max(0, Number(e.target.value) || 0) })}
className="w-full px-3 py-2 border border-gray-300 rounded-md text-sm" />
</div>
<div>
<label className="block text-xs text-gray-500 mb-1"> IO (MB/s0=)</label>
<input type="number" min={0} value={resourceEdit.ioWriteMbps}
onChange={(e) => setResourceEdit({ ...resourceEdit, ioWriteMbps: Math.max(0, Number(e.target.value) || 0) })}
className="w-full px-3 py-2 border border-gray-300 rounded-md text-sm" />
</div>
</div>
@@ -2459,6 +2488,32 @@ function clampResourceInt(value: number, min: number, max?: number, fallback = m
return Math.min(Math.max(next, min), max ?? next)
}
function resourceLimitValue(value?: number, fallback?: number) {
return Math.max(0, Number(value || fallback || 0))
}
function symmetricLimit(a: number, b: number) {
const left = resourceLimitValue(a)
const right = resourceLimitValue(b)
if (left === right) return left
if (left === 0) return right
if (right === 0) return left
return Math.min(left, right)
}
function directionUsagePercent(bytesPerSecond: number, limit: number, bytesPerLimitUnit: number, fallbackBytesPerSecond: number) {
const denominator = limit > 0 ? limit * bytesPerLimitUnit : fallbackBytesPerSecond
return denominator > 0 ? clamp((bytesPerSecond / denominator) * 100) : 0
}
function formatLimit(value: number, unit: string) {
return value > 0 ? `${value} ${unit}` : '不限制'
}
function formatDirectionalLimit(firstLabel: string, firstValue: number, secondLabel: string, secondValue: number, unit: string) {
return `${firstLabel} ${formatLimit(firstValue, unit)} / ${secondLabel} ${formatLimit(secondValue, unit)}`
}
function toChartPoints<T extends keyof Omit<MetricPoint, 'ts'>>(history: MetricPoint[], key: T): ChartPoint[] {
return history.map((point) => ({ ts: point.ts, value: Number(point[key]) || 0 }))
}
+4
View File
@@ -704,6 +704,8 @@ function toPlaceholder(cfg: CreateContainerRequest): DisplayContainer {
ram_mb: cfg.ram_mb,
disk_gb: cfg.disk_gb,
network_bw_mbps: cfg.network_bw_mbps,
network_down_mbps: cfg.network_down_mbps,
network_up_mbps: cfg.network_up_mbps,
monthly_traffic_gb: cfg.monthly_traffic_gb,
traffic_mode: cfg.traffic_mode || 'total',
traffic_in_gb: cfg.traffic_in_gb || 0,
@@ -712,6 +714,8 @@ function toPlaceholder(cfg: CreateContainerRequest): DisplayContainer {
traffic_used_tx: 0,
traffic_reset_date: '',
io_speed_mbps: cfg.io_speed_mbps,
io_read_mbps: cfg.io_read_mbps,
io_write_mbps: cfg.io_write_mbps,
status: 'creating',
ip: '',
public_ipv4s: [],
+14 -2
View File
@@ -80,6 +80,8 @@ export interface Container {
ram_mb: number
disk_gb: number
network_bw_mbps: number
network_down_mbps: number
network_up_mbps: number
monthly_traffic_gb: number
traffic_mode: string
traffic_in_gb: number
@@ -88,6 +90,8 @@ export interface Container {
traffic_used_tx: number
traffic_reset_date: string
io_speed_mbps: number
io_read_mbps: number
io_write_mbps: number
status: string
ip: string
public_ipv4s?: PublicIPv4Assignment[]
@@ -138,11 +142,15 @@ export interface CreateContainerRequest {
ram_mb: number
disk_gb: number
network_bw_mbps: number
network_down_mbps: number
network_up_mbps: number
monthly_traffic_gb: number
traffic_mode: string
traffic_in_gb: number
traffic_out_gb: number
io_speed_mbps: number
io_read_mbps: number
io_write_mbps: number
extra_ports: number[]
port_mapping_count: number
assign_nat?: boolean
@@ -488,8 +496,12 @@ export const updateTrafficLimit = (id: ContainerIdentifier, data: {
export const updateResourceLimit = (id: ContainerIdentifier, data: {
vcpu: number
ram_mb: number
io_speed_mbps: number
network_bw_mbps: number
io_speed_mbps?: number
io_read_mbps?: number
io_write_mbps?: number
network_bw_mbps?: number
network_down_mbps?: number
network_up_mbps?: number
}) =>
api.put<APIResponse>(`/containers/${id}/resource-limit`, data)
+35 -1
View File
@@ -92,6 +92,22 @@ const exact: Record<string, string> = {
'创建时间': 'Created At',
'网络速率': 'Network Speed',
'IO 速度': 'IO Speed',
'下行带宽': 'Download Bandwidth',
'上行带宽': 'Upload Bandwidth',
'读取 IO': 'Read IO',
'写入 IO': 'Write IO',
'下行带宽 (Mbps)': 'Download Bandwidth (Mbps)',
'上行带宽 (Mbps)': 'Upload Bandwidth (Mbps)',
'读取 IO (MB/s)': 'Read IO (MB/s)',
'写入 IO (MB/s)': 'Write IO (MB/s)',
'下行带宽 (Mbps0=不限制)': 'Download Bandwidth (Mbps, 0=unlimited)',
'上行带宽 (Mbps0=不限制)': 'Upload Bandwidth (Mbps, 0=unlimited)',
'读取 IO (MB/s0=不限制)': 'Read IO (MB/s, 0=unlimited)',
'写入 IO (MB/s0=不限制)': 'Write IO (MB/s, 0=unlimited)',
'限速占用': 'Limit Usage',
'支持独立限制上行/下行带宽和读/写 I/O 操作。': 'Supports independent upload/download bandwidth limits and read/write I/O limits.',
'支持独立限制上行/下行带宽和读/写 I/O 操作。network_bw_mbps 与 io_speed_mbps 为旧版对称限制兼容别名,建议新对接使用 network_down_mbps、network_up_mbps、io_read_mbps、io_write_mbps。': 'Supports independent upload/download bandwidth limits and read/write I/O limits. network_bw_mbps and io_speed_mbps are deprecated symmetric compatibility aliases. New integrations should use network_down_mbps, network_up_mbps, io_read_mbps, and io_write_mbps.',
'支持独立限制下行/上行带宽和读取/写入 I/O。未传字段保持原值,显式传 0 表示该方向不限速;network_bw_mbps 与 io_speed_mbps 为旧版对称限制兼容别名。': 'Supports independent download/upload bandwidth limits and read/write I/O limits. Omitted fields keep their current values, and explicitly passing 0 makes that direction unlimited. network_bw_mbps and io_speed_mbps are deprecated symmetric compatibility aliases.',
'月流量': 'Monthly Traffic',
'统计信息': 'Statistics',
'CPU 使用率': 'CPU Usage',
@@ -578,7 +594,11 @@ const exact: Record<string, string> = {
'更新 Key': 'Update Key',
'删除 Key': 'Delete Key',
'总览': 'Overview',
'NAT/IPv4/IPv6 路由': 'NAT / IPv4 / IPv6 Routing',
'NAT/IPv6 路由': 'NAT / IPv6 Routing',
'更新公网 IPv4/IPv6 池': 'Update Public IPv4 / IPv6 Pools',
'扫描公网 IPv4 段': 'Scan Public IPv4 Prefixes',
'公网 IPv4/IPv6 池': 'Public IPv4 / IPv6 Pools',
'任务队列': 'Task Queue',
'任务列表': 'Task List',
'操作记录': 'audit records',
@@ -588,6 +608,7 @@ const exact: Record<string, string> = {
'管理员接口': 'Admin API',
'控制面板统计': 'Dashboard Stats',
'立即安全检查': 'Run Security Check',
'路由配置': 'Routing Configuration',
'返回响应样例': 'Response Example',
'请求参数': 'Request Parameters',
'响应字段': 'Response Fields',
@@ -616,11 +637,14 @@ const exact: Record<string, string> = {
'添加端口映射': 'Add Port Mapping',
'更新端口映射': 'Update Port Mapping',
'删除端口映射': 'Delete Port Mapping',
'获取防火墙设置': 'Get Firewall Settings',
'更新防火墙设置': 'Update Firewall Settings',
'快照总览': 'Snapshot Overview',
'容器快照': 'Container Snapshots',
'计划快照': 'Scheduled Snapshots',
'快照配额': 'Snapshot Quota',
'模板列表': 'Template List',
'镜像管理列表': 'Image Management List',
'取消镜像下载': 'Cancel Image Download',
'启用/禁用镜像': 'Enable / Disable Image',
'安全连接日志': 'Security Connection Logs',
@@ -650,7 +674,6 @@ const exact: Record<string, string> = {
'WebVNC 票据': 'WebVNC Ticket',
'容器列表(兼容 POST 写法)': 'Container List (compatible POST form)',
'调整到期时间': 'Adjust Expiration Time',
'镜像管理列表': 'Image Management List',
'批量创建容器': 'Batch Create Containers',
'创建 WebSSH 票据': 'Create WebSSH Ticket',
'创建 WebVNC 票据': 'Create WebVNC Ticket',
@@ -677,6 +700,12 @@ const exact: Record<string, string> = {
'CI/CD、计费系统、自动化脚本': 'CI/CD, billing systems, automation scripts',
'SWAP 已调整为 16384 MB': 'SWAP adjusted to 16384 MB',
'***60秒有效票据***': '***60-second valid ticket***',
'Linux 创建支持 ssh_auth_mode=auto_password|password|key;公网 IPv4、IPv6 与 NAT 可通过 assign_nat、assign_ipv4、assign_ipv6 组合使用。': 'Linux container creation supports ssh_auth_mode=auto_password|password|key. Public IPv4, IPv6, and NAT can be configured with assign_nat, assign_ipv4, and assign_ipv6.',
'重装支持 ssh_auth_mode=keep|auto_password|password|keykeep 仅用于重装,未传 SSH 字段时保持原有行为。': 'Reinstall supports ssh_auth_mode=keep|auto_password|password|key. keep is only for reinstall requests; if SSH fields are omitted, the existing behavior is kept.',
'批量创建的单个 containers[] 项支持与 POST /api/v1/containers 相同的网络和 SSH 认证字段。': 'Each containers[] item in batch creation supports the same network and SSH authentication fields as POST /api/v1/containers.',
'action=reinstall 时可追加 template_id、ssh_auth_mode、ssh_password、ssh_public_key;其他 action 会忽略这些重装字段。': 'When action=reinstall, you can include template_id, ssh_auth_mode, ssh_password, and ssh_public_key. Other actions ignore these reinstall fields.',
'更新公网地址池需要 routing:write;已分配给容器的地址不能从池中移除。': 'Updating public address pools requires routing:write. Addresses already assigned to containers cannot be removed from the pool.',
'扫描公网 IPv4 段需要 routing:writeverify=true 时会尝试校验地址可用性。': 'Scanning public IPv4 prefixes requires routing:write. When verify=true, the API also attempts to check address availability.',
'WebVNC 仅适用于 KVM 虚拟机;LXC 容器会返回 VNC console is only available for KVM VMs。': 'WebVNC only applies to KVM VMs; LXC containers return "VNC console is only available for KVM VMs".',
'该接口会进入任务队列,请随后调用 GET /api/v1/tasks 查看执行状态。': 'This API enters the task queue. Call GET /api/v1/tasks afterward to check execution status.',
'样例中的密钥、密码和票据已脱敏;创建类接口的完整密钥只在创建响应中出现一次。': 'Keys, passwords, and tickets in examples are masked. Full secrets from create APIs appear only once in the creation response.',
@@ -943,7 +972,12 @@ const replacements: Array<[RegExp, string]> = [
[/当前证书:/g, 'Current certificate: '],
[/第\s*(\d+)\s*页/g, 'Page $1'],
[/入\s*([^/]+)\s*\/\s*出\s*([^]+),累计\s*(.+)$/g, 'In $1 / Out $2, total $3'],
[/入\s*([^/]+)\s*\/\s*出\s*([^]+),限速占用\s*([^]+),累计\s*(.+)$/g, 'In $1 / Out $2, limit usage $3, total $4'],
[/下\s*([^/]+)\s*\/\s*上\s*(.+)$/g, 'Down $1 / Up $2'],
[/下行\s*([^/]+)\s*\/\s*上行\s*(.+)$/g, 'Download $1 / Upload $2'],
[/读取\s*([^/]+)\s*\/\s*写入\s*(.+)$/g, 'Read $1 / Write $2'],
[/读\s*([^/]+)\s*\/\s*写\s*([^]+),累计\s*([^]+),容量\s*(.+)$/g, 'Read $1 / Write $2, total $3, capacity $4'],
[/读\s*([^/]+)\s*\/\s*写\s*([^]+),限速占用\s*([^]+),累计\s*([^]+),容量\s*(.+)$/g, 'Read $1 / Write $2, limit usage $3, total $4, capacity $5'],
[/(.+?),筛选后\s*(\d+)\s*items/g, '$1, filtered $2 items'],
[/(.+?),已选\s*(\d+)\s*items/g, '$1, selected $2 items'],
[/将创建\s*(\d+)\s*个容器:(.+?)\s*至\s*(.+)$/g, 'Will create $1 containers: $2 to $3'],