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.
This commit is contained in:
catfromplan9
2025-04-21 18:40:49 +00:00
committed by GitHub
parent 563a25d7c2
commit cd0fadf952

View File

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