From 41747f048178cf4a966f3ae0badb14cc1cd946f4 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Wed, 10 Apr 2024 13:24:47 -0700 Subject: [PATCH] Release v1.0.3 (#5) - emit a log entry when all DNS lists pass (to show its working) --- .release | 2 +- CHANGELOG.md | 7 ++++++- CONTRIBUTORS.md | 2 +- index.js | 21 +++++++++++---------- package.json | 2 +- 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/.release b/.release index f18c599..e5763bc 160000 --- a/.release +++ b/.release @@ -1 +1 @@ -Subproject commit f18c599497f7cb1c3b68e9555fb14e8075c4866b +Subproject commit e5763bcea4decd4298e432b2d6251a364f755c12 diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ef9822..f484e6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). ### Unreleased +### [1.0.3] - 2024-04-10 + +- emit a log entry when all DNS lists pass (to show its working) + ### [1.0.2] - 2024-04-09 - dep: eslint-plugin-haraka -> @haraka/eslint-config @@ -18,4 +22,5 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). - Initial release [1.0.1]: https://github.com/haraka/haraka-plugin-dns-list/releases/tag/1.0.1 -[1.0.2]: https://github.com/haraka/haraka-plugin-dns-list/releases/tag/1.0.2 +[1.0.2]: https://github.com/haraka/haraka-plugin-dns-list/releases/tag/v1.0.2 +[1.0.3]: https://github.com/haraka/haraka-plugin-dns-list/releases/tag/v1.0.3 diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 9f1c3fa..e9858c7 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -2,7 +2,7 @@ This handcrafted artisinal software is brought to you by: -|
msimerson (4) |
lnedry (1) | +|
msimerson (5) |
lnedry (1) | | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | this file is maintained by [.release](https://github.com/msimerson/.release) diff --git a/index.js b/index.js index d6aabce..5959047 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ // dns-lists plugin -const dnsPromises = require('dns').promises; -const dns = new dnsPromises.Resolver({timeout: 25000, tries: 1}); +const dnsPromises = require('dns').promises +const dns = new dnsPromises.Resolver({ timeout: 25000, tries: 1 }) const net = require('net') const net_utils = require('haraka-net-utils') @@ -17,9 +17,9 @@ exports.register = function () { this.register_hook('connect', 'onConnect') // IMPORTANT: don't run this on hook_rcpt otherwise we're an open relay... - ;['ehlo', 'helo', 'mail'].forEach((hook) => { + for (const hook of ['ehlo', 'helo', 'mail']) { this.register_hook(hook, 'check_dnswl') - }) + } } exports.load_config = function () { @@ -67,12 +67,15 @@ exports.should_skip = function (connection) { if (!connection) return true if (connection.remote.is_private) { - connection.logdebug(this, `skip private: ${connection.remote.ip}`) + connection.results.add(this, { + skip: `private: ${connection.remote.ip}`, + emit: true, + }) return true } if (this.zones.length === 0) { - connection.logerror(this, 'no zones') + connection.results.add(this, { err: `no zones` }) return true } @@ -92,7 +95,6 @@ exports.eachActiveDnsList = async function (connection, zone, nextOnce) { for (const i of ips) { if (this.cfg[zone] && this.cfg[zone][i]) { - // console.log(`zone: ${zone} i: ${this.cfg[zone][i]}`) connection.results.add(this, { msg: this.cfg[zone][i] }) } } @@ -122,8 +124,7 @@ exports.eachActiveDnsList = async function (connection, zone, nextOnce) { } exports.onConnect = function (next, connection) { - // console.log(`onConnect`) - + const plugin = this if (this.should_skip(connection)) return next() let calledNext = false @@ -131,6 +132,7 @@ exports.onConnect = function (next, connection) { // console.log(`nextOnce: ${code} : ${zones}`) if (calledNext) return calledNext = true + connection.results.add(plugin, { emit: true }) if (code === undefined || zones === undefined) return next() next( code, @@ -140,7 +142,6 @@ exports.onConnect = function (next, connection) { const promises = [] for (const zone of this.zones) { - // console.log(`promise zone: ${zone}`) promises.push(this.eachActiveDnsList(connection, zone, nextOnce)) } diff --git a/package.json b/package.json index 2c262d4..9965ec7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "haraka-plugin-dns-list", - "version": "1.0.2", + "version": "1.0.3", "description": "Haraka plugin for DNS lists (DNSBL, DNSWL)", "main": "index.js", "files": [