@jebcode-dev/jebcode-tunnel 1.0.5 → 1.0.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.
- package/README.md +1 -1
- package/index.js +17 -10
- package/package.json +1 -1
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -131,34 +131,41 @@ function startTunnel(port, options = {}) {
|
|
|
131
131
|
process.exit(1);
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
const subdomain = options.subdomain ||
|
|
134
|
+
const subdomain = options.subdomain || null; // Se for null, o servidor gera um automático
|
|
135
135
|
const insecure = options.insecure || false;
|
|
136
136
|
|
|
137
137
|
process.stdout.write(chalk.blue(" ☁ Conectando à infraestrutura JebCode... "));
|
|
138
138
|
|
|
139
139
|
const socket = io(SERVER_URL, {
|
|
140
|
-
transports: ["websocket",
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
140
|
+
transports: ["websocket"], // FORÇA WEBSOCKET (Mais estável que polling)
|
|
141
|
+
reconnection: true,
|
|
142
|
+
reconnectionAttempts: Infinity,
|
|
143
|
+
reconnectionDelay: 1000,
|
|
144
|
+
reconnectionDelayMax: 5000,
|
|
145
|
+
timeout: 20000, // Mais tempo para o handshake
|
|
146
|
+
rejectUnauthorized: !insecure
|
|
146
147
|
});
|
|
147
148
|
|
|
148
149
|
socket.on("connect", () => {
|
|
149
150
|
process.stdout.write(chalk.green("OK\n"));
|
|
150
|
-
socket.emit("authenticate", { token: config.token, subdomain });
|
|
151
|
+
socket.emit("authenticate", { token: config.token, subdomain, port });
|
|
151
152
|
});
|
|
152
153
|
|
|
153
154
|
let hasShownHeader = false;
|
|
154
155
|
socket.on("auth_result", (result) => {
|
|
155
156
|
if (result.success) {
|
|
157
|
+
const finalSubdomain = result.subdomain || subdomain;
|
|
156
158
|
if (!hasShownHeader) {
|
|
157
159
|
console.clear();
|
|
158
160
|
console.log(getHeader());
|
|
161
|
+
const displayDomain = SERVER_URL.includes("localhost") ? "localhost:3000" : "jebcodetunnel.com";
|
|
162
|
+
const publicUrl = SERVER_URL.includes("localhost")
|
|
163
|
+
? `http://${finalSubdomain}.localhost:3000`
|
|
164
|
+
: `https://${finalSubdomain}.jebcodetunnel.com`;
|
|
165
|
+
|
|
159
166
|
console.log(chalk.white(" STATUS DO TÚNEL ATIVO"));
|
|
160
|
-
console.log(chalk.blue(" ▪"), chalk.bold("URL Pública: "), chalk.yellow(
|
|
161
|
-
console.log(chalk.blue(" ▪"), chalk.bold("Encaminhando:"), chalk.white(`http://localhost:${port}`), chalk.gray("➔"), chalk.cyan(
|
|
167
|
+
console.log(chalk.blue(" ▪"), chalk.bold("URL Pública: "), chalk.yellow(publicUrl));
|
|
168
|
+
console.log(chalk.blue(" ▪"), chalk.bold("Encaminhando:"), chalk.white(`http://localhost:${port}`), chalk.gray("➔"), chalk.cyan(displayDomain));
|
|
162
169
|
console.log(chalk.blue(" ▪"), chalk.bold("Dashboard: "), chalk.gray(`${SERVER_URL}/dashboard`));
|
|
163
170
|
|
|
164
171
|
console.log(chalk.gray("\n Pressione CTRL+C para encerrar o túnel"));
|