private-connect 0.5.0 → 0.5.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.
Files changed (4) hide show
  1. package/README.md +25 -2
  2. package/dist/index.js +143 -15
  3. package/package.json +7 -6
  4. package/LICENSE +0 -110
package/README.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  Zero-friction connectivity tools. No signup required.
4
4
 
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm i private-connect # add to your project
9
+ npm i -g private-connect # install globally
10
+ ```
11
+
12
+ **Run it:** after a global install use `private-connect`; after a local install use `npx private-connect`. Or run without installing: `npx private-connect <command>`.
13
+
5
14
  ## Quick Start
6
15
 
7
16
  ```bash
@@ -53,7 +62,7 @@ Private Connect - Temporary Tunnel
53
62
  ────────────────────────────────────
54
63
 
55
64
  Local: localhost:3000
56
- Public: https://privateconnect.co/w/abc12345
65
+ Public: https://abc12345.privateconnect.co
57
66
  Anyone can access this URL
58
67
  Inspector: https://privateconnect.co/debug/s-xyz789
59
68
  Live traffic monitoring & request replay
@@ -64,6 +73,20 @@ Private Connect - Temporary Tunnel
64
73
  Press Ctrl+C to stop
65
74
  ```
66
75
 
76
+ **TCP/UDP Tunnels:**
77
+ ```bash
78
+ npx private-connect tunnel 5432 --tcp # TCP tunnel (databases, etc.)
79
+ npx private-connect tunnel 27015 --udp # UDP tunnel (game servers, etc.)
80
+ ```
81
+
82
+ TCP/UDP output shows connection details:
83
+ ```
84
+ Local: localhost:5432
85
+ Public: tcp://api.privateconnect.co:40001
86
+ Connect: api.privateconnect.co:40001
87
+ Expires: 120 minutes
88
+ ```
89
+
67
90
  **Sharing:**
68
91
  - The public URL shows your actual website (like ngrok)
69
92
  - Perfect for demos, testing, and sharing with teammates
@@ -73,7 +96,7 @@ Private Connect - Temporary Tunnel
73
96
  - No signup or account required
74
97
  - Auto-expires in 2 hours
75
98
  - Real-time request logging
76
- - Works with any HTTP service
99
+ - Works with HTTP, TCP, and UDP services
77
100
  - **Shareable URLs** - The public URL shows your actual website, perfect for demos and testing
78
101
 
79
102
  ### `setup-openclaw` - One-command OpenClaw setup
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@
11
11
  */
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  const net = require("net");
14
+ const dgram = require("dgram");
14
15
  const tls = require("tls");
15
16
  const https = require("https");
16
17
  const http = require("http");
@@ -260,6 +261,7 @@ ${c.bold}Examples:${c.reset}
260
261
  npx private-connect tunnel 3000
261
262
  npx private-connect tunnel localhost:8080
262
263
  npx private-connect tunnel 4096 --tcp
264
+ npx private-connect tunnel 27015 --udp
263
265
  npx private-connect list
264
266
  npx private-connect close abc123
265
267
  npx private-connect setup-openclaw
@@ -268,7 +270,7 @@ ${c.bold}Examples:${c.reset}
268
270
  ${c.bold}Tunnel:${c.reset}
269
271
  • No signup required
270
272
  • Auto-expires in 2 hours
271
- • HTTP or raw TCP (--tcp flag)
273
+ • HTTP, TCP (--tcp), or UDP (--udp)
272
274
 
273
275
  ${c.bold}Test:${c.reset}
274
276
  • TCP reachability
@@ -290,24 +292,38 @@ ${c.dim}For permanent tunnels: https://privateconnect.co${c.reset}
290
292
  const HUB_URL = process.env.CONNECT_HUB_URL || 'https://api.privateconnect.co';
291
293
  const TUNNEL_DOMAIN = process.env.CONNECT_TUNNEL_DOMAIN || 'tunnel.privateconnect.co';
292
294
  async function createTemporaryTunnel(options) {
293
- const { host, port, ttl = 120, tcp = false } = options;
294
- const tunnelType = tcp ? 'tcp' : 'http';
295
+ const { host, port, ttl = 120, tcp = false, udp = false } = options;
296
+ const tunnelType = udp ? 'udp' : (tcp ? 'tcp' : 'http');
295
297
  console.log();
296
- console.log(`${c.bold}Private Connect${c.reset} - Temporary ${tcp ? 'TCP ' : ''}Tunnel`);
298
+ console.log(`${c.bold}Private Connect${c.reset} - Temporary ${udp ? 'UDP ' : tcp ? 'TCP ' : ''}Tunnel`);
297
299
  console.log(`${c.gray}────────────────────────────────────${c.reset}`);
298
300
  console.log();
299
301
  // Check if local service is running
300
302
  process.stdout.write(` Checking ${c.cyan}${host}:${port}${c.reset}... `);
301
- const localCheck = await testTcp(host, port, 2000);
302
- if (!localCheck.ok) {
303
- console.log(`${fail}`);
304
- console.log();
305
- console.log(` ${c.red}Cannot connect to ${host}:${port}${c.reset}`);
306
- console.log(` ${c.gray}Make sure your service is running${c.reset}`);
307
- console.log();
308
- process.exit(1);
303
+ if (udp) {
304
+ // For UDP, we can't really test connectivity without sending data
305
+ // Just verify it's a valid port
306
+ if (port < 1 || port > 65535) {
307
+ console.log(`${fail}`);
308
+ console.log();
309
+ console.log(` ${c.red}Invalid port: ${port}${c.reset}`);
310
+ console.log();
311
+ process.exit(1);
312
+ }
313
+ console.log(`${ok} ${c.dim}(UDP - assuming service is ready)${c.reset}`);
314
+ }
315
+ else {
316
+ const localCheck = await testTcp(host, port, 2000);
317
+ if (!localCheck.ok) {
318
+ console.log(`${fail}`);
319
+ console.log();
320
+ console.log(` ${c.red}Cannot connect to ${host}:${port}${c.reset}`);
321
+ console.log(` ${c.gray}Make sure your service is running${c.reset}`);
322
+ console.log();
323
+ process.exit(1);
324
+ }
325
+ console.log(`${ok}`);
309
326
  }
310
- console.log(`${ok}`);
311
327
  // Generate a temporary tunnel ID
312
328
  const tunnelId = (0, crypto_1.randomBytes)(6).toString('hex');
313
329
  // Request tunnel from hub
@@ -388,6 +404,9 @@ async function createTemporaryTunnel(options) {
388
404
  if (data.tunnel.type === 'tcp' && data.tunnel.tcpHost && data.tunnel.tcpPort) {
389
405
  console.log(` ${c.bold}Connect:${c.reset} ${c.cyan}${data.tunnel.tcpHost}:${data.tunnel.tcpPort}${c.reset}`);
390
406
  }
407
+ if (data.tunnel.type === 'udp' && data.tunnel.udpHost && data.tunnel.udpPort) {
408
+ console.log(` ${c.bold}Connect:${c.reset} ${c.cyan}${data.tunnel.udpHost}:${data.tunnel.udpPort}${c.reset} ${c.dim}(UDP)${c.reset}`);
409
+ }
391
410
  console.log(` ${c.bold}Expires:${c.reset} ${data.tunnel.ttlMinutes} minutes`);
392
411
  console.log();
393
412
  console.log(`${c.gray}────────────────────────────────────${c.reset}`);
@@ -395,7 +414,10 @@ async function createTemporaryTunnel(options) {
395
414
  console.log(` ${c.dim}Press Ctrl+C to stop${c.reset}`);
396
415
  console.log();
397
416
  // Keep connection alive and handle incoming requests
398
- if (data.tunnel.type === 'tcp') {
417
+ if (data.tunnel.type === 'udp') {
418
+ await runUdpTunnelProxy(data.tunnel.tunnelId, wsUrl, host, port);
419
+ }
420
+ else if (data.tunnel.type === 'tcp') {
399
421
  await runTcpTunnelProxy(data.tunnel.tunnelId, wsUrl, host, port);
400
422
  }
401
423
  else {
@@ -698,6 +720,106 @@ async function runTcpTunnelProxy(tunnelId, wsUrl, localHost, localPort) {
698
720
  });
699
721
  });
700
722
  }
723
+ /**
724
+ * Run UDP tunnel proxy - forward UDP datagrams
725
+ */
726
+ async function runUdpTunnelProxy(tunnelId, wsUrl, localHost, localPort) {
727
+ return new Promise((resolve) => {
728
+ const url = new url_1.URL(wsUrl.replace('ws://', 'http://').replace('wss://', 'https://'));
729
+ const baseUrl = `${url.protocol}//${url.host}`;
730
+ const namespace = url.pathname || '/temp-tunnel';
731
+ const socket = (0, socket_io_client_1.io)(`${baseUrl}${namespace}`, {
732
+ transports: ['websocket'],
733
+ reconnection: true,
734
+ reconnectionAttempts: 10,
735
+ reconnectionDelay: 1000,
736
+ });
737
+ // Create local UDP socket for forwarding to local service
738
+ const localUdpSocket = dgram.createSocket('udp4');
739
+ // Track UDP "sessions" by remote address for response routing
740
+ // sessionId -> { remoteInfo from server }
741
+ const sessions = new Map();
742
+ let packetCount = 0;
743
+ socket.on('connect', () => {
744
+ socket.emit('register', { tunnelId }, (response) => {
745
+ if (!response.success) {
746
+ console.log(` ${c.red}Failed to register: ${response.error}${c.reset}`);
747
+ socket.disconnect();
748
+ resolve();
749
+ }
750
+ });
751
+ });
752
+ socket.on('disconnect', (reason) => {
753
+ localUdpSocket.close();
754
+ if (reason === 'io server disconnect') {
755
+ console.log(` ${c.yellow}Tunnel expired or closed by server${c.reset}`);
756
+ }
757
+ });
758
+ socket.on('tunnel_expired', () => {
759
+ console.log();
760
+ console.log(` ${c.yellow}Tunnel expired${c.reset}`);
761
+ console.log();
762
+ localUdpSocket.close();
763
+ socket.disconnect();
764
+ resolve();
765
+ });
766
+ socket.on('server_shutdown', (data) => {
767
+ console.log();
768
+ console.log(` ${c.yellow}⚠ Server shutting down${c.reset}`);
769
+ if (data.message) {
770
+ console.log(` ${c.dim}${data.message}${c.reset}`);
771
+ }
772
+ if (data.reconnectIn) {
773
+ console.log(` ${c.dim}Reconnect in ${data.reconnectIn} seconds...${c.reset}`);
774
+ }
775
+ console.log();
776
+ });
777
+ // Handle incoming UDP datagram from server (from remote client)
778
+ socket.on('udp_datagram', (data) => {
779
+ packetCount++;
780
+ const timestamp = new Date().toLocaleTimeString();
781
+ console.log(` ${c.gray}[${timestamp}]${c.reset} ${c.cyan}UDP${c.reset} ← ${data.remoteAddress}:${data.remotePort} (${Buffer.from(data.data, 'base64').length} bytes)`);
782
+ // Store session info for response routing
783
+ sessions.set(data.sessionId, { address: data.remoteAddress, port: data.remotePort });
784
+ // Forward to local UDP service
785
+ const buffer = Buffer.from(data.data, 'base64');
786
+ localUdpSocket.send(buffer, localPort, localHost, (err) => {
787
+ if (err) {
788
+ console.log(` ${c.red}UDP send error: ${err.message}${c.reset}`);
789
+ }
790
+ });
791
+ });
792
+ // Handle response from local UDP service
793
+ localUdpSocket.on('message', (msg, rinfo) => {
794
+ const timestamp = new Date().toLocaleTimeString();
795
+ console.log(` ${c.gray}[${timestamp}]${c.reset} ${c.cyan}UDP${c.reset} → response (${msg.length} bytes)`);
796
+ // Find the most recent session to send response to
797
+ // In practice, you might need more sophisticated session tracking
798
+ const lastSession = Array.from(sessions.entries()).pop();
799
+ if (lastSession) {
800
+ socket.emit('udp_response', {
801
+ sessionId: lastSession[0],
802
+ data: msg.toString('base64'),
803
+ });
804
+ }
805
+ });
806
+ localUdpSocket.on('error', (err) => {
807
+ console.log(` ${c.red}Local UDP socket error: ${err.message}${c.reset}`);
808
+ });
809
+ // Bind local socket to receive responses
810
+ localUdpSocket.bind();
811
+ // Handle shutdown
812
+ process.on('SIGINT', () => {
813
+ console.log();
814
+ console.log(` ${c.yellow}Tunnel closed${c.reset}`);
815
+ console.log(` ${c.gray}Handled ${packetCount} UDP packets${c.reset}`);
816
+ console.log();
817
+ localUdpSocket.close();
818
+ socket.disconnect();
819
+ resolve();
820
+ });
821
+ });
822
+ }
701
823
  function parseTunnelTarget(target) {
702
824
  // Handle just port number
703
825
  if (/^\d+$/.test(target)) {
@@ -989,11 +1111,17 @@ else if (args[0] === 'tunnel') {
989
1111
  console.error(`Usage: npx private-connect tunnel <port>`);
990
1112
  console.error(` npx private-connect tunnel localhost:3000`);
991
1113
  console.error(` npx private-connect tunnel 4096 --tcp`);
1114
+ console.error(` npx private-connect tunnel 27015 --udp`);
992
1115
  process.exit(1);
993
1116
  }
994
1117
  const { host, port } = parseTunnelTarget(args[1]);
995
1118
  const tcp = args.includes('--tcp') || args.includes('-t');
996
- createTemporaryTunnel({ host, port, tcp }).catch(console.error);
1119
+ const udp = args.includes('--udp') || args.includes('-u');
1120
+ if (tcp && udp) {
1121
+ console.error(`${c.red}Error: Cannot use both --tcp and --udp${c.reset}`);
1122
+ process.exit(1);
1123
+ }
1124
+ createTemporaryTunnel({ host, port, tcp, udp }).catch(console.error);
997
1125
  }
998
1126
  else if (args[0] === 'list' || args[0] === 'ls') {
999
1127
  listTunnels().catch(console.error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "private-connect",
3
- "version": "0.5.0",
3
+ "version": "0.5.8",
4
4
  "description": "Access private services by name from anywhere. No VPN setup, no firewall rules. Open source alternative to ngrok and Tailscale for service-level connectivity.",
5
5
  "bin": {
6
6
  "private-connect": "./dist/index.js"
@@ -10,6 +10,10 @@
10
10
  "dist",
11
11
  "README.md"
12
12
  ],
13
+ "scripts": {
14
+ "build": "tsc",
15
+ "dev": "tsc -w"
16
+ },
13
17
  "keywords": [
14
18
  "vpn-alternative",
15
19
  "ngrok-alternative",
@@ -40,9 +44,6 @@
40
44
  "devDependencies": {
41
45
  "@types/node": "^20.0.0",
42
46
  "typescript": "^5.0.0"
43
- },
44
- "scripts": {
45
- "build": "tsc",
46
- "dev": "tsc -w"
47
47
  }
48
- }
48
+ }
49
+
package/LICENSE DELETED
@@ -1,110 +0,0 @@
1
- # Functional Source License, Version 1.1
2
-
3
- ## Abbreviation
4
-
5
- FSL-1.1-MIT
6
-
7
- ## Notice
8
-
9
- Copyright (c) 2025 Treadie, Inc
10
-
11
- ## Terms and Conditions
12
-
13
- ### Licensor ("We")
14
-
15
- The party offering the Software under these Terms and Conditions.
16
-
17
- ### The Software
18
-
19
- The "Software" is each version of the software that we make available under
20
- these Terms and Conditions, as indicated by our inclusion of these Terms and
21
- Conditions with the Software.
22
-
23
- ### License Grant
24
-
25
- Subject to your compliance with this License Grant and the Patents,
26
- Redistribution and Trademark clauses below, we hereby grant you the right to
27
- use, copy, modify, create derivative works, publicly perform, publicly display
28
- and redistribute the Software for any Permitted Purpose identified below.
29
-
30
- ### Permitted Purpose
31
-
32
- A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
- means making the Software available to others in a commercial product or
34
- service that:
35
-
36
- 1. substitutes for the Software;
37
-
38
- 2. substitutes for any other product or service we offer using the Software
39
- that exists as of the date we make the Software available; or
40
-
41
- 3. offers the same or substantially similar functionality as the Software.
42
-
43
- Permitted Purposes specifically include using the Software:
44
-
45
- 1. for your internal use and access;
46
-
47
- 2. for non-commercial education;
48
-
49
- 3. for non-commercial research; and
50
-
51
- 4. in connection with professional services that you provide to a licensee
52
- using the Software in accordance with these Terms and Conditions.
53
-
54
- ### Patents
55
-
56
- To the extent your use for a Permitted Purpose would necessarily infringe our
57
- patents, the license grant above includes a license under our patents. If you
58
- make a claim against any party that the Software infringes or contributes to
59
- the infringement of any patent, then your patent license to the Software ends
60
- immediately.
61
-
62
- ### Redistribution
63
-
64
- The Terms and Conditions apply to all copies, modifications and derivatives of
65
- the Software.
66
-
67
- If you redistribute any copies, modifications or derivatives of the Software,
68
- you must include a copy of or a link to these Terms and Conditions and not
69
- remove any copyright notices provided in or with the Software.
70
-
71
- ### Disclaimer
72
-
73
- THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
- IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
- PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
-
77
- IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
- SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79
- EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
-
81
- ### Trademarks
82
-
83
- Except for displaying the License Details and identifying us as the origin of
84
- the Software, you have no right under these Terms and Conditions to use our
85
- trademarks, trade names, service marks or product names.
86
-
87
- ## Grant of Future License
88
-
89
- We hereby irrevocably grant you an additional license to use the Software under
90
- the MIT license that is effective on the second anniversary of the date we make
91
- the Software available. On or after that date, you may use the Software under
92
- the MIT license, in which case the following will apply:
93
-
94
- Permission is hereby granted, free of charge, to any person obtaining a copy of
95
- this software and associated documentation files (the "Software"), to deal in
96
- the Software without restriction, including without limitation the rights to
97
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
98
- of the Software, and to permit persons to whom the Software is furnished to do
99
- so, subject to the following conditions:
100
-
101
- The above copyright notice and this permission notice shall be included in all
102
- copies or substantial portions of the Software.
103
-
104
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
105
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
106
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
107
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
108
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
109
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
110
- SOFTWARE.