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.
Files changed (160) hide show
  1. package/.prettierignore +4 -0
  2. package/CONTRIBUTORS.md +5 -5
  3. package/Changes.md +69 -50
  4. package/Plugins.md +3 -1
  5. package/README.md +1 -1
  6. package/bin/haraka +475 -478
  7. package/config/outbound.ini +3 -0
  8. package/connection.js +1072 -1108
  9. package/docs/Connection.md +29 -30
  10. package/docs/CoreConfig.md +38 -39
  11. package/docs/CustomReturnCodes.md +0 -1
  12. package/docs/HAProxy.md +2 -2
  13. package/docs/Header.md +1 -1
  14. package/docs/Logging.md +29 -5
  15. package/docs/Outbound.md +93 -78
  16. package/docs/Plugins.md +103 -108
  17. package/docs/Transaction.md +49 -51
  18. package/docs/Tutorial.md +127 -143
  19. package/docs/deprecated/access.md +0 -1
  20. package/docs/deprecated/backscatterer.md +2 -3
  21. package/docs/deprecated/connect.rdns_access.md +18 -27
  22. package/docs/deprecated/data.headers.md +0 -1
  23. package/docs/deprecated/data.nomsgid.md +1 -2
  24. package/docs/deprecated/data.noreceived.md +1 -2
  25. package/docs/deprecated/data.rfc5322_header_checks.md +1 -2
  26. package/docs/deprecated/dkim_sign.md +13 -17
  27. package/docs/deprecated/dkim_verify.md +9 -17
  28. package/docs/deprecated/dnsbl.md +36 -38
  29. package/docs/deprecated/dnswl.md +41 -43
  30. package/docs/deprecated/lookup_rdns.strict.md +21 -34
  31. package/docs/deprecated/mail_from.access.md +17 -25
  32. package/docs/deprecated/mail_from.blocklist.md +9 -12
  33. package/docs/deprecated/mail_from.nobounces.md +1 -2
  34. package/docs/deprecated/rcpt_to.access.md +20 -27
  35. package/docs/deprecated/rcpt_to.blocklist.md +10 -13
  36. package/docs/deprecated/rcpt_to.routes.md +0 -1
  37. package/docs/deprecated/rdns.regexp.md +13 -15
  38. package/docs/plugins/aliases.md +89 -89
  39. package/docs/plugins/auth/auth_bridge.md +5 -7
  40. package/docs/plugins/auth/auth_ldap.md +11 -14
  41. package/docs/plugins/auth/auth_proxy.md +10 -12
  42. package/docs/plugins/auth/auth_vpopmaild.md +5 -6
  43. package/docs/plugins/auth/flat_file.md +4 -4
  44. package/docs/plugins/block_me.md +3 -3
  45. package/docs/plugins/data.signatures.md +1 -2
  46. package/docs/plugins/delay_deny.md +3 -4
  47. package/docs/plugins/max_unrecognized_commands.md +4 -4
  48. package/docs/plugins/prevent_credential_leaks.md +6 -6
  49. package/docs/plugins/process_title.md +18 -18
  50. package/docs/plugins/queue/deliver.md +2 -3
  51. package/docs/plugins/queue/discard.md +4 -4
  52. package/docs/plugins/queue/lmtp.md +1 -3
  53. package/docs/plugins/queue/qmail-queue.md +7 -9
  54. package/docs/plugins/queue/quarantine.md +16 -21
  55. package/docs/plugins/queue/rabbitmq.md +8 -11
  56. package/docs/plugins/queue/rabbitmq_amqplib.md +43 -39
  57. package/docs/plugins/queue/smtp_bridge.md +7 -10
  58. package/docs/plugins/queue/smtp_forward.md +42 -34
  59. package/docs/plugins/queue/smtp_proxy.md +30 -29
  60. package/docs/plugins/queue/test.md +1 -3
  61. package/docs/plugins/rcpt_to.in_host_list.md +6 -6
  62. package/docs/plugins/rcpt_to.max_count.md +1 -1
  63. package/docs/plugins/record_envelope_addresses.md +3 -3
  64. package/docs/plugins/reseed_rng.md +6 -6
  65. package/docs/plugins/status.md +9 -8
  66. package/docs/plugins/tarpit.md +7 -11
  67. package/docs/plugins/tls.md +12 -17
  68. package/docs/plugins/toobusy.md +4 -4
  69. package/docs/plugins/xclient.md +3 -3
  70. package/docs/tutorials/Migrating_from_v1_to_v2.md +19 -41
  71. package/docs/tutorials/SettingUpOutbound.md +6 -9
  72. package/endpoint.js +35 -38
  73. package/eslint.config.mjs +22 -19
  74. package/haraka.js +42 -47
  75. package/host_pool.js +75 -79
  76. package/http/html/404.html +45 -49
  77. package/http/html/index.html +39 -28
  78. package/http/package.json +2 -4
  79. package/line_socket.js +27 -28
  80. package/logger.js +182 -201
  81. package/outbound/client_pool.js +34 -27
  82. package/outbound/config.js +64 -59
  83. package/outbound/fsync_writestream.js +24 -25
  84. package/outbound/hmail.js +888 -835
  85. package/outbound/index.js +194 -187
  86. package/outbound/qfile.js +49 -52
  87. package/outbound/queue.js +197 -190
  88. package/outbound/timer_queue.js +41 -43
  89. package/outbound/tls.js +68 -61
  90. package/outbound/todo.js +11 -11
  91. package/package.json +38 -33
  92. package/plugins/.eslintrc.yaml +0 -1
  93. package/plugins/auth/auth_base.js +123 -127
  94. package/plugins/auth/auth_bridge.js +7 -7
  95. package/plugins/auth/auth_proxy.js +121 -126
  96. package/plugins/auth/auth_vpopmaild.js +84 -85
  97. package/plugins/auth/flat_file.js +18 -17
  98. package/plugins/block_me.js +31 -31
  99. package/plugins/data.signatures.js +13 -13
  100. package/plugins/delay_deny.js +65 -61
  101. package/plugins/prevent_credential_leaks.js +23 -23
  102. package/plugins/process_title.js +125 -128
  103. package/plugins/profile.js +5 -5
  104. package/plugins/queue/deliver.js +3 -3
  105. package/plugins/queue/discard.js +13 -14
  106. package/plugins/queue/lmtp.js +16 -17
  107. package/plugins/queue/qmail-queue.js +54 -55
  108. package/plugins/queue/quarantine.js +68 -70
  109. package/plugins/queue/rabbitmq.js +80 -87
  110. package/plugins/queue/rabbitmq_amqplib.js +75 -54
  111. package/plugins/queue/smtp_bridge.js +16 -16
  112. package/plugins/queue/smtp_forward.js +175 -179
  113. package/plugins/queue/smtp_proxy.js +69 -71
  114. package/plugins/queue/test.js +9 -9
  115. package/plugins/rcpt_to.host_list_base.js +30 -34
  116. package/plugins/rcpt_to.in_host_list.js +19 -19
  117. package/plugins/record_envelope_addresses.js +4 -4
  118. package/plugins/reseed_rng.js +4 -4
  119. package/plugins/status.js +90 -97
  120. package/plugins/tarpit.js +25 -14
  121. package/plugins/tls.js +68 -68
  122. package/plugins/toobusy.js +21 -23
  123. package/plugins/xclient.js +51 -53
  124. package/plugins.js +276 -293
  125. package/rfc1869.js +30 -35
  126. package/server.js +308 -299
  127. package/smtp_client.js +244 -228
  128. package/test/.eslintrc.yaml +0 -1
  129. package/test/connection.js +127 -134
  130. package/test/endpoint.js +53 -47
  131. package/test/fixtures/line_socket.js +12 -12
  132. package/test/fixtures/util_hmailitem.js +89 -85
  133. package/test/host_pool.js +90 -92
  134. package/test/installation/plugins/base_plugin.js +2 -2
  135. package/test/installation/plugins/folder_plugin/index.js +2 -3
  136. package/test/installation/plugins/inherits.js +3 -3
  137. package/test/installation/plugins/load_first.js +2 -3
  138. package/test/installation/plugins/plugin.js +1 -3
  139. package/test/installation/plugins/tls.js +2 -4
  140. package/test/logger.js +135 -116
  141. package/test/outbound/hmail.js +49 -35
  142. package/test/outbound/index.js +118 -101
  143. package/test/outbound/qfile.js +51 -53
  144. package/test/outbound_bounce_net_errors.js +84 -69
  145. package/test/outbound_bounce_rfc3464.js +235 -165
  146. package/test/plugins/auth/auth_base.js +420 -279
  147. package/test/plugins/auth/auth_vpopmaild.js +38 -39
  148. package/test/plugins/queue/smtp_forward.js +126 -104
  149. package/test/plugins/rcpt_to.host_list_base.js +85 -67
  150. package/test/plugins/rcpt_to.in_host_list.js +159 -112
  151. package/test/plugins/status.js +71 -64
  152. package/test/plugins/tls.js +37 -34
  153. package/test/plugins.js +97 -92
  154. package/test/rfc1869.js +19 -26
  155. package/test/server.js +293 -272
  156. package/test/smtp_client.js +180 -176
  157. package/test/tls_socket.js +62 -66
  158. package/test/transaction.js +159 -160
  159. package/tls_socket.js +331 -333
  160. 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
- else {
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 = require('haraka-test-fixtures');
7
- const Notes = require('haraka-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
- new Address('<matt@example.com>')
67
- );
68
- const cfg = this.plugin.get_config(this.connection);
69
- assert.equal(cfg.enable_tls, true);
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
- new Address('<matt@test1.com>')
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
- new Address('<matt@test.com>'),
100
- new Address('<matt@test.com>')
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; // clear this for future tests
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((code, mx) => {
129
- assert.equal(code, undefined);
130
- assert.deepEqual(mx, undefined);
131
- done();
132
- }, this.hmail, 'undefined.com');
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((code, mx) => {
139
- assert.equal(code, undefined);
140
- assert.deepEqual(mx, undefined);
141
- done();
142
- }, this.hmail, 'undefined.com');
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((code, mx) => {
147
- assert.equal(code, OK);
148
- assert.deepEqual(mx, {
149
- priority: 0, exchange: '1.2.3.4', port: 2555,
150
- auth_user: 'postmaster@test.com',
151
- auth_pass: 'superDuperSecret'
152
- });
153
- done();
154
- }, this.hmail, 'test.com');
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((code, mx) => {
161
- assert.equal(code, OK);
162
- assert.deepEqual(mx, { priority: 0, port: 465, exchange: '4.3.2.1' });
163
- done();
164
- }, this.hmail, 'undefined.com');
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((code, mx) => {
171
- assert.equal(code, OK);
172
- assert.deepEqual(mx, { priority: 0, port: 24, using_lmtp: true, exchange: '4.3.2.1' });
173
- done();
174
- }, this.hmail, 'undefined.com');
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 = [ new Address('<postmaster@test.com>') ];
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 = [ new Address('<postmaster@test.com>') ];
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; // this will be ignored
200
- this.plugin.cfg['test.com'].enable_outbound = false;
201
- this.connection.transaction.rcpt_to = [ new Address('<postmaster@test.com>') ];
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 } = require('address-rfc2821');
5
- const fixtures = require('haraka-test-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.plugin = new fixtures.plugin('rcpt_to.host_list_base');
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 (`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i');
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 (`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i');
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 (`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i');
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((rc, msg) => {
70
- assert.equal(undefined, rc);
71
- assert.equal(undefined, msg);
72
- done();
73
- }, this.connection, [new Address('<>')]);
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((rc, msg) => {
79
- assert.equal(undefined, rc);
80
- assert.equal(undefined, msg);
81
- const res = this.connection.transaction.results.get('rcpt_to.host_list_base');
82
- assert.notEqual(-1, res.msg.indexOf('mail_from!local'));
83
- done();
84
- }, this.connection, [new Address('<user@example.com>')]);
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((rc, msg) => {
90
- assert.equal(undefined, rc);
91
- assert.equal(undefined, msg);
92
- const res = this.connection.transaction.results.get('rcpt_to.host_list_base');
93
- assert.notEqual(-1, res.pass.indexOf('mail_from'));
94
- done();
95
- }, this.connection, [new Address('<user@example.com>')]);
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 (`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i');
101
- this.plugin.hook_mail((rc, msg) => {
102
- assert.equal(undefined, rc);
103
- assert.equal(undefined, msg);
104
- const res = this.connection.transaction.results.get('rcpt_to.host_list_base');
105
- assert.notEqual(-1, res.pass.indexOf('mail_from'));
106
- done();
107
- }, this.connection, [new Address('<user@example.com>')]);
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 (`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i');
113
- this.plugin.hook_mail((rc, msg) => {
114
- assert.equal(undefined, rc);
115
- assert.equal(undefined, msg);
116
- const res = this.connection.transaction.results.get('rcpt_to.host_list_base');
117
- assert.notEqual(-1, res.pass.indexOf('mail_from'));
118
- done();
119
- }, this.connection, [new Address('<user@example.com>')]);
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
  })