chemicaljs 2.0.1 → 2.1.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/index.js +67 -16
- package/package.json +28 -28
- package/rammerhead.tgz +0 -0
package/index.js
CHANGED
|
@@ -19,12 +19,7 @@ import { epoxyPath } from "@mercuryworkshop/epoxy-transport";
|
|
|
19
19
|
import { uvPath } from "@titaniumnetwork-dev/ultraviolet";
|
|
20
20
|
import { scramjetPath } from "@mercuryworkshop/scramjet";
|
|
21
21
|
import { meteorPath } from "meteorproxy";
|
|
22
|
-
import
|
|
23
|
-
createRammerhead,
|
|
24
|
-
shouldRouteRh,
|
|
25
|
-
routeRhUpgrade,
|
|
26
|
-
routeRhRequest,
|
|
27
|
-
} from "@rubynetwork/rammerhead";
|
|
22
|
+
import createRammerhead from "rammerhead/src/server/index.js";
|
|
28
23
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
29
24
|
|
|
30
25
|
logging.set_level(logging.ERROR);
|
|
@@ -68,9 +63,37 @@ class ChemicalServer {
|
|
|
68
63
|
return [this.app, this.listen];
|
|
69
64
|
}
|
|
70
65
|
serveChemical = () => {
|
|
71
|
-
const rh = createRammerhead(
|
|
72
|
-
|
|
73
|
-
|
|
66
|
+
const rh = createRammerhead();
|
|
67
|
+
const rammerheadScopes = [
|
|
68
|
+
"/rammerhead.js",
|
|
69
|
+
"/hammerhead.js",
|
|
70
|
+
"/transport-worker.js",
|
|
71
|
+
"/task.js",
|
|
72
|
+
"/iframe-task.js",
|
|
73
|
+
"/worker-hammerhead.js",
|
|
74
|
+
"/messaging",
|
|
75
|
+
"/sessionexists",
|
|
76
|
+
"/deletesession",
|
|
77
|
+
"/newsession",
|
|
78
|
+
"/editsession",
|
|
79
|
+
"/needpassword",
|
|
80
|
+
"/syncLocalStorage",
|
|
81
|
+
"/api/shuffleDict",
|
|
82
|
+
];
|
|
83
|
+
const rammerheadSession = /^\/[a-z0-9]{32}/;
|
|
84
|
+
const shouldRouteRh = (req) => {
|
|
85
|
+
const url = new URL(req.url, "http://0.0.0.0");
|
|
86
|
+
return (
|
|
87
|
+
rammerheadScopes.includes(url.pathname) ||
|
|
88
|
+
rammerheadSession.test(url.pathname)
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
const routeRhRequest = (req, res) => {
|
|
92
|
+
rh.emit("request", req, res);
|
|
93
|
+
};
|
|
94
|
+
const routeRhUpgrade = (req, socket, head) => {
|
|
95
|
+
rh.emit("upgrade", req, socket, head);
|
|
96
|
+
};
|
|
74
97
|
|
|
75
98
|
this.app.get("/chemical.js", async (req, res) => {
|
|
76
99
|
let chemicalMain = await readFileSync(
|
|
@@ -169,7 +192,7 @@ class ChemicalServer {
|
|
|
169
192
|
}
|
|
170
193
|
this.server.on("request", (req, res) => {
|
|
171
194
|
if (this.options.rammerhead && shouldRouteRh(req)) {
|
|
172
|
-
routeRhRequest(
|
|
195
|
+
routeRhRequest(req, res);
|
|
173
196
|
} else {
|
|
174
197
|
this.app(req, res);
|
|
175
198
|
}
|
|
@@ -183,7 +206,7 @@ class ChemicalServer {
|
|
|
183
206
|
}
|
|
184
207
|
wisp.routeRequest(req, socket, head);
|
|
185
208
|
} else if (this.options.rammerhead && shouldRouteRh(req)) {
|
|
186
|
-
routeRhUpgrade(
|
|
209
|
+
routeRhUpgrade(req, socket, head);
|
|
187
210
|
} else {
|
|
188
211
|
socket.end();
|
|
189
212
|
}
|
|
@@ -226,9 +249,37 @@ const ChemicalVitePlugin = (options) => ({
|
|
|
226
249
|
options.rammerhead = true;
|
|
227
250
|
}
|
|
228
251
|
|
|
229
|
-
const rh = createRammerhead(
|
|
230
|
-
|
|
231
|
-
|
|
252
|
+
const rh = createRammerhead();
|
|
253
|
+
const rammerheadScopes = [
|
|
254
|
+
"/rammerhead.js",
|
|
255
|
+
"/hammerhead.js",
|
|
256
|
+
"/transport-worker.js",
|
|
257
|
+
"/task.js",
|
|
258
|
+
"/iframe-task.js",
|
|
259
|
+
"/worker-hammerhead.js",
|
|
260
|
+
"/messaging",
|
|
261
|
+
"/sessionexists",
|
|
262
|
+
"/deletesession",
|
|
263
|
+
"/newsession",
|
|
264
|
+
"/editsession",
|
|
265
|
+
"/needpassword",
|
|
266
|
+
"/syncLocalStorage",
|
|
267
|
+
"/api/shuffleDict",
|
|
268
|
+
];
|
|
269
|
+
const rammerheadSession = /^\/[a-z0-9]{32}/;
|
|
270
|
+
const shouldRouteRh = (req) => {
|
|
271
|
+
const url = new URL(req.url, "http://0.0.0.0");
|
|
272
|
+
return (
|
|
273
|
+
rammerheadScopes.includes(url.pathname) ||
|
|
274
|
+
rammerheadSession.test(url.pathname)
|
|
275
|
+
);
|
|
276
|
+
};
|
|
277
|
+
const routeRhRequest = (req, res) => {
|
|
278
|
+
rh.emit("request", req, res);
|
|
279
|
+
};
|
|
280
|
+
const routeRhUpgrade = (req, socket, head) => {
|
|
281
|
+
rh.emit("upgrade", req, socket, head);
|
|
282
|
+
};
|
|
232
283
|
|
|
233
284
|
const app = express();
|
|
234
285
|
app.get("/chemical.js", async function (req, res) {
|
|
@@ -325,7 +376,7 @@ const ChemicalVitePlugin = (options) => ({
|
|
|
325
376
|
|
|
326
377
|
server.middlewares.use((req, res, next) => {
|
|
327
378
|
if (options.rammerhead && shouldRouteRh(req)) {
|
|
328
|
-
routeRhRequest(
|
|
379
|
+
routeRhRequest(req, res);
|
|
329
380
|
} else {
|
|
330
381
|
next();
|
|
331
382
|
}
|
|
@@ -346,7 +397,7 @@ const ChemicalVitePlugin = (options) => ({
|
|
|
346
397
|
}
|
|
347
398
|
wisp.routeRequest(req, socket, head);
|
|
348
399
|
} else if (options.rammerhead && shouldRouteRh(req)) {
|
|
349
|
-
routeRhUpgrade(
|
|
400
|
+
routeRhUpgrade(req, socket, head);
|
|
350
401
|
} else {
|
|
351
402
|
for (const upgrader of upgraders) {
|
|
352
403
|
upgrader(req, socket, head);
|
package/package.json
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
2
|
+
"name": "chemicaljs",
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"description": "Easily create your own web proxy with no experience required.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/chemicaljs/chemical.git"
|
|
8
|
+
},
|
|
9
|
+
"main": "index.js",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"author": "Nebelung",
|
|
12
|
+
"license": "AGPL-3.0-only",
|
|
13
|
+
"scripts": {
|
|
14
|
+
"update": "npx npm-check-updates -u && npm i"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@mercuryworkshop/bare-mux": "^2.1.2",
|
|
18
|
+
"@mercuryworkshop/epoxy-transport": "^2.1.17",
|
|
19
|
+
"@mercuryworkshop/libcurl-transport": "^1.3.10",
|
|
20
|
+
"@mercuryworkshop/scramjet": "^1.0.2",
|
|
21
|
+
"@mercuryworkshop/wisp-js": "^0.3.2",
|
|
22
|
+
"@titaniumnetwork-dev/ultraviolet": "^3.2.7",
|
|
23
|
+
"express": "^4.21.1",
|
|
24
|
+
"meteorproxy": "^1.0.6-patch.1",
|
|
25
|
+
"rammerhead": "https://github.com/chemicaljs/chemical/raw/main/rammerhead.tgz"
|
|
26
|
+
},
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=20.11.0"
|
|
29
|
+
}
|
|
30
30
|
}
|
package/rammerhead.tgz
ADDED
|
Binary file
|