Created
March 21, 2023 13:24
-
-
Save homburg/fdc049a0976896dc7dcac35023316356 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const suffix_length = ".l.jfjf.dk".length; | |
async function onRequest(context, url, request) { | |
const [fake_host, raw_port] = request.host.slice(0, -suffix_length).split("__"); | |
let port = Number(raw_port); | |
if (!port || isNaN(port)) { | |
port = 443; | |
} | |
const host = fake_host.replaceAll("_", "."); | |
request.host = host; | |
request.port = port; | |
request.scheme = port === 443 ? "https" : "http"; | |
return request; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment