From c3cc83dd1c316ef4ad63337aff678a47c31e177c Mon Sep 17 00:00:00 2001 From: wearrrrr Date: Sat, 16 Mar 2024 18:09:25 -0500 Subject: [PATCH] try to get libcurl working, didn't work --- .vscode/settings.json | 5 ++ index.js | 60 ++++++------- package-lock.json | 86 ++++--------------- package.json | 5 +- public/sw.js | 1 + src/components/Footer.astro | 2 +- src/components/Input.astro | 4 + src/components/SettingsContent/ProxyTab.astro | 10 +-- src/components/SettingsTablist.astro | 21 +---- src/components/TransportManager.astro | 3 +- src/i18n/en.json | 4 +- src/i18n/jp.json | 5 +- src/json/games.json | 5 -- src/pages/[lang]/index.astro | 6 +- 14 files changed, 67 insertions(+), 150 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..26ce4f1 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "search.exclude": { + "/public/games/**": true + } +} \ No newline at end of file diff --git a/index.js b/index.js index a592f7e..c37bdc0 100644 --- a/index.js +++ b/index.js @@ -2,7 +2,6 @@ import { uvPath } from "@titaniumnetwork-dev/ultraviolet"; import { epoxyPath } from "@mercuryworkshop/epoxy-transport"; import { baremuxPath } from "@mercuryworkshop/bare-mux"; import { libcurlPath } from "@mercuryworkshop/libcurl-transport"; -import { createBareServer } from "@tomphttp/bare-server-node"; import express from "express"; import { createServer } from "http"; import path from "node:path"; @@ -42,16 +41,12 @@ const rammerheadScopes = [ "/api/shuffleDict", ]; const rammerheadSession = /^\/[a-z0-9]{32}/; -const bare = createBareServer("/bare/"); -console.log(chalk.gray("Starting Bare...")); - const app = express(); app.use(compression({ threshold: 0, filter: () => true })); app.use(cookieParser()); async function MasqFail(req, res) { if (!req.headers.host) { - // no bitch still using HTTP/1.0 go away return; } const unsafeSuffix = req.headers.host + ".html"; @@ -76,40 +71,30 @@ async function MasqFail(req, res) { // uncomment for masqr app.use(async (req, res, next) => { if (req.headers.host && whiteListedDomains.includes(req.headers.host)) { - next(); - return; + next(); + return; } - // set this to your bare endpoint - if (req.url.includes("/bare/")) { - next(); - return; - } - const authheader = req.headers.authorization; - if (req.cookies["authcheck"]) { - next(); - return; + next(); + return; } - if (req.cookies['refreshcheck'] != "true") { - res.cookie("refreshcheck", "true", {maxAge: 10000}) // 10s refresh check - MasqFail(req, res) - return; + if (req.cookies['refreshcheck'] != "true") { + res.cookie("refreshcheck", "true", {maxAge: 10000}) // 10s refresh check + MasqFail(req, res) + return; } if (!authheader) { - - res.setHeader('WWW-Authenticate', 'Basic'); // Yeah so we need to do this to get the auth params, kinda annoying and just showing a login prompt gives it away so its behind a 10s refresh check - res.status(401); - MasqFail(req, res) - return; + res.setHeader('WWW-Authenticate', 'Basic'); // Yeah so we need to do this to get the auth params, kinda annoying and just showing a login prompt gives it away so its behind a 10s refresh check + res.status(401); + MasqFail(req, res) + return; } - const auth = Buffer.from(authheader.split(' ')[1], - 'base64').toString().split(':'); - const user = auth[0]; + const auth = Buffer.from(authheader.split(' ')[1], 'base64').toString().split(':'); const pass = auth[1]; const licenseCheck = ((await (await fetch(LICENSE_SERVER_URL + pass + "&host=" + req.headers.host)).json()))["status"] @@ -130,7 +115,11 @@ app.use(express.static(path.join(process.cwd(), "build"))); app.use("/uv/", express.static(uvPath)); app.use("/epoxy/", express.static(epoxyPath)); app.use("/baremux/", express.static(baremuxPath)); -app.use("/libcurl/", express.static(libcurlPath)); +// Make libcurl a middleware that will send application/javascript and serve the path +app.use("/libcurl/", (req, res, next) => { + res.setHeader("Content-Type", "application/javascript"); + next(); +}, express.static(libcurlPath)); app.use(express.json()); app.use( express.urlencoded({ @@ -138,8 +127,11 @@ app.use( }) ); app.use(function (req, res, next) { - if (req.originalUrl.includes("/games")) { + if (req.originalUrl.includes("/games/")) { + console.log("Game request"); res.header("Cross-Origin-Opener-Policy", "same-origin"); + res.header("Cross-Origin-Embedder-Policy", "require-corp"); + } next(); }); @@ -166,9 +158,7 @@ app.get("*", function (req, res) { let server = createServer(); server.on("request", (req, res) => { - if (bare.shouldRoute(req)) { - bare.routeRequest(req, res); - } else if (shouldRouteRh(req)) { + if (shouldRouteRh(req)) { routeRhRequest(req, res); } else { app(req, res); @@ -176,9 +166,7 @@ server.on("request", (req, res) => { }); server.on("upgrade", (req, socket, head) => { - if (bare.shouldRoute(req)) { - bare.routeUpgrade(req, socket, head); - } else if (shouldRouteRh(req)) { + if (shouldRouteRh(req)) { routeRhUpgrade(req, socket, head); } else if (req.url.endsWith("/")) { wisp.routeRequest(req, socket, head); diff --git a/package-lock.json b/package-lock.json index 3b39c15..99d5942 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,10 +11,9 @@ "@astrojs/node": "^8.2.0", "@mercuryworkshop/bare-mux": "^1.0.5", "@mercuryworkshop/epoxy-transport": "^1.1.0", - "@mercuryworkshop/libcurl-transport": "^1.2.1", + "@mercuryworkshop/libcurl-transport": "^1.2.4", "@titaniumnetwork-dev/ultraviolet": "^3.0.0", "@tomphttp/bare-client": "^2.2.0-alpha", - "@tomphttp/bare-server-node": "^2.0.3", "astro": "^4.4.1", "chalk": "^5.3.0", "compression": "^1.7.4", @@ -25,7 +24,7 @@ "path": "^0.12.7", "rammerhead": "https://github.com/NebulaServices/rammerhead/releases/download/rammerhead-1.2.41-nebula.8/rammerhead-1.2.41-nebula.7.tgz", "typescript": "^5.3.3", - "wisp-server-node": "^1.0.1" + "wisp-server-node": "^1.0.2" }, "devDependencies": { "prettier": "3.2.5", @@ -965,12 +964,12 @@ } }, "node_modules/@mercuryworkshop/libcurl-transport": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@mercuryworkshop/libcurl-transport/-/libcurl-transport-1.2.1.tgz", - "integrity": "sha512-HwlC36KSMoUHQmZ8y2EkF57oV6UfLrg6rUbdniMQqWw2HEDBT5Ua+gcyQybjW6pNMqvneqnOWLJFF9LwZzGHoA==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@mercuryworkshop/libcurl-transport/-/libcurl-transport-1.2.4.tgz", + "integrity": "sha512-BiqTOcHzjNYy0AHCxw3IAfe81+xX07Gjig9cZkEJ7eRLcuEwkLPwTnf36RopxFQh4yShbk1lMjmU4SjMIi6/uQ==", "dependencies": { "esbuild-plugin-umd-wrapper": "^2.0.0", - "libcurl.js": "^0.5.0", + "libcurl.js": "^0.5.3", "rollup": "^4.12.0", "rollup-plugin-node-resolve": "^5.2.0", "rollup-plugin-typescript2": "^0.36.0", @@ -1328,34 +1327,6 @@ "resolved": "https://registry.npmjs.org/@tomphttp/bare-client/-/bare-client-2.2.0-alpha.tgz", "integrity": "sha512-xhcflOpwr92tkpp8SoDhB3nK3LHMBIjx+vgow37XobQew2k0/mXSxmaU7BsDFpOIa1CcLCEsR8gWn0v7Cy9+7Q==" }, - "node_modules/@tomphttp/bare-server-node": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@tomphttp/bare-server-node/-/bare-server-node-2.0.3.tgz", - "integrity": "sha512-IGzZspDwzto+oPsvlV99OALJKH3X1nRWnpBE8EY6nrqu5I83xw3uSUacEdHNnW4rXG0IQ8vZwMH87VOMoArJ3A==", - "dependencies": { - "async-exit-hook": "^2.0.1", - "commander": "^10.0.1", - "dotenv": "^16.0.3", - "http-errors": "^2.0.0", - "ipaddr.js": "^2.1.0", - "source-map-support": "^0.5.21", - "ws": "^8.13.0" - }, - "bin": { - "bare-server-node": "bin.js" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@tomphttp/bare-server-node/node_modules/ipaddr.js": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-2.1.0.tgz", - "integrity": "sha512-LlbxQ7xKzfBusov6UMi4MFpEg0m+mAm9xyNGEduwXMEDuf4WfzB/RZwMVYEd7IKGvh4IUkEXYxtAVu9T3OelJQ==", - "engines": { - "node": ">= 10" - } - }, "node_modules/@tootallnate/once": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", @@ -2088,11 +2059,6 @@ "ieee754": "^1.2.1" } }, - "node_modules/buffer-from": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", - "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" - }, "node_modules/builtin-modules": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz", @@ -2441,14 +2407,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/commander": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.1.tgz", - "integrity": "sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==", - "engines": { - "node": ">=14" - } - }, "node_modules/common-ancestor-path": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/common-ancestor-path/-/common-ancestor-path-1.0.1.tgz", @@ -4258,9 +4216,9 @@ } }, "node_modules/libcurl.js": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/libcurl.js/-/libcurl.js-0.5.2.tgz", - "integrity": "sha512-kj4Em8YYzx8Xl1wtXo04sGulQTqnxFkXsmtMDPqPZ8OIZCoyzilSQKMhmF2XVnoB0g+HK68A2v32b3lMPGCtfQ==" + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/libcurl.js/-/libcurl.js-0.5.3.tgz", + "integrity": "sha512-tHa5c18irBGzafPKwGMBU7c9RMxAQfuf3BHTLgAHToNvJaFXUYRAsKXDqV2SWKLMm5OaW2b1XGu8MsfMh1b08A==" }, "node_modules/load-yaml-file": { "version": "0.2.0", @@ -10181,14 +10139,6 @@ "node": ">= 10" } }, - "node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/source-map-js": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", @@ -10210,15 +10160,6 @@ "urix": "^0.1.0" } }, - "node_modules/source-map-support": { - "version": "0.5.21", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", - "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", - "dependencies": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, "node_modules/source-map-url": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.1.tgz", @@ -11343,9 +11284,12 @@ } }, "node_modules/wisp-server-node": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/wisp-server-node/-/wisp-server-node-1.0.1.tgz", - "integrity": "sha512-RPid1o/q8NWE0zVFmMIUBIWS7WnUeHmfzrxaNeFsWKXYKD5RO74qYnDLbXSKFDCTSrPQ+uXtRI2I/EpunXfAvw==" + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wisp-server-node/-/wisp-server-node-1.0.2.tgz", + "integrity": "sha512-a48BYDSaGljTV54OtDjdkTYGbqehEfuNhSMZ9ZHIqtFSesMBi84WmyPYSZ9IgJUenw5p8iR0xjbcx9/nVJWJ+A==", + "dependencies": { + "ws": "^8.16.0" + } }, "node_modules/wrap-ansi": { "version": "8.1.0", diff --git a/package.json b/package.json index 11abdf1..715e7f0 100644 --- a/package.json +++ b/package.json @@ -12,10 +12,9 @@ "@astrojs/node": "^8.2.0", "@mercuryworkshop/bare-mux": "^1.0.5", "@mercuryworkshop/epoxy-transport": "^1.1.0", - "@mercuryworkshop/libcurl-transport": "^1.2.1", + "@mercuryworkshop/libcurl-transport": "^1.2.4", "@titaniumnetwork-dev/ultraviolet": "^3.0.0", "@tomphttp/bare-client": "^2.2.0-alpha", - "@tomphttp/bare-server-node": "^2.0.3", "astro": "^4.4.1", "chalk": "^5.3.0", "compression": "^1.7.4", @@ -26,7 +25,7 @@ "path": "^0.12.7", "rammerhead": "https://github.com/NebulaServices/rammerhead/releases/download/rammerhead-1.2.41-nebula.8/rammerhead-1.2.41-nebula.7.tgz", "typescript": "^5.3.3", - "wisp-server-node": "^1.0.1" + "wisp-server-node": "^1.0.2" }, "devDependencies": { "prettier": "3.2.5", diff --git a/public/sw.js b/public/sw.js index ad2434c..aa05bbd 100644 --- a/public/sw.js +++ b/public/sw.js @@ -1,4 +1,5 @@ importScripts("/epoxy/index.js"); +importScripts("/libcurl/index.cjs"); importScripts("/uv/uv.bundle.js"); importScripts("/uv.config.js"); importScripts(__uv$config.sw); diff --git a/src/components/Footer.astro b/src/components/Footer.astro index baae025..3371c37 100644 --- a/src/components/Footer.astro +++ b/src/components/Footer.astro @@ -47,7 +47,7 @@ const t = useTranslations(lang); justify-content: space-around; color: var(--text-color); position: relative; - padding-top: 200px; + padding-top: 275px; gap: 50px; } .footer-top, diff --git a/src/components/Input.astro b/src/components/Input.astro index 7d0632a..4c0271d 100644 --- a/src/components/Input.astro +++ b/src/components/Input.astro @@ -19,6 +19,7 @@ interface Props {