MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / normalizePorts

Function normalizePorts

vmm/ui/src/composables/useVmManager.ts:349–375  ·  view source on GitHub ↗
(ports: PortFormEntry[] = [])

Source from the content-addressed store, hash-verified

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) {

Callers 2

buildCreateVmPayloadFunction · 0.85
updateVMFunction · 0.85

Calls 1

NumberInterface · 0.85

Tested by

no test coverage detected