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 } )
55const net = require ( 'net' )
66const 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
2525exports . 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
124126exports . 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
0 commit comments