From 043c9a1d7df7cc41845bb316f51f0a4ea6493d0f Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Mon, 10 Jun 2024 14:54:31 +0200 Subject: [PATCH] Add open proxy script --- scripts/openProxy.ts | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 scripts/openProxy.ts diff --git a/scripts/openProxy.ts b/scripts/openProxy.ts new file mode 100644 index 0000000000..826603b63f --- /dev/null +++ b/scripts/openProxy.ts @@ -0,0 +1,33 @@ +import Script from "./Script" +import { Server } from "./server" +import ScriptUtils from "./ScriptUtils" + +class OpenProxy extends Script{ + + constructor() { + super("Allows any MapComplete-related domain to access the open internet via the proxy. No caching is done") + } + async main(args: string[]): Promise { + new Server(1237,{ + + },[ + { + mustMatch: "json", + mimetype: "application/json", + handle: async (_, params) => { + const url = decodeURIComponent(params.get("url")) + let content = await ScriptUtils.Download(url) + while(content["redirect"]){ + content = await ScriptUtils.Download(content["redirect"]) + } + return content["content"] + } + } + ]) + } + + + +} + +new OpenProxy().run()