(ports: PortFormEntry[] = [])
| 347 | })); |
| 348 | |
| 349 | const normalizePorts = (ports: PortFormEntry[] = []): VmmTypes.IPortMapping[] => |
| 350 | ports |
| 351 | .map((port) => { |
| 352 | const protocol = (port.protocol || '').trim(); |
| 353 | const hostPort = |
| 354 | port.host_port === null || port.host_port === undefined ? Number.NaN : Number(port.host_port); |
| 355 | const vmPort = |
| 356 | port.vm_port === null || port.vm_port === undefined ? Number.NaN : Number(port.vm_port); |
| 357 | return { |
| 358 | protocol, |
| 359 | host_address: (port.host_address || '127.0.0.1').trim() || '127.0.0.1', |
| 360 | host_port: hostPort, |
| 361 | vm_port: vmPort, |
| 362 | }; |
| 363 | }) |
| 364 | .filter( |
| 365 | (port) => |
| 366 | port.protocol.length > 0 && |
| 367 | Number.isFinite(port.host_port) && |
| 368 | Number.isFinite(port.vm_port), |
| 369 | ) |
| 370 | .map((port) => ({ |
| 371 | protocol: port.protocol, |
| 372 | host_address: port.host_address, |
| 373 | host_port: port.host_port, |
| 374 | vm_port: port.vm_port, |
| 375 | })); |
| 376 | |
| 377 | function deriveGpuSelection(gpuConfig?: VmmTypes.IGpuConfig) { |
| 378 | if (!gpuConfig) { |
no test coverage detected