diff --git a/index.js b/index.js index cd35a2a..c27c356 100644 --- a/index.js +++ b/index.js @@ -143,6 +143,14 @@ const processLogLine = async (line, test = false) => { (async () => { log(`${repoFullUrl} - v${version} | Author: ${authorEmailWebsite}`); + // Auto updates + if (AUTO_UPDATE_ENABLED && AUTO_UPDATE_SCHEDULE && SERVER_ID !== 'development') { + await require('./scripts/services/updates.js')(); + } else { + await require('./scripts/services/version.js')(); + } + + // Bulk await loadReportedIPs(); await loadBufferFromFile(); @@ -151,6 +159,8 @@ const processLogLine = async (line, test = false) => { await sendBulkReport(); } + + // Fetch IPs log('Trying to fetch your IPv4 and IPv6 address from api.sefinek.net...'); await refreshServerIPs(); log(`Fetched ${getServerIPs()?.length} of your IP addresses. If any of them accidentally appear in the UFW logs, they will be ignored.`, 1); @@ -160,8 +170,8 @@ const processLogLine = async (line, test = false) => { return; } + // Watch fileOffset = fs.statSync(UFW_LOG_FILE).size; - chokidar.watch(UFW_LOG_FILE, { persistent: true, ignoreInitial: true }) .on('change', path => { const stats = fs.statSync(path); @@ -177,20 +187,13 @@ const processLogLine = async (line, test = false) => { }); }); - // Auto updates - if (AUTO_UPDATE_ENABLED && AUTO_UPDATE_SCHEDULE && SERVER_ID !== 'development') { - await require('./scripts/services/updates.js')(); - } else { - await require('./scripts/services/version.js')(); - } - // Summaries if (DISCORD_WEBHOOKS_ENABLED && DISCORD_WEBHOOKS_URL) await require('./scripts/services/summaries.js')(); // Ready await sendWebhook(`[${name}](${repoFullUrl}) has been successfully started on the device \`${SERVER_ID}\`.`, 0x59D267); log(`Ready! Now monitoring: ${UFW_LOG_FILE}`, 1); - process.send && process.send('ready'); + process.send?.('ready'); })(); module.exports = processLogLine; \ No newline at end of file diff --git a/scripts b/scripts index 0688a89..a84dc77 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit 0688a8955e44e21f5ae8db1d691918c200d40725 +Subproject commit a84dc770ce95467f07dbd2a052b0c03f7a50372a