Haraka 3.1.0 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierignore +4 -0
- package/CONTRIBUTORS.md +5 -5
- package/Changes.md +69 -50
- package/Plugins.md +3 -1
- package/README.md +1 -1
- package/bin/haraka +475 -478
- package/config/outbound.ini +3 -0
- package/connection.js +1072 -1108
- package/docs/Connection.md +29 -30
- package/docs/CoreConfig.md +38 -39
- package/docs/CustomReturnCodes.md +0 -1
- package/docs/HAProxy.md +2 -2
- package/docs/Header.md +1 -1
- package/docs/Logging.md +29 -5
- package/docs/Outbound.md +93 -78
- package/docs/Plugins.md +103 -108
- package/docs/Transaction.md +49 -51
- package/docs/Tutorial.md +127 -143
- package/docs/deprecated/access.md +0 -1
- package/docs/deprecated/backscatterer.md +2 -3
- package/docs/deprecated/connect.rdns_access.md +18 -27
- package/docs/deprecated/data.headers.md +0 -1
- package/docs/deprecated/data.nomsgid.md +1 -2
- package/docs/deprecated/data.noreceived.md +1 -2
- package/docs/deprecated/data.rfc5322_header_checks.md +1 -2
- package/docs/deprecated/dkim_sign.md +13 -17
- package/docs/deprecated/dkim_verify.md +9 -17
- package/docs/deprecated/dnsbl.md +36 -38
- package/docs/deprecated/dnswl.md +41 -43
- package/docs/deprecated/lookup_rdns.strict.md +21 -34
- package/docs/deprecated/mail_from.access.md +17 -25
- package/docs/deprecated/mail_from.blocklist.md +9 -12
- package/docs/deprecated/mail_from.nobounces.md +1 -2
- package/docs/deprecated/rcpt_to.access.md +20 -27
- package/docs/deprecated/rcpt_to.blocklist.md +10 -13
- package/docs/deprecated/rcpt_to.routes.md +0 -1
- package/docs/deprecated/rdns.regexp.md +13 -15
- package/docs/plugins/aliases.md +89 -89
- package/docs/plugins/auth/auth_bridge.md +5 -7
- package/docs/plugins/auth/auth_ldap.md +11 -14
- package/docs/plugins/auth/auth_proxy.md +10 -12
- package/docs/plugins/auth/auth_vpopmaild.md +5 -6
- package/docs/plugins/auth/flat_file.md +4 -4
- package/docs/plugins/block_me.md +3 -3
- package/docs/plugins/data.signatures.md +1 -2
- package/docs/plugins/delay_deny.md +3 -4
- package/docs/plugins/max_unrecognized_commands.md +4 -4
- package/docs/plugins/prevent_credential_leaks.md +6 -6
- package/docs/plugins/process_title.md +18 -18
- package/docs/plugins/queue/deliver.md +2 -3
- package/docs/plugins/queue/discard.md +4 -4
- package/docs/plugins/queue/lmtp.md +1 -3
- package/docs/plugins/queue/qmail-queue.md +7 -9
- package/docs/plugins/queue/quarantine.md +16 -21
- package/docs/plugins/queue/rabbitmq.md +8 -11
- package/docs/plugins/queue/rabbitmq_amqplib.md +43 -39
- package/docs/plugins/queue/smtp_bridge.md +7 -10
- package/docs/plugins/queue/smtp_forward.md +42 -34
- package/docs/plugins/queue/smtp_proxy.md +30 -29
- package/docs/plugins/queue/test.md +1 -3
- package/docs/plugins/rcpt_to.in_host_list.md +6 -6
- package/docs/plugins/rcpt_to.max_count.md +1 -1
- package/docs/plugins/record_envelope_addresses.md +3 -3
- package/docs/plugins/reseed_rng.md +6 -6
- package/docs/plugins/status.md +9 -8
- package/docs/plugins/tarpit.md +7 -11
- package/docs/plugins/tls.md +12 -17
- package/docs/plugins/toobusy.md +4 -4
- package/docs/plugins/xclient.md +3 -3
- package/docs/tutorials/Migrating_from_v1_to_v2.md +19 -41
- package/docs/tutorials/SettingUpOutbound.md +6 -9
- package/endpoint.js +35 -38
- package/eslint.config.mjs +22 -19
- package/haraka.js +42 -47
- package/host_pool.js +75 -79
- package/http/html/404.html +45 -49
- package/http/html/index.html +39 -28
- package/http/package.json +2 -4
- package/line_socket.js +27 -28
- package/logger.js +182 -201
- package/outbound/client_pool.js +34 -27
- package/outbound/config.js +64 -59
- package/outbound/fsync_writestream.js +24 -25
- package/outbound/hmail.js +888 -835
- package/outbound/index.js +194 -187
- package/outbound/qfile.js +49 -52
- package/outbound/queue.js +197 -190
- package/outbound/timer_queue.js +41 -43
- package/outbound/tls.js +68 -61
- package/outbound/todo.js +11 -11
- package/package.json +38 -33
- package/plugins/.eslintrc.yaml +0 -1
- package/plugins/auth/auth_base.js +123 -127
- package/plugins/auth/auth_bridge.js +7 -7
- package/plugins/auth/auth_proxy.js +121 -126
- package/plugins/auth/auth_vpopmaild.js +84 -85
- package/plugins/auth/flat_file.js +18 -17
- package/plugins/block_me.js +31 -31
- package/plugins/data.signatures.js +13 -13
- package/plugins/delay_deny.js +65 -61
- package/plugins/prevent_credential_leaks.js +23 -23
- package/plugins/process_title.js +125 -128
- package/plugins/profile.js +5 -5
- package/plugins/queue/deliver.js +3 -3
- package/plugins/queue/discard.js +13 -14
- package/plugins/queue/lmtp.js +16 -17
- package/plugins/queue/qmail-queue.js +54 -55
- package/plugins/queue/quarantine.js +68 -70
- package/plugins/queue/rabbitmq.js +80 -87
- package/plugins/queue/rabbitmq_amqplib.js +75 -54
- package/plugins/queue/smtp_bridge.js +16 -16
- package/plugins/queue/smtp_forward.js +175 -179
- package/plugins/queue/smtp_proxy.js +69 -71
- package/plugins/queue/test.js +9 -9
- package/plugins/rcpt_to.host_list_base.js +30 -34
- package/plugins/rcpt_to.in_host_list.js +19 -19
- package/plugins/record_envelope_addresses.js +4 -4
- package/plugins/reseed_rng.js +4 -4
- package/plugins/status.js +90 -97
- package/plugins/tarpit.js +25 -14
- package/plugins/tls.js +68 -68
- package/plugins/toobusy.js +21 -23
- package/plugins/xclient.js +51 -53
- package/plugins.js +276 -293
- package/rfc1869.js +30 -35
- package/server.js +308 -299
- package/smtp_client.js +244 -228
- package/test/.eslintrc.yaml +0 -1
- package/test/connection.js +127 -134
- package/test/endpoint.js +53 -47
- package/test/fixtures/line_socket.js +12 -12
- package/test/fixtures/util_hmailitem.js +89 -85
- package/test/host_pool.js +90 -92
- package/test/installation/plugins/base_plugin.js +2 -2
- package/test/installation/plugins/folder_plugin/index.js +2 -3
- package/test/installation/plugins/inherits.js +3 -3
- package/test/installation/plugins/load_first.js +2 -3
- package/test/installation/plugins/plugin.js +1 -3
- package/test/installation/plugins/tls.js +2 -4
- package/test/logger.js +135 -116
- package/test/outbound/hmail.js +49 -35
- package/test/outbound/index.js +118 -101
- package/test/outbound/qfile.js +51 -53
- package/test/outbound_bounce_net_errors.js +84 -69
- package/test/outbound_bounce_rfc3464.js +235 -165
- package/test/plugins/auth/auth_base.js +420 -279
- package/test/plugins/auth/auth_vpopmaild.js +38 -39
- package/test/plugins/queue/smtp_forward.js +126 -104
- package/test/plugins/rcpt_to.host_list_base.js +85 -67
- package/test/plugins/rcpt_to.in_host_list.js +159 -112
- package/test/plugins/status.js +71 -64
- package/test/plugins/tls.js +37 -34
- package/test/plugins.js +97 -92
- package/test/rfc1869.js +19 -26
- package/test/server.js +293 -272
- package/test/smtp_client.js +180 -176
- package/test/tls_socket.js +62 -66
- package/test/transaction.js +159 -160
- package/tls_socket.js +331 -333
- package/transaction.js +129 -137
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
'use strict'
|
|
1
|
+
'use strict'
|
|
2
2
|
|
|
3
3
|
const assert = require('node:assert')
|
|
4
|
-
const path = require('node:path')
|
|
4
|
+
const path = require('node:path')
|
|
5
5
|
|
|
6
|
-
const fixtures = require('haraka-test-fixtures')
|
|
6
|
+
const fixtures = require('haraka-test-fixtures')
|
|
7
7
|
|
|
8
8
|
const _set_up = (done) => {
|
|
9
|
-
this.backup = {}
|
|
9
|
+
this.backup = {}
|
|
10
10
|
|
|
11
|
-
this.plugin = new fixtures.plugin('auth/auth_vpopmaild')
|
|
12
|
-
this.plugin.inherits('auth/auth_base')
|
|
11
|
+
this.plugin = new fixtures.plugin('auth/auth_vpopmaild')
|
|
12
|
+
this.plugin.inherits('auth/auth_base')
|
|
13
13
|
|
|
14
14
|
// reset the config/root_path
|
|
15
|
-
this.plugin.config.root_path = path.resolve(__dirname, '../../../config')
|
|
16
|
-
this.plugin.cfg = this.plugin.config.get('auth_vpopmaild.ini')
|
|
15
|
+
this.plugin.config.root_path = path.resolve(__dirname, '../../../config')
|
|
16
|
+
this.plugin.cfg = this.plugin.config.get('auth_vpopmaild.ini')
|
|
17
17
|
|
|
18
|
-
this.connection = fixtures.connection.createConnection()
|
|
19
|
-
this.connection.capabilities=null
|
|
18
|
+
this.connection = fixtures.connection.createConnection()
|
|
19
|
+
this.connection.capabilities = null
|
|
20
20
|
|
|
21
|
-
done()
|
|
21
|
+
done()
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
describe('hook_capabilities', () => {
|
|
@@ -26,33 +26,33 @@ describe('hook_capabilities', () => {
|
|
|
26
26
|
|
|
27
27
|
it('no TLS', (done) => {
|
|
28
28
|
this.plugin.hook_capabilities((rc, msg) => {
|
|
29
|
-
assert.equal(undefined, rc)
|
|
30
|
-
assert.equal(undefined, msg)
|
|
31
|
-
assert.equal(null, this.connection.capabilities)
|
|
32
|
-
done()
|
|
33
|
-
}, this.connection)
|
|
29
|
+
assert.equal(undefined, rc)
|
|
30
|
+
assert.equal(undefined, msg)
|
|
31
|
+
assert.equal(null, this.connection.capabilities)
|
|
32
|
+
done()
|
|
33
|
+
}, this.connection)
|
|
34
34
|
})
|
|
35
35
|
|
|
36
36
|
it('with TLS', (done) => {
|
|
37
|
-
this.connection.tls.enabled=true
|
|
38
|
-
this.connection.capabilities=[]
|
|
37
|
+
this.connection.tls.enabled = true
|
|
38
|
+
this.connection.capabilities = []
|
|
39
39
|
this.plugin.hook_capabilities((rc, msg) => {
|
|
40
|
-
assert.equal(undefined, rc)
|
|
41
|
-
assert.equal(undefined, msg)
|
|
42
|
-
assert.ok(this.connection.capabilities.length)
|
|
43
|
-
done()
|
|
44
|
-
}, this.connection)
|
|
40
|
+
assert.equal(undefined, rc)
|
|
41
|
+
assert.equal(undefined, msg)
|
|
42
|
+
assert.ok(this.connection.capabilities.length)
|
|
43
|
+
done()
|
|
44
|
+
}, this.connection)
|
|
45
45
|
})
|
|
46
46
|
|
|
47
47
|
it('with TLS, sysadmin', (done) => {
|
|
48
|
-
this.connection.tls.enabled=true
|
|
49
|
-
this.connection.capabilities=[]
|
|
48
|
+
this.connection.tls.enabled = true
|
|
49
|
+
this.connection.capabilities = []
|
|
50
50
|
this.plugin.hook_capabilities((rc, msg) => {
|
|
51
|
-
assert.equal(undefined, rc)
|
|
52
|
-
assert.equal(undefined, msg)
|
|
53
|
-
assert.ok(this.connection.capabilities.length)
|
|
54
|
-
done()
|
|
55
|
-
}, this.connection)
|
|
51
|
+
assert.equal(undefined, rc)
|
|
52
|
+
assert.equal(undefined, msg)
|
|
53
|
+
assert.ok(this.connection.capabilities.length)
|
|
54
|
+
done()
|
|
55
|
+
}, this.connection)
|
|
56
56
|
})
|
|
57
57
|
})
|
|
58
58
|
|
|
@@ -60,9 +60,9 @@ describe('get_vpopmaild_socket', () => {
|
|
|
60
60
|
beforeEach(_set_up)
|
|
61
61
|
|
|
62
62
|
it('any', () => {
|
|
63
|
-
const socket = this.plugin.get_vpopmaild_socket('foo@localhost.com')
|
|
64
|
-
assert.ok(socket)
|
|
65
|
-
socket.end()
|
|
63
|
+
const socket = this.plugin.get_vpopmaild_socket('foo@localhost.com')
|
|
64
|
+
assert.ok(socket)
|
|
65
|
+
socket.end()
|
|
66
66
|
})
|
|
67
67
|
})
|
|
68
68
|
|
|
@@ -72,12 +72,11 @@ describe('get_plain_passwd', () => {
|
|
|
72
72
|
it('matt@example.com', (done) => {
|
|
73
73
|
if (this.plugin.cfg['example.com'].sysadmin) {
|
|
74
74
|
this.plugin.get_plain_passwd('matt@example.com', (pass) => {
|
|
75
|
-
assert.ok(pass)
|
|
76
|
-
done()
|
|
77
|
-
})
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
done();
|
|
75
|
+
assert.ok(pass)
|
|
76
|
+
done()
|
|
77
|
+
})
|
|
78
|
+
} else {
|
|
79
|
+
done()
|
|
81
80
|
}
|
|
82
81
|
})
|
|
83
82
|
})
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
'use strict'
|
|
1
|
+
'use strict'
|
|
2
2
|
const assert = require('node:assert')
|
|
3
|
-
const path = require('node:path')
|
|
3
|
+
const path = require('node:path')
|
|
4
4
|
|
|
5
|
-
const { Address } = require('address-rfc2821')
|
|
6
|
-
const fixtures
|
|
7
|
-
const Notes
|
|
5
|
+
const { Address } = require('address-rfc2821')
|
|
6
|
+
const fixtures = require('haraka-test-fixtures')
|
|
7
|
+
const Notes = require('haraka-notes')
|
|
8
8
|
|
|
9
|
-
const OK = 906
|
|
9
|
+
const OK = 906
|
|
10
10
|
|
|
11
11
|
const _setup = (done) => {
|
|
12
|
-
this.plugin = new fixtures.plugin('queue/smtp_forward')
|
|
12
|
+
this.plugin = new fixtures.plugin('queue/smtp_forward')
|
|
13
13
|
|
|
14
14
|
// switch config directory to 'test/config'
|
|
15
|
-
this.plugin.config = this.plugin.config.module_config(path.resolve('test'))
|
|
15
|
+
this.plugin.config = this.plugin.config.module_config(path.resolve('test'))
|
|
16
16
|
|
|
17
|
-
this.plugin.register()
|
|
18
|
-
this.hmail = { todo: { notes: new Notes() } }
|
|
17
|
+
this.plugin.register()
|
|
18
|
+
this.hmail = { todo: { notes: new Notes() } }
|
|
19
19
|
|
|
20
|
-
this.connection = new fixtures.connection.createConnection()
|
|
21
|
-
this.connection.init_transaction()
|
|
20
|
+
this.connection = new fixtures.connection.createConnection()
|
|
21
|
+
this.connection.init_transaction()
|
|
22
22
|
|
|
23
|
-
done()
|
|
23
|
+
done()
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
describe('smtp_forward', () => {
|
|
27
27
|
describe('tls config', () => {
|
|
28
28
|
it('TLS enabled but no outbound config in tls.ini', () => {
|
|
29
|
-
const plugin = new fixtures.plugin('queue/smtp_forward')
|
|
30
|
-
plugin.register()
|
|
29
|
+
const plugin = new fixtures.plugin('queue/smtp_forward')
|
|
30
|
+
plugin.register()
|
|
31
31
|
|
|
32
|
-
assert.equal(plugin.tls_options, undefined)
|
|
33
|
-
assert.equal(plugin.register_hook.called, true)
|
|
32
|
+
assert.equal(plugin.tls_options, undefined)
|
|
33
|
+
assert.equal(plugin.register_hook.called, true)
|
|
34
34
|
})
|
|
35
35
|
})
|
|
36
36
|
|
|
@@ -38,8 +38,8 @@ describe('smtp_forward', () => {
|
|
|
38
38
|
beforeEach(_setup)
|
|
39
39
|
|
|
40
40
|
it('register', () => {
|
|
41
|
-
this.plugin.register()
|
|
42
|
-
assert.ok(this.plugin.cfg.main)
|
|
41
|
+
this.plugin.register()
|
|
42
|
+
assert.ok(this.plugin.cfg.main)
|
|
43
43
|
})
|
|
44
44
|
})
|
|
45
45
|
|
|
@@ -47,77 +47,68 @@ describe('smtp_forward', () => {
|
|
|
47
47
|
beforeEach(_setup)
|
|
48
48
|
|
|
49
49
|
it('no recipient', () => {
|
|
50
|
-
const cfg = this.plugin.get_config(this.connection)
|
|
51
|
-
assert.equal(cfg.host, 'localhost')
|
|
52
|
-
assert.equal(cfg.enable_tls, true)
|
|
53
|
-
assert.equal(cfg.one_message_per_rcpt, true)
|
|
50
|
+
const cfg = this.plugin.get_config(this.connection)
|
|
51
|
+
assert.equal(cfg.host, 'localhost')
|
|
52
|
+
assert.equal(cfg.enable_tls, true)
|
|
53
|
+
assert.equal(cfg.one_message_per_rcpt, true)
|
|
54
54
|
})
|
|
55
55
|
|
|
56
56
|
it('null recipient', () => {
|
|
57
|
-
this.connection.transaction.rcpt_to.push(new Address('<>'))
|
|
58
|
-
const cfg = this.plugin.get_config(this.connection)
|
|
59
|
-
assert.equal(cfg.host, 'localhost')
|
|
60
|
-
assert.equal(cfg.enable_tls, true)
|
|
61
|
-
assert.equal(cfg.one_message_per_rcpt, true)
|
|
57
|
+
this.connection.transaction.rcpt_to.push(new Address('<>'))
|
|
58
|
+
const cfg = this.plugin.get_config(this.connection)
|
|
59
|
+
assert.equal(cfg.host, 'localhost')
|
|
60
|
+
assert.equal(cfg.enable_tls, true)
|
|
61
|
+
assert.equal(cfg.one_message_per_rcpt, true)
|
|
62
62
|
})
|
|
63
63
|
|
|
64
64
|
it('valid recipient', () => {
|
|
65
|
-
this.connection.transaction.rcpt_to.push(
|
|
66
|
-
|
|
67
|
-
)
|
|
68
|
-
|
|
69
|
-
assert.equal(cfg.
|
|
70
|
-
assert.equal(cfg.one_message_per_rcpt, true);
|
|
71
|
-
assert.equal(cfg.host, 'localhost');
|
|
65
|
+
this.connection.transaction.rcpt_to.push(new Address('<matt@example.com>'))
|
|
66
|
+
const cfg = this.plugin.get_config(this.connection)
|
|
67
|
+
assert.equal(cfg.enable_tls, true)
|
|
68
|
+
assert.equal(cfg.one_message_per_rcpt, true)
|
|
69
|
+
assert.equal(cfg.host, 'localhost')
|
|
72
70
|
})
|
|
73
71
|
|
|
74
72
|
it('valid recipient with route', () => {
|
|
75
|
-
this.connection.transaction.rcpt_to.push(
|
|
76
|
-
new Address('<matt@test.com>')
|
|
77
|
-
);
|
|
73
|
+
this.connection.transaction.rcpt_to.push(new Address('<matt@test.com>'))
|
|
78
74
|
assert.deepEqual(this.plugin.get_config(this.connection), {
|
|
79
75
|
host: '1.2.3.4',
|
|
80
76
|
enable_tls: true,
|
|
81
77
|
auth_user: 'postmaster@test.com',
|
|
82
78
|
auth_pass: 'superDuperSecret',
|
|
83
|
-
})
|
|
79
|
+
})
|
|
84
80
|
})
|
|
85
81
|
|
|
86
82
|
it('valid recipient with route & diff config', () => {
|
|
87
|
-
this.connection.transaction.rcpt_to.push(
|
|
88
|
-
|
|
89
|
-
);
|
|
90
|
-
const cfg = this.plugin.get_config(this.connection);
|
|
83
|
+
this.connection.transaction.rcpt_to.push(new Address('<matt@test1.com>'))
|
|
84
|
+
const cfg = this.plugin.get_config(this.connection)
|
|
91
85
|
assert.deepEqual(cfg, {
|
|
92
86
|
host: '1.2.3.4',
|
|
93
|
-
enable_tls: false
|
|
94
|
-
})
|
|
87
|
+
enable_tls: false,
|
|
88
|
+
})
|
|
95
89
|
})
|
|
96
90
|
|
|
97
91
|
it('valid 2 recipients with same route', () => {
|
|
98
|
-
this.connection.transaction.rcpt_to.push(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
);
|
|
102
|
-
const cfg = this.plugin.get_config(this.connection);
|
|
103
|
-
assert.deepEqual(cfg.host, '1.2.3.4' );
|
|
92
|
+
this.connection.transaction.rcpt_to.push(new Address('<matt@test.com>'), new Address('<matt@test.com>'))
|
|
93
|
+
const cfg = this.plugin.get_config(this.connection)
|
|
94
|
+
assert.deepEqual(cfg.host, '1.2.3.4')
|
|
104
95
|
})
|
|
105
96
|
|
|
106
97
|
it('null sender', () => {
|
|
107
|
-
this.plugin.cfg.main.domain_selector = 'mail_from'
|
|
108
|
-
this.connection.transaction.mail_from = new Address('<>')
|
|
109
|
-
const cfg = this.plugin.get_config(this.connection)
|
|
110
|
-
assert.equal(cfg.host, 'localhost')
|
|
111
|
-
assert.equal(cfg.enable_tls, true)
|
|
112
|
-
assert.equal(cfg.one_message_per_rcpt, true)
|
|
98
|
+
this.plugin.cfg.main.domain_selector = 'mail_from'
|
|
99
|
+
this.connection.transaction.mail_from = new Address('<>')
|
|
100
|
+
const cfg = this.plugin.get_config(this.connection)
|
|
101
|
+
assert.equal(cfg.host, 'localhost')
|
|
102
|
+
assert.equal(cfg.enable_tls, true)
|
|
103
|
+
assert.equal(cfg.one_message_per_rcpt, true)
|
|
113
104
|
})
|
|
114
105
|
|
|
115
106
|
it('return mail_from domain configuration', () => {
|
|
116
|
-
this.connection.transaction.mail_from = new Address('<matt@test2.com>')
|
|
117
|
-
this.plugin.cfg.main.domain_selector = 'mail_from'
|
|
118
|
-
const cfg = this.plugin.get_config(this.connection)
|
|
119
|
-
assert.deepEqual(cfg.host, '2.3.4.5')
|
|
120
|
-
delete this.plugin.cfg.main.domain_selector
|
|
107
|
+
this.connection.transaction.mail_from = new Address('<matt@test2.com>')
|
|
108
|
+
this.plugin.cfg.main.domain_selector = 'mail_from'
|
|
109
|
+
const cfg = this.plugin.get_config(this.connection)
|
|
110
|
+
assert.deepEqual(cfg.host, '2.3.4.5')
|
|
111
|
+
delete this.plugin.cfg.main.domain_selector // clear this for future tests
|
|
121
112
|
})
|
|
122
113
|
})
|
|
123
114
|
|
|
@@ -125,53 +116,84 @@ describe('smtp_forward', () => {
|
|
|
125
116
|
beforeEach(_setup)
|
|
126
117
|
|
|
127
118
|
it('returns no outbound route for undefined domains', (done) => {
|
|
128
|
-
this.plugin.get_mx(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
119
|
+
this.plugin.get_mx(
|
|
120
|
+
(code, mx) => {
|
|
121
|
+
assert.equal(code, undefined)
|
|
122
|
+
assert.deepEqual(mx, undefined)
|
|
123
|
+
done()
|
|
124
|
+
},
|
|
125
|
+
this.hmail,
|
|
126
|
+
'undefined.com',
|
|
127
|
+
)
|
|
133
128
|
})
|
|
134
129
|
|
|
135
130
|
it('returns no outbound route when queue.wants !== smtp_forward', (done) => {
|
|
136
131
|
this.hmail.todo.notes.set('queue.wants', 'outbound')
|
|
137
132
|
this.hmail.todo.notes.set('queue.next_hop', 'smtp://5.4.3.2:26')
|
|
138
|
-
this.plugin.get_mx(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
133
|
+
this.plugin.get_mx(
|
|
134
|
+
(code, mx) => {
|
|
135
|
+
assert.equal(code, undefined)
|
|
136
|
+
assert.deepEqual(mx, undefined)
|
|
137
|
+
done()
|
|
138
|
+
},
|
|
139
|
+
this.hmail,
|
|
140
|
+
'undefined.com',
|
|
141
|
+
)
|
|
143
142
|
})
|
|
144
143
|
|
|
145
144
|
it('returns an outbound route for defined domains', (done) => {
|
|
146
|
-
this.plugin.get_mx(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
145
|
+
this.plugin.get_mx(
|
|
146
|
+
(code, mx) => {
|
|
147
|
+
assert.equal(code, OK)
|
|
148
|
+
assert.deepEqual(mx, {
|
|
149
|
+
priority: 0,
|
|
150
|
+
exchange: '1.2.3.4',
|
|
151
|
+
port: 2555,
|
|
152
|
+
auth_user: 'postmaster@test.com',
|
|
153
|
+
auth_pass: 'superDuperSecret',
|
|
154
|
+
})
|
|
155
|
+
done()
|
|
156
|
+
},
|
|
157
|
+
this.hmail,
|
|
158
|
+
'test.com',
|
|
159
|
+
)
|
|
155
160
|
})
|
|
156
161
|
|
|
157
162
|
it('is enabled when queue.wants is set', (done) => {
|
|
158
163
|
this.hmail.todo.notes.set('queue.wants', 'smtp_forward')
|
|
159
164
|
this.hmail.todo.notes.set('queue.next_hop', 'smtp://4.3.2.1:465')
|
|
160
|
-
this.plugin.get_mx(
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
+
this.plugin.get_mx(
|
|
166
|
+
(code, mx) => {
|
|
167
|
+
assert.equal(code, OK)
|
|
168
|
+
assert.deepEqual(mx, {
|
|
169
|
+
priority: 0,
|
|
170
|
+
port: 465,
|
|
171
|
+
exchange: '4.3.2.1',
|
|
172
|
+
})
|
|
173
|
+
done()
|
|
174
|
+
},
|
|
175
|
+
this.hmail,
|
|
176
|
+
'undefined.com',
|
|
177
|
+
)
|
|
165
178
|
})
|
|
166
179
|
|
|
167
180
|
it('sets using_lmtp when next_hop URL is lmtp', (done) => {
|
|
168
181
|
this.hmail.todo.notes.set('queue.wants', 'smtp_forward')
|
|
169
182
|
this.hmail.todo.notes.set('queue.next_hop', 'lmtp://4.3.2.1')
|
|
170
|
-
this.plugin.get_mx(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
183
|
+
this.plugin.get_mx(
|
|
184
|
+
(code, mx) => {
|
|
185
|
+
assert.equal(code, OK)
|
|
186
|
+
assert.deepEqual(mx, {
|
|
187
|
+
priority: 0,
|
|
188
|
+
port: 24,
|
|
189
|
+
using_lmtp: true,
|
|
190
|
+
exchange: '4.3.2.1',
|
|
191
|
+
})
|
|
192
|
+
done()
|
|
193
|
+
},
|
|
194
|
+
this.hmail,
|
|
195
|
+
'undefined.com',
|
|
196
|
+
)
|
|
175
197
|
})
|
|
176
198
|
})
|
|
177
199
|
|
|
@@ -179,28 +201,28 @@ describe('smtp_forward', () => {
|
|
|
179
201
|
beforeEach(_setup)
|
|
180
202
|
|
|
181
203
|
it('enable_outbound is false by default', () => {
|
|
182
|
-
assert.equal(this.plugin.is_outbound_enabled(this.plugin.cfg), false)
|
|
204
|
+
assert.equal(this.plugin.is_outbound_enabled(this.plugin.cfg), false)
|
|
183
205
|
})
|
|
184
206
|
|
|
185
207
|
it('per-domain enable_outbound is false by default', () => {
|
|
186
|
-
this.connection.transaction.rcpt_to = [
|
|
187
|
-
const cfg = this.plugin.get_config(this.connection)
|
|
188
|
-
assert.equal(this.plugin.is_outbound_enabled(cfg), false)
|
|
208
|
+
this.connection.transaction.rcpt_to = [new Address('<postmaster@test.com>')]
|
|
209
|
+
const cfg = this.plugin.get_config(this.connection)
|
|
210
|
+
assert.equal(this.plugin.is_outbound_enabled(cfg), false)
|
|
189
211
|
})
|
|
190
212
|
|
|
191
213
|
it('per-domain enable_outbound can be set to true', () => {
|
|
192
|
-
this.plugin.cfg['test.com'].enable_outbound = true
|
|
193
|
-
this.connection.transaction.rcpt_to = [
|
|
194
|
-
const cfg = this.plugin.get_config(this.connection)
|
|
195
|
-
assert.equal(this.plugin.is_outbound_enabled(cfg), true)
|
|
214
|
+
this.plugin.cfg['test.com'].enable_outbound = true
|
|
215
|
+
this.connection.transaction.rcpt_to = [new Address('<postmaster@test.com>')]
|
|
216
|
+
const cfg = this.plugin.get_config(this.connection)
|
|
217
|
+
assert.equal(this.plugin.is_outbound_enabled(cfg), true)
|
|
196
218
|
})
|
|
197
219
|
|
|
198
220
|
it('per-domain enable_outbound is false even if top level is false', () => {
|
|
199
|
-
this.plugin.cfg.main.enable_outbound = false
|
|
200
|
-
this.plugin.cfg['test.com'].enable_outbound = false
|
|
201
|
-
this.connection.transaction.rcpt_to = [
|
|
202
|
-
const cfg = this.plugin.get_config(this.connection)
|
|
203
|
-
assert.equal(this.plugin.is_outbound_enabled(cfg), false)
|
|
221
|
+
this.plugin.cfg.main.enable_outbound = false // this will be ignored
|
|
222
|
+
this.plugin.cfg['test.com'].enable_outbound = false
|
|
223
|
+
this.connection.transaction.rcpt_to = [new Address('<postmaster@test.com>')]
|
|
224
|
+
const cfg = this.plugin.get_config(this.connection)
|
|
225
|
+
assert.equal(this.plugin.is_outbound_enabled(cfg), false)
|
|
204
226
|
})
|
|
205
227
|
})
|
|
206
228
|
})
|
|
@@ -1,33 +1,31 @@
|
|
|
1
|
-
'use strict'
|
|
1
|
+
'use strict'
|
|
2
2
|
const assert = require('node:assert')
|
|
3
3
|
|
|
4
|
-
const { Address }
|
|
5
|
-
const fixtures
|
|
4
|
+
const { Address } = require('address-rfc2821')
|
|
5
|
+
const fixtures = require('haraka-test-fixtures')
|
|
6
6
|
|
|
7
7
|
const _set_up = (done) => {
|
|
8
|
+
this.plugin = new fixtures.plugin('rcpt_to.host_list_base')
|
|
9
|
+
this.plugin.cfg = {}
|
|
10
|
+
this.plugin.host_list = {}
|
|
8
11
|
|
|
9
|
-
this.
|
|
10
|
-
this.plugin.cfg = {};
|
|
11
|
-
this.plugin.host_list = {};
|
|
12
|
-
|
|
13
|
-
this.connection = fixtures.connection.createConnection();
|
|
12
|
+
this.connection = fixtures.connection.createConnection()
|
|
14
13
|
this.connection.init_transaction()
|
|
15
14
|
|
|
16
|
-
done()
|
|
15
|
+
done()
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
describe('rcpt_to.host_list_base', () => {
|
|
20
|
-
|
|
21
19
|
describe('in_host_list', () => {
|
|
22
20
|
beforeEach(_set_up)
|
|
23
21
|
|
|
24
22
|
it('miss', () => {
|
|
25
|
-
assert.equal(false, this.plugin.in_host_list('test.com'))
|
|
23
|
+
assert.equal(false, this.plugin.in_host_list('test.com'))
|
|
26
24
|
})
|
|
27
25
|
|
|
28
26
|
it('hit', () => {
|
|
29
|
-
this.plugin.host_list['test.com'] = true
|
|
30
|
-
assert.equal(true, this.plugin.in_host_list('test.com'))
|
|
27
|
+
this.plugin.host_list['test.com'] = true
|
|
28
|
+
assert.equal(true, this.plugin.in_host_list('test.com'))
|
|
31
29
|
})
|
|
32
30
|
})
|
|
33
31
|
|
|
@@ -35,29 +33,29 @@ describe('rcpt_to.host_list_base', () => {
|
|
|
35
33
|
beforeEach(_set_up)
|
|
36
34
|
|
|
37
35
|
it('undef', () => {
|
|
38
|
-
const r = this.plugin.in_host_regex('test.com')
|
|
39
|
-
assert.equal(false, r)
|
|
36
|
+
const r = this.plugin.in_host_regex('test.com')
|
|
37
|
+
assert.equal(false, r)
|
|
40
38
|
})
|
|
41
39
|
|
|
42
40
|
it('miss', () => {
|
|
43
|
-
this.plugin.host_list_regex=['miss.com']
|
|
44
|
-
this.plugin.hl_re = new RegExp
|
|
45
|
-
const r = this.plugin.in_host_regex('test.com')
|
|
46
|
-
assert.equal(false, r)
|
|
41
|
+
this.plugin.host_list_regex = ['miss.com']
|
|
42
|
+
this.plugin.hl_re = new RegExp(`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i')
|
|
43
|
+
const r = this.plugin.in_host_regex('test.com')
|
|
44
|
+
assert.equal(false, r)
|
|
47
45
|
})
|
|
48
46
|
|
|
49
47
|
it('exact hit', () => {
|
|
50
|
-
this.plugin.host_list_regex=['test.com']
|
|
51
|
-
this.plugin.hl_re = new RegExp
|
|
52
|
-
const r = this.plugin.in_host_regex('test.com')
|
|
53
|
-
assert.equal(true, r)
|
|
48
|
+
this.plugin.host_list_regex = ['test.com']
|
|
49
|
+
this.plugin.hl_re = new RegExp(`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i')
|
|
50
|
+
const r = this.plugin.in_host_regex('test.com')
|
|
51
|
+
assert.equal(true, r)
|
|
54
52
|
})
|
|
55
53
|
|
|
56
54
|
it('re hit', () => {
|
|
57
|
-
this.plugin.host_list_regex=['.*est.com']
|
|
58
|
-
this.plugin.hl_re = new RegExp
|
|
59
|
-
const r = this.plugin.in_host_regex('test.com')
|
|
60
|
-
assert.equal(true, r)
|
|
55
|
+
this.plugin.host_list_regex = ['.*est.com']
|
|
56
|
+
this.plugin.hl_re = new RegExp(`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i')
|
|
57
|
+
const r = this.plugin.in_host_regex('test.com')
|
|
58
|
+
assert.equal(true, r)
|
|
61
59
|
})
|
|
62
60
|
})
|
|
63
61
|
|
|
@@ -65,58 +63,78 @@ describe('rcpt_to.host_list_base', () => {
|
|
|
65
63
|
beforeEach(_set_up)
|
|
66
64
|
|
|
67
65
|
it('null sender', (done) => {
|
|
68
|
-
this.connection.relaying=true
|
|
69
|
-
this.plugin.hook_mail(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
66
|
+
this.connection.relaying = true
|
|
67
|
+
this.plugin.hook_mail(
|
|
68
|
+
(rc, msg) => {
|
|
69
|
+
assert.equal(undefined, rc)
|
|
70
|
+
assert.equal(undefined, msg)
|
|
71
|
+
done()
|
|
72
|
+
},
|
|
73
|
+
this.connection,
|
|
74
|
+
[new Address('<>')],
|
|
75
|
+
)
|
|
74
76
|
})
|
|
75
77
|
|
|
76
78
|
it('miss', (done) => {
|
|
77
|
-
this.plugin.host_list = { 'miss.com': true }
|
|
78
|
-
this.plugin.hook_mail(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
79
|
+
this.plugin.host_list = { 'miss.com': true }
|
|
80
|
+
this.plugin.hook_mail(
|
|
81
|
+
(rc, msg) => {
|
|
82
|
+
assert.equal(undefined, rc)
|
|
83
|
+
assert.equal(undefined, msg)
|
|
84
|
+
const res = this.connection.transaction.results.get('rcpt_to.host_list_base')
|
|
85
|
+
assert.notEqual(-1, res.msg.indexOf('mail_from!local'))
|
|
86
|
+
done()
|
|
87
|
+
},
|
|
88
|
+
this.connection,
|
|
89
|
+
[new Address('<user@example.com>')],
|
|
90
|
+
)
|
|
85
91
|
})
|
|
86
92
|
|
|
87
93
|
it('hit', (done) => {
|
|
88
|
-
this.plugin.host_list = { 'example.com': true }
|
|
89
|
-
this.plugin.hook_mail(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
this.plugin.host_list = { 'example.com': true }
|
|
95
|
+
this.plugin.hook_mail(
|
|
96
|
+
(rc, msg) => {
|
|
97
|
+
assert.equal(undefined, rc)
|
|
98
|
+
assert.equal(undefined, msg)
|
|
99
|
+
const res = this.connection.transaction.results.get('rcpt_to.host_list_base')
|
|
100
|
+
assert.notEqual(-1, res.pass.indexOf('mail_from'))
|
|
101
|
+
done()
|
|
102
|
+
},
|
|
103
|
+
this.connection,
|
|
104
|
+
[new Address('<user@example.com>')],
|
|
105
|
+
)
|
|
96
106
|
})
|
|
97
107
|
|
|
98
108
|
it('hit, regex, exact', (done) => {
|
|
99
|
-
this.plugin.host_list_regex = ['example.com']
|
|
100
|
-
this.plugin.hl_re = new RegExp
|
|
101
|
-
this.plugin.hook_mail(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
109
|
+
this.plugin.host_list_regex = ['example.com']
|
|
110
|
+
this.plugin.hl_re = new RegExp(`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i')
|
|
111
|
+
this.plugin.hook_mail(
|
|
112
|
+
(rc, msg) => {
|
|
113
|
+
assert.equal(undefined, rc)
|
|
114
|
+
assert.equal(undefined, msg)
|
|
115
|
+
const res = this.connection.transaction.results.get('rcpt_to.host_list_base')
|
|
116
|
+
assert.notEqual(-1, res.pass.indexOf('mail_from'))
|
|
117
|
+
done()
|
|
118
|
+
},
|
|
119
|
+
this.connection,
|
|
120
|
+
[new Address('<user@example.com>')],
|
|
121
|
+
)
|
|
108
122
|
})
|
|
109
123
|
|
|
110
124
|
it('hit, regex, pattern', (done) => {
|
|
111
|
-
this.plugin.host_list_regex = ['.*mple.com']
|
|
112
|
-
this.plugin.hl_re = new RegExp
|
|
113
|
-
this.plugin.hook_mail(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
125
|
+
this.plugin.host_list_regex = ['.*mple.com']
|
|
126
|
+
this.plugin.hl_re = new RegExp(`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i')
|
|
127
|
+
this.plugin.hook_mail(
|
|
128
|
+
(rc, msg) => {
|
|
129
|
+
assert.equal(undefined, rc)
|
|
130
|
+
assert.equal(undefined, msg)
|
|
131
|
+
const res = this.connection.transaction.results.get('rcpt_to.host_list_base')
|
|
132
|
+
assert.notEqual(-1, res.pass.indexOf('mail_from'))
|
|
133
|
+
done()
|
|
134
|
+
},
|
|
135
|
+
this.connection,
|
|
136
|
+
[new Address('<user@example.com>')],
|
|
137
|
+
)
|
|
120
138
|
})
|
|
121
139
|
})
|
|
122
140
|
})
|