traforo 0.2.0 → 0.2.1
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/dist/client.js +1 -1
- package/dist/run-tunnel.d.ts +3 -0
- package/dist/run-tunnel.js +6 -4
- package/package.json +14 -13
- package/LICENSE +0 -21
package/dist/client.js
CHANGED
|
@@ -46,7 +46,7 @@ export class TunnelClient {
|
|
|
46
46
|
return new Promise((resolve, reject) => {
|
|
47
47
|
this.ws = new WebSocket(wsUrl);
|
|
48
48
|
this.ws.on('open', () => {
|
|
49
|
-
console.log(`Connected with Traforo
|
|
49
|
+
console.log(`Connected with Traforo!\n${this.url}`);
|
|
50
50
|
this.startPingInterval();
|
|
51
51
|
resolve();
|
|
52
52
|
});
|
package/dist/run-tunnel.d.ts
CHANGED
package/dist/run-tunnel.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
1
2
|
import { exec, spawn } from 'node:child_process';
|
|
2
3
|
import net from 'node:net';
|
|
3
4
|
import { promisify } from 'node:util';
|
|
4
5
|
import { TunnelClient } from './client.js';
|
|
5
6
|
const execPromise = promisify(exec);
|
|
6
7
|
export const CLI_NAME = 'traforo';
|
|
7
|
-
const
|
|
8
|
+
const DEFAULT_TUNNEL_ID_BYTES = 16;
|
|
9
|
+
export function createRandomTunnelId({ port }) {
|
|
10
|
+
return `${crypto.randomBytes(DEFAULT_TUNNEL_ID_BYTES).toString('hex')}-${port}`;
|
|
11
|
+
}
|
|
8
12
|
/**
|
|
9
13
|
* Wait for a port to be available (accepting connections).
|
|
10
14
|
* Used when spawning a child process to wait for the server to start.
|
|
@@ -157,11 +161,9 @@ export function parseCommandFromArgv(argv) {
|
|
|
157
161
|
* Run the tunnel, optionally spawning a child process first.
|
|
158
162
|
*/
|
|
159
163
|
export async function runTunnel(options) {
|
|
160
|
-
const tunnelId = options.tunnelId ||
|
|
161
|
-
crypto.randomUUID().replaceAll('-', '').slice(0, DEFAULT_TUNNEL_ID_LENGTH) +
|
|
162
|
-
options.port;
|
|
163
164
|
const localHost = options.localHost || 'localhost';
|
|
164
165
|
const port = options.port;
|
|
166
|
+
const tunnelId = options.tunnelId || createRandomTunnelId({ port });
|
|
165
167
|
// Kill existing process on port if requested
|
|
166
168
|
if (options.kill) {
|
|
167
169
|
await killProcessOnPort(port);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "traforo",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "HTTP tunnel via Cloudflare Durable Objects and WebSockets. Edge caching and password protection.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,6 +28,18 @@
|
|
|
28
28
|
"import": "./dist/run-tunnel.js"
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc -p tsconfig.client.json && chmod +x dist/cli.js",
|
|
33
|
+
"prepublishOnly": "pnpm build",
|
|
34
|
+
"dev": "wrangler dev",
|
|
35
|
+
"deploy": "wrangler deploy",
|
|
36
|
+
"deploy:preview": "wrangler deploy --env preview",
|
|
37
|
+
"typecheck": "tsc --noEmit",
|
|
38
|
+
"typecheck:client": "tsc --noEmit -p tsconfig.client.json",
|
|
39
|
+
"typecheck:test": "tsc --noEmit -p tsconfig.test.json",
|
|
40
|
+
"cli": "tsx src/cli.ts",
|
|
41
|
+
"test": "vitest --run"
|
|
42
|
+
},
|
|
31
43
|
"devDependencies": {
|
|
32
44
|
"@cloudflare/workers-types": "^4.20250712.0",
|
|
33
45
|
"@types/http-cache-semantics": "^4.2.0",
|
|
@@ -45,16 +57,5 @@
|
|
|
45
57
|
"http-cache-semantics": "^4.2.0",
|
|
46
58
|
"string-dedent": "^3.0.2",
|
|
47
59
|
"ws": "^8.19.0"
|
|
48
|
-
},
|
|
49
|
-
"scripts": {
|
|
50
|
-
"build": "tsc -p tsconfig.client.json && chmod +x dist/cli.js",
|
|
51
|
-
"dev": "wrangler dev",
|
|
52
|
-
"deploy": "wrangler deploy",
|
|
53
|
-
"deploy:preview": "wrangler deploy --env preview",
|
|
54
|
-
"typecheck": "tsc --noEmit",
|
|
55
|
-
"typecheck:client": "tsc --noEmit -p tsconfig.client.json",
|
|
56
|
-
"typecheck:test": "tsc --noEmit -p tsconfig.test.json",
|
|
57
|
-
"cli": "tsx src/cli.ts",
|
|
58
|
-
"test": "vitest --run"
|
|
59
60
|
}
|
|
60
|
-
}
|
|
61
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Kimaki
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|