onion rules

This commit is contained in:
2026-07-28 03:08:46 +02:00
parent 20aaf183d8
commit ec895a285b
3 changed files with 29 additions and 8 deletions

View File

@@ -460,4 +460,14 @@ export default new class {
console.error(`[ERROR REF ${errId}] ${context}:`, err);
return `Internal Error. Reference: ${errId}`;
}
isOnionRequest(req) {
if (!req || !req.headers) return false;
const rawHost = req.headers['x-forwarded-host'] || req.headers['host'] || '';
if (!rawHost) return false;
const firstHost = rawHost.split(',')[0].trim();
const hostNoPort = firstHost.split(':')[0].trim().toLowerCase();
return hostNoPort.endsWith('.onion');
}
};

View File

@@ -89,7 +89,7 @@ export default (router, tpl) => {
}
// reCAPTCHA verification (bypassed for .onion requests as Google reCAPTCHA cannot validate .onion domains)
const isOnion = req.headers['host']?.endsWith('.onion');
const isOnion = lib.isOnionRequest(req);
if (!isOnion && cfg.recaptcha?.enabled && cfg.recaptcha?.secret_key) {
const rcToken = req.post['g-recaptcha-response'];
if (!rcToken) return renderError("Please complete the reCAPTCHA.");