瀏覽代碼

now add directSocketsInterface on linux.create() call in place of networkInterface, does not crash somehow, still need to understand what goes in get_networkInterface(). still yet to find implementation somewhere

oscar 2 月之前
父節點
當前提交
16a1d5b0c8
共有 3 個文件被更改,包括 12 次插入8 次删除
  1. 1 1
      src/lib/NetworkingTab.svelte
  2. 1 7
      src/lib/WebVM.svelte
  3. 10 0
      src/lib/network.js

+ 1 - 1
src/lib/NetworkingTab.svelte

@@ -20,4 +20,4 @@
 		<i class='fas fa-circle fa-xs ml-auto {$exitNode ? 'text-green-500' : 'text-amber-500'}' title={$exitNode ? 'Ready' : 'No exit node'}></i>
 	{/if}
 </PanelButton>
-<p>WebVM can connect to the Internet via TCP through directSockets API!</p>
+<p>Connect</p>

+ 1 - 7
src/lib/WebVM.svelte

@@ -254,7 +254,6 @@
 				try
 				{
 					blockDevice = await CheerpX.CloudDevice.create(configObj.diskImageUrl);
-					console.debug("finished creating cloudDevice");
 				}
 				catch(e)
 				{
@@ -288,7 +287,6 @@
 		var webDevice = await CheerpX.WebDevice.create("");
 		var documentsDevice = await CheerpX.WebDevice.create("documents");
 		var dataDevice = await CheerpX.DataDevice.create();
-		console.debug("moving to mount points");
 		var mountPoints = [
 			// The root filesystem, as an Ext2 image
 			{type:"ext2", dev:overlayDevice, path:"/"},
@@ -309,9 +307,7 @@
 		];
 		try
 		{
-			console.debug("calling Linux.create()");
-			cx = await CheerpX.Linux.create({mounts: mountPoints, directSocketsInterface: directSocketsInterface});
-			console.debug("Linux.create() finished");
+			cx = await CheerpX.Linux.create({mounts: mountPoints, networkInterface: directSocketsInterface});
 		}
 		catch(e)
 		{
@@ -319,13 +315,11 @@
 			printMessage([e.toString()]);
 			return;
 		}
-		console.debug("registering callbacks");
 		cx.registerCallback("cpuActivity", cpuCallback);
 		cx.registerCallback("diskActivity", hddCallback);
 		cx.registerCallback("diskLatency", latencyCallback);
 		cx.registerCallback("processCreated", handleProcessCreated);
 		term.scrollToBottom();
-		console.debug("Scrolled to bottom");
 		cxReadFunc = cx.setCustomConsole(writeData, term.cols, term.rows);
 		const display = document.getElementById("display");
 		if(display)

+ 10 - 0
src/lib/network.js

@@ -82,6 +82,15 @@ async function handleCopyIP(event)
 
 export function updateButtonData(state, handleConnect) {
 	switch(state) {
+		case "DISCONNECTED":
+			return {
+				buttonText: "Connect to Tailscale",
+				isClickable: true,
+				clickHandler: handleConnect,
+				clickUrl: null,
+				buttonTooltip: null,
+				rightClickHandler: null
+			};
 		case "DOWNLOADING":
 			return {
 				buttonText: "Loading IP stack...",
@@ -146,6 +155,7 @@ export const networkData = { currentIp: null, connectionState: connectionState,
 //
 // IWA test
 // 
+// let localhost = "localhost";
 let host = "127.0.0.1";
 let port = 4321;
 let kind = "TCP";