tnmn-cli 1.0.0 → 1.0.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/tnmn.js +31 -13
- package/package.json +7 -5
package/dist/tnmn.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env -S node --openssl-legacy-provider
|
|
2
2
|
"use strict";
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -7387,8 +7387,15 @@ __export(websocket_exports, {
|
|
|
7387
7387
|
});
|
|
7388
7388
|
async function dialMux(url, headers = {}) {
|
|
7389
7389
|
return new Promise((resolve, reject) => {
|
|
7390
|
-
|
|
7390
|
+
console.error(`[ws] Dialing: ${url}`);
|
|
7391
|
+
console.error(`[ws] Headers: ${JSON.stringify(headers)}`);
|
|
7392
|
+
const ws = new wrapper_default(url, {
|
|
7393
|
+
headers,
|
|
7394
|
+
rejectUnauthorized: false
|
|
7395
|
+
// Allow self-signed / mismatched certs (dev/staging)
|
|
7396
|
+
});
|
|
7391
7397
|
ws.on("open", () => {
|
|
7398
|
+
console.error("[ws] Connection opened");
|
|
7392
7399
|
const conn = new WebSocketConn(ws);
|
|
7393
7400
|
const session = new YamuxSession(conn, {
|
|
7394
7401
|
isClient: true,
|
|
@@ -7397,8 +7404,12 @@ async function dialMux(url, headers = {}) {
|
|
|
7397
7404
|
resolve(session);
|
|
7398
7405
|
});
|
|
7399
7406
|
ws.on("error", (err) => {
|
|
7407
|
+
console.error(`[ws] Error: ${err.message}`);
|
|
7400
7408
|
reject(new Error(`websocket dial: ${err.message}`));
|
|
7401
7409
|
});
|
|
7410
|
+
ws.on("unexpected-response", (req, res) => {
|
|
7411
|
+
console.error(`[ws] Unexpected response: ${res.statusCode} ${res.statusMessage}`);
|
|
7412
|
+
});
|
|
7402
7413
|
});
|
|
7403
7414
|
}
|
|
7404
7415
|
function fallbackURL(baseURL) {
|
|
@@ -7613,7 +7624,7 @@ function timestamp() {
|
|
|
7613
7624
|
var _wsTransport = null;
|
|
7614
7625
|
function wsTransport() {
|
|
7615
7626
|
if (!_wsTransport) {
|
|
7616
|
-
_wsTransport = (init_websocket(), __toCommonJS(websocket_exports))
|
|
7627
|
+
_wsTransport = (init_websocket(), __toCommonJS(websocket_exports));
|
|
7617
7628
|
}
|
|
7618
7629
|
return _wsTransport;
|
|
7619
7630
|
}
|
|
@@ -7641,7 +7652,7 @@ var TunnelClient = class {
|
|
|
7641
7652
|
* 5. Record round-trip latency.
|
|
7642
7653
|
*/
|
|
7643
7654
|
async connect() {
|
|
7644
|
-
const scheme =
|
|
7655
|
+
const scheme = "wss";
|
|
7645
7656
|
const url = `${scheme}://${this.config.server}/tunnel/connect`;
|
|
7646
7657
|
const headers = {};
|
|
7647
7658
|
if (this.config.token) {
|
|
@@ -7971,8 +7982,11 @@ async function saveConfig(cfg) {
|
|
|
7971
7982
|
// src/api/index.ts
|
|
7972
7983
|
function getBaseURL(server) {
|
|
7973
7984
|
const localhosts = ["localhost", "127.0.0.1", "[::1]"];
|
|
7974
|
-
|
|
7975
|
-
|
|
7985
|
+
if (/^connect\.tnmn\.click$/i.test(server)) return `https://${server}`;
|
|
7986
|
+
if (/:\d+$/.test(server)) return `https://${server}`;
|
|
7987
|
+
if (localhosts.some((l) => server.includes(l))) return `http://${server}`;
|
|
7988
|
+
if (server.includes("103.")) return `http://${server}`;
|
|
7989
|
+
return `https://${server}`;
|
|
7976
7990
|
}
|
|
7977
7991
|
async function apiFetch(url, token, options = {}) {
|
|
7978
7992
|
const res = await fetch(url, {
|
|
@@ -8182,13 +8196,16 @@ rdpCmd.command.action(async (opts) => {
|
|
|
8182
8196
|
insecure: program2.opts().insecure
|
|
8183
8197
|
});
|
|
8184
8198
|
});
|
|
8185
|
-
program2.command("login").description("Login to TNMN server (
|
|
8186
|
-
|
|
8187
|
-
|
|
8188
|
-
|
|
8189
|
-
|
|
8190
|
-
|
|
8191
|
-
|
|
8199
|
+
program2.command("login").description("Login to TNMN server").option("-e, --email <email>", "Email address").option("-p, --password <password>", "Password").action(async (opts) => {
|
|
8200
|
+
let { email, password } = opts;
|
|
8201
|
+
if (!email || !password) {
|
|
8202
|
+
const readline = await import("readline");
|
|
8203
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
8204
|
+
const question = (q) => new Promise((resolve) => rl.question(q, (answer) => resolve(answer)));
|
|
8205
|
+
if (!email) email = await question("Email: ");
|
|
8206
|
+
if (!password) password = await question("Password: ");
|
|
8207
|
+
rl.close();
|
|
8208
|
+
}
|
|
8192
8209
|
const auth = new AuthManager({ server: program2.opts().server });
|
|
8193
8210
|
try {
|
|
8194
8211
|
await auth.login(email, password);
|
|
@@ -8207,4 +8224,5 @@ program2.command("logout").description("Logout and clear stored token").action(a
|
|
|
8207
8224
|
});
|
|
8208
8225
|
|
|
8209
8226
|
// src/index.ts
|
|
8227
|
+
process.env.NODE_OPTIONS = "--openssl-legacy-provider";
|
|
8210
8228
|
program2.parse(process.argv);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tnmn-cli",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "TNMN Tunnel CLI
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "TNMN Tunnel CLI — expose local services to the internet via secure WebSocket tunnels",
|
|
5
5
|
"main": "dist/tnmn.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"tnmn": "dist/tnmn.js"
|
|
@@ -23,10 +23,12 @@
|
|
|
23
23
|
"ngrok-alternative",
|
|
24
24
|
"cli",
|
|
25
25
|
"websocket",
|
|
26
|
-
"yamux"
|
|
26
|
+
"yamux",
|
|
27
|
+
"reverse-proxy",
|
|
28
|
+
"localtunnel"
|
|
27
29
|
],
|
|
28
|
-
"author": "",
|
|
29
|
-
"license": "
|
|
30
|
+
"author": "TNMN <nhat@tnmn.click>",
|
|
31
|
+
"license": "MIT",
|
|
30
32
|
"devDependencies": {
|
|
31
33
|
"@types/node": "^20.19.38",
|
|
32
34
|
"@types/ws": "^8.18.1",
|