vite-plugin-rpx 0.11.21 → 0.11.23
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/index.js +94 -69
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -22765,6 +22765,7 @@ class UpstreamPool {
|
|
|
22765
22765
|
host;
|
|
22766
22766
|
port;
|
|
22767
22767
|
maxTotal;
|
|
22768
|
+
key;
|
|
22768
22769
|
idle = [];
|
|
22769
22770
|
waiters = [];
|
|
22770
22771
|
open = 0;
|
|
@@ -22773,10 +22774,11 @@ class UpstreamPool {
|
|
|
22773
22774
|
maxWaiters;
|
|
22774
22775
|
checkoutIdleMs = checkoutIdleMs();
|
|
22775
22776
|
inUse = new Set;
|
|
22776
|
-
constructor(host, port, maxTotal) {
|
|
22777
|
+
constructor(host, port, maxTotal, key = "") {
|
|
22777
22778
|
this.host = host;
|
|
22778
22779
|
this.port = port;
|
|
22779
22780
|
this.maxTotal = maxTotal;
|
|
22781
|
+
this.key = key;
|
|
22780
22782
|
this.maxWaiters = maxQueued(maxTotal);
|
|
22781
22783
|
}
|
|
22782
22784
|
trackCheckout(conn) {
|
|
@@ -22935,6 +22937,8 @@ class UpstreamPool {
|
|
|
22935
22937
|
if (this.idle.length === 0 && this.inUse.size === 0 && this.sweeper) {
|
|
22936
22938
|
clearInterval(this.sweeper);
|
|
22937
22939
|
this.sweeper = null;
|
|
22940
|
+
if (this.key && pools.get(this.key) === this)
|
|
22941
|
+
pools.delete(this.key);
|
|
22938
22942
|
}
|
|
22939
22943
|
}
|
|
22940
22944
|
}
|
|
@@ -22944,7 +22948,7 @@ function poolFor(hostPort, maxPerHost) {
|
|
|
22944
22948
|
const idx = hostPort.lastIndexOf(":");
|
|
22945
22949
|
const host = idx === -1 ? hostPort : hostPort.slice(0, idx);
|
|
22946
22950
|
const port = idx === -1 ? 80 : Number(hostPort.slice(idx + 1));
|
|
22947
|
-
pool = new UpstreamPool(host, port, maxPerHost);
|
|
22951
|
+
pool = new UpstreamPool(host, port, maxPerHost, hostPort);
|
|
22948
22952
|
pools.set(hostPort, pool);
|
|
22949
22953
|
}
|
|
22950
22954
|
return pool;
|
|
@@ -23519,6 +23523,9 @@ var init_static_files = __esm(() => {
|
|
|
23519
23523
|
});
|
|
23520
23524
|
|
|
23521
23525
|
// ../rpx/src/proxy-handler.ts
|
|
23526
|
+
function wsPendingCapBytes() {
|
|
23527
|
+
return Math.max(0, Number(process.env.RPX_MAX_WS_PENDING_BYTES)) || 8 * 1024 * 1024;
|
|
23528
|
+
}
|
|
23522
23529
|
function extractHostname2(req) {
|
|
23523
23530
|
const hostHeader = req.headers.get("host") || "";
|
|
23524
23531
|
const colon = hostHeader.indexOf(":");
|
|
@@ -23678,6 +23685,7 @@ function createProxyFetchHandler(getRoute, verbose, onNoRoute) {
|
|
|
23678
23685
|
}
|
|
23679
23686
|
function createProxyWebSocketHandler(verbose) {
|
|
23680
23687
|
const state = new WeakMap;
|
|
23688
|
+
const maxPendingBytes = wsPendingCapBytes();
|
|
23681
23689
|
return {
|
|
23682
23690
|
open(ws) {
|
|
23683
23691
|
const { targetUrl, forwardHeaders } = ws.data;
|
|
@@ -23690,13 +23698,14 @@ function createProxyWebSocketHandler(verbose) {
|
|
|
23690
23698
|
return;
|
|
23691
23699
|
}
|
|
23692
23700
|
upstream.binaryType = "arraybuffer";
|
|
23693
|
-
const st = { upstream, upstreamOpen: false, pending: [] };
|
|
23701
|
+
const st = { upstream, upstreamOpen: false, pending: [], pendingBytes: 0 };
|
|
23694
23702
|
state.set(ws, st);
|
|
23695
23703
|
upstream.addEventListener("open", () => {
|
|
23696
23704
|
st.upstreamOpen = true;
|
|
23697
23705
|
for (const frame of st.pending)
|
|
23698
23706
|
upstream.send(frame);
|
|
23699
23707
|
st.pending = [];
|
|
23708
|
+
st.pendingBytes = 0;
|
|
23700
23709
|
});
|
|
23701
23710
|
upstream.addEventListener("message", (ev) => {
|
|
23702
23711
|
ws.send(ev.data);
|
|
@@ -23718,10 +23727,24 @@ function createProxyWebSocketHandler(verbose) {
|
|
|
23718
23727
|
if (!st)
|
|
23719
23728
|
return;
|
|
23720
23729
|
const frame = typeof message === "string" ? message : new Uint8Array(message);
|
|
23721
|
-
if (st.upstreamOpen)
|
|
23730
|
+
if (st.upstreamOpen) {
|
|
23722
23731
|
st.upstream.send(frame);
|
|
23723
|
-
|
|
23724
|
-
|
|
23732
|
+
return;
|
|
23733
|
+
}
|
|
23734
|
+
const size = typeof frame === "string" ? Buffer.byteLength(frame) : frame.byteLength;
|
|
23735
|
+
if (st.pendingBytes + size > maxPendingBytes) {
|
|
23736
|
+
debugLog("ws", `pending buffer would exceed ${maxPendingBytes}B before upstream open; closing socket`, verbose);
|
|
23737
|
+
try {
|
|
23738
|
+
ws.close(1009, "buffer limit");
|
|
23739
|
+
} catch {}
|
|
23740
|
+
try {
|
|
23741
|
+
st.upstream.close(1011, "client buffer overflow");
|
|
23742
|
+
} catch {}
|
|
23743
|
+
state.delete(ws);
|
|
23744
|
+
return;
|
|
23745
|
+
}
|
|
23746
|
+
st.pending.push(frame);
|
|
23747
|
+
st.pendingBytes += size;
|
|
23725
23748
|
},
|
|
23726
23749
|
close(ws, code, reason) {
|
|
23727
23750
|
const st = state.get(ws);
|
|
@@ -23755,6 +23778,24 @@ var init_proxy_handler = __esm(() => {
|
|
|
23755
23778
|
]);
|
|
23756
23779
|
});
|
|
23757
23780
|
|
|
23781
|
+
// ../rpx/src/acme-challenge.ts
|
|
23782
|
+
import * as fs3 from "node:fs";
|
|
23783
|
+
import * as path3 from "node:path";
|
|
23784
|
+
function readAcmeChallenge(webroot, pathname) {
|
|
23785
|
+
if (!webroot || !pathname.startsWith(ACME_CHALLENGE_PREFIX2))
|
|
23786
|
+
return null;
|
|
23787
|
+
const token = pathname.slice(ACME_CHALLENGE_PREFIX2.length);
|
|
23788
|
+
if (!token || !/^[A-Za-z0-9_-]+$/.test(token))
|
|
23789
|
+
return null;
|
|
23790
|
+
try {
|
|
23791
|
+
return fs3.readFileSync(path3.join(webroot, token), "utf8");
|
|
23792
|
+
} catch {
|
|
23793
|
+
return null;
|
|
23794
|
+
}
|
|
23795
|
+
}
|
|
23796
|
+
var ACME_CHALLENGE_PREFIX2 = "/.well-known/acme-challenge/";
|
|
23797
|
+
var init_acme_challenge = () => {};
|
|
23798
|
+
|
|
23758
23799
|
// ../rpx/src/host-match.ts
|
|
23759
23800
|
function isWildcardPattern(pattern) {
|
|
23760
23801
|
return pattern.startsWith("*.");
|
|
@@ -23767,10 +23808,10 @@ function matchesWildcard(hostname, pattern) {
|
|
|
23767
23808
|
}
|
|
23768
23809
|
|
|
23769
23810
|
// ../rpx/src/host-routes.ts
|
|
23770
|
-
function normalizePathPrefix(
|
|
23771
|
-
if (!
|
|
23811
|
+
function normalizePathPrefix(path4) {
|
|
23812
|
+
if (!path4 || path4 === "/")
|
|
23772
23813
|
return "/";
|
|
23773
|
-
let p2 =
|
|
23814
|
+
let p2 = path4.trim();
|
|
23774
23815
|
if (!p2.startsWith("/"))
|
|
23775
23816
|
p2 = `/${p2}`;
|
|
23776
23817
|
p2 = p2.replace(/\/+$/, "");
|
|
@@ -23797,8 +23838,8 @@ function buildHostRoutes(entries) {
|
|
|
23797
23838
|
const table = new Map;
|
|
23798
23839
|
for (const [host, paths] of byHost) {
|
|
23799
23840
|
const list = [];
|
|
23800
|
-
for (const [
|
|
23801
|
-
list.push({ path:
|
|
23841
|
+
for (const [path4, route] of paths)
|
|
23842
|
+
list.push({ path: path4, route });
|
|
23802
23843
|
list.sort((a2, b2) => b2.path.length - a2.path.length);
|
|
23803
23844
|
table.set(host, list);
|
|
23804
23845
|
}
|
|
@@ -23837,7 +23878,7 @@ var init_host_routes = () => {};
|
|
|
23837
23878
|
|
|
23838
23879
|
// ../rpx/src/sni.ts
|
|
23839
23880
|
import * as fsp from "node:fs/promises";
|
|
23840
|
-
import * as
|
|
23881
|
+
import * as path4 from "node:path";
|
|
23841
23882
|
function serverNameFromCertFilename(filename) {
|
|
23842
23883
|
if (!filename.endsWith(".crt"))
|
|
23843
23884
|
return null;
|
|
@@ -23875,8 +23916,8 @@ async function buildSniTlsConfig(cfg, verbose) {
|
|
|
23875
23916
|
continue;
|
|
23876
23917
|
const base = name.slice(0, -".crt".length);
|
|
23877
23918
|
bySrvName.set(serverName, {
|
|
23878
|
-
certPath:
|
|
23879
|
-
keyPath:
|
|
23919
|
+
certPath: path4.join(cfg.certsDir, name),
|
|
23920
|
+
keyPath: path4.join(cfg.certsDir, `${base}.key`)
|
|
23880
23921
|
});
|
|
23881
23922
|
}
|
|
23882
23923
|
}
|
|
@@ -23898,7 +23939,7 @@ var init_sni = __esm(() => {
|
|
|
23898
23939
|
|
|
23899
23940
|
// ../rpx/src/on-demand.ts
|
|
23900
23941
|
import * as fsp2 from "node:fs/promises";
|
|
23901
|
-
import * as
|
|
23942
|
+
import * as path5 from "node:path";
|
|
23902
23943
|
function matchesAllowedSuffix(host, suffixes) {
|
|
23903
23944
|
if (!suffixes || suffixes.length === 0)
|
|
23904
23945
|
return false;
|
|
@@ -24049,8 +24090,8 @@ class OnDemandCertManager {
|
|
|
24049
24090
|
}
|
|
24050
24091
|
pathsFor(host) {
|
|
24051
24092
|
return {
|
|
24052
|
-
certPath:
|
|
24053
|
-
keyPath:
|
|
24093
|
+
certPath: path5.join(this.certsDir, `${host}.crt`),
|
|
24094
|
+
keyPath: path5.join(this.certsDir, `${host}.key`)
|
|
24054
24095
|
};
|
|
24055
24096
|
}
|
|
24056
24097
|
async persist(host, certPem, keyPem) {
|
|
@@ -24209,10 +24250,10 @@ var init_port_manager = __esm(() => {
|
|
|
24209
24250
|
// ../rpx/src/registry.ts
|
|
24210
24251
|
import * as fsp3 from "node:fs/promises";
|
|
24211
24252
|
import { homedir as homedir9 } from "node:os";
|
|
24212
|
-
import * as
|
|
24253
|
+
import * as path6 from "node:path";
|
|
24213
24254
|
import * as process23 from "node:process";
|
|
24214
24255
|
function getRegistryDir() {
|
|
24215
|
-
return
|
|
24256
|
+
return path6.join(homedir9(), ".stacks", "rpx", "registry.d");
|
|
24216
24257
|
}
|
|
24217
24258
|
function isValidId(id) {
|
|
24218
24259
|
return typeof id === "string" && id.length > 0 && id.length <= 128 && ID_PATTERN.test(id);
|
|
@@ -24220,7 +24261,7 @@ function isValidId(id) {
|
|
|
24220
24261
|
function entryPath(dir, id) {
|
|
24221
24262
|
if (!isValidId(id))
|
|
24222
24263
|
throw new Error(`invalid registry id: ${JSON.stringify(id)}`);
|
|
24223
|
-
return
|
|
24264
|
+
return path6.join(dir, `${id}.json`);
|
|
24224
24265
|
}
|
|
24225
24266
|
function isPidAlive(pid2) {
|
|
24226
24267
|
if (!Number.isInteger(pid2) || pid2 <= 0)
|
|
@@ -24278,11 +24319,11 @@ var init_registry = __esm(() => {
|
|
|
24278
24319
|
});
|
|
24279
24320
|
|
|
24280
24321
|
// ../rpx/src/site-supervisor.ts
|
|
24281
|
-
import { closeSync as closeSync6, openSync as openSync6, readFileSync as
|
|
24322
|
+
import { closeSync as closeSync6, openSync as openSync6, readFileSync as readFileSync4 } from "node:fs";
|
|
24282
24323
|
import * as fsp4 from "node:fs/promises";
|
|
24283
24324
|
import { spawn } from "node:child_process";
|
|
24284
24325
|
import { homedir as homedir10 } from "node:os";
|
|
24285
|
-
import * as
|
|
24326
|
+
import * as path7 from "node:path";
|
|
24286
24327
|
import * as process25 from "node:process";
|
|
24287
24328
|
|
|
24288
24329
|
class SiteSupervisor {
|
|
@@ -24308,7 +24349,7 @@ class SiteSupervisor {
|
|
|
24308
24349
|
constructor(opts) {
|
|
24309
24350
|
this.resolver = opts.resolver;
|
|
24310
24351
|
this.registryDir = opts.registryDir ?? getRegistryDir();
|
|
24311
|
-
this.rpxDir = opts.rpxDir ??
|
|
24352
|
+
this.rpxDir = opts.rpxDir ?? path7.join(homedir10(), ".stacks", "rpx");
|
|
24312
24353
|
this.verbose = opts.verbose ?? false;
|
|
24313
24354
|
this.startupTimeoutMs = opts.startupTimeoutMs ?? DEFAULT_STARTUP_TIMEOUT_MS;
|
|
24314
24355
|
this.pollIntervalMs = opts.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
|
|
@@ -24363,8 +24404,8 @@ class SiteSupervisor {
|
|
|
24363
24404
|
ports.set(route.portEnv, port);
|
|
24364
24405
|
}
|
|
24365
24406
|
}
|
|
24366
|
-
const logPath =
|
|
24367
|
-
await fsp4.mkdir(
|
|
24407
|
+
const logPath = path7.join(this.rpxDir, "sites", `${site.id}.log`);
|
|
24408
|
+
await fsp4.mkdir(path7.dirname(logPath), { recursive: true }).catch(() => {});
|
|
24368
24409
|
const env2 = this.buildEnv(site, ports);
|
|
24369
24410
|
let handle = null;
|
|
24370
24411
|
let startError;
|
|
@@ -24502,7 +24543,7 @@ class SiteSupervisor {
|
|
|
24502
24543
|
}
|
|
24503
24544
|
readLogTail(state, lines = 40) {
|
|
24504
24545
|
try {
|
|
24505
|
-
const text =
|
|
24546
|
+
const text = readFileSync4(state.logPath, "utf8");
|
|
24506
24547
|
return text.split(`
|
|
24507
24548
|
`).slice(-lines).join(`
|
|
24508
24549
|
`).trim();
|
|
@@ -24660,12 +24701,12 @@ var init_site_supervisor = __esm(() => {
|
|
|
24660
24701
|
// ../rpx/src/dns-state.ts
|
|
24661
24702
|
import * as fsp5 from "node:fs/promises";
|
|
24662
24703
|
import { homedir as homedir11 } from "node:os";
|
|
24663
|
-
import * as
|
|
24704
|
+
import * as path8 from "node:path";
|
|
24664
24705
|
function defaultRpxDir() {
|
|
24665
|
-
return
|
|
24706
|
+
return path8.join(homedir11(), ".stacks", "rpx");
|
|
24666
24707
|
}
|
|
24667
24708
|
function getDnsStatePath(rpxDir = defaultRpxDir()) {
|
|
24668
|
-
return
|
|
24709
|
+
return path8.join(rpxDir, RPX_DNS_STATE_FILE);
|
|
24669
24710
|
}
|
|
24670
24711
|
async function loadDnsState(rpxDir = defaultRpxDir()) {
|
|
24671
24712
|
try {
|
|
@@ -24769,7 +24810,7 @@ __export(exports_dns, {
|
|
|
24769
24810
|
});
|
|
24770
24811
|
import dgram from "node:dgram";
|
|
24771
24812
|
import * as fsp6 from "node:fs/promises";
|
|
24772
|
-
import * as
|
|
24813
|
+
import * as path9 from "node:path";
|
|
24773
24814
|
import * as process26 from "node:process";
|
|
24774
24815
|
function parseHeader(buffer) {
|
|
24775
24816
|
return {
|
|
@@ -25004,7 +25045,7 @@ port ${DNS_PORT}
|
|
|
25004
25045
|
`;
|
|
25005
25046
|
}
|
|
25006
25047
|
function resolverFilePath(basename) {
|
|
25007
|
-
return
|
|
25048
|
+
return path9.join(MACOS_RESOLVER_DIR, basename);
|
|
25008
25049
|
}
|
|
25009
25050
|
function contentLooksLikeRpxResolver(content) {
|
|
25010
25051
|
return content.includes("127.0.0.1") && content.includes(String(DNS_PORT));
|
|
@@ -25189,13 +25230,13 @@ var init_dns = __esm(() => {
|
|
|
25189
25230
|
import { spawn as nodeSpawn } from "node:child_process";
|
|
25190
25231
|
import * as fsp7 from "node:fs/promises";
|
|
25191
25232
|
import { homedir as homedir12 } from "node:os";
|
|
25192
|
-
import * as
|
|
25233
|
+
import * as path10 from "node:path";
|
|
25193
25234
|
import * as process27 from "node:process";
|
|
25194
25235
|
function getDaemonRpxDir() {
|
|
25195
|
-
return
|
|
25236
|
+
return path10.join(homedir12(), ".stacks", "rpx");
|
|
25196
25237
|
}
|
|
25197
25238
|
function getDaemonPidPath(rpxDir = getDaemonRpxDir()) {
|
|
25198
|
-
return
|
|
25239
|
+
return path10.join(rpxDir, "daemon.pid");
|
|
25199
25240
|
}
|
|
25200
25241
|
async function readDaemonPid(rpxDir = getDaemonRpxDir()) {
|
|
25201
25242
|
try {
|
|
@@ -25215,7 +25256,7 @@ async function releaseDaemonLock(rpxDir = getDaemonRpxDir()) {
|
|
|
25215
25256
|
}
|
|
25216
25257
|
function defaultDaemonSpawnCommand() {
|
|
25217
25258
|
const exec = process27.execPath;
|
|
25218
|
-
const interpName =
|
|
25259
|
+
const interpName = path10.basename(exec).toLowerCase();
|
|
25219
25260
|
const isInterpreter = interpName === "bun" || interpName === "node" || interpName.startsWith("bun-");
|
|
25220
25261
|
if (isInterpreter && process27.argv[1])
|
|
25221
25262
|
return [exec, process27.argv[1], "daemon:start"];
|
|
@@ -25273,6 +25314,7 @@ var init_daemon = __esm(() => {
|
|
|
25273
25314
|
init_logger();
|
|
25274
25315
|
init_https();
|
|
25275
25316
|
init_proxy_handler();
|
|
25317
|
+
init_acme_challenge();
|
|
25276
25318
|
init_host_routes();
|
|
25277
25319
|
init_sni();
|
|
25278
25320
|
init_on_demand();
|
|
@@ -25314,8 +25356,8 @@ init_daemon();
|
|
|
25314
25356
|
init_logger();
|
|
25315
25357
|
init_registry();
|
|
25316
25358
|
init_utils();
|
|
25317
|
-
import * as
|
|
25318
|
-
import * as
|
|
25359
|
+
import * as fs4 from "node:fs";
|
|
25360
|
+
import * as path11 from "node:path";
|
|
25319
25361
|
import * as process28 from "node:process";
|
|
25320
25362
|
function deriveIdFromTarget(to, routePath) {
|
|
25321
25363
|
const base = routePath && routePath !== "/" ? `${to}${routePath}` : to;
|
|
@@ -25391,7 +25433,7 @@ async function runViaDaemon(opts) {
|
|
|
25391
25433
|
return;
|
|
25392
25434
|
for (const id of idsForCleanup) {
|
|
25393
25435
|
try {
|
|
25394
|
-
|
|
25436
|
+
fs4.unlinkSync(path11.join(dirForCleanup, `${id}.json`));
|
|
25395
25437
|
} catch {}
|
|
25396
25438
|
}
|
|
25397
25439
|
});
|
|
@@ -25401,9 +25443,9 @@ async function runViaDaemon(opts) {
|
|
|
25401
25443
|
// ../rpx/src/hosts.ts
|
|
25402
25444
|
init_utils();
|
|
25403
25445
|
import { exec } from "node:child_process";
|
|
25404
|
-
import
|
|
25446
|
+
import fs5 from "node:fs";
|
|
25405
25447
|
import os2 from "node:os";
|
|
25406
|
-
import
|
|
25448
|
+
import path12 from "node:path";
|
|
25407
25449
|
import * as process29 from "node:process";
|
|
25408
25450
|
import { promisify } from "node:util";
|
|
25409
25451
|
var execAsync = promisify(exec);
|
|
@@ -25411,7 +25453,7 @@ function isLoopbackDevelopmentHost(host) {
|
|
|
25411
25453
|
const normalized = host.trim().toLowerCase();
|
|
25412
25454
|
return normalized === "localhost" || normalized.endsWith(".localhost") || normalized.endsWith(".localhost.");
|
|
25413
25455
|
}
|
|
25414
|
-
var hostsFilePath = process29.platform === "win32" ?
|
|
25456
|
+
var hostsFilePath = process29.platform === "win32" ? path12.join(process29.env.windir || "C:\\Windows", "System32", "drivers", "etc", "hosts") : "/etc/hosts";
|
|
25415
25457
|
var sudoPrivilegesAcquired = false;
|
|
25416
25458
|
async function execSudo(command) {
|
|
25417
25459
|
if (process29.platform === "win32")
|
|
@@ -25460,7 +25502,7 @@ async function addHosts(hosts, verbose) {
|
|
|
25460
25502
|
try {
|
|
25461
25503
|
let existingContent;
|
|
25462
25504
|
try {
|
|
25463
|
-
existingContent = await
|
|
25505
|
+
existingContent = await fs5.promises.readFile(hostsFilePath, "utf-8");
|
|
25464
25506
|
} catch {
|
|
25465
25507
|
debugLog("hosts", "Reading hosts file requires elevated permissions, using sudo", verbose);
|
|
25466
25508
|
try {
|
|
@@ -25485,9 +25527,9 @@ async function addHosts(hosts, verbose) {
|
|
|
25485
25527
|
127.0.0.1 ${host}
|
|
25486
25528
|
::1 ${host}`).join(`
|
|
25487
25529
|
`);
|
|
25488
|
-
const tmpFile =
|
|
25530
|
+
const tmpFile = path12.join(os2.tmpdir(), `rpx-hosts-${Date.now()}.tmp`);
|
|
25489
25531
|
try {
|
|
25490
|
-
await
|
|
25532
|
+
await fs5.promises.writeFile(tmpFile, existingContent + hostEntries, "utf8");
|
|
25491
25533
|
await execSudo(`cat "${tmpFile}" | tee "${hostsFilePath}" > /dev/null`);
|
|
25492
25534
|
console.log(` Hosts updated: ${newEntries.join(", ")}`);
|
|
25493
25535
|
} catch (error) {
|
|
@@ -25500,7 +25542,7 @@ async function addHosts(hosts, verbose) {
|
|
|
25500
25542
|
console.log(` Or run: sudo nano ${hostsFilePath}`);
|
|
25501
25543
|
} finally {
|
|
25502
25544
|
try {
|
|
25503
|
-
await
|
|
25545
|
+
await fs5.promises.unlink(tmpFile);
|
|
25504
25546
|
} catch {}
|
|
25505
25547
|
}
|
|
25506
25548
|
} catch (err) {
|
|
@@ -25513,7 +25555,7 @@ async function removeHosts(hosts, verbose) {
|
|
|
25513
25555
|
try {
|
|
25514
25556
|
let content;
|
|
25515
25557
|
try {
|
|
25516
|
-
content = await
|
|
25558
|
+
content = await fs5.promises.readFile(hostsFilePath, "utf-8");
|
|
25517
25559
|
} catch {
|
|
25518
25560
|
debugLog("hosts", "Reading hosts file requires elevated permissions, using sudo", verbose);
|
|
25519
25561
|
try {
|
|
@@ -25547,16 +25589,16 @@ async function removeHosts(hosts, verbose) {
|
|
|
25547
25589
|
const newContent = `${filteredLines.join(`
|
|
25548
25590
|
`)}
|
|
25549
25591
|
`;
|
|
25550
|
-
const tmpFile =
|
|
25592
|
+
const tmpFile = path12.join(os2.tmpdir(), `rpx-hosts-${Date.now()}.tmp`);
|
|
25551
25593
|
try {
|
|
25552
|
-
await
|
|
25594
|
+
await fs5.promises.writeFile(tmpFile, newContent, "utf8");
|
|
25553
25595
|
await execSudo(`cat "${tmpFile}" | tee "${hostsFilePath}" > /dev/null`);
|
|
25554
25596
|
debugLog("hosts", "Hosts removed successfully", verbose);
|
|
25555
25597
|
} catch (error) {
|
|
25556
25598
|
debugLog("hosts", "Could not clean up hosts file automatically", verbose);
|
|
25557
25599
|
} finally {
|
|
25558
25600
|
try {
|
|
25559
|
-
await
|
|
25601
|
+
await fs5.promises.unlink(tmpFile);
|
|
25560
25602
|
} catch (unlinkErr) {
|
|
25561
25603
|
debugLog("hosts", `Failed to remove temporary file: ${unlinkErr}`, verbose);
|
|
25562
25604
|
}
|
|
@@ -25569,7 +25611,7 @@ async function checkHosts(hosts, verbose) {
|
|
|
25569
25611
|
debugLog("hosts", `Checking hosts: ${hosts}`, verbose);
|
|
25570
25612
|
let content;
|
|
25571
25613
|
try {
|
|
25572
|
-
content = await
|
|
25614
|
+
content = await fs5.promises.readFile(hostsFilePath, "utf-8");
|
|
25573
25615
|
} catch (readErr) {
|
|
25574
25616
|
debugLog("hosts", `Error reading hosts file: ${readErr}`, verbose);
|
|
25575
25617
|
try {
|
|
@@ -25782,25 +25824,7 @@ function createOriginGuard(options) {
|
|
|
25782
25824
|
|
|
25783
25825
|
// ../rpx/src/start.ts
|
|
25784
25826
|
init_proxy_handler();
|
|
25785
|
-
|
|
25786
|
-
// ../rpx/src/acme-challenge.ts
|
|
25787
|
-
import * as fs5 from "node:fs";
|
|
25788
|
-
import * as path12 from "node:path";
|
|
25789
|
-
var ACME_CHALLENGE_PREFIX2 = "/.well-known/acme-challenge/";
|
|
25790
|
-
function readAcmeChallenge(webroot, pathname) {
|
|
25791
|
-
if (!webroot || !pathname.startsWith(ACME_CHALLENGE_PREFIX2))
|
|
25792
|
-
return null;
|
|
25793
|
-
const token = pathname.slice(ACME_CHALLENGE_PREFIX2.length);
|
|
25794
|
-
if (!token || !/^[A-Za-z0-9_-]+$/.test(token))
|
|
25795
|
-
return null;
|
|
25796
|
-
try {
|
|
25797
|
-
return fs5.readFileSync(path12.join(webroot, token), "utf8");
|
|
25798
|
-
} catch {
|
|
25799
|
-
return null;
|
|
25800
|
-
}
|
|
25801
|
-
}
|
|
25802
|
-
|
|
25803
|
-
// ../rpx/src/start.ts
|
|
25827
|
+
init_acme_challenge();
|
|
25804
25828
|
init_auth();
|
|
25805
25829
|
init_host_routes();
|
|
25806
25830
|
init_sni();
|
|
@@ -26632,6 +26656,7 @@ init_dns();
|
|
|
26632
26656
|
init_dns_state();
|
|
26633
26657
|
init_daemon();
|
|
26634
26658
|
init_proxy_handler();
|
|
26659
|
+
init_acme_challenge();
|
|
26635
26660
|
init_auth();
|
|
26636
26661
|
init_host_routes();
|
|
26637
26662
|
init_static_files();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-rpx",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.23",
|
|
5
5
|
"description": "A modern and smart reverse proxy. Vite plugin.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"typecheck": "bunx tsc --noEmit"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@stacksjs/rpx": "0.11.
|
|
50
|
+
"@stacksjs/rpx": "0.11.23",
|
|
51
51
|
"@stacksjs/tlsx": "^0.13.9"
|
|
52
52
|
},
|
|
53
53
|
"simple-git-hooks": {
|