try to get libcurl working, didn't work

This commit is contained in:
wearrrrr 2024-03-16 18:09:25 -05:00
parent fdb93bbd96
commit c3cc83dd1c
14 changed files with 67 additions and 150 deletions

5
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,5 @@
{
"search.exclude": {
"/public/games/**": true
}
}

View file

@ -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);

86
package-lock.json generated
View file

@ -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",

View file

@ -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",

View file

@ -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);

View file

@ -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,

View file

@ -19,6 +19,7 @@ interface Props {
<style>
input {
font-size: 16px;
width: 100%;
border: 2px solid var(--background-highlight);
border-radius: 10px;
@ -26,6 +27,9 @@ interface Props {
color: var(--text-color);
transition: 0.1s ease-in-out;
}
input::placeholder {
color: var(--text-color);
}
input:focus {
outline: none;
border: 2px solid var(--text-color);

View file

@ -61,8 +61,12 @@ const transportsList = [
id="dropdown__open-with"
/>
</div>
<div class="setting__wisp_url">
<label for="wisp-url-input" class="setting-label">{t("settings.proxy.wispURL")}</label>
<Input height="50px" inputName="wisp-url" defaultTextContent="wss://aluu.xyz/" />
</div>
<div class="setting__transport">
<label class="setting-label">{t("settings.proxy.selectedTransport")}</label>
<label class="setting-label">{t("settings.proxy.transport")}</label>
<Dropdown
buttonNameDefault="Epoxy"
dropdownList={transportsList}
@ -70,10 +74,6 @@ const transportsList = [
id="dropdown__transport"
/>
</div>
<div class="setting__bare-url">
<label class="setting-label" for="bare-url-input">{t("settings.proxy.bareURL")}</label>
<Input inputName="bare-url" height="50px" />
</div>
</div>
<div class="setting__searxng-url">
<label for="searxng-url-input" class="setting-label">{t("settings.proxy.searxngURL")}</label>

View file

@ -298,8 +298,8 @@ const t = useTranslations(lang);
let searchEngineDropdown = document.getElementById("dropdown__search-engine-menu");
let openWithDropdown = document.getElementById("dropdown__open-with-menu");
let currentTransportDropdown = document.getElementById("dropdown__transport-menu");
let bareUrlInput = document.getElementById("bare-url-input");
let searxngUrlInput = document.getElementById("searxng-url-input");
let wispURLInput = document.getElementById("wisp-url-input");
let savedSearxngUrl = localStorage.getItem("alu__searxngUrl");
if (savedSearxngUrl != undefined) {
if (savedSearxngUrl == "")
@ -307,11 +307,11 @@ const t = useTranslations(lang);
searxngUrlInput.value = localStorage.getItem("alu__searxngUrl");
}
// Proxy settings
applyInputListeners(bareUrlInput, "alu__bareUrl");
applyInputListeners(searxngUrlInput, "alu__searxngUrl");
applyInputListeners(wispURLInput, "alu__wispUrl");
[selectedProxyDropdown, openWithDropdown, currentTransportDropdown].forEach((dropdown) => {
let dropdownButton = document.getElementById(dropdown.id.replace("-menu", ""))
console.log(dropdownButton)
applyDropdownEventListeners(
dropdown,
dropdownButton.id,
@ -324,21 +324,6 @@ const t = useTranslations(lang);
"alu__searchEngine",
checkSearxng
);
// applyDropdownEventListeners(
// selectedProxyDropdown,
// "dropdown__selected-proxy",
// "alu__selectedProxy"
// );
// applyDropdownEventListeners(
// openWithDropdown,
// "dropdown__open-with",
// "alu__selectedOpenWith"
// );
if (localStorage.getItem("bareUrl")) {
bareUrlInput.value = localStorage.getItem("bareUrl");
} else {
bareUrlInput.value = "/bare/";
}
checkSearxng();
} else if (event.detail == "setting-tab-customization") {
setupCustomizationSettings();

View file

@ -32,7 +32,6 @@
// Set the default transport for the next reload.
localStorage.setItem("alu__selectedTransport", JSON.stringify({ value: this.transport }));
}
console.log(this.transport)
}
getTransport() {
return this.transport;
@ -54,7 +53,7 @@
});
swRegister.then((registration) => {
registration.update().then(() => {
TransportMgr.setTransport(TransportMgr.getTransport());
TransportMgr.setTransport(TransportMgr.getTransport(), localStorage.getItem("alu__wispUrl") || wispURLDefault);
});
});
</script>

View file

@ -40,9 +40,9 @@
"settings.proxy.openPageWith": "Open With",
"settings.proxy.openPageWith.embed": "Embed",
"settings.proxy.openPageWith.newTab": "New Tab",
"settings.proxy.selectedTransport": "Transport",
"settings.proxy.searxngURL": "Searx URL",
"settings.proxy.bareURL": "Bare URL",
"settings.proxy.transport": "Transport",
"settings.proxy.wispURL": "Wisp URL",
"settings.customization": "Customization",
"settings.customization.theme": "Theme",

View file

@ -37,10 +37,11 @@
"settings.proxy.selectedProxy": "選択されたプロキシ",
"settings.proxy.searchEngine": "検索エンジン",
"settings.proxy.openPageWith": "開く",
"settings.proxy.searxngURL": "SearxのURL",
"settings.proxy.openPageWith.embed": "埋め込み",
"settings.proxy.openPageWith.newTab": "新しいタブ",
"settings.proxy.bareURL": "BareのURL",
"settings.proxy.searxngURL": "SearxのURL",
"settings.proxy.transport": "トランスポート",
"settings.proxy.wispURL": "ウィスプのURL",
"settings.customization": "カスタマイズ",
"settings.customization.theme": "テーマ",

View file

@ -209,11 +209,6 @@
"image": "/games/solitaire/logo.png",
"slug": "solitaire"
},
"sort-the-court": {
"name": "Sort the Court",
"image": "/games/sort-the-court/logo.jpg",
"slug": "sort-the-court"
},
"suika-combination": {
"name": "Suika Combination",
"image": "/games/suika-combination/logo.webp",

View file

@ -14,12 +14,8 @@ export function getStaticPaths() {
<Layout title={t("pages.home")}>
<script src="/epoxy/index.js" is:inline></script>
<script src="/libcurl/index.mjs" is:inline type="module"></script>
<script src="/libcurl/index.cjs" is:inline></script>
<script src="/baremux/bare.cjs" is:inline></script>
<script>
import { createBareClient } from '@tomphttp/bare-client';
createBareClient('/bare/');
</script>
<TransportManager />
<div class="main-content">