uplink-cli 0.1.20 → 0.1.22

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.
@@ -3,6 +3,19 @@ import { join } from "path";
3
3
  import { apiRequest } from "../../http";
4
4
 
5
5
  export async function createAndStartTunnel(port: number): Promise<string> {
6
+ // Check if tunnel already running on this port
7
+ const existing = findTunnelClients().filter(c => c.port === port);
8
+ if (existing.length > 0) {
9
+ return [
10
+ `⚠ Tunnel already running on port ${port}`,
11
+ ``,
12
+ `→ PID: ${existing[0].pid}`,
13
+ `→ Token: ${existing[0].token.substring(0, 8)}...`,
14
+ ``,
15
+ `Use "Stop Tunnel" first to disconnect the existing tunnel.`,
16
+ ].join("\n");
17
+ }
18
+
6
19
  const result = await apiRequest("POST", "/v1/tunnels", { port });
7
20
  const url = result.url || "(no url)";
8
21
  const token = result.token || "(no token)";
@@ -1339,6 +1339,19 @@ export const menuCommand = new Command("menu")
1339
1339
  });
1340
1340
 
1341
1341
  async function createAndStartTunnel(port: number): Promise<string> {
1342
+ // Check if tunnel already running on this port
1343
+ const existing = findTunnelClients().filter(c => c.port === port);
1344
+ if (existing.length > 0) {
1345
+ return [
1346
+ `⚠ Tunnel already running on port ${port}`,
1347
+ ``,
1348
+ `→ PID: ${existing[0].pid}`,
1349
+ `→ Token: ${existing[0].token.substring(0, 8)}...`,
1350
+ ``,
1351
+ `Use "Stop Tunnel" first to disconnect the existing tunnel.`,
1352
+ ].join("\n");
1353
+ }
1354
+
1342
1355
  // Create tunnel
1343
1356
  const result = await apiRequest("POST", "/v1/tunnels", { port });
1344
1357
  const url = result.url || "(no url)";
@@ -1394,8 +1407,8 @@ function findTunnelClients(): Array<{ pid: number; port: number; token: string }
1394
1407
  const clients: Array<{ pid: number; port: number; token: string }> = [];
1395
1408
 
1396
1409
  for (const line of lines) {
1397
- // Parse process line: USER PID ... node scripts/tunnel/client-improved.js --token TOKEN --port PORT --ctrl CTRL
1398
- const pidMatch = line.match(/^\S+\s+(\d+)/);
1410
+ // Parse process line: PID COMMAND (from ps -o pid=,command=)
1411
+ const pidMatch = line.match(/^\s*(\d+)/);
1399
1412
  const tokenMatch = line.match(/--token\s+(\S+)/);
1400
1413
  const portMatch = line.match(/--port\s+(\d+)/);
1401
1414
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uplink-cli",
3
- "version": "0.1.20",
3
+ "version": "0.1.22",
4
4
  "description": "Expose localhost to the internet in seconds. Interactive terminal UI, permanent custom domains, zero config. A modern ngrok alternative.",
5
5
  "keywords": [
6
6
  "tunnel",