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,60 +1,59 @@
|
|
|
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.in_host_list')
|
|
9
|
+
this.plugin.inherits('rcpt_to.host_list_base')
|
|
10
|
+
this.plugin.cfg = {}
|
|
11
|
+
this.plugin.host_list = {}
|
|
8
12
|
|
|
9
|
-
this.
|
|
10
|
-
this.plugin.inherits('rcpt_to.host_list_base');
|
|
11
|
-
this.plugin.cfg = {};
|
|
12
|
-
this.plugin.host_list = {};
|
|
13
|
-
|
|
14
|
-
this.connection = fixtures.connection.createConnection();
|
|
13
|
+
this.connection = fixtures.connection.createConnection()
|
|
15
14
|
this.connection.transaction = {
|
|
16
15
|
results: new fixtures.results(this.connection),
|
|
17
16
|
notes: {},
|
|
18
|
-
}
|
|
17
|
+
}
|
|
19
18
|
|
|
20
|
-
done()
|
|
19
|
+
done()
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
describe('in_host_list', () => {
|
|
24
23
|
beforeEach(_set_up)
|
|
25
24
|
|
|
26
25
|
it('miss', () => {
|
|
27
|
-
assert.equal(this.plugin.in_host_list('test.com'), false)
|
|
26
|
+
assert.equal(this.plugin.in_host_list('test.com'), false)
|
|
28
27
|
})
|
|
29
28
|
|
|
30
29
|
it('hit', () => {
|
|
31
|
-
this.plugin.host_list['test.com'] = true
|
|
32
|
-
assert.equal(this.plugin.in_host_list('test.com'), true)
|
|
30
|
+
this.plugin.host_list['test.com'] = true
|
|
31
|
+
assert.equal(this.plugin.in_host_list('test.com'), true)
|
|
33
32
|
})
|
|
34
33
|
|
|
35
34
|
describe('in_host_regex', () => {
|
|
36
35
|
beforeEach(_set_up)
|
|
37
36
|
|
|
38
37
|
it('undef', () => {
|
|
39
|
-
assert.equal(this.plugin.in_host_regex('test.com'), false)
|
|
38
|
+
assert.equal(this.plugin.in_host_regex('test.com'), false)
|
|
40
39
|
})
|
|
41
40
|
|
|
42
41
|
it('miss', () => {
|
|
43
|
-
this.plugin.host_list_regex=['miss.com']
|
|
44
|
-
this.plugin.hl_re = new RegExp
|
|
45
|
-
assert.equal(this.plugin.in_host_regex('test.com'), false)
|
|
42
|
+
this.plugin.host_list_regex = ['miss.com']
|
|
43
|
+
this.plugin.hl_re = new RegExp(`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i')
|
|
44
|
+
assert.equal(this.plugin.in_host_regex('test.com'), false)
|
|
46
45
|
})
|
|
47
46
|
|
|
48
47
|
it('exact hit', () => {
|
|
49
|
-
this.plugin.host_list_regex=['test.com']
|
|
50
|
-
this.plugin.hl_re = new RegExp
|
|
51
|
-
assert.equal(this.plugin.in_host_regex('test.com'), true)
|
|
48
|
+
this.plugin.host_list_regex = ['test.com']
|
|
49
|
+
this.plugin.hl_re = new RegExp(`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i')
|
|
50
|
+
assert.equal(this.plugin.in_host_regex('test.com'), true)
|
|
52
51
|
})
|
|
53
52
|
|
|
54
53
|
it('re hit', () => {
|
|
55
|
-
this.plugin.host_list_regex=['.*est.com']
|
|
56
|
-
this.plugin.hl_re = new RegExp
|
|
57
|
-
assert.equal(this.plugin.in_host_regex('test.com'), true)
|
|
54
|
+
this.plugin.host_list_regex = ['.*est.com']
|
|
55
|
+
this.plugin.hl_re = new RegExp(`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i')
|
|
56
|
+
assert.equal(this.plugin.in_host_regex('test.com'), true)
|
|
58
57
|
})
|
|
59
58
|
})
|
|
60
59
|
|
|
@@ -62,59 +61,79 @@ describe('in_host_list', () => {
|
|
|
62
61
|
beforeEach(_set_up)
|
|
63
62
|
|
|
64
63
|
it('null sender', (done) => {
|
|
65
|
-
this.connection.relaying=true
|
|
66
|
-
this.plugin.hook_mail(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
this.connection.relaying = true
|
|
65
|
+
this.plugin.hook_mail(
|
|
66
|
+
(rc, msg) => {
|
|
67
|
+
assert.equal(undefined, rc)
|
|
68
|
+
assert.equal(undefined, msg)
|
|
69
|
+
done()
|
|
70
|
+
},
|
|
71
|
+
this.connection,
|
|
72
|
+
[new Address('<>')],
|
|
73
|
+
)
|
|
71
74
|
})
|
|
72
75
|
|
|
73
76
|
it('miss', (done) => {
|
|
74
|
-
this.plugin.host_list = { 'miss.com': true }
|
|
75
|
-
this.plugin.hook_mail(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
77
|
+
this.plugin.host_list = { 'miss.com': true }
|
|
78
|
+
this.plugin.hook_mail(
|
|
79
|
+
(rc, msg) => {
|
|
80
|
+
assert.equal(undefined, rc)
|
|
81
|
+
assert.equal(undefined, msg)
|
|
82
|
+
const res = this.connection.transaction.results.get('rcpt_to.in_host_list')
|
|
83
|
+
assert.notEqual(-1, res.msg.indexOf('mail_from!local'))
|
|
84
|
+
done()
|
|
85
|
+
},
|
|
86
|
+
this.connection,
|
|
87
|
+
[new Address('<user@example.com>')],
|
|
88
|
+
)
|
|
82
89
|
})
|
|
83
90
|
|
|
84
91
|
it('hit', (done) => {
|
|
85
|
-
this.plugin.host_list = { 'example.com': true }
|
|
86
|
-
this.plugin.hook_mail(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
92
|
+
this.plugin.host_list = { 'example.com': true }
|
|
93
|
+
this.plugin.hook_mail(
|
|
94
|
+
(rc, msg) => {
|
|
95
|
+
assert.equal(undefined, rc)
|
|
96
|
+
assert.equal(undefined, msg)
|
|
97
|
+
const res = this.connection.transaction.results.get('rcpt_to.in_host_list')
|
|
98
|
+
assert.notEqual(-1, res.pass.indexOf('mail_from'))
|
|
99
|
+
done()
|
|
100
|
+
},
|
|
101
|
+
this.connection,
|
|
102
|
+
[new Address('<user@example.com>')],
|
|
103
|
+
)
|
|
93
104
|
})
|
|
94
105
|
|
|
95
106
|
it('hit, regex, exact', (done) => {
|
|
96
|
-
this.plugin.host_list_regex = ['example.com']
|
|
97
|
-
this.plugin.hl_re = new RegExp
|
|
98
|
-
this.plugin.hook_mail(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
107
|
+
this.plugin.host_list_regex = ['example.com']
|
|
108
|
+
this.plugin.hl_re = new RegExp(`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i')
|
|
109
|
+
this.plugin.hook_mail(
|
|
110
|
+
(rc, msg) => {
|
|
111
|
+
assert.equal(undefined, rc)
|
|
112
|
+
assert.equal(undefined, msg)
|
|
113
|
+
const res = this.connection.transaction.results.get('rcpt_to.in_host_list')
|
|
114
|
+
assert.notEqual(-1, res.pass.indexOf('mail_from'))
|
|
115
|
+
done()
|
|
116
|
+
},
|
|
117
|
+
this.connection,
|
|
118
|
+
[new Address('<user@example.com>')],
|
|
119
|
+
)
|
|
105
120
|
})
|
|
106
121
|
|
|
107
122
|
it('hit, regex, pattern', (done) => {
|
|
108
|
-
this.plugin.host_list_regex = ['.*mple.com']
|
|
109
|
-
this.plugin.hl_re = new RegExp
|
|
110
|
-
this.plugin.hook_mail(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
123
|
+
this.plugin.host_list_regex = ['.*mple.com']
|
|
124
|
+
this.plugin.hl_re = new RegExp(`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i')
|
|
125
|
+
this.plugin.hook_mail(
|
|
126
|
+
(rc, msg) => {
|
|
127
|
+
assert.equal(undefined, rc)
|
|
128
|
+
assert.equal(undefined, msg)
|
|
129
|
+
const res = this.connection.transaction.results.get('rcpt_to.in_host_list')
|
|
130
|
+
// console.log(res);
|
|
131
|
+
assert.notEqual(-1, res.pass.indexOf('mail_from'))
|
|
132
|
+
done()
|
|
133
|
+
},
|
|
134
|
+
this.connection,
|
|
135
|
+
[new Address('<user@example.com>')],
|
|
136
|
+
)
|
|
118
137
|
})
|
|
119
138
|
})
|
|
120
139
|
|
|
@@ -123,71 +142,99 @@ describe('in_host_list', () => {
|
|
|
123
142
|
|
|
124
143
|
it('missing txn', (done) => {
|
|
125
144
|
// sometimes txn goes away, make sure it's handled
|
|
126
|
-
delete this.connection.transaction
|
|
127
|
-
this.plugin.hook_rcpt(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
145
|
+
delete this.connection.transaction
|
|
146
|
+
this.plugin.hook_rcpt(
|
|
147
|
+
(rc, msg) => {
|
|
148
|
+
assert.equal(undefined, rc)
|
|
149
|
+
assert.equal(undefined, msg)
|
|
150
|
+
},
|
|
151
|
+
this.connection,
|
|
152
|
+
[new Address('test@test.com')],
|
|
153
|
+
)
|
|
154
|
+
assert.ok(true)
|
|
155
|
+
done()
|
|
133
156
|
})
|
|
134
157
|
|
|
135
158
|
it('hit list', (done) => {
|
|
136
|
-
this.plugin.host_list = { 'test.com': true }
|
|
137
|
-
this.plugin.hook_rcpt(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
159
|
+
this.plugin.host_list = { 'test.com': true }
|
|
160
|
+
this.plugin.hook_rcpt(
|
|
161
|
+
(rc, msg) => {
|
|
162
|
+
assert.equal(OK, rc)
|
|
163
|
+
assert.equal(undefined, msg)
|
|
164
|
+
done()
|
|
165
|
+
},
|
|
166
|
+
this.connection,
|
|
167
|
+
[new Address('test@test.com')],
|
|
168
|
+
)
|
|
142
169
|
})
|
|
143
170
|
|
|
144
171
|
it('miss list', (done) => {
|
|
145
|
-
this.plugin.host_list = { 'miss.com': true }
|
|
146
|
-
this.plugin.hook_rcpt(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
172
|
+
this.plugin.host_list = { 'miss.com': true }
|
|
173
|
+
this.plugin.hook_rcpt(
|
|
174
|
+
(rc, msg) => {
|
|
175
|
+
assert.equal(undefined, rc)
|
|
176
|
+
assert.equal(undefined, msg)
|
|
177
|
+
done()
|
|
178
|
+
},
|
|
179
|
+
this.connection,
|
|
180
|
+
[new Address('test@test.com')],
|
|
181
|
+
)
|
|
151
182
|
})
|
|
152
183
|
|
|
153
184
|
it('hit regex, exact', (done) => {
|
|
154
|
-
this.plugin.host_list_regex=['test.com']
|
|
155
|
-
this.plugin.hl_re = new RegExp
|
|
156
|
-
this.plugin.hook_rcpt(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
185
|
+
this.plugin.host_list_regex = ['test.com']
|
|
186
|
+
this.plugin.hl_re = new RegExp(`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i')
|
|
187
|
+
this.plugin.hook_rcpt(
|
|
188
|
+
(rc, msg) => {
|
|
189
|
+
assert.equal(OK, rc)
|
|
190
|
+
assert.equal(undefined, msg)
|
|
191
|
+
done()
|
|
192
|
+
},
|
|
193
|
+
this.connection,
|
|
194
|
+
[new Address('test@test.com')],
|
|
195
|
+
)
|
|
161
196
|
})
|
|
162
197
|
|
|
163
198
|
it('hit regex, pattern', (done) => {
|
|
164
|
-
this.plugin.host_list_regex=['.est.com']
|
|
165
|
-
this.plugin.hl_re = new RegExp
|
|
166
|
-
this.plugin.hook_rcpt(
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
199
|
+
this.plugin.host_list_regex = ['.est.com']
|
|
200
|
+
this.plugin.hl_re = new RegExp(`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i')
|
|
201
|
+
this.plugin.hook_rcpt(
|
|
202
|
+
(rc, msg) => {
|
|
203
|
+
assert.equal(OK, rc)
|
|
204
|
+
assert.equal(undefined, msg)
|
|
205
|
+
done()
|
|
206
|
+
},
|
|
207
|
+
this.connection,
|
|
208
|
+
[new Address('test@test.com')],
|
|
209
|
+
)
|
|
171
210
|
})
|
|
172
211
|
|
|
173
212
|
it('miss regex, pattern', (done) => {
|
|
174
|
-
this.plugin.host_list_regex=['a.est.com']
|
|
175
|
-
this.plugin.hl_re = new RegExp
|
|
176
|
-
this.plugin.hook_rcpt(
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
213
|
+
this.plugin.host_list_regex = ['a.est.com']
|
|
214
|
+
this.plugin.hl_re = new RegExp(`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i')
|
|
215
|
+
this.plugin.hook_rcpt(
|
|
216
|
+
(rc, msg) => {
|
|
217
|
+
assert.equal(undefined, rc)
|
|
218
|
+
assert.equal(undefined, msg)
|
|
219
|
+
done()
|
|
220
|
+
},
|
|
221
|
+
this.connection,
|
|
222
|
+
[new Address('test@test.com')],
|
|
223
|
+
)
|
|
181
224
|
})
|
|
182
225
|
|
|
183
226
|
it('rcpt miss, relaying to local sender', (done) => {
|
|
184
|
-
this.connection.relaying=true
|
|
185
|
-
this.connection.transaction.notes = { local_sender: true }
|
|
186
|
-
this.plugin.hook_rcpt(
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
227
|
+
this.connection.relaying = true
|
|
228
|
+
this.connection.transaction.notes = { local_sender: true }
|
|
229
|
+
this.plugin.hook_rcpt(
|
|
230
|
+
(rc, msg) => {
|
|
231
|
+
assert.equal(OK, rc)
|
|
232
|
+
assert.equal(undefined, msg)
|
|
233
|
+
done()
|
|
234
|
+
},
|
|
235
|
+
this.connection,
|
|
236
|
+
[new Address('test@test.com')],
|
|
237
|
+
)
|
|
191
238
|
})
|
|
192
239
|
})
|
|
193
240
|
})
|
package/test/plugins/status.js
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
|
-
'use strict'
|
|
1
|
+
'use strict'
|
|
2
2
|
|
|
3
3
|
const assert = require('node:assert')
|
|
4
4
|
|
|
5
|
-
const fixtures = require('haraka-test-fixtures')
|
|
6
|
-
const outbound = require('../../outbound')
|
|
7
|
-
const TimerQueue = require('../../outbound/timer_queue')
|
|
5
|
+
const fixtures = require('haraka-test-fixtures')
|
|
6
|
+
const outbound = require('../../outbound')
|
|
7
|
+
const TimerQueue = require('../../outbound/timer_queue')
|
|
8
8
|
|
|
9
|
-
const Connection = fixtures.connection
|
|
9
|
+
const Connection = fixtures.connection
|
|
10
10
|
|
|
11
11
|
const _set_up = (done) => {
|
|
12
|
-
this.plugin = new fixtures.plugin('status')
|
|
13
|
-
this.plugin.outbound = outbound
|
|
12
|
+
this.plugin = new fixtures.plugin('status')
|
|
13
|
+
this.plugin.outbound = outbound
|
|
14
14
|
|
|
15
|
-
this.connection = Connection.createConnection()
|
|
16
|
-
this.connection.remote.is_local = true
|
|
17
|
-
done()
|
|
15
|
+
this.connection = Connection.createConnection()
|
|
16
|
+
this.connection.remote.is_local = true
|
|
17
|
+
done()
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
describe('status', () => {
|
|
21
|
-
|
|
22
21
|
describe('register', () => {
|
|
23
22
|
beforeEach(_set_up)
|
|
24
23
|
|
|
25
24
|
it('loads the status plugin', () => {
|
|
26
|
-
assert.equal('status', this.plugin.name)
|
|
25
|
+
assert.equal('status', this.plugin.name)
|
|
27
26
|
})
|
|
28
27
|
})
|
|
29
28
|
|
|
@@ -31,11 +30,15 @@ describe('status', () => {
|
|
|
31
30
|
beforeEach(_set_up)
|
|
32
31
|
|
|
33
32
|
it('remote', (done) => {
|
|
34
|
-
this.connection.remote.is_local = false
|
|
35
|
-
this.plugin.hook_unrecognized_command(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
this.connection.remote.is_local = false
|
|
34
|
+
this.plugin.hook_unrecognized_command(
|
|
35
|
+
(code) => {
|
|
36
|
+
assert.equal(DENY, code)
|
|
37
|
+
done()
|
|
38
|
+
},
|
|
39
|
+
this.connection,
|
|
40
|
+
['STATUS', 'POOL LIST'],
|
|
41
|
+
)
|
|
39
42
|
})
|
|
40
43
|
})
|
|
41
44
|
|
|
@@ -44,11 +47,11 @@ describe('status', () => {
|
|
|
44
47
|
|
|
45
48
|
it('list_pools', (done) => {
|
|
46
49
|
this.connection.respond = (code, message) => {
|
|
47
|
-
const data = JSON.parse(message)
|
|
48
|
-
assert.equal('object', typeof data)
|
|
49
|
-
done()
|
|
50
|
-
}
|
|
51
|
-
this.plugin.hook_unrecognized_command(() => {}, this.connection, ['STATUS', 'POOL LIST'])
|
|
50
|
+
const data = JSON.parse(message)
|
|
51
|
+
assert.equal('object', typeof data) // there should be one pools array for noncluster and more for cluster
|
|
52
|
+
done()
|
|
53
|
+
}
|
|
54
|
+
this.plugin.hook_unrecognized_command(() => {}, this.connection, ['STATUS', 'POOL LIST'])
|
|
52
55
|
})
|
|
53
56
|
})
|
|
54
57
|
|
|
@@ -57,74 +60,78 @@ describe('status', () => {
|
|
|
57
60
|
|
|
58
61
|
it('inspect_queue', (done) => {
|
|
59
62
|
// should list delivery_queue and temp_fail_queue per cluster children
|
|
60
|
-
outbound.temp_fail_queue = new TimerQueue(10)
|
|
61
|
-
outbound.temp_fail_queue.add('file1', 100, () => {})
|
|
62
|
-
outbound.temp_fail_queue.add('file2', 100, () => {})
|
|
63
|
+
outbound.temp_fail_queue = new TimerQueue(10)
|
|
64
|
+
outbound.temp_fail_queue.add('file1', 100, () => {})
|
|
65
|
+
outbound.temp_fail_queue.add('file2', 100, () => {})
|
|
63
66
|
|
|
64
67
|
this.connection.respond = (code, message) => {
|
|
65
|
-
const data = JSON.parse(message)
|
|
66
|
-
assert.equal(0, data.delivery_queue.length)
|
|
67
|
-
assert.equal(2, data.temp_fail_queue.length)
|
|
68
|
-
done()
|
|
69
|
-
}
|
|
70
|
-
this.plugin.hook_unrecognized_command(() => {}, this.connection, ['STATUS', 'QUEUE INSPECT'])
|
|
68
|
+
const data = JSON.parse(message)
|
|
69
|
+
assert.equal(0, data.delivery_queue.length)
|
|
70
|
+
assert.equal(2, data.temp_fail_queue.length)
|
|
71
|
+
done()
|
|
72
|
+
}
|
|
73
|
+
this.plugin.hook_unrecognized_command(() => {}, this.connection, ['STATUS', 'QUEUE INSPECT'])
|
|
71
74
|
})
|
|
72
75
|
|
|
73
76
|
it('stat_queue', (done) => {
|
|
74
77
|
// should list files only
|
|
75
78
|
this.connection.respond = (code, message) => {
|
|
76
|
-
const data = JSON.parse(message)
|
|
77
|
-
assert.ok(/^\d+\/\d+\/\d+$/.test(data))
|
|
78
|
-
done()
|
|
79
|
-
}
|
|
80
|
-
this.plugin.hook_unrecognized_command(() => {}, this.connection, ['STATUS', 'QUEUE STATS'])
|
|
79
|
+
const data = JSON.parse(message)
|
|
80
|
+
assert.ok(/^\d+\/\d+\/\d+$/.test(data))
|
|
81
|
+
done()
|
|
82
|
+
}
|
|
83
|
+
this.plugin.hook_unrecognized_command(() => {}, this.connection, ['STATUS', 'QUEUE STATS'])
|
|
81
84
|
})
|
|
82
85
|
|
|
83
86
|
it('list_queue', (done) => {
|
|
84
87
|
// should list files only
|
|
85
88
|
this.connection.respond = (code, message) => {
|
|
86
|
-
const data = JSON.parse(message)
|
|
87
|
-
assert.equal(0, data.length)
|
|
88
|
-
done()
|
|
89
|
-
}
|
|
90
|
-
this.plugin.hook_unrecognized_command(() => {}, this.connection, ['STATUS', 'QUEUE LIST'])
|
|
89
|
+
const data = JSON.parse(message)
|
|
90
|
+
assert.equal(0, data.length)
|
|
91
|
+
done()
|
|
92
|
+
}
|
|
93
|
+
this.plugin.hook_unrecognized_command(() => {}, this.connection, ['STATUS', 'QUEUE LIST'])
|
|
91
94
|
})
|
|
92
95
|
|
|
93
96
|
it('discard_from_queue', (done) => {
|
|
94
|
-
const self = this
|
|
97
|
+
const self = this
|
|
95
98
|
|
|
96
|
-
outbound.temp_fail_queue = new TimerQueue(10)
|
|
99
|
+
outbound.temp_fail_queue = new TimerQueue(10)
|
|
97
100
|
outbound.temp_fail_queue.add('file1', 10, () => {
|
|
98
|
-
assert.ok(false, 'This callback should not be called')
|
|
99
|
-
done()
|
|
101
|
+
assert.ok(false, 'This callback should not be called')
|
|
102
|
+
done()
|
|
100
103
|
})
|
|
101
104
|
|
|
102
|
-
outbound.temp_fail_queue.add('file2', 2000, () => {})
|
|
103
|
-
|
|
104
|
-
this.plugin.hook_unrecognized_command(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
105
|
+
outbound.temp_fail_queue.add('file2', 2000, () => {})
|
|
106
|
+
|
|
107
|
+
this.plugin.hook_unrecognized_command(
|
|
108
|
+
() => {
|
|
109
|
+
self.connection.respond = (code, message) => {
|
|
110
|
+
const data = JSON.parse(message)
|
|
111
|
+
assert.equal(1, data.temp_fail_queue.length)
|
|
112
|
+
done()
|
|
113
|
+
}
|
|
114
|
+
self.plugin.hook_unrecognized_command(() => {}, self.connection, ['STATUS', 'QUEUE INSPECT'])
|
|
115
|
+
},
|
|
116
|
+
this.connection,
|
|
117
|
+
['STATUS', 'QUEUE DISCARD file1'],
|
|
118
|
+
)
|
|
112
119
|
})
|
|
113
120
|
|
|
114
121
|
it('push_email_at_queue', (done) => {
|
|
115
122
|
const timeout = setTimeout(() => {
|
|
116
|
-
assert.ok(false, 'Timeout')
|
|
117
|
-
done()
|
|
118
|
-
}, 1000)
|
|
123
|
+
assert.ok(false, 'Timeout')
|
|
124
|
+
done()
|
|
125
|
+
}, 1000)
|
|
119
126
|
|
|
120
127
|
outbound.temp_fail_queue.add('file', 1500, () => {
|
|
121
|
-
clearTimeout(timeout)
|
|
128
|
+
clearTimeout(timeout)
|
|
122
129
|
|
|
123
|
-
assert.ok(true)
|
|
124
|
-
done()
|
|
125
|
-
})
|
|
130
|
+
assert.ok(true)
|
|
131
|
+
done()
|
|
132
|
+
})
|
|
126
133
|
|
|
127
|
-
this.plugin.hook_unrecognized_command(() => {}, this.connection, ['STATUS', 'QUEUE PUSH file'])
|
|
134
|
+
this.plugin.hook_unrecognized_command(() => {}, this.connection, ['STATUS', 'QUEUE PUSH file'])
|
|
128
135
|
})
|
|
129
136
|
})
|
|
130
|
-
})
|
|
137
|
+
})
|