From 4cd8829bc6dae069b5f6f6aab8dabc5db5d17efb Mon Sep 17 00:00:00 2001 From: dangered wolf Date: Tue, 14 Nov 2023 17:23:38 -0500 Subject: [PATCH] Console log more detailed info on cf workers platform --- src/worker.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/worker.ts b/src/worker.ts index 1306989..6a24d22 100644 --- a/src/worker.ts +++ b/src/worker.ts @@ -105,9 +105,15 @@ app.use('*', logger(customLogger)); app.use('*', async (c, next) => { if (c.req.raw.cf) { - console.log(`Hello from β›… ${c.req.raw.cf.colo ?? 'UNK'}`); + const cf = c.req.raw.cf; + console.log(`Hello from β›… ${cf.colo ?? 'UNK'}`); + console.log(`πŸ“Ά ${cf.httpProtocol ?? 'Unknown HTTP Protocol'} πŸ“ ${cf.clientTcpRtt ?? 'N/A'} ms RTT πŸ”’ ${cf.tlsVersion ?? 'Unencrypted Connection'} (${cf.tlsCipher ?? ''})`) + console.log(`πŸ—ΊοΈ ${cf.city ?? 'Unknown City'}, ${cf.regionCode ? (cf.regionCode + ', ') : ''}${cf.country ?? 'Unknown Country'} ${cf.isEUCountry ? '(EU)' : ''}`); + console.log(`🌐 ${c.req.header('x-real-ip') ?? ''} (${cf.asn ? ('AS' + cf.asn) : 'Unknown ASN'}, ${cf.asOrganization ?? 'Unknown Organization'})`); + } else { + console.log(`🌐 ${c.req.header('x-real-ip') ?? ''}`); } - console.log('userAgent', c.req.header('user-agent')); + console.log('πŸ•΅οΈβ€β™‚οΈ', c.req.header('user-agent')); await next(); });