Skip to content

Commit 41747f0

Browse files
authored
Release v1.0.3 (#5)
- emit a log entry when all DNS lists pass (to show its working)
1 parent d5720ee commit 41747f0

File tree

5 files changed

+20
-14
lines changed

5 files changed

+20
-14
lines changed

.release

Submodule .release updated 1 file

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
44

55
### Unreleased
66

7+
### [1.0.3] - 2024-04-10
8+
9+
- emit a log entry when all DNS lists pass (to show its working)
10+
711
### [1.0.2] - 2024-04-09
812

913
- dep: eslint-plugin-haraka -> @haraka/eslint-config
@@ -18,4 +22,5 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
1822
- Initial release
1923

2024
[1.0.1]: https://github.com/haraka/haraka-plugin-dns-list/releases/tag/1.0.1
21-
[1.0.2]: https://github.com/haraka/haraka-plugin-dns-list/releases/tag/1.0.2
25+
[1.0.2]: https://github.com/haraka/haraka-plugin-dns-list/releases/tag/v1.0.2
26+
[1.0.3]: https://github.com/haraka/haraka-plugin-dns-list/releases/tag/v1.0.3

CONTRIBUTORS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This handcrafted artisinal software is brought to you by:
44

5-
| <img height="80" src="https://avatars.githubusercontent.com/u/261635?v=4"><br><a href="https://github.com/msimerson">msimerson</a> (<a href="https://github.com/haraka/haraka-plugin-access/commits?author=msimerson">4</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/203240?v=4"><br><a href="https://github.com/lnedry">lnedry</a> (<a href="https://github.com/haraka/haraka-plugin-access/commits?author=lnedry">1</a>) |
5+
| <img height="80" src="https://avatars.githubusercontent.com/u/261635?v=4"><br><a href="https://github.com/msimerson">msimerson</a> (<a href="https://github.com/haraka/haraka-plugin-access/commits?author=msimerson">5</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/203240?v=4"><br><a href="https://github.com/lnedry">lnedry</a> (<a href="https://github.com/haraka/haraka-plugin-access/commits?author=lnedry">1</a>) |
66
| :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
77

88
<sub>this file is maintained by [.release](https://github.com/msimerson/.release)</sub>

index.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// dns-lists plugin
22

3-
const dnsPromises = require('dns').promises;
4-
const dns = new dnsPromises.Resolver({timeout: 25000, tries: 1});
3+
const dnsPromises = require('dns').promises
4+
const dns = new dnsPromises.Resolver({ timeout: 25000, tries: 1 })
55
const net = require('net')
66
const net_utils = require('haraka-net-utils')
77

@@ -17,9 +17,9 @@ exports.register = function () {
1717
this.register_hook('connect', 'onConnect')
1818

1919
// IMPORTANT: don't run this on hook_rcpt otherwise we're an open relay...
20-
;['ehlo', 'helo', 'mail'].forEach((hook) => {
20+
for (const hook of ['ehlo', 'helo', 'mail']) {
2121
this.register_hook(hook, 'check_dnswl')
22-
})
22+
}
2323
}
2424

2525
exports.load_config = function () {
@@ -67,12 +67,15 @@ exports.should_skip = function (connection) {
6767
if (!connection) return true
6868

6969
if (connection.remote.is_private) {
70-
connection.logdebug(this, `skip private: ${connection.remote.ip}`)
70+
connection.results.add(this, {
71+
skip: `private: ${connection.remote.ip}`,
72+
emit: true,
73+
})
7174
return true
7275
}
7376

7477
if (this.zones.length === 0) {
75-
connection.logerror(this, 'no zones')
78+
connection.results.add(this, { err: `no zones` })
7679
return true
7780
}
7881

@@ -92,7 +95,6 @@ exports.eachActiveDnsList = async function (connection, zone, nextOnce) {
9295

9396
for (const i of ips) {
9497
if (this.cfg[zone] && this.cfg[zone][i]) {
95-
// console.log(`zone: ${zone} i: ${this.cfg[zone][i]}`)
9698
connection.results.add(this, { msg: this.cfg[zone][i] })
9799
}
98100
}
@@ -122,15 +124,15 @@ exports.eachActiveDnsList = async function (connection, zone, nextOnce) {
122124
}
123125

124126
exports.onConnect = function (next, connection) {
125-
// console.log(`onConnect`)
126-
127+
const plugin = this
127128
if (this.should_skip(connection)) return next()
128129

129130
let calledNext = false
130131
function nextOnce(code, zones) {
131132
// console.log(`nextOnce: ${code} : ${zones}`)
132133
if (calledNext) return
133134
calledNext = true
135+
connection.results.add(plugin, { emit: true })
134136
if (code === undefined || zones === undefined) return next()
135137
next(
136138
code,
@@ -140,7 +142,6 @@ exports.onConnect = function (next, connection) {
140142

141143
const promises = []
142144
for (const zone of this.zones) {
143-
// console.log(`promise zone: ${zone}`)
144145
promises.push(this.eachActiveDnsList(connection, zone, nextOnce))
145146
}
146147

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "haraka-plugin-dns-list",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "Haraka plugin for DNS lists (DNSBL, DNSWL)",
55
"main": "index.js",
66
"files": [

0 commit comments

Comments
 (0)