Skip to content

Commit 6ae1e6f

Browse files
Merge pull request #567 from QuiteAFancyEmerald/revert-566-master
Revert "Switch over to mrrowisp"
2 parents 1ff15f1 + 41165b3 commit 6ae1e6f

4 files changed

Lines changed: 106 additions & 131 deletions

File tree

TODO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ This will be our nonexhaustive todo list for InvisiProxy LTS v6.x.x and above. R
99
- [ ] Implement multi-lang support!
1010

1111
## Proxy/Site Functionality
12+
- [ ] Implement wisp python to the project instead of the unreliable wisp-server-node
1213
- [ ] Add booksmark menu (source wise already present pretty much)
1314
- [ ] Add Chii + ensuring users can access devtools while browsing - partial
1415
- [ ] Omnibox should state what the current site the user is on like a proper URL bar
1516
- [ ] Improve adblocking functions on site using Workerware + a pre-bundled uBlock Origin
1617
- [ ] Implement advanced data URI system
1718
- [ ] Allow custom Wisp urls from the settings menu (not config side)
1819
- [ ] Setting to open multiple stealth frames; basically about:blank but using our system. Pops out in another tab
19-
- [x] Swap to mrrowisp over wisp-js for performance - done
2020
- [x] Hide local browser history on launch - done
2121
- [x] Setting to open about:blank and blob frames - done
2222
- [x] Transport Options Swapping on Frame (Settings Menu doesn't swap) - done

package-lock.json

Lines changed: 61 additions & 74 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@
3838
"@mercuryworkshop/epoxy-transport": "^2.1.28",
3939
"@mercuryworkshop/libcurl-transport": "^1.5.1",
4040
"@mercuryworkshop/scramjet": "https://github.com/MercuryWorkshop/scramjet/releases/download/v1.1.0/mercuryworkshop-scramjet-1.1.0.tgz",
41+
"@mercuryworkshop/wisp-js": "^0.4.1",
4142
"@titaniumnetwork-dev/ultraviolet": "^3.2.10",
4243
"axios": "^1.13.5",
4344
"chii": "^1.15.5",
4445
"fastify": "^5.8.5",
45-
"mrrowisp": "^2.10.0",
4646
"pm2": "^7.0.1",
4747
"puppeteer": "^24.37.2",
4848
"utf-8-validate": "^6.0.6",

src/server.mjs

Lines changed: 43 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Fastify from 'fastify';
22
import { createServer } from 'node:http';
3-
import { Mrrowisp } from "mrrowisp";
3+
import { server as wisp, logging } from "@mercuryworkshop/wisp-js/server";
44
import createRammerhead from '../lib/rammerhead/src/server/index.js';
55
import fastifyHelmet from '@fastify/helmet';
66
import fastifyStatic from '@fastify/static';
@@ -21,40 +21,29 @@ import { existsSync, unlinkSync } from 'node:fs';
2121
*/
2222
console.log(serverUrl);
2323

24-
const wisp = new Mrrowisp({
25-
port: 6001,
26-
allowUDP: false,
27-
allowLoopbackIPs: true,
28-
whitelist: {
29-
ports: [80, 443, 9050, 7000, 7001],
30-
},
31-
tcpBufferSize: 65535,
32-
streamLimitPerHost: 256,
33-
streamLimitTotal: 8192,
34-
dnsTTLSeconds: 300,
35-
dnsMethod: "resolve",
36-
dnsResultOrder: "ipv4first",
37-
enableV2: true,
38-
bandwidthLimitKbps: 51200,
39-
connectionsLimitPerIP: 100,
40-
connectionWindowSeconds: 10,
41-
maxMessageSize: 262144,
42-
writeTimeoutSeconds: 30,
43-
frameReadTimeoutSeconds: 60,
44-
banDurationSeconds: 86400,
45-
banMaxStrikes: 5,
46-
banEscalationMultiplier: 2,
47-
maxHandshakeFailures: 20,
48-
maxPacketRate: 2000,
49-
maxConnectionLifetimeSeconds: 7200,
50-
maxStreamsPerConnection: 256,
51-
maxConnectionsPerIP: 100,
52-
globalMaxConnections: 10000,
53-
writeQueueSize: 16384,
54-
maxInboundBytesPerSecond: 10485760,
55-
});
56-
57-
wisp.start();
24+
// Wisp Configuration: Refer to the documentation at https://www.npmjs.com/package/@mercuryworkshop/wisp-js
25+
26+
logging.set_level(logging.NONE);
27+
wisp.options.allow_udp_streams = false;
28+
wisp.options.allow_loopback_ips = true;
29+
30+
// For security reasons only allow these ports. Any additional regional proxies or default sandboxed Tor ports should be added here.
31+
wisp.options.port_whitelist = [
32+
80,
33+
443,
34+
9050,
35+
7000,
36+
7001
37+
];
38+
39+
wisp.options.port_blacklist = [
40+
[6881, 6889],
41+
6969,
42+
1337,
43+
[6969, 6969],
44+
51413,
45+
[49152, 65535]
46+
];
5847

5948
// The server will check for the existence of this file when a shutdown is requested.
6049
// The shutdown script in run-command.js will temporarily produce this file.
@@ -80,8 +69,8 @@ const rammerheadScopes = [
8069
].map((pathname) => pathname.replace('/', serverUrl.pathname));
8170

8271
const rammerheadSession = new RegExp(
83-
`^${serverUrl.pathname.replaceAll('.', '\\.')}[a-z0-9]{32}`
84-
),
72+
`^${serverUrl.pathname.replaceAll('.', '\\.')}[a-z0-9]{32}`
73+
),
8574
shouldRouteRh = (req) => {
8675
try {
8776
const url = new URL(req.url, serverUrl);
@@ -112,7 +101,7 @@ const serverFactory = (handler) => {
112101
.on('upgrade', (req, socket, head) => {
113102
if (shouldRouteRh(req)) routeRhUpgrade(req, socket, head);
114103
else if (req.url.endsWith(getAltPrefix('wisp', serverUrl.pathname)))
115-
wisp.route(req, socket, head);
104+
wisp.routeRequest(req, socket, head);
116105
});
117106
};
118107

@@ -195,33 +184,33 @@ app.register(fastifyStatic, {
195184
*/
196185

197186
const supportedTypes = {
198-
default: config.disguiseFiles ? 'image/vnd.microsoft.icon' : 'text/html',
199-
html: 'text/html',
200-
txt: 'text/plain',
201-
xml: 'application/xml',
202-
ico: 'image/vnd.microsoft.icon',
203-
},
187+
default: config.disguiseFiles ? 'image/vnd.microsoft.icon' : 'text/html',
188+
html: 'text/html',
189+
txt: 'text/plain',
190+
xml: 'application/xml',
191+
ico: 'image/vnd.microsoft.icon',
192+
},
204193
disguise = 'ico';
205194

206195
if (config.disguiseFiles) {
207196
const getActualPath = (path) =>
208-
path.slice(0, path.length - 1 - disguise.length),
197+
path.slice(0, path.length - 1 - disguise.length),
209198
shouldNotHandle = new RegExp(`\\.(?!html$|${disguise}$)[\\w-]+$`, 'i'),
210199
loaderFile = tryReadFile(
211200
'../views/dist/pages/misc/deobf/loader.html',
212201
import.meta.url,
213202
false
214203
);
215204
let exemptDirs = [
216-
'assets',
217-
'uv',
218-
'scram',
219-
'epoxy',
220-
'libcurl',
221-
'baremux',
222-
'wisp',
223-
'chii',
224-
].map((dir) => getAltPrefix(dir, serverUrl.pathname).slice(1, -1)),
205+
'assets',
206+
'uv',
207+
'scram',
208+
'epoxy',
209+
'libcurl',
210+
'baremux',
211+
'wisp',
212+
'chii',
213+
].map((dir) => getAltPrefix(dir, serverUrl.pathname).slice(1, -1)),
225214
exemptPages = ['login', 'test-shutdown', 'favicon.ico'];
226215
for (const [key, value] of Object.entries(externalPages))
227216
if ('string' === typeof value) exemptPages.push(key);
@@ -292,7 +281,6 @@ app.get(serverUrl.pathname + ':path', (req, reply) => {
292281
// is present, gracefully shut the server down.
293282
if (reqPath === 'test-shutdown' && existsSync(shutdown)) {
294283
console.log('InvisiProxy is shutting down.');
295-
wisp.stop();
296284
app.close();
297285
unlinkSync(shutdown);
298286
process.exitCode = 0;

0 commit comments

Comments
 (0)