fbi-proxy 1.3.0 → 1.4.0
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/package.json
CHANGED
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"dev:rs": "cd rs && bacon run",
|
|
53
53
|
"dev:rs-watch": "cd rs && cargo watch -x run",
|
|
54
54
|
"start": "bun ts/cli.ts",
|
|
55
|
+
"start:js": "node dist/cli.js",
|
|
55
56
|
"start:caddy": "./caddy run",
|
|
56
57
|
"start:rs": "./target/release/fbi-proxy",
|
|
57
58
|
"prepare": "husky && bunx rustup && bacon --version || cargo install bacon"
|
|
@@ -67,5 +68,5 @@
|
|
|
67
68
|
"bin": {
|
|
68
69
|
"fbi-proxy": "dist/cli.js"
|
|
69
70
|
},
|
|
70
|
-
"version": "1.
|
|
71
|
+
"version": "1.4.0"
|
|
71
72
|
}
|
|
Binary file
|
|
Binary file
|
package/ts/buildFbiProxy.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fsp from "fs/promises";
|
|
2
|
+
import { existsSync } from "fs";
|
|
2
3
|
import { getProxyFilename } from "./getProxyFilename";
|
|
3
4
|
import { copyFile } from "fs/promises";
|
|
4
5
|
import { $ } from "./dRun";
|
|
@@ -16,16 +17,16 @@ export async function buildFbiProxy({ rebuild = false } = {}) {
|
|
|
16
17
|
const built = `./target/release/fbi-proxy${isWin ? ".exe" : ""}`;
|
|
17
18
|
|
|
18
19
|
// return built if exists
|
|
19
|
-
if (!rebuild && (
|
|
20
|
+
if (!rebuild && existsSync(built)) {
|
|
20
21
|
return built;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
// return release if exists
|
|
24
|
-
if (!rebuild && (
|
|
25
|
+
if (!rebuild && existsSync(release)) return release;
|
|
25
26
|
|
|
26
27
|
// build and return built target
|
|
27
28
|
await $`cargo build --release`;
|
|
28
|
-
if (
|
|
29
|
+
if (existsSync(built)) return built;
|
|
29
30
|
|
|
30
31
|
throw new Error(
|
|
31
32
|
"Oops, failed to build fbi-proxy binary. Please check your Rust setup.",
|
package/ts/cli.ts
CHANGED
|
@@ -1,52 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
import getPort from "get-port";
|
|
3
|
+
import hotMemo from "hot-memo";
|
|
3
4
|
import minimist from "minimist";
|
|
4
|
-
import { exec, spawn } from "child_process";
|
|
5
5
|
import path from "path";
|
|
6
|
-
import tsaComposer from "tsa-composer";
|
|
7
|
-
import { fromStdio } from "from-node-stream";
|
|
8
|
-
import sflow from "sflow";
|
|
9
|
-
import hotMemo from "hot-memo";
|
|
10
|
-
import fsp from "fs/promises";
|
|
11
|
-
import { exists, existsSync } from "fs";
|
|
12
|
-
import { getProxyFilename } from "./getProxyFilename";
|
|
13
|
-
import { DIE } from "phpdie";
|
|
14
6
|
import promiseAllProperties from "promise-all-properties";
|
|
15
7
|
import { buildFbiProxy } from "./buildFbiProxy";
|
|
16
8
|
import { $ } from "./dRun";
|
|
9
|
+
import { downloadCaddy } from "./downloadCaddy";
|
|
17
10
|
|
|
18
11
|
process.chdir(path.resolve(__dirname, "..")); // Change to project root directory
|
|
19
12
|
|
|
20
13
|
console.log("Preparing Binaries");
|
|
21
14
|
|
|
22
|
-
const downloadCaddy = async () => {
|
|
23
|
-
// use pwdCaddy if already downloaded
|
|
24
|
-
const pwdCaddy = "./caddy";
|
|
25
|
-
|
|
26
|
-
// if ./caddy exists in pwd, return it
|
|
27
|
-
if (await fsp.exists(pwdCaddy)) return pwdCaddy;
|
|
28
|
-
|
|
29
|
-
// or use system caddy if installed, run `caddy --version` to check
|
|
30
|
-
if (await $`caddy --version`.catch(() => false)) {
|
|
31
|
-
return "caddy";
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// or if system caddy is not installed, download caddy using caddy-baron
|
|
35
|
-
if (!existsSync(pwdCaddy)) {
|
|
36
|
-
// download latest caddy to ./caddy
|
|
37
|
-
console.log("Downloading Caddy...");
|
|
38
|
-
// @ts-ignore
|
|
39
|
-
await import("../node_modules/caddy-baron/index.mjs");
|
|
40
|
-
|
|
41
|
-
if (!existsSync(pwdCaddy))
|
|
42
|
-
throw new Error(
|
|
43
|
-
"Failed to download Caddy. Please install Caddy manually or check your network connection.",
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return pwdCaddy;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
15
|
const { proxy, caddy } = await promiseAllProperties({
|
|
51
16
|
proxy: buildFbiProxy(),
|
|
52
17
|
caddy: downloadCaddy(),
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { existsSync } from "fs";
|
|
2
|
+
import fsp from "fs/promises";
|
|
3
|
+
import { $ } from "./dRun";
|
|
4
|
+
|
|
5
|
+
export const downloadCaddy = async () => {
|
|
6
|
+
// use pwdCaddy if already downloaded
|
|
7
|
+
const pwdCaddy = "./caddy";
|
|
8
|
+
|
|
9
|
+
// if ./caddy exists in pwd, return it
|
|
10
|
+
if (existsSync(pwdCaddy)) return pwdCaddy;
|
|
11
|
+
|
|
12
|
+
// or use system caddy if installed, run `caddy --version` to check
|
|
13
|
+
if (await $`caddy --version`.catch(() => false)) {
|
|
14
|
+
return "caddy";
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// or if system caddy is not installed, download caddy using caddy-baron
|
|
18
|
+
if (!existsSync(pwdCaddy)) {
|
|
19
|
+
// download latest caddy to ./caddy
|
|
20
|
+
console.log("Downloading Caddy...");
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
await import("../node_modules/caddy-baron/index.mjs");
|
|
23
|
+
|
|
24
|
+
if (!existsSync(pwdCaddy))
|
|
25
|
+
throw new Error(
|
|
26
|
+
"Failed to download Caddy. Please install Caddy manually or check your network connection.",
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return pwdCaddy;
|
|
31
|
+
};
|
package/ts/download-fbiproxy.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { getProxyFilename } from "./getProxyFilename";
|
|
2
|
-
|
|
3
|
-
// download latest github release
|
|
4
|
-
// https://github.com/snomiao/fbi-proxy/releases/download/v1.2.0/proxy-windows-x64.exe
|
|
5
|
-
// https://github.com/snomiao/fbi-proxy/releases/latest/download/fbi-proxy-windows-x64.exe
|
|
6
|
-
const url = 'https://github.com/snomiao/fbi-proxy/releases/latest/download/' + getProxyFilename()
|
|
7
|
-
console.log(url)
|
|
8
|
-
|
|
9
|
-
// const res = await fetch()
|
|
10
|
-
// if (!res.ok) {
|
|
11
|
-
// throw new Error("Failed to download proxy file: " + res.statusText);
|
|
12
|
-
// }
|
|
13
|
-
// // show progress
|
|
14
|
-
// const progress = new ReadableStream({
|
|
15
|
-
// start(controller) {
|
|
16
|
-
// const reader = res.body.getReader();
|
|
17
|
-
// let loaded = 0;
|
|
18
|
-
// const total = Number(res.headers.get('Content-Length'));
|
|
19
|
-
// function push() {
|
|
20
|
-
// reader.read().then(({ done, value }) => {
|
|
21
|
-
// if (done) {
|
|
22
|
-
// controller.close();
|
|
23
|
-
// return;
|
|
24
|
-
// }
|
|
25
|
-
// loaded += value.length;
|
|
26
|
-
// console.log(`Downloaded ${((loaded / total) * 100).toFixed(2)}%`);
|
|
27
|
-
// controller.enqueue(value);
|
|
28
|
-
// push();
|
|
29
|
-
// });
|
|
30
|
-
// }
|
|
31
|
-
// push();
|
|
32
|
-
// }
|
|
33
|
-
// });
|
|
34
|
-
// console.log(await Bun.write(('release/' + getProxyFilename()), progress))
|
|
35
|
-
|