From cd0fadf952cdf5b0bbda61196cd8d90b86e5a308 Mon Sep 17 00:00:00 2001 From: catfromplan9 <104175360+catfromplan9@users.noreply.github.com> Date: Mon, 21 Apr 2025 18:40:49 +0000 Subject: [PATCH] stop: Pass domain to HTML template (#27) This passes along the domain being accessed as a variable, which is useful for those who choose to customize the HTML. --- src/core/Handler.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/Handler.cpp b/src/core/Handler.cpp index c987a34..05e46aa 100644 --- a/src/core/Handler.cpp +++ b/src/core/Handler.cpp @@ -362,11 +362,16 @@ void CServerHandler::serveStop(const Pistache::Http::Request& req, Pistache::Htt const auto NONCE = generateNonce(); const auto CHALLENGE = CChallenge(fingerprintForRequest(req), NONCE, difficulty); + auto hostDomain = req.headers().getRaw("Host").value(); + if (hostDomain.contains(":")) + hostDomain = hostDomain.substr(0, hostDomain.find(':')); + page.add("challengeDifficulty", CTinylatesProp(std::to_string(difficulty))); page.add("challengeNonce", CTinylatesProp(NONCE)); page.add("challengeSignature", CTinylatesProp(CHALLENGE.signature())); page.add("challengeFingerprint", CTinylatesProp(CHALLENGE.fingerprint())); page.add("challengeTimestamp", CTinylatesProp(CHALLENGE.timestampAsString())); + page.add("hostDomain", CTinylatesProp(hostDomain)); page.add("checkpointVersion", CTinylatesProp(CHECKPOINT_VERSION)); response.send(Pistache::Http::Code::Ok, page.render().value_or("error")); }