api-response-manager 2.6.6 ā 2.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commands/tunnel.js +21 -15
- package/package.json +1 -1
package/commands/tunnel.js
CHANGED
|
@@ -153,10 +153,14 @@ async function connectTunnelClient(tunnelId, subdomain, localPort, protocol = 'h
|
|
|
153
153
|
console.log(chalk.white('Your local server is now accessible at:'));
|
|
154
154
|
console.log(chalk.cyan.bold(` ${message.publicUrl}\n`));
|
|
155
155
|
|
|
156
|
-
// Show TCP/SSH specific info
|
|
156
|
+
// Show TCP/SSH specific info
|
|
157
157
|
if (isTcpTunnel && message.tcpHost && message.tcpPort) {
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
console.log(chalk.yellow.bold('š SSH/TCP Tunnel Ready!\n'));
|
|
159
|
+
console.log(chalk.white.bold(' š Share this with anyone to connect:\n'));
|
|
160
|
+
console.log(chalk.cyan.bold(` ssh <user>@${message.tcpHost} -p ${message.tcpPort}\n`));
|
|
161
|
+
console.log(chalk.gray(' With SSH Key:'));
|
|
162
|
+
console.log(chalk.cyan(` ssh -i ~/.ssh/your_key <user>@${message.tcpHost} -p ${message.tcpPort}\n`));
|
|
163
|
+
console.log(chalk.gray.italic(' Replace <user> with the remote device\'s SSH username\n'));
|
|
160
164
|
} else {
|
|
161
165
|
// Display QR code for HTTP/HTTPS tunnels (not for TCP/SSH)
|
|
162
166
|
displayQRCode(message.publicUrl);
|
|
@@ -275,11 +279,6 @@ async function connectTunnelClient(tunnelId, subdomain, localPort, protocol = 'h
|
|
|
275
279
|
process.on('SIGINT', () => {
|
|
276
280
|
if (heartbeatInterval) clearInterval(heartbeatInterval);
|
|
277
281
|
console.log(chalk.yellow('\n\nā Stopping tunnel...'));
|
|
278
|
-
// Close local TCP proxy if running
|
|
279
|
-
if (localProxyServer) {
|
|
280
|
-
localProxyServer.close();
|
|
281
|
-
localProxyServer = null;
|
|
282
|
-
}
|
|
283
282
|
ws.close();
|
|
284
283
|
});
|
|
285
284
|
}
|
|
@@ -612,17 +611,24 @@ function startLocalTcpProxy(subdomain, remoteHost, remotePort, silent) {
|
|
|
612
611
|
});
|
|
613
612
|
});
|
|
614
613
|
|
|
615
|
-
// Listen on port 0 to get a random available port
|
|
616
|
-
localProxyServer.listen(0, '
|
|
614
|
+
// Listen on port 0 to get a random available port, bind to 0.0.0.0 for network access
|
|
615
|
+
localProxyServer.listen(0, '0.0.0.0', () => {
|
|
617
616
|
const localPort = localProxyServer.address().port;
|
|
618
617
|
|
|
619
618
|
if (!silent) {
|
|
620
619
|
console.log(chalk.yellow.bold('š SSH/TCP Tunnel Ready!\n'));
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
620
|
+
|
|
621
|
+
// Build the shareable SSH command
|
|
622
|
+
// Uses FIFO-based ProxyCommand for bidirectional relay through the tunnel server
|
|
623
|
+
const sshCmd = `ssh -o "ProxyCommand=bash -c 'F=\\$(mktemp -u);mkfifo \\$F;nc %h %p <\\$F & printf SUBDOMAIN:${subdomain}\\\\\\\\n >\\$F;cat >\\$F;rm \\$F'" <user>@${remoteHost} -p ${remotePort}`;
|
|
624
|
+
|
|
625
|
+
console.log(chalk.white.bold(' š Share with anyone to connect (Linux/Mac/WSL):\n'));
|
|
626
|
+
console.log(chalk.cyan(` ${sshCmd}\n`));
|
|
627
|
+
|
|
628
|
+
console.log(chalk.white.bold(' š» Connect from this machine:\n'));
|
|
629
|
+
console.log(chalk.cyan(` ssh <user>@localhost -p ${localPort}\n`));
|
|
630
|
+
|
|
631
|
+
console.log(chalk.gray.italic(' Replace <user> with the remote device\'s SSH username\n'));
|
|
626
632
|
}
|
|
627
633
|
});
|
|
628
634
|
|