Skip to content

Commit 8e5c0f7

Browse files
committed
Use vscode externalURI forwarding
1 parent f97c2dd commit 8e5c0f7

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/commands/capture.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -309,13 +309,12 @@ export async function captureEdgesharkVNC(
309309
}
310310
}
311311

312-
const containerId = await utils.execWithProgress(`docker run -d --rm -P ${edgesharkNetwork} ${volumeMount} ${darkModeSetting} -e PACKETFLIX_LINK="${modifiedPacketflixUri}" ${extraDockerArgs} --name clab_vsc_ws-${node.parentName}_${node.name}-${Date.now()} ${dockerImage}`, "Starting Wireshark")
312+
const port = await utils.getFreePort()
313+
const containerId = await utils.execWithProgress(`docker run -d --rm -p 127.0.0.1:${port}:5800 ${edgesharkNetwork} ${volumeMount} ${darkModeSetting} -e PACKETFLIX_LINK="${modifiedPacketflixUri}" ${extraDockerArgs} --name clab_vsc_ws-${node.parentName}_${node.name}-${Date.now()} ${dockerImage}`, "Starting Wireshark")
313314

314-
const dockerInspectStdout = execSync(`docker inspect ${containerId}`, { encoding: 'utf-8' });
315-
const dockerInspectJSON = JSON.parse(dockerInspectStdout);
316-
317-
// grab the random port that docker opened
318-
const webviewPort = dockerInspectJSON[0].NetworkSettings.Ports['5800/tcp'][0].HostPort;
315+
// let vscode port forward for us
316+
const localUri = vscode.Uri.parse(`http://localhost:${port}`);
317+
const externalUri = (await vscode.env.asExternalUri(localUri)).toString();
319318

320319
const panel = vscode.window.createWebviewPanel(
321320
'clabWiresharkVNC',
@@ -330,7 +329,7 @@ export async function captureEdgesharkVNC(
330329
execSync(`docker rm -f ${containerId}`)
331330
})
332331

333-
const iframeUrl = `http://${packetflixUri[1]}:${webviewPort}`;
332+
const iframeUrl = externalUri;
334333

335334
// Show info about where to save pcap files if volume is mounted
336335
if (volumeMount) {

0 commit comments

Comments
 (0)