Improves logging.

This commit is contained in:
Pierre Lannoy 2024-10-30 16:56:34 +01:00
commit 584fa75842
Signed by: Pierre Lannoy
GPG key ID: D27231EF87D53F31

View file

@ -69,6 +69,7 @@ const listener = async function (req, res) {
if (!host) { if (!host) {
res.writeHead(400); res.writeHead(400);
res.write('Host header is required'); res.write('Host header is required');
console.log('⏹ HTTP/2 400 - Host header is required');
return; return;
} }
let cache = resolveCache[host]; let cache = resolveCache[host];
@ -80,15 +81,18 @@ const listener = async function (req, res) {
res.writeHead(302, { res.writeHead(302, {
'Location': (process.env.BLACKLIST_REDIRECT || 'https://www.youtube.com/watch?v=dQw4w9WgXcQ') /*+ "?d=" + req.headers.host*/, 'Location': (process.env.BLACKLIST_REDIRECT || 'https://www.youtube.com/watch?v=dQw4w9WgXcQ') /*+ "?d=" + req.headers.host*/,
}); });
console.log('⏸ HTTP/2 302 - Blacklist: ' + req.headers.host );
return; return;
} }
res.writeHead(cache.httpStatus, { res.writeHead(cache.httpStatus, {
'Location': cache.expand ? combineURLs(cache.url, url) : cache.url, 'Location': cache.expand ? combineURLs(cache.url, url) : cache.url,
}); });
console.log('⏵ HTTP/2 ' + cache.httpStatus + ' OK: ' + req.headers.host );
return; return;
} catch (error) { } catch (error) {
res.writeHead(400); res.writeHead(400);
res.write(error.message || 'Unknown error'); res.write(error.message || 'Unknown error');
console.log('⏹ HTTP/2 400 - ' + (error.message || 'Unknown error'));
} finally { } finally {
res.end(); res.end();
} }