unplugin-https-reverse-proxy 1.0.0 → 2.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/README.md +6 -2
- package/dist/{chunk-2VGRJ3QS.js → chunk-2P7SUCQ3.js} +23 -5
- package/dist/{chunk-KVE7AVSI.js → chunk-DKHKFLLC.js} +89 -23
- package/dist/esbuild.cjs +125 -43
- package/dist/esbuild.js +2 -2
- package/dist/index.cjs +125 -43
- package/dist/index.js +2 -2
- package/dist/nuxt.cjs +116 -42
- package/dist/nuxt.d.cts +1 -1
- package/dist/nuxt.d.ts +1 -1
- package/dist/nuxt.js +6 -2
- package/dist/rollup.cjs +125 -43
- package/dist/rollup.js +2 -2
- package/dist/rspack.cjs +125 -43
- package/dist/rspack.js +2 -2
- package/dist/utils.cjs +24 -4
- package/dist/utils.d.cts +6 -4
- package/dist/utils.d.ts +6 -4
- package/dist/utils.js +5 -1
- package/dist/vite.cjs +125 -43
- package/dist/vite.d.cts +2 -1
- package/dist/vite.d.ts +2 -1
- package/dist/vite.js +2 -2
- package/dist/webpack.cjs +125 -43
- package/dist/webpack.js +2 -2
- package/package.json +29 -26
- package/scripts/postinstall.cjs +30 -24
- package/src/caddy/constants.ts +2 -2
- package/src/caddy/index.ts +41 -20
- package/src/caddy/utils.ts +9 -9
- package/src/host/index.ts +9 -8
- package/src/index.ts +63 -10
- package/src/nuxt.ts +8 -3
- package/src/utils.ts +33 -6
package/dist/webpack.cjs
CHANGED
|
@@ -37,15 +37,38 @@ var import_unplugin2 = require("unplugin");
|
|
|
37
37
|
|
|
38
38
|
// src/index.ts
|
|
39
39
|
var import_node_process5 = __toESM(require("process"), 1);
|
|
40
|
+
var import_console_table_printer = require("console-table-printer");
|
|
41
|
+
var import_picocolors2 = __toESM(require("picocolors"), 1);
|
|
40
42
|
var import_unplugin = require("unplugin");
|
|
41
|
-
|
|
43
|
+
|
|
44
|
+
// src/caddy/index.ts
|
|
45
|
+
var import_node_child_process4 = require("child_process");
|
|
46
|
+
var import_node_fs2 = require("fs");
|
|
47
|
+
var import_promises2 = require("fs/promises");
|
|
48
|
+
var import_node_os3 = require("os");
|
|
49
|
+
var import_node_path3 = require("path");
|
|
50
|
+
var import_node_process4 = __toESM(require("process"), 1);
|
|
51
|
+
var import_got_cjs = require("got-cjs");
|
|
52
|
+
var import_http_proxy_agent = require("http-proxy-agent");
|
|
53
|
+
var import_https_proxy_agent = require("https-proxy-agent");
|
|
54
|
+
var lockfile = __toESM(require("proper-lockfile"), 1);
|
|
55
|
+
|
|
56
|
+
// src/host/index.ts
|
|
57
|
+
var import_node_child_process2 = require("child_process");
|
|
58
|
+
var import_node_fs = require("fs");
|
|
59
|
+
var import_node_process2 = __toESM(require("process"), 1);
|
|
60
|
+
var import_node_util = require("util");
|
|
61
|
+
var import_hostile = __toESM(require("hostile"), 1);
|
|
42
62
|
|
|
43
63
|
// src/utils.ts
|
|
44
|
-
var import_node_process = __toESM(require("process"), 1);
|
|
45
|
-
var import_node_path = __toESM(require("path"), 1);
|
|
46
|
-
var import_promises = require("fs/promises");
|
|
47
64
|
var import_node_child_process = require("child_process");
|
|
65
|
+
var import_promises = require("fs/promises");
|
|
66
|
+
var import_node_os = require("os");
|
|
67
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
68
|
+
var import_node_process = __toESM(require("process"), 1);
|
|
48
69
|
var import_consola = require("consola");
|
|
70
|
+
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
71
|
+
var import_qrcode_terminal = __toESM(require("qrcode-terminal"), 1);
|
|
49
72
|
var consola = (0, import_consola.createConsola)({
|
|
50
73
|
level: 3
|
|
51
74
|
}).withTag("reverse-proxy");
|
|
@@ -75,37 +98,34 @@ function isAdmin() {
|
|
|
75
98
|
return false;
|
|
76
99
|
}
|
|
77
100
|
} else {
|
|
78
|
-
return import_node_process.default.getuid && import_node_process.default.getuid() === 0;
|
|
101
|
+
return !!(import_node_process.default.getuid && import_node_process.default.getuid() === 0);
|
|
79
102
|
}
|
|
80
103
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
104
|
+
function getIpv4List() {
|
|
105
|
+
const interfaces = (0, import_node_os.networkInterfaces)();
|
|
106
|
+
return Object.values(interfaces).flatMap((nInterface) => nInterface ?? []).filter(
|
|
107
|
+
(detail) => detail.address && (detail.family === "IPv4" || detail.family === 4)
|
|
108
|
+
).filter((detail) => detail.family === "IPv4" && !detail.internal).map((detail) => detail.address);
|
|
109
|
+
}
|
|
110
|
+
async function generateQrcode(input) {
|
|
111
|
+
return new Promise((resolve) => {
|
|
112
|
+
import_qrcode_terminal.default.generate(input, { small: true }, (code) => {
|
|
113
|
+
resolve(code.split("\n").map((line) => import_picocolors.default.bgBlack(import_picocolors.default.white(line))).join("\n"));
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
}
|
|
92
117
|
|
|
93
118
|
// src/host/index.ts
|
|
94
|
-
var import_node_process2 = __toESM(require("process"), 1);
|
|
95
|
-
var import_node_child_process2 = require("child_process");
|
|
96
|
-
var import_node_fs = require("fs");
|
|
97
|
-
var import_node_util = require("util");
|
|
98
|
-
var import_hostile = __toESM(require("hostile"), 1);
|
|
99
119
|
var _setHost = (0, import_node_util.promisify)(import_hostile.default.set);
|
|
100
120
|
var _removeHost = (0, import_node_util.promisify)(import_hostile.default.remove);
|
|
101
121
|
function getPathOfSystemHostsPath() {
|
|
102
122
|
return import_node_process2.default.platform === "win32" ? `${import_node_process2.default.env.windir || "C:\\WINDOWS"}\\system32\\drivers\\etc\\hosts` : "/etc/hosts";
|
|
103
123
|
}
|
|
104
124
|
async function syncHost() {
|
|
105
|
-
return new Promise((resolve,
|
|
125
|
+
return new Promise((resolve, _reject) => {
|
|
106
126
|
(0, import_node_child_process2.exec)(
|
|
107
127
|
import_node_process2.default.platform === "win32" ? "ipconfig /flushdns" : "sudo -E killall -HUP mDNSResponder",
|
|
108
|
-
(error,
|
|
128
|
+
(error, _stdout, _stderr) => {
|
|
109
129
|
if (error) {
|
|
110
130
|
consola.error(`exec error: ${error}`);
|
|
111
131
|
return resolve(false);
|
|
@@ -134,8 +154,8 @@ async function removeHost(ip, host) {
|
|
|
134
154
|
}
|
|
135
155
|
|
|
136
156
|
// src/caddy/constants.ts
|
|
157
|
+
var import_node_os2 = __toESM(require("os"), 1);
|
|
137
158
|
var import_node_path2 = require("path");
|
|
138
|
-
var import_node_os = __toESM(require("os"), 1);
|
|
139
159
|
var import_node_process3 = __toESM(require("process"), 1);
|
|
140
160
|
var import_dotenv_flow = __toESM(require("dotenv-flow"), 1);
|
|
141
161
|
import_dotenv_flow.default.config({
|
|
@@ -143,7 +163,7 @@ import_dotenv_flow.default.config({
|
|
|
143
163
|
});
|
|
144
164
|
function resolvePath(path2) {
|
|
145
165
|
if (path2.startsWith("~"))
|
|
146
|
-
return (0, import_node_path2.join)(
|
|
166
|
+
return (0, import_node_path2.join)(import_node_os2.default.homedir() || "", path2.slice(1));
|
|
147
167
|
return path2;
|
|
148
168
|
}
|
|
149
169
|
var TEMP_DIR = resolvePath(import_node_process3.default.env.UHRP_CADDY_PATH || import_node_process3.default.env.TEMP || import_node_process3.default.env.TMPDIR || "/tmp");
|
|
@@ -262,12 +282,12 @@ var supportList = [
|
|
|
262
282
|
];
|
|
263
283
|
|
|
264
284
|
// src/caddy/utils.ts
|
|
265
|
-
var import_node_net = require("net");
|
|
266
285
|
var import_node_child_process3 = require("child_process");
|
|
286
|
+
var import_node_net = require("net");
|
|
267
287
|
var import_ora = __toESM(require("ora"), 1);
|
|
268
288
|
var spinner;
|
|
269
289
|
function tryPort(port) {
|
|
270
|
-
return new Promise((resolve,
|
|
290
|
+
return new Promise((resolve, _reject) => {
|
|
271
291
|
try {
|
|
272
292
|
const server = (0, import_node_net.createServer)().listen(port);
|
|
273
293
|
server.on("listening", () => {
|
|
@@ -279,14 +299,14 @@ function tryPort(port) {
|
|
|
279
299
|
resolve(true);
|
|
280
300
|
server.close();
|
|
281
301
|
});
|
|
282
|
-
} catch
|
|
302
|
+
} catch {
|
|
283
303
|
resolve(true);
|
|
284
304
|
}
|
|
285
305
|
});
|
|
286
306
|
}
|
|
287
307
|
async function kill(port) {
|
|
288
308
|
return new Promise((resolve, reject) => {
|
|
289
|
-
(0, import_node_child_process3.exec)(`npx @maxbo/free-port ${port} -s`, (err, stdout,
|
|
309
|
+
(0, import_node_child_process3.exec)(`npx @maxbo/free-port ${port} -s`, (err, stdout, _stderr) => {
|
|
290
310
|
if (err) {
|
|
291
311
|
reject(err);
|
|
292
312
|
} else {
|
|
@@ -339,14 +359,14 @@ async function download() {
|
|
|
339
359
|
(0, import_node_fs2.chmodSync)(TEMP_DIR, 511);
|
|
340
360
|
}
|
|
341
361
|
const file = (0, import_node_fs2.createWriteStream)(caddyPath);
|
|
342
|
-
let _platform = (0,
|
|
362
|
+
let _platform = (0, import_node_os3.platform)().toString();
|
|
343
363
|
_platform === "win32" && (_platform = "windows");
|
|
344
364
|
let _arch = import_node_process4.default.arch.toString();
|
|
345
365
|
_arch === "x64" && (_arch = "amd64");
|
|
346
366
|
const support = supportList.find((item) => item.platform === _platform && item.arch === _arch);
|
|
347
367
|
if (!support)
|
|
348
368
|
return reject(new Error("not support"));
|
|
349
|
-
const dowmloadLink = `https://caddyserver.com/api/download?os=${support.platform}&arch=${support.arch}`;
|
|
369
|
+
const dowmloadLink = `https://caddyserver.com/api/download?os=${support.platform}&arch=${support.arch}&p=github.com%2Fcaddyserver%2Fforwardproxy`;
|
|
350
370
|
(0, import_node_fs2.existsSync)(caddyPath) && (0, import_node_fs2.unlinkSync)(caddyPath);
|
|
351
371
|
const httpProxy = import_node_process4.default.env.HTTP_PROXY || import_node_process4.default.env.http_proxy;
|
|
352
372
|
const httpsProxy = import_node_process4.default.env.HTTPS_PROXY || import_node_process4.default.env.https_proxy;
|
|
@@ -420,7 +440,27 @@ var CaddyInstant = class {
|
|
|
420
440
|
debug
|
|
421
441
|
auto_https disable_redirects
|
|
422
442
|
}
|
|
423
|
-
|
|
443
|
+
|
|
444
|
+
:7601 {
|
|
445
|
+
root * "${(0, import_node_path3.join)(
|
|
446
|
+
import_node_process4.default.platform === "win32" ? `${import_node_process4.default.env.AppData}/Caddy` : `${import_node_process4.default.env.HOME}/Library/Application Support/Caddy`,
|
|
447
|
+
"./pki/authorities/local"
|
|
448
|
+
)}"
|
|
449
|
+
file_server browse
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
# \u6B63\u5411\u4EE3\u7406\u914D\u7F6E
|
|
453
|
+
:7600 {
|
|
454
|
+
bind 0.0.0.0
|
|
455
|
+
|
|
456
|
+
forward_proxy {
|
|
457
|
+
hide_ip
|
|
458
|
+
hide_via
|
|
459
|
+
acl {
|
|
460
|
+
allow all
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
424
464
|
`;
|
|
425
465
|
await (0, import_promises2.writeFile)(caddyFilePath, contet);
|
|
426
466
|
this.caddyfile = contet;
|
|
@@ -438,7 +478,6 @@ var CaddyInstant = class {
|
|
|
438
478
|
/**
|
|
439
479
|
* @param source like `127.0.0.1:8080`
|
|
440
480
|
* @param target like `test.abc.com`. And if you provide a port ,it will be ignore.
|
|
441
|
-
* @returns
|
|
442
481
|
*/
|
|
443
482
|
async run(source, target, options) {
|
|
444
483
|
source = source.replace("0.0.0.0", "127.0.0.1");
|
|
@@ -483,7 +522,6 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
|
|
|
483
522
|
}
|
|
484
523
|
}
|
|
485
524
|
}
|
|
486
|
-
|
|
487
525
|
`;
|
|
488
526
|
await this.writeCaddyfile();
|
|
489
527
|
}
|
|
@@ -617,6 +655,38 @@ ${line}
|
|
|
617
655
|
var config;
|
|
618
656
|
var caddy;
|
|
619
657
|
var cwd = import_node_process5.default.cwd();
|
|
658
|
+
function colorUrl(url) {
|
|
659
|
+
return import_picocolors2.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors2.default.bold(port)}/`));
|
|
660
|
+
}
|
|
661
|
+
async function printForwardProxy() {
|
|
662
|
+
const ipv4List = getIpv4List();
|
|
663
|
+
if (ipv4List.length) {
|
|
664
|
+
const ips = ipv4List.map((ip) => import_picocolors2.default.cyan(ip)).join(", ");
|
|
665
|
+
consola.info(`${import_picocolors2.default.bold("Mobile device proxy access")}:
|
|
666
|
+
`);
|
|
667
|
+
consola.info("1. Install certificate: scan the QR code and download the `root.crt` file,");
|
|
668
|
+
consola.info(" then install it on your mobile device");
|
|
669
|
+
const ipTable = await Promise.all(
|
|
670
|
+
ipv4List.map(async (ip) => ({
|
|
671
|
+
target: `http://${ip}:7601`,
|
|
672
|
+
certificate: await generateQrcode(`http://${ip}:7601`)
|
|
673
|
+
}))
|
|
674
|
+
);
|
|
675
|
+
const table = new import_console_table_printer.Table({
|
|
676
|
+
columns: [
|
|
677
|
+
{ name: "target", alignment: "left" },
|
|
678
|
+
{ name: "certificate", alignment: "center", minLen: 28 }
|
|
679
|
+
]
|
|
680
|
+
});
|
|
681
|
+
ipTable.forEach((ip) => {
|
|
682
|
+
table.addRow(ip);
|
|
683
|
+
});
|
|
684
|
+
table.printTable();
|
|
685
|
+
consola.info(`2. Set proxy on mobile device (Available IPs: ${ips}):${import_picocolors2.default.bold(7600)}
|
|
686
|
+
|
|
687
|
+
`);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
620
690
|
var vitePrintUrls = once((options, source, target, base = "/", _printUrls) => {
|
|
621
691
|
_printUrls == null ? void 0 : _printUrls();
|
|
622
692
|
if (caddy)
|
|
@@ -625,9 +695,9 @@ var vitePrintUrls = once((options, source, target, base = "/", _printUrls) => {
|
|
|
625
695
|
caddy.run(source, target, {
|
|
626
696
|
base,
|
|
627
697
|
...options
|
|
628
|
-
}).then(() => {
|
|
629
|
-
|
|
630
|
-
consola.success(` ${
|
|
698
|
+
}).then(async () => {
|
|
699
|
+
await printForwardProxy();
|
|
700
|
+
consola.success(` ${import_picocolors2.default.green("\u279C")} ${import_picocolors2.default.bold("run caddy reverse proxy success")}: ${colorUrl(`${options.https ? "https" : "http"}://${target}${base}`)}`);
|
|
631
701
|
}).catch((e) => {
|
|
632
702
|
throw e;
|
|
633
703
|
});
|
|
@@ -657,6 +727,10 @@ var unpluginFactory = (options) => ({
|
|
|
657
727
|
consola.fail("please provide target");
|
|
658
728
|
return;
|
|
659
729
|
}
|
|
730
|
+
if (target.match(/^(?:https?)?:\/\//)) {
|
|
731
|
+
consola.fail("target must be a domain");
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
660
734
|
const _printUrls = server.printUrls.bind(server);
|
|
661
735
|
let source = `localhost:${config.server.port || 5173}`;
|
|
662
736
|
const url = (_a = server.resolvedUrls) == null ? void 0 : _a.local[0];
|
|
@@ -686,6 +760,10 @@ var unpluginFactory = (options) => ({
|
|
|
686
760
|
consola.fail("please provide target");
|
|
687
761
|
return;
|
|
688
762
|
}
|
|
763
|
+
if (target.match(/^(?:https?)?:\/\//)) {
|
|
764
|
+
consola.fail("target must be a domain");
|
|
765
|
+
return;
|
|
766
|
+
}
|
|
689
767
|
const devServer = {
|
|
690
768
|
host: "localhost",
|
|
691
769
|
port: 8080,
|
|
@@ -710,9 +788,9 @@ var unpluginFactory = (options) => ({
|
|
|
710
788
|
caddy.run(source, target, {
|
|
711
789
|
...options
|
|
712
790
|
}).then(() => {
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
consola.success(` ${
|
|
791
|
+
compiler.hooks.done.tap("unplugin-https-reverse-proxy", async () => {
|
|
792
|
+
await printForwardProxy();
|
|
793
|
+
consola.success(` ${import_picocolors2.default.green("\u279C")} ${import_picocolors2.default.bold("run caddy reverse proxy success")}: ${colorUrl(`${options.https ? "https" : "http"}://${target}`)}`);
|
|
716
794
|
});
|
|
717
795
|
}).catch((e) => {
|
|
718
796
|
throw e;
|
|
@@ -736,6 +814,10 @@ var unpluginFactory = (options) => ({
|
|
|
736
814
|
consola.fail("please provide target");
|
|
737
815
|
return;
|
|
738
816
|
}
|
|
817
|
+
if (target.match(/^(?:https?)?:\/\//)) {
|
|
818
|
+
consola.fail("target must be a domain");
|
|
819
|
+
return;
|
|
820
|
+
}
|
|
739
821
|
const devServer = {
|
|
740
822
|
host: "localhost",
|
|
741
823
|
port: 8080,
|
|
@@ -750,9 +832,9 @@ var unpluginFactory = (options) => ({
|
|
|
750
832
|
caddy = new CaddyInstant();
|
|
751
833
|
caddy.run(source, target, {
|
|
752
834
|
...options
|
|
753
|
-
}).then(() => {
|
|
754
|
-
|
|
755
|
-
consola.success(` ${
|
|
835
|
+
}).then(async () => {
|
|
836
|
+
await printForwardProxy();
|
|
837
|
+
consola.success(` ${import_picocolors2.default.green("\u279C")} ${import_picocolors2.default.bold("run caddy reverse proxy success")}: ${colorUrl(`${options.https ? "https" : "http"}://${target}`)}`);
|
|
756
838
|
}).catch((e) => {
|
|
757
839
|
throw e;
|
|
758
840
|
});
|
package/dist/webpack.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-https-reverse-proxy",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.1",
|
|
5
5
|
"description": "",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/zcf0508/unplugin-https-reverse-proxy#readme",
|
|
@@ -90,67 +90,70 @@
|
|
|
90
90
|
"webpack": "^4 || ^5"
|
|
91
91
|
},
|
|
92
92
|
"peerDependenciesMeta": {
|
|
93
|
-
"
|
|
93
|
+
"@nuxt/kit": {
|
|
94
94
|
"optional": true
|
|
95
95
|
},
|
|
96
|
-
"@
|
|
96
|
+
"@nuxt/schema": {
|
|
97
97
|
"optional": true
|
|
98
98
|
},
|
|
99
99
|
"@rsbuild/core": {
|
|
100
100
|
"optional": true
|
|
101
101
|
},
|
|
102
|
-
"
|
|
102
|
+
"@rspack/core": {
|
|
103
103
|
"optional": true
|
|
104
104
|
},
|
|
105
|
-
"
|
|
105
|
+
"esbuild": {
|
|
106
106
|
"optional": true
|
|
107
107
|
},
|
|
108
|
-
"
|
|
108
|
+
"rollup": {
|
|
109
109
|
"optional": true
|
|
110
110
|
},
|
|
111
|
-
"
|
|
111
|
+
"vite": {
|
|
112
112
|
"optional": true
|
|
113
113
|
},
|
|
114
|
-
"
|
|
114
|
+
"webpack": {
|
|
115
115
|
"optional": true
|
|
116
116
|
}
|
|
117
117
|
},
|
|
118
118
|
"dependencies": {
|
|
119
|
-
"consola": "^3.2
|
|
119
|
+
"consola": "^3.4.2",
|
|
120
|
+
"console-table-printer": "^2.12.1",
|
|
120
121
|
"dotenv-flow": "^4.1.0",
|
|
121
122
|
"got-cjs": "^12.5.4",
|
|
122
123
|
"hostile": "^1.4.0",
|
|
123
124
|
"http-proxy-agent": "^7.0.2",
|
|
124
|
-
"https-proxy-agent": "^7.0.
|
|
125
|
+
"https-proxy-agent": "^7.0.6",
|
|
125
126
|
"ora": "5",
|
|
126
|
-
"picocolors": "^1.
|
|
127
|
-
"
|
|
128
|
-
"unplugin": "^
|
|
127
|
+
"picocolors": "^1.1.1",
|
|
128
|
+
"qrcode-terminal": "^0.12.0",
|
|
129
|
+
"unplugin": "^2.2.0"
|
|
129
130
|
},
|
|
130
131
|
"devDependencies": {
|
|
131
|
-
"@antfu/eslint-config": "^
|
|
132
|
-
"@nuxt/kit": "^3.
|
|
133
|
-
"@nuxt/schema": "^3.
|
|
134
|
-
"@rsbuild/core": "^0.4.
|
|
135
|
-
"@rspack/core": "^0.5.
|
|
132
|
+
"@antfu/eslint-config": "^4.10.2",
|
|
133
|
+
"@nuxt/kit": "^3.16.1",
|
|
134
|
+
"@nuxt/schema": "^3.16.1",
|
|
135
|
+
"@rsbuild/core": "^0.4.15",
|
|
136
|
+
"@rspack/core": "^0.5.9",
|
|
136
137
|
"@types/hostile": "^1.3.5",
|
|
137
138
|
"@types/kill-port": "^2.0.3",
|
|
138
139
|
"@types/node": "^20.11.19",
|
|
139
140
|
"@types/proper-lockfile": "^4.1.4",
|
|
141
|
+
"@types/qrcode-terminal": "^0.12.2",
|
|
140
142
|
"@vue/cli": "^5.0.8",
|
|
141
|
-
"bumpp": "^9.
|
|
142
|
-
"chalk": "^5.
|
|
143
|
+
"bumpp": "^9.11.1",
|
|
144
|
+
"chalk": "^5.4.1",
|
|
143
145
|
"cross-env": "^7.0.3",
|
|
144
|
-
"eslint": "^
|
|
145
|
-
"fast-glob": "^3.3.
|
|
146
|
-
"nodemon": "^3.
|
|
146
|
+
"eslint": "^9.20.0",
|
|
147
|
+
"fast-glob": "^3.3.3",
|
|
148
|
+
"nodemon": "^3.1.9",
|
|
147
149
|
"proper-lockfile": "^4.1.2",
|
|
148
|
-
"rimraf": "^5.0.
|
|
150
|
+
"rimraf": "^5.0.10",
|
|
149
151
|
"rollup": "^3.29.4",
|
|
150
152
|
"tsup": "^7.3.0",
|
|
151
|
-
"
|
|
153
|
+
"tsx": "^4.19.3",
|
|
154
|
+
"typescript": "^5.8.0",
|
|
152
155
|
"vite": "^4.5.2",
|
|
153
|
-
"vitest": "^
|
|
156
|
+
"vitest": "^3.0.9",
|
|
154
157
|
"webpack": "^5.90.3"
|
|
155
158
|
},
|
|
156
159
|
"scripts": {
|
package/scripts/postinstall.cjs
CHANGED
|
@@ -26,12 +26,34 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
var import_node_fs3 = require("fs");
|
|
27
27
|
var import_node_process5 = __toESM(require("process"), 1);
|
|
28
28
|
|
|
29
|
+
// src/caddy/index.ts
|
|
30
|
+
var import_node_child_process4 = require("child_process");
|
|
31
|
+
var import_node_fs2 = require("fs");
|
|
32
|
+
var import_promises2 = require("fs/promises");
|
|
33
|
+
var import_node_os3 = require("os");
|
|
34
|
+
var import_node_path3 = require("path");
|
|
35
|
+
var import_node_process4 = __toESM(require("process"), 1);
|
|
36
|
+
var import_got_cjs = require("got-cjs");
|
|
37
|
+
var import_http_proxy_agent = require("http-proxy-agent");
|
|
38
|
+
var import_https_proxy_agent = require("https-proxy-agent");
|
|
39
|
+
var lockfile = __toESM(require("proper-lockfile"), 1);
|
|
40
|
+
|
|
41
|
+
// src/host/index.ts
|
|
42
|
+
var import_node_child_process2 = require("child_process");
|
|
43
|
+
var import_node_fs = require("fs");
|
|
44
|
+
var import_node_process2 = __toESM(require("process"), 1);
|
|
45
|
+
var import_node_util = require("util");
|
|
46
|
+
var import_hostile = __toESM(require("hostile"), 1);
|
|
47
|
+
|
|
29
48
|
// src/utils.ts
|
|
30
|
-
var import_node_process = __toESM(require("process"), 1);
|
|
31
|
-
var import_node_path = __toESM(require("path"), 1);
|
|
32
|
-
var import_promises = require("fs/promises");
|
|
33
49
|
var import_node_child_process = require("child_process");
|
|
50
|
+
var import_promises = require("fs/promises");
|
|
51
|
+
var import_node_os = require("os");
|
|
52
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
53
|
+
var import_node_process = __toESM(require("process"), 1);
|
|
34
54
|
var import_consola = require("consola");
|
|
55
|
+
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
56
|
+
var import_qrcode_terminal = __toESM(require("qrcode-terminal"), 1);
|
|
35
57
|
var consola = (0, import_consola.createConsola)({
|
|
36
58
|
level: 3
|
|
37
59
|
}).withTag("reverse-proxy");
|
|
@@ -45,29 +67,13 @@ function once(fn) {
|
|
|
45
67
|
};
|
|
46
68
|
}
|
|
47
69
|
|
|
48
|
-
// src/caddy/index.ts
|
|
49
|
-
var import_node_os2 = require("os");
|
|
50
|
-
var import_node_process4 = __toESM(require("process"), 1);
|
|
51
|
-
var import_node_fs2 = require("fs");
|
|
52
|
-
var import_node_child_process4 = require("child_process");
|
|
53
|
-
var import_promises2 = require("fs/promises");
|
|
54
|
-
var import_got_cjs = require("got-cjs");
|
|
55
|
-
var import_http_proxy_agent = require("http-proxy-agent");
|
|
56
|
-
var import_https_proxy_agent = require("https-proxy-agent");
|
|
57
|
-
var lockfile = __toESM(require("proper-lockfile"), 1);
|
|
58
|
-
|
|
59
70
|
// src/host/index.ts
|
|
60
|
-
var import_node_process2 = __toESM(require("process"), 1);
|
|
61
|
-
var import_node_child_process2 = require("child_process");
|
|
62
|
-
var import_node_fs = require("fs");
|
|
63
|
-
var import_node_util = require("util");
|
|
64
|
-
var import_hostile = __toESM(require("hostile"), 1);
|
|
65
71
|
var _setHost = (0, import_node_util.promisify)(import_hostile.default.set);
|
|
66
72
|
var _removeHost = (0, import_node_util.promisify)(import_hostile.default.remove);
|
|
67
73
|
|
|
68
74
|
// src/caddy/constants.ts
|
|
75
|
+
var import_node_os2 = __toESM(require("os"), 1);
|
|
69
76
|
var import_node_path2 = require("path");
|
|
70
|
-
var import_node_os = __toESM(require("os"), 1);
|
|
71
77
|
var import_node_process3 = __toESM(require("process"), 1);
|
|
72
78
|
var import_dotenv_flow = __toESM(require("dotenv-flow"), 1);
|
|
73
79
|
import_dotenv_flow.default.config({
|
|
@@ -75,7 +81,7 @@ import_dotenv_flow.default.config({
|
|
|
75
81
|
});
|
|
76
82
|
function resolvePath(path2) {
|
|
77
83
|
if (path2.startsWith("~"))
|
|
78
|
-
return (0, import_node_path2.join)(
|
|
84
|
+
return (0, import_node_path2.join)(import_node_os2.default.homedir() || "", path2.slice(1));
|
|
79
85
|
return path2;
|
|
80
86
|
}
|
|
81
87
|
var TEMP_DIR = resolvePath(import_node_process3.default.env.UHRP_CADDY_PATH || import_node_process3.default.env.TEMP || import_node_process3.default.env.TMPDIR || "/tmp");
|
|
@@ -194,8 +200,8 @@ var supportList = [
|
|
|
194
200
|
];
|
|
195
201
|
|
|
196
202
|
// src/caddy/utils.ts
|
|
197
|
-
var import_node_net = require("net");
|
|
198
203
|
var import_node_child_process3 = require("child_process");
|
|
204
|
+
var import_node_net = require("net");
|
|
199
205
|
var import_ora = __toESM(require("ora"), 1);
|
|
200
206
|
var spinner;
|
|
201
207
|
function getNumber(number) {
|
|
@@ -241,14 +247,14 @@ async function download() {
|
|
|
241
247
|
(0, import_node_fs2.chmodSync)(TEMP_DIR, 511);
|
|
242
248
|
}
|
|
243
249
|
const file = (0, import_node_fs2.createWriteStream)(caddyPath);
|
|
244
|
-
let _platform = (0,
|
|
250
|
+
let _platform = (0, import_node_os3.platform)().toString();
|
|
245
251
|
_platform === "win32" && (_platform = "windows");
|
|
246
252
|
let _arch = import_node_process4.default.arch.toString();
|
|
247
253
|
_arch === "x64" && (_arch = "amd64");
|
|
248
254
|
const support = supportList.find((item) => item.platform === _platform && item.arch === _arch);
|
|
249
255
|
if (!support)
|
|
250
256
|
return reject(new Error("not support"));
|
|
251
|
-
const dowmloadLink = `https://caddyserver.com/api/download?os=${support.platform}&arch=${support.arch}`;
|
|
257
|
+
const dowmloadLink = `https://caddyserver.com/api/download?os=${support.platform}&arch=${support.arch}&p=github.com%2Fcaddyserver%2Fforwardproxy`;
|
|
252
258
|
(0, import_node_fs2.existsSync)(caddyPath) && (0, import_node_fs2.unlinkSync)(caddyPath);
|
|
253
259
|
const httpProxy = import_node_process4.default.env.HTTP_PROXY || import_node_process4.default.env.http_proxy;
|
|
254
260
|
const httpsProxy = import_node_process4.default.env.HTTPS_PROXY || import_node_process4.default.env.https_proxy;
|
package/src/caddy/constants.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { join } from 'node:path'
|
|
2
1
|
import os from 'node:os'
|
|
2
|
+
import { join } from 'node:path'
|
|
3
3
|
import process from 'node:process'
|
|
4
4
|
import dotenvFlow from 'dotenv-flow'
|
|
5
5
|
|
|
@@ -7,7 +7,7 @@ dotenvFlow.config({
|
|
|
7
7
|
silent: true,
|
|
8
8
|
})
|
|
9
9
|
|
|
10
|
-
function resolvePath(path: string) {
|
|
10
|
+
function resolvePath(path: string): string {
|
|
11
11
|
if (path.startsWith('~'))
|
|
12
12
|
return join(os.homedir() || '', path.slice(1))
|
|
13
13
|
return path
|