Skip to content

Commit

Permalink
Release v1.1.0 (#6)
Browse files Browse the repository at this point in the history
- feat: imported backscatterer from haraka/Haraka
  • Loading branch information
msimerson authored Apr 11, 2024
1 parent 41747f0 commit eb1f94d
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .release
Submodule .release updated 1 files
+2 −3 contributors.js
5 changes: 5 additions & 0 deletions 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.1.0] - 2024-04-10

- feat: imported backscatterer from haraka/Haraka

### [1.0.3] - 2024-04-10

- emit a log entry when all DNS lists pass (to show its working)
Expand All @@ -24,3 +28,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
[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/v1.0.2
[1.0.3]: https://github.com/haraka/haraka-plugin-dns-list/releases/tag/v1.0.3
[1.1.0]: https://github.com/haraka/haraka-plugin-dns-list/releases/tag/v1.1.0
4 changes: 2 additions & 2 deletions 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">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>) |
| :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| <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-dns-list/commits?author=msimerson">6</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-dns-list/commits?author=lnedry">1</a>) |
| :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |

<sub>this file is maintained by [.release](https://github.com/msimerson/.release)</sub>
3 changes: 3 additions & 0 deletions config/dns-list.ini
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,6 @@ type=allow
; 1 = low – reduce chance of false positives (-1.0)
; 2 = medium – make sure to avoid false positives but allow override for clear cases (-10.0)
; 3 = high – avoid override (-100.0)

[ips.backscatterer.org]
enable=false
21 changes: 21 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ exports.register = function () {
for (const hook of ['ehlo', 'helo', 'mail']) {
this.register_hook(hook, 'check_dnswl')
}
this.register_hook('mail', 'check_backscatterer')
}

exports.load_config = function () {
Expand All @@ -31,6 +32,7 @@ exports.load_config = function () {
'*.reject',
'*.ipv6',
'*.loopback_is_rejected',
'-ips.backscatterer.org.enable',
],
},
() => {
Expand Down Expand Up @@ -158,6 +160,25 @@ exports.onConnect = function (next, connection) {
exports.check_dnswl = (next, connection) =>
connection.notes.dnswl ? next(OK) : next()

exports.check_backscatterer = async function (next, connection, params) {
if (!this.cfg['ips.backscatterer.org'].enable) return next()

const user = params[0]?.user ? params[0].user.toLowerCase() : null
if (!(!user || user === 'postmaster')) return next()

try {
const a = await this.lookup(connection.remote.ip, 'ips.backscatterer.org')
if (a)
return next(
DENY,
`Host ${connection.remote.host} [${connection.remote.ip}] is listed by ips.backscatterer.org`,
)
} catch (err) {
connection.logerror(this, err)
}
next()
}

function ipQuery(ip, zone) {
// 1.2.3.4 -> 4.3.2.1.$zone.
if (net.isIPv6(ip)) return [net_utils.ipv6_reverse(ip), zone, ''].join('.')
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.3",
"version": "1.1.0",
"description": "Haraka plugin for DNS lists (DNSBL, DNSWL)",
"main": "index.js",
"files": [
Expand Down
6 changes: 3 additions & 3 deletions test/dns-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ describe('dns-list', function () {

it('loads config/dns-list.ini', function () {
this.plugin.load_config()
// console.log(this.plugin.cfg)
assert.ok(this.plugin.cfg)
})

it('config initializes a boolean', function () {
assert.equal(this.plugin.cfg.stats.enable, false, this.plugin.cfg)
assert.equal(this.plugin.cfg['ips.backscatterer.org'].enable, false)
})

it('sets up a connection', function () {
Expand Down Expand Up @@ -83,10 +83,10 @@ describe('check_zone', function () {
})

describe('check_zones', function () {
this.timeout(22000)
this.timeout(29000)

it('tests each block list', async function () {
await this.plugin.check_zones(6000)
await this.plugin.check_zones(8000)
})
})

Expand Down

0 comments on commit eb1f94d

Please sign in to comment.