From 1f2fcec4db3dec4d00c584745b945cc2bbaca627 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 18 Aug 2024 22:18:27 -0400 Subject: [PATCH] switched back to wisp because tgt's gonna fucking bully me --- index.js | 24 ++++++++---------------- package.json | 6 +++--- static/404.html | 16 ++++++++-------- static/apps.html | 22 +++++++++++----------- static/assets/js/loader.js | 2 +- static/assets/js/preload.js | 6 ++++-- static/assets/js/register.js | 4 ++-- static/gms.html | 22 +++++++++++----------- static/index.html | 22 +++++++++++----------- static/info.html | 16 ++++++++-------- static/loader.html | 18 +++++++++--------- static/loading.html | 10 +++++----- static/mobile.html | 16 ++++++++-------- static/settings.html | 20 ++++++++++---------- 14 files changed, 99 insertions(+), 105 deletions(-) diff --git a/index.js b/index.js index 847936c4..b4f529c8 100644 --- a/index.js +++ b/index.js @@ -1,20 +1,18 @@ import express from 'express'; import http from 'node:http'; import path from 'node:path'; -import { createBareServer } from "@tomphttp/bare-server-node"; -import { bareModulePath } from "@mercuryworkshop/bare-as-module3"; +import { libcurlPath } from "@mercuryworkshop/libcurl-transport"; import { baremuxPath } from "@mercuryworkshop/bare-mux/node"; +import wisp from "wisp-server-node"; import request from '@cypress/request'; import chalk from 'chalk'; import packageJson from './package.json' assert { type: 'json' }; -// Removed libcurl and replaced it with Bare -// For some reason using Bare is faster (Isn't bare supposed to suck) + const __dirname = path.resolve(); const server = http.createServer(); const app = express(server); const version = packageJson.version; const discord = 'https://discord.gg/unblocking'; -const bareServer = createBareServer("/bear/"); app.use(express.json()); app.use( @@ -23,8 +21,8 @@ app.use( }) ); +app.use("/libcurl/", express.static(libcurlPath)); app.use("/baremux/", express.static(baremuxPath)); -app.use("/baremod/", express.static(bareModulePath)); app.use(express.static(path.join(__dirname, 'static'))); app.get('/app', (req, res) => { @@ -65,19 +63,13 @@ app.use((req, res) => { }); server.on("request", (req, res) => { - if (bareServer.shouldRoute(req)) { - bareServer.routeRequest(req, res); - } else { - app(req, res); - } + app(req, res); }); server.on("upgrade", (req, socket, head) => { - if (bareServer.shouldRoute(req)) { - bareServer.routeUpgrade(req, socket, head); - } else { - socket.end(); - } + if (req.url.endsWith("/wisp/")) { + wisp.routeRequest(req, socket, head); + } else socket.end(); }); server.on('listening', () => { diff --git a/package.json b/package.json index 512f234d..2a56c188 100644 --- a/package.json +++ b/package.json @@ -15,10 +15,10 @@ "license": "GPL-3.0-or-later", "dependencies": { "@cypress/request": "^3.0.0", - "@mercuryworkshop/bare-as-module3": "^2.2.2", "@mercuryworkshop/bare-mux": "^2.0.4", - "@tomphttp/bare-server-node": "2.0.3", + "@mercuryworkshop/libcurl-transport": "^1.3.7", + "wisp-server-node": "^1.1.3", "chalk": "^5.3.0", "express": "^4.18.2" } -} +} \ No newline at end of file diff --git a/static/404.html b/static/404.html index 31e2415e..e2e36ec5 100644 --- a/static/404.html +++ b/static/404.html @@ -4,12 +4,12 @@ - - - - - - + + + + + + 404 | Doge @@ -32,8 +32,8 @@

404 Not Found

Site Info
- - + + \ No newline at end of file diff --git a/static/apps.html b/static/apps.html index 831cef7f..df56c495 100644 --- a/static/apps.html +++ b/static/apps.html @@ -4,13 +4,13 @@ - - - - - - - + + + + + + + Doge | V4 @@ -32,10 +32,10 @@
Loading apps...

- - - - + + + + \ No newline at end of file diff --git a/static/assets/js/loader.js b/static/assets/js/loader.js index 146be4a2..87b595fb 100644 --- a/static/assets/js/loader.js +++ b/static/assets/js/loader.js @@ -137,7 +137,7 @@ function decode(url) { if (url === 'about:blank' || url === 'welcome.html') { return '' } - else if (url === 'welcome.html' || url === 'https://' + location.hostname + '/welcome.html') { + else if (url === 'welcome.html' || url === 'https://beta.derpman.lol/welcome.html') { return '' } var uvPrefix = '/service/'; diff --git a/static/assets/js/preload.js b/static/assets/js/preload.js index 424c4d7d..88079205 100644 --- a/static/assets/js/preload.js +++ b/static/assets/js/preload.js @@ -1,14 +1,16 @@ window.onload = function() { const stockSW = "/uv/sw.js"; const swAllowedHostnames = ["localhost", "127.0.0.1"]; - const bareUrl = location.protocol + "//" + location.host + "/bear/"; + const wispUrl = (location.protocol === "https:" ? "wss" : "ws") + "://" + location.host + "/wisp/"; const connection = new BareMux.BareMuxConnection("/baremux/worker.js"); async function registerSW() { if(!navigator.serviceWorker) { if(location.protocol !== "https:" && !swAllowedHostnames.includes(location.hostname)) throw new Error("Service workers cannot be registered without https."); throw new Error("Your browser doesn't support service workers."); } - await connection.setTransport("/baremod/index.mjs", [bareUrl]); + await connection.setTransport("/libcurl/index.mjs", [{ + wisp: wispUrl + }]); await navigator.serviceWorker.register(stockSW); let encodedUrl = localStorage.getItem("encodedUrl"); encodedUrl = "/service/" + encodedUrl; diff --git a/static/assets/js/register.js b/static/assets/js/register.js index e46ada8e..47a5a21b 100644 --- a/static/assets/js/register.js +++ b/static/assets/js/register.js @@ -1,6 +1,6 @@ const stockSW = "/uv/sw.js"; const swAllowedHostnames = ["localhost", "127.0.0.1"]; -const bareUrl = location.protocol + "//" + location.host + "/bear/"; +const wispUrl = (location.protocol === "https:" ? "wss" : "ws") + "://" + location.host + "/wisp/"; const connection = new BareMux.BareMuxConnection("/baremux/worker.js"); async function registerSW() { @@ -14,7 +14,7 @@ async function registerSW() { throw new Error("Your browser doesn't support service workers."); } - await connection.setTransport("/baremod/index.mjs", [bareUrl]); + await connection.setTransport("/libcurl/index.mjs", [{ wisp: wispUrl }]); await navigator.serviceWorker.register(stockSW); } diff --git a/static/gms.html b/static/gms.html index a8afca4d..2cc5d614 100644 --- a/static/gms.html +++ b/static/gms.html @@ -4,13 +4,13 @@ - - - - - - - + + + + + + + Doge | V4 @@ -32,10 +32,10 @@
Loading assets...

- - - - + + + + \ No newline at end of file diff --git a/static/index.html b/static/index.html index 936727d2..623d55db 100644 --- a/static/index.html +++ b/static/index.html @@ -4,11 +4,11 @@ - - - - - + + + + + Doge | V4 @@ -35,12 +35,12 @@
Site Info
- - - - - - + + + + + + diff --git a/static/info.html b/static/info.html index ce1e7a36..d68c529b 100644 --- a/static/info.html +++ b/static/info.html @@ -4,12 +4,12 @@ - - - - - - + + + + + + - +
@@ -39,7 +39,7 @@
- + - + \ No newline at end of file diff --git a/static/mobile.html b/static/mobile.html index 769761c2..8f1be874 100644 --- a/static/mobile.html +++ b/static/mobile.html @@ -2,9 +2,9 @@ - - - + + + Mobile | Doge