Skip to content

Commit

Permalink
Release v1.0.3 (#5)
Browse files Browse the repository at this point in the history
- emit a log entry when all DNS lists pass (to show its working)
  • Loading branch information
msimerson authored Apr 10, 2024
1 parent d5720ee commit 41747f0
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .release
Submodule .release updated 1 files
+11 −5 start.sh
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This handcrafted artisinal software is brought to you by:

| <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>) |
| <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>) |
| :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |

<sub>this file is maintained by [.release](https://github.com/msimerson/.release)</sub>
21 changes: 11 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
@@ -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')

Expand All @@ -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 () {
Expand Down Expand Up @@ -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
}

Expand All @@ -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] })
}
}
Expand Down Expand Up @@ -122,15 +124,15 @@ 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
function nextOnce(code, zones) {
// 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,
Expand All @@ -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))
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down

0 comments on commit 41747f0

Please sign in to comment.