option to advertise onion url

This commit is contained in:
2026-07-26 21:43:39 +02:00
parent abedf7a789
commit a3148848f2
2 changed files with 10 additions and 0 deletions

View File

@@ -5,6 +5,7 @@
"domain": "example.com", "domain": "example.com",
"regex": "example\\.com" "regex": "example\\.com"
}, },
"onion": "http://your-onion-address.onion",
"socks": "socks5://127.0.0.1:9050", "socks": "socks5://127.0.0.1:9050",
"mail": "admin@example.com", "mail": "admin@example.com",
"maxfilesize": 104857600, "maxfilesize": 104857600,

View File

@@ -456,6 +456,15 @@ process.on('uncaughtException', err => {
res.setHeader('Permissions-Policy', 'geolocation=(), microphone=(), camera=()'); res.setHeader('Permissions-Policy', 'geolocation=(), microphone=(), camera=()');
// Encourage connection reuse — helps external tools like ShareX avoid repeated TCP/TLS handshakes // Encourage connection reuse — helps external tools like ShareX avoid repeated TCP/TLS handshakes
res.setHeader('Connection', 'keep-alive'); res.setHeader('Connection', 'keep-alive');
// Tor Onion-Location header: advertises .onion service counterpart to Tor Browser users
if (cfg.main.onion && !req.headers['host']?.endsWith('.onion')) {
const p = req.url?.pathname || '/';
const s = req.url?.search || '';
const onionHost = cfg.main.onion.replace(/\/+$/, '');
res.setHeader('Onion-Location', `${onionHost}${p}${s}`);
}
if (isSecure) { if (isSecure) {
res.setHeader('Strict-Transport-Security', 'max-age=31536000; includeSubDomains'); res.setHeader('Strict-Transport-Security', 'max-age=31536000; includeSubDomains');
} }