@lifeaitools/clauth 0.5.1 → 0.5.2
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/cli/commands/serve.js +7 -29
- package/cli/index.js +1 -1
- package/package.json +1 -1
package/cli/commands/serve.js
CHANGED
|
@@ -897,9 +897,7 @@ function createServer(initPassword, whitelist, port) {
|
|
|
897
897
|
tunnelError = null;
|
|
898
898
|
|
|
899
899
|
try {
|
|
900
|
-
//
|
|
901
|
-
const tunnelName = "clauth";
|
|
902
|
-
|
|
900
|
+
// Quick tunnel — no DNS/config needed, new random URL each session
|
|
903
901
|
// Resolve cloudflared binary — may not be on PATH in bash shells
|
|
904
902
|
let cfBin = "cloudflared";
|
|
905
903
|
if (os.platform() === "win32") {
|
|
@@ -915,40 +913,20 @@ function createServer(initPassword, whitelist, port) {
|
|
|
915
913
|
}
|
|
916
914
|
}
|
|
917
915
|
|
|
918
|
-
const proc = spawnProc(cfBin, ["tunnel", "
|
|
916
|
+
const proc = spawnProc(cfBin, ["tunnel", "--url", `http://127.0.0.1:${port}`], {
|
|
919
917
|
stdio: ["ignore", "pipe", "pipe"],
|
|
920
918
|
});
|
|
921
919
|
|
|
922
920
|
tunnelProc = proc;
|
|
923
921
|
|
|
924
|
-
// cloudflared
|
|
922
|
+
// cloudflared prints the quick tunnel URL to stderr
|
|
925
923
|
let stderrBuf = "";
|
|
926
924
|
proc.stderr.on("data", (chunk) => {
|
|
927
|
-
|
|
928
|
-
stderrBuf += text;
|
|
929
|
-
|
|
930
|
-
// Detect connection registered (named tunnel is live)
|
|
931
|
-
if (!tunnelUrl && stderrBuf.includes("Registered tunnel connection")) {
|
|
932
|
-
// Named tunnel URL comes from config, not stderr.
|
|
933
|
-
// Read it from cloudflared config if available.
|
|
934
|
-
try {
|
|
935
|
-
const cfgPath = path.join(os.homedir(), ".cloudflared", "config.yml");
|
|
936
|
-
const cfgText = fs.readFileSync(cfgPath, "utf8");
|
|
937
|
-
const hostnameMatch = cfgText.match(/hostname:\s*(\S+)/);
|
|
938
|
-
if (hostnameMatch) {
|
|
939
|
-
tunnelUrl = hostnameMatch[1].startsWith("http") ? hostnameMatch[1] : `https://${hostnameMatch[1]}`;
|
|
940
|
-
}
|
|
941
|
-
} catch {}
|
|
942
|
-
if (!tunnelUrl) tunnelUrl = `(named tunnel "${tunnelName}" connected — check DNS)`;
|
|
943
|
-
const logLine = `[${new Date().toISOString()}] Tunnel started: ${tunnelUrl}\n`;
|
|
944
|
-
try { fs.appendFileSync(LOG_FILE, logLine); } catch {}
|
|
945
|
-
}
|
|
946
|
-
|
|
947
|
-
// Quick tunnel fallback: trycloudflare.com URL
|
|
925
|
+
stderrBuf += chunk.toString();
|
|
948
926
|
if (!tunnelUrl) {
|
|
949
|
-
const
|
|
950
|
-
if (
|
|
951
|
-
tunnelUrl =
|
|
927
|
+
const match = stderrBuf.match(/https:\/\/[a-z0-9-]+\.trycloudflare\.com/);
|
|
928
|
+
if (match) {
|
|
929
|
+
tunnelUrl = match[0];
|
|
952
930
|
const logLine = `[${new Date().toISOString()}] Tunnel started: ${tunnelUrl}\n`;
|
|
953
931
|
try { fs.appendFileSync(LOG_FILE, logLine); } catch {}
|
|
954
932
|
}
|
package/cli/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import * as api from "./api.js";
|
|
|
12
12
|
import os from "os";
|
|
13
13
|
|
|
14
14
|
const config = new Conf(getConfOptions());
|
|
15
|
-
const VERSION = "0.5.
|
|
15
|
+
const VERSION = "0.5.2";
|
|
16
16
|
|
|
17
17
|
// ============================================================
|
|
18
18
|
// Password prompt helper
|