Haraka 2.8.28 → 3.0.1

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 (135) hide show
  1. package/.eslintrc.yaml +2 -10
  2. package/Changes.md +84 -2
  3. package/Dockerfile +1 -1
  4. package/Plugins.md +9 -4
  5. package/README.md +2 -6
  6. package/bin/haraka +5 -4
  7. package/config/outbound.ini +0 -7
  8. package/config/plugins +1 -1
  9. package/config/smtp.ini +1 -1
  10. package/config/smtp_forward.ini +2 -8
  11. package/config/smtp_proxy.ini +0 -6
  12. package/connection.js +178 -204
  13. package/coverage/lcov.info +13863 -0
  14. package/coverage/tmp/coverage-42958-1658373250585-0.json +1 -0
  15. package/coverage/tmp/coverage-42961-1658373250529-0.json +1 -0
  16. package/dkim.js +66 -73
  17. package/docs/Body.md +1 -22
  18. package/docs/CoreConfig.md +2 -2
  19. package/docs/Header.md +1 -47
  20. package/docs/Outbound.md +8 -36
  21. package/endpoint.js +1 -1
  22. package/haraka.js +1 -1
  23. package/host_pool.js +8 -12
  24. package/logger.js +25 -32
  25. package/outbound/client_pool.js +11 -153
  26. package/outbound/config.js +5 -11
  27. package/outbound/hmail.js +109 -143
  28. package/outbound/index.js +13 -25
  29. package/outbound/mx_lookup.js +10 -7
  30. package/outbound/queue.js +8 -12
  31. package/outbound/timer_queue.js +2 -4
  32. package/outbound/tls.js +17 -18
  33. package/outbound/todo.js +1 -0
  34. package/package.json +57 -55
  35. package/plugins/auth/auth_base.js +39 -63
  36. package/plugins/auth/auth_bridge.js +3 -4
  37. package/plugins/auth/auth_proxy.js +16 -16
  38. package/plugins/auth/auth_vpopmaild.js +30 -37
  39. package/plugins/auth/flat_file.js +9 -13
  40. package/plugins/avg.js +9 -11
  41. package/plugins/backscatterer.js +1 -1
  42. package/plugins/block_me.js +2 -6
  43. package/plugins/bounce.js +106 -124
  44. package/plugins/clamd.js +59 -63
  45. package/plugins/data.signatures.js +6 -6
  46. package/plugins/data.uribl.js +1 -415
  47. package/plugins/delay_deny.js +19 -20
  48. package/plugins/dkim_sign.js +56 -62
  49. package/plugins/dkim_verify.js +9 -8
  50. package/plugins/dns_list_base.js +43 -42
  51. package/plugins/dnsbl.js +41 -46
  52. package/plugins/dnswl.js +23 -26
  53. package/plugins/early_talker.js +24 -28
  54. package/plugins/esets.js +8 -11
  55. package/plugins/greylist.js +161 -190
  56. package/plugins/helo.checks.js +175 -197
  57. package/plugins/mail_from.is_resolvable.js +38 -38
  58. package/plugins/messagesniffer.js +33 -40
  59. package/plugins/prevent_credential_leaks.js +7 -5
  60. package/plugins/process_title.js +16 -17
  61. package/plugins/queue/deliver.js +2 -2
  62. package/plugins/queue/lmtp.js +5 -6
  63. package/plugins/queue/qmail-queue.js +11 -13
  64. package/plugins/queue/quarantine.js +25 -34
  65. package/plugins/queue/rabbitmq.js +3 -2
  66. package/plugins/queue/rabbitmq_amqplib.js +9 -9
  67. package/plugins/queue/smtp_bridge.js +5 -4
  68. package/plugins/queue/smtp_forward.js +81 -89
  69. package/plugins/queue/smtp_proxy.js +21 -22
  70. package/plugins/queue/test.js +2 -1
  71. package/plugins/rcpt_to.host_list_base.js +20 -30
  72. package/plugins/rcpt_to.in_host_list.js +12 -14
  73. package/plugins/rcpt_to.max_count.js +7 -5
  74. package/plugins/record_envelope_addresses.js +4 -6
  75. package/plugins/relay.js +64 -74
  76. package/plugins/reseed_rng.js +1 -2
  77. package/plugins/spamassassin.js +56 -68
  78. package/plugins/status.js +2 -3
  79. package/plugins/tarpit.js +8 -11
  80. package/plugins/tls.js +14 -17
  81. package/plugins/toobusy.js +6 -8
  82. package/plugins/xclient.js +14 -25
  83. package/plugins.js +24 -29
  84. package/rfc1869.js +2 -2
  85. package/server.js +3 -13
  86. package/smtp_client.js +138 -215
  87. package/tests/config/smtp_forward.ini +0 -6
  88. package/tests/fixtures/line_socket.js +1 -1
  89. package/tests/fixtures/util_hmailitem.js +5 -7
  90. package/tests/fixtures/vm_harness.js +2 -2
  91. package/tests/host_pool.js +13 -14
  92. package/tests/installation/plugins/inherits.js +1 -2
  93. package/tests/logger.js +2 -2
  94. package/tests/plugins/bounce.js +6 -8
  95. package/tests/plugins/dkim_signer.js +7 -7
  96. package/tests/plugins/dns_list_base.js +7 -7
  97. package/tests/plugins/helo.checks.js +1 -1
  98. package/tests/plugins/mail_from.is_resolvable.js +10 -54
  99. package/tests/plugins/queue/smtp_forward.js +11 -11
  100. package/tests/plugins/rcpt_to.host_list_base.js +1 -1
  101. package/tests/plugins/rcpt_to.in_host_list.js +1 -1
  102. package/tests/plugins/spamassassin.js +1 -1
  103. package/tests/queue/multibyte +0 -0
  104. package/tests/queue/plain +0 -0
  105. package/tests/rfc1869.js +4 -1
  106. package/tests/server.js +15 -9
  107. package/tests/smtp_client/auth.js +4 -14
  108. package/tests/smtp_client/basic.js +5 -15
  109. package/tests/smtp_client.js +7 -3
  110. package/tests/transaction.js +72 -19
  111. package/tls_socket.js +75 -85
  112. package/transaction.js +7 -9
  113. package/attachment_stream.js +0 -118
  114. package/bin/spf +0 -48
  115. package/chunkemitter.js +0 -75
  116. package/config/data.uribl.excludes +0 -202
  117. package/config/data.uribl.ini +0 -37
  118. package/config/spf.ini +0 -1
  119. package/docs/plugins/attachment.md +0 -92
  120. package/docs/plugins/data.uribl.md +0 -120
  121. package/docs/plugins/spf.md +0 -142
  122. package/mailbody.js +0 -502
  123. package/mailheader.js +0 -304
  124. package/messagestream.js +0 -441
  125. package/plugins/aliases.js +0 -120
  126. package/plugins/attachment.js +0 -503
  127. package/plugins/connect.p0f.js +0 -5
  128. package/plugins/spf.js +0 -327
  129. package/spf.js +0 -689
  130. package/tests/mailbody.js +0 -348
  131. package/tests/mailheader.js +0 -138
  132. package/tests/messagestream.js +0 -34
  133. package/tests/plugins/aliases.js +0 -376
  134. package/tests/plugins/spf.js +0 -251
  135. package/tests/spf.js +0 -96
@@ -2,12 +2,10 @@
2
2
 
3
3
  const Address = require('address-rfc2821');
4
4
  const fixtures = require('haraka-test-fixtures');
5
+ const message = require('haraka-email-message')
5
6
 
6
7
  const Connection = fixtures.connection;
7
8
 
8
- const Body = require('../../mailbody').Body;
9
- const Header = require('../../mailheader').Header;
10
-
11
9
  function _set_up (done) {
12
10
 
13
11
  this.plugin = new fixtures.plugin('bounce');
@@ -31,7 +29,7 @@ function _set_up (done) {
31
29
  this.connection = Connection.createConnection();
32
30
  this.connection.remote.ip = '8.8.8.8';
33
31
  this.connection.transaction = {
34
- header: new Header(),
32
+ header: new message.Header(),
35
33
  results: new fixtures.results(this.plugin),
36
34
  };
37
35
 
@@ -126,7 +124,7 @@ exports.non_local_msgid = {
126
124
  test.expect(1);
127
125
  this.connection.transaction.mail_from= new Address.Address('<>');
128
126
  this.connection.transaction.rcpt_to= [ new Address.Address('test@good.com') ];
129
- this.connection.transaction.body = new Body();
127
+ this.connection.transaction.body = new message.Body();
130
128
  this.connection.transaction.body.bodytext = '';
131
129
  const cb = function () {
132
130
  test.equal(DENY, arguments[0]);
@@ -138,7 +136,7 @@ exports.non_local_msgid = {
138
136
  test.expect(1);
139
137
  this.connection.transaction.mail_from= new Address.Address('<>');
140
138
  this.connection.transaction.rcpt_to= [ new Address.Address('test@good.com') ];
141
- this.connection.transaction.body = new Body();
139
+ this.connection.transaction.body = new message.Body();
142
140
  this.connection.transaction.body.bodytext = 'Message-ID:<blah>';
143
141
  const cb = function () {
144
142
  test.equal(DENY, arguments[0]);
@@ -150,7 +148,7 @@ exports.non_local_msgid = {
150
148
  test.expect(2);
151
149
  this.connection.transaction.mail_from= new Address.Address('<>');
152
150
  this.connection.transaction.rcpt_to= [ new Address.Address('test@good.com') ];
153
- this.connection.transaction.body = new Body();
151
+ this.connection.transaction.body = new message.Body();
154
152
  this.connection.transaction.body.bodytext = 'Message-ID: <blah@foo.cooooooom>';
155
153
  const cb = function () {
156
154
  test.equal(DENY, arguments[0]);
@@ -164,7 +162,7 @@ exports.non_local_msgid = {
164
162
  test.expect(2);
165
163
  this.connection.transaction.mail_from= new Address.Address('<>');
166
164
  this.connection.transaction.rcpt_to= [ new Address.Address('test@good.com') ];
167
- this.connection.transaction.body = new Body();
165
+ this.connection.transaction.body = new message.Body();
168
166
  this.connection.transaction.body.bodytext = 'Message-ID: <blah@foo.com>';
169
167
  var cb = function () {
170
168
  test.equal(DENY, arguments[0]);
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  const fixtures = require('haraka-test-fixtures');
4
+ const message = require('haraka-email-message')
4
5
 
5
- const DKIMSignStream = require('../../plugins/dkim_sign').DKIMSignStream;
6
- const Header = require('../../mailheader').Header;
6
+ const { DKIMSignStream } = require('../../plugins/dkim_sign');
7
7
 
8
8
  const privateKey = `-----BEGIN RSA PRIVATE KEY-----
9
9
  MIICXwIBAAKBgQDwIRP/UC3SBsEmGqZ9ZJW3/DkMoGeLnQg1fWn7/zYtIxN2SnFC
@@ -33,7 +33,7 @@ frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN/XKdLCPjaYaY=
33
33
  function getValueFromDKIM (dkim_header, key) {
34
34
  const kv = dkim_header.split(';');
35
35
  for (let i = 0, len = kv.length; i < len; i++) {
36
- const arr = kv[i].match(/^([^=]+)=(.*)$/);
36
+ const arr = kv[i].match(/^\s*([^=]+)=(.*)$/);
37
37
  if (arr[1] === key) {
38
38
  return arr[2];
39
39
  }
@@ -55,7 +55,7 @@ exports.sign = {
55
55
  test.expect(1);
56
56
  const email = 'Ignored: header\r\n\r\nHi.\r\n\r\nWe lost the game. Are you hungry yet?\r\n\r\nJoe.\r\n';
57
57
 
58
- const header = new Header();
58
+ const header = new message.Header();
59
59
  header.parse(['Ignored: header']);
60
60
  const signer = new DKIMSignStream(props, header, (n, dkim) => {
61
61
  test.equal(getValueFromDKIM(dkim, 'bh'), '2jUSOH9NhtVGCQWNr9BrIAPreKQjO6Sn7XIkfJVOzv8=');
@@ -69,7 +69,7 @@ exports.sign = {
69
69
 
70
70
  const email = 'Ignored: header\r\n\r\n';
71
71
 
72
- const header = new Header();
72
+ const header = new message.Header();
73
73
  header.parse(['Ignored: header']);
74
74
  const signer = new DKIMSignStream(props, header, (n, dkim) => {
75
75
  test.equal(getValueFromDKIM(dkim, 'bh'), 'frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN/XKdLCPjaYaY=');
@@ -81,7 +81,7 @@ exports.sign = {
81
81
  'body hash simple, two writes' (test) {
82
82
  test.expect(1);
83
83
 
84
- const header = new Header();
84
+ const header = new message.Header();
85
85
  header.parse(['Ignored: header']);
86
86
  const signer = new DKIMSignStream(props, header, (n, dkim) => {
87
87
  test.equal(getValueFromDKIM(dkim, 'bh'), '2jUSOH9NhtVGCQWNr9BrIAPreKQjO6Sn7XIkfJVOzv8=');
@@ -96,7 +96,7 @@ exports.sign = {
96
96
 
97
97
  const email = 'Ignored: header\r\n\r\nHi.\r\n\r\nWe lost the game. Are you hungry yet?\r\n\r\nJoe.\r\n\r\n\r\n';
98
98
 
99
- const header = new Header();
99
+ const header = new message.Header();
100
100
  header.parse(['Ignored: header']);
101
101
  const signer = new DKIMSignStream(props, header, (n, dkim) => {
102
102
  test.equal(getValueFromDKIM(dkim, 'bh'), '2jUSOH9NhtVGCQWNr9BrIAPreKQjO6Sn7XIkfJVOzv8=');
@@ -93,7 +93,7 @@ exports.multi = {
93
93
  test.done();
94
94
  }
95
95
  }
96
- this.plugin.multi('127.0.0.2', 'cbl.abuseat.org', cb);
96
+ this.plugin.multi('127.0.0.2', 'xbl.spamhaus.org', cb);
97
97
  },
98
98
  'Spamcop + CBL' (test) {
99
99
  test.expect(12);
@@ -111,7 +111,7 @@ exports.multi = {
111
111
  test.done();
112
112
  }
113
113
  }
114
- const dnsbls = ['bl.spamcop.net','cbl.abuseat.org'];
114
+ const dnsbls = ['bl.spamcop.net','xbl.spamhaus.org'];
115
115
  this.plugin.multi('127.0.0.2', dnsbls, cb);
116
116
  },
117
117
  'Spamcop + CBL + negative result' (test) {
@@ -129,7 +129,7 @@ exports.multi = {
129
129
  test.done();
130
130
  }
131
131
  }
132
- const dnsbls = ['bl.spamcop.net','cbl.abuseat.org'];
132
+ const dnsbls = ['bl.spamcop.net','xbl.spamhaus.org'];
133
133
  this.plugin.multi('127.0.0.1', dnsbls, cb);
134
134
  },
135
135
  'IPv6 addresses supported' (test) {
@@ -148,7 +148,7 @@ exports.multi = {
148
148
  test.done();
149
149
  }
150
150
  }
151
- const dnsbls = ['bl.spamcop.net','cbl.abuseat.org'];
151
+ const dnsbls = ['bl.spamcop.net','xbl.spamhaus.org'];
152
152
  this.plugin.multi('::1', dnsbls, cb);
153
153
  }
154
154
  }
@@ -163,7 +163,7 @@ exports.first = {
163
163
  test.ok((Array.isArray(a) && a.length > 0));
164
164
  test.done();
165
165
  }
166
- const dnsbls = [ 'cbl.abuseat.org', 'bl.spamcop.net' ];
166
+ const dnsbls = [ 'xbl.spamhaus.org', 'bl.spamcop.net' ];
167
167
  this.plugin.first('127.0.0.2', dnsbls , cb);
168
168
  },
169
169
  'negative result' (test) {
@@ -174,12 +174,12 @@ exports.first = {
174
174
  test.equal(null, a);
175
175
  test.done();
176
176
  }
177
- const dnsbls = [ 'cbl.abuseat.org', 'bl.spamcop.net' ];
177
+ const dnsbls = [ 'xbl.spamhaus.org', 'bl.spamcop.net' ];
178
178
  this.plugin.first('127.0.0.1', dnsbls, cb);
179
179
  },
180
180
  'each_cb' (test) {
181
181
  test.expect(7);
182
- const dnsbls = [ 'cbl.abuseat.org', 'bl.spamcop.net' ];
182
+ const dnsbls = [ 'xbl.spamhaus.org', 'bl.spamcop.net' ];
183
183
  let pending = dnsbls.length;
184
184
  function cb () {
185
185
  test.ok(pending);
@@ -3,7 +3,7 @@
3
3
  const path = require('path');
4
4
  const fixtures = require('haraka-test-fixtures');
5
5
 
6
- const stub = fixtures.stub.stub;
6
+ const { stub } = fixtures.stub;
7
7
 
8
8
  const _set_up = function (done) {
9
9
 
@@ -22,13 +22,12 @@ exports.mxErr = {
22
22
  setUp : _set_up,
23
23
  'any.com, no err code' (test) {
24
24
  test.expect(3);
25
- const t = this;
26
- const txn = t.connection.transaction;
25
+ const txn = this.connection.transaction;
27
26
  const err = new Error('oops');
28
27
  err.code = null;
29
28
  let called = false;
30
29
  function cb () { called = true; }
31
- const r = t.plugin.mxErr(t.connection, 'any.com', 'MX', err, cb);
30
+ const r = this.plugin.mxErr(this.connection, 'any.com', 'MX', err, cb);
32
31
  test.equal(r, true);
33
32
  test.equal(called, true);
34
33
  const mf = txn.results.get('mail_from.is_resolvable');
@@ -37,13 +36,12 @@ exports.mxErr = {
37
36
  },
38
37
  'any.com, bypass err code' (test) {
39
38
  test.expect(3);
40
- const t = this;
41
- const txn = t.connection.transaction;
39
+ const txn = this.connection.transaction;
42
40
  const err = new Error('oops');
43
41
  err.code=dns.NOTFOUND;
44
42
  let called = false;
45
43
  function cb () { called = true; }
46
- const r = t.plugin.mxErr(t.connection, 'any.com', 'MX', err, cb);
44
+ const r = this.plugin.mxErr(this.connection, 'any.com', 'MX', err, cb);
47
45
  test.equal(r, false);
48
46
  test.equal(called, false);
49
47
  const mf = txn.results.get('mail_from.is_resolvable');
@@ -56,9 +54,8 @@ exports.implicit_mx = {
56
54
  setUp : _set_up,
57
55
  'tnpi.net' (test) {
58
56
  test.expect(2);
59
- const t = this;
60
57
  const txn = this.connection.transaction;
61
- t.plugin.implicit_mx(t.connection, 'tnpi.net', err => {
58
+ this.plugin.implicit_mx(this.connection, 'tnpi.net', err => {
62
59
  test.equal(err, undefined);
63
60
  const mf = txn.results.get('mail_from.is_resolvable');
64
61
  test.equal(mf.pass.length, 1);
@@ -67,9 +64,8 @@ exports.implicit_mx = {
67
64
  },
68
65
  'harakamail.com' (test) {
69
66
  test.expect(1);
70
- const t = this;
71
67
  const txn = this.connection.transaction;
72
- t.plugin.implicit_mx(t.connection, 'harakamail.com', () => {
68
+ this.plugin.implicit_mx(this.connection, 'harakamail.com', () => {
73
69
  // console.log(arguments);
74
70
  const mf = txn.results.get('mail_from.is_resolvable');
75
71
  // console.log(mf);
@@ -79,56 +75,18 @@ exports.implicit_mx = {
79
75
  },
80
76
  'mx.theartfarm.com' (test) {
81
77
  test.expect(1);
82
- const t = this;
83
78
  const txn = this.connection.transaction;
84
- t.plugin.implicit_mx(t.connection, 'mx.theartfarm.com', () => {
79
+ this.plugin.implicit_mx(this.connection, 'mx.theartfarm.com', () => {
85
80
  const mf = txn.results.get('mail_from.is_resolvable');
86
81
  // console.log(mf);
87
82
  test.equal(mf.fail.length, 1);
88
83
  test.done();
89
84
  });
90
85
  },
91
- 'mxs4am.josef-froehle.de' (test) {
92
- test.expect(1);
93
- const t = this;
94
- const txn = this.connection.transaction;
95
- t.plugin.implicit_mx(t.connection, 'mxs4am.josef-froehle.de', () => {
96
- //console.log(arguments);
97
- const mf = txn.results.get('mail_from.is_resolvable');
98
- //console.log(mf);
99
- test.equal(mf.pass.length, 1);
100
- test.done();
101
- });
102
- },
103
- 'mxs4am-a.josef-froehle.de' (test) {
104
- test.expect(1);
105
- const t = this;
106
- const txn = this.connection.transaction;
107
- t.plugin.implicit_mx(t.connection, 'mxs4am-a.josef-froehle.de', () => {
108
- //console.log(arguments);
109
- const mf = txn.results.get('mail_from.is_resolvable');
110
- //console.log(mf);
111
- test.equal(mf.pass.length, 1);
112
- test.done();
113
- });
114
- },
115
- 'mxs4am-aaaa.josef-froehle.de' (test) {
116
- test.expect(1);
117
- const t = this;
118
- const txn = this.connection.transaction;
119
- t.plugin.implicit_mx(t.connection, 'mxs4am-aaaa.josef-froehle.de', () => {
120
- //console.log(arguments);
121
- const mf = txn.results.get('mail_from.is_resolvable');
122
- //console.log(mf);
123
- test.equal(mf.pass.length, 1);
124
- test.done();
125
- });
126
- },
127
86
  'resolve-fail-definitive.josef-froehle.de' (test) {
128
87
  test.expect(1);
129
- const t = this;
130
88
  const txn = this.connection.transaction;
131
- t.plugin.implicit_mx(t.connection, 'resolve-fail-definitive.josef-froehle.de', () => {
89
+ this.plugin.implicit_mx(this.connection, 'resolve-fail-definitive.josef-froehle.de', () => {
132
90
  const mf = txn.results.get('mail_from.is_resolvable');
133
91
  //console.log(mf);
134
92
  test.equal(mf.fail.length, 1);
@@ -137,9 +95,8 @@ exports.implicit_mx = {
137
95
  },
138
96
  'resolve-fail-a.josef-froehle.de' (test) {
139
97
  test.expect(1);
140
- const t = this;
141
98
  const txn = this.connection.transaction;
142
- t.plugin.implicit_mx(t.connection, 'resolve-fail-a.josef-froehle.de', () => {
99
+ this.plugin.implicit_mx(this.connection, 'resolve-fail-a.josef-froehle.de', () => {
143
100
  const mf = txn.results.get('mail_from.is_resolvable');
144
101
  //console.log(mf);
145
102
  test.equal(mf.fail.length, 1);
@@ -148,9 +105,8 @@ exports.implicit_mx = {
148
105
  },
149
106
  'resolve-fail-aaaa.josef-froehle.de' (test) {
150
107
  test.expect(1);
151
- const t = this;
152
108
  const txn = this.connection.transaction;
153
- t.plugin.implicit_mx(t.connection, 'resolve-fail-aaaa.josef-froehle.de', () => {
109
+ this.plugin.implicit_mx(this.connection, 'resolve-fail-aaaa.josef-froehle.de', () => {
154
110
  const mf = txn.results.get('mail_from.is_resolvable');
155
111
  //console.log(mf);
156
112
  test.equal(mf.fail.length, 1);
@@ -2,7 +2,7 @@
2
2
 
3
3
  const path = require('path');
4
4
 
5
- const Address = require('address-rfc2821').Address;
5
+ const { Address } = require('address-rfc2821');
6
6
  const fixtures = require('haraka-test-fixtures');
7
7
 
8
8
  const OK = 906;
@@ -160,33 +160,33 @@ exports.get_mx = {
160
160
 
161
161
  exports.is_outbound_enabled = {
162
162
  setUp : _setup,
163
- 'enable_outbound is true by default' (test) {
163
+ 'enable_outbound is false by default' (test) {
164
164
  test.expect(1);
165
- test.equal(this.plugin.is_outbound_enabled(this.plugin.cfg), true);
165
+ test.equal(this.plugin.is_outbound_enabled(this.plugin.cfg), false);
166
166
  test.done();
167
167
  },
168
- 'per-domain enable_outbound is true by default' (test) {
168
+ 'per-domain enable_outbound is false by default' (test) {
169
169
  test.expect(1);
170
170
  this.connection.transaction.rcpt_to = [ new Address('<postmaster@test.com>') ];
171
171
  const cfg = this.plugin.get_config(this.connection);
172
- test.equal(this.plugin.is_outbound_enabled(cfg), true);
172
+ test.equal(this.plugin.is_outbound_enabled(cfg), false);
173
173
  test.done();
174
174
  },
175
- 'per-domain enable_outbound can be set to false' (test) {
175
+ 'per-domain enable_outbound can be set to true' (test) {
176
176
  test.expect(1);
177
- this.plugin.cfg['test.com'].enable_outbound = false;
177
+ this.plugin.cfg['test.com'].enable_outbound = true;
178
178
  this.connection.transaction.rcpt_to = [ new Address('<postmaster@test.com>') ];
179
179
  const cfg = this.plugin.get_config(this.connection);
180
- test.equal(this.plugin.is_outbound_enabled(cfg), false);
180
+ test.equal(this.plugin.is_outbound_enabled(cfg), true);
181
181
  test.done();
182
182
  },
183
- 'per-domain enable_outbound is true even if top level is false' (test) {
183
+ 'per-domain enable_outbound is false even if top level is false' (test) {
184
184
  test.expect(1);
185
185
  this.plugin.cfg.main.enable_outbound = false; // this will be ignored
186
- this.plugin.cfg['test.com'].enable_outbound = true;
186
+ this.plugin.cfg['test.com'].enable_outbound = false;
187
187
  this.connection.transaction.rcpt_to = [ new Address('<postmaster@test.com>') ];
188
188
  const cfg = this.plugin.get_config(this.connection);
189
- test.equal(this.plugin.is_outbound_enabled(cfg), true);
189
+ test.equal(this.plugin.is_outbound_enabled(cfg), false);
190
190
  test.done();
191
191
  }
192
192
  }
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const Address = require('address-rfc2821').Address;
3
+ const { Address } = require('address-rfc2821');
4
4
  const fixtures = require('haraka-test-fixtures');
5
5
 
6
6
  function _set_up (done) {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const Address = require('address-rfc2821').Address;
3
+ const { Address } = require('address-rfc2821');
4
4
  const fixtures = require('haraka-test-fixtures');
5
5
 
6
6
  function _set_up (done) {
@@ -158,7 +158,7 @@ exports.score_too_high = {
158
158
  test.expect(1);
159
159
  this.connection.relaying = true;
160
160
  this.plugin.cfg.main.relay_reject_threshold = 7;
161
- test.equal(false, this.plugin.score_too_high(this.connection, {score: 6}));
161
+ test.equal('', this.plugin.score_too_high(this.connection, {score: 6}));
162
162
  test.done();
163
163
  },
164
164
  'too high score with relaying is too high' (test) {
Binary file
package/tests/queue/plain CHANGED
Binary file
package/tests/rfc1869.js CHANGED
@@ -1,4 +1,4 @@
1
- const parse = require('../rfc1869').parse;
1
+ const { parse } = require('../rfc1869');
2
2
 
3
3
  function _check (test, line, expected) {
4
4
  test.expect(1 + expected.length);
@@ -55,4 +55,7 @@ exports.basic = {
55
55
  _check(test, 'RCPT TO:<user=name@domain.com> foo=bar',
56
56
  ['<user=name@domain.com>', 'foo=bar']);
57
57
  },
58
+ 'RCPT TO:<postmaster>': test => {
59
+ _check(test, 'RCPT TO:<postmaster>', ['<postmaster>']);
60
+ },
58
61
  }
package/tests/server.js CHANGED
@@ -1,5 +1,6 @@
1
1
  const path = require('path');
2
2
  const endpoint = require('../endpoint');
3
+ const message = require('haraka-email-message')
3
4
 
4
5
  function _set_up (done) {
5
6
 
@@ -204,14 +205,11 @@ exports.smtp_client = {
204
205
  const server = { notes: { } };
205
206
  const cfg = {
206
207
  connect_timeout: 2,
207
- pool_timeout: 5,
208
- max_connections: 3,
209
208
  }
210
209
 
211
210
  const smtp_client = require('../smtp_client');
212
- const MessageStream = require('../messagestream');
213
211
 
214
- smtp_client.get_client(server, (err, client) => {
212
+ smtp_client.get_client(server, (client) => {
215
213
 
216
214
  client
217
215
  .on('greeting', command => {
@@ -227,7 +225,7 @@ exports.smtp_client = {
227
225
  client.send_command('DATA');
228
226
  })
229
227
  .on('data', () => {
230
- const message_stream = new MessageStream(
228
+ const message_stream = new message.stream(
231
229
  { main : { spool_after : 1024 } }, "theMessageId"
232
230
  );
233
231
 
@@ -251,7 +249,7 @@ exports.smtp_client = {
251
249
  test.done();
252
250
  });
253
251
 
254
- }, 2500, 'localhost', cfg);
252
+ }, { port: 2500, host: 'localhost', cfg });
255
253
  },
256
254
  }
257
255
 
@@ -415,7 +413,7 @@ exports.nodemailer = {
415
413
 
416
414
  exports.requireAuthorized_SMTPS = {
417
415
  setUp (done) {
418
- _setupServer(this, 'localhost:2465', done);
416
+ _setupServer(this, '127.0.0.1:2465', done);
419
417
  },
420
418
  tearDown: _tearDownServer,
421
419
  'rejects non-validated SMTPS connection': test => {
@@ -451,6 +449,9 @@ exports.requireAuthorized_SMTPS = {
451
449
  if (error.message === 'socket hang up') { // node 6 & 8
452
450
  test.equal(error.message, 'socket hang up');
453
451
  }
452
+ else if (/alert certificate required/.test(error.message)) { // node 18
453
+ test.ok(/alert certificate required/.test(error.message))
454
+ }
454
455
  else { // node 10+
455
456
  test.equal(error.message, 'Client network socket disconnected before secure TLS connection was established');
456
457
  }
@@ -463,7 +464,7 @@ exports.requireAuthorized_SMTPS = {
463
464
 
464
465
  exports.requireAuthorized_STARTTLS = {
465
466
  setUp (done) {
466
- _setupServer(this, 'localhost:2587', done);
467
+ _setupServer(this, '127.0.0.1:2587', done);
467
468
  },
468
469
  'rejects non-validated STARTTLS connection': test => {
469
470
 
@@ -495,7 +496,12 @@ exports.requireAuthorized_STARTTLS = {
495
496
  (error, info) => {
496
497
  if (error) {
497
498
  // console.log(error);
498
- test.equal(error.message, 'Client network socket disconnected before secure TLS connection was established');
499
+ if (/alert certificate required/.test(error.message)) { // node 18
500
+ test.ok(/alert certificate required/.test(error.message))
501
+ }
502
+ else {
503
+ test.equal(error.message, 'Client network socket disconnected before secure TLS connection was established');
504
+ }
499
505
  }
500
506
  test.done();
501
507
  });
@@ -1,21 +1,11 @@
1
- const MessageStream = require('./messagestream');
1
+ const message = require('haraka-email-message')
2
2
 
3
- test.expect(22);
3
+ test.expect(15);
4
4
  const server = {notes: {}};
5
5
 
6
- exports.get_pool(server);
7
- const pool_name = '25:localhost:300:no_user';
8
- test.equals(1, Object.keys(server.notes.pool).length);
9
- test.equals(pool_name, Object.keys(server.notes.pool)[0]);
10
- test.equals(0, server.notes.pool[pool_name].getPoolSize());
11
- test.equals(0, server.notes.pool[pool_name].availableObjectsCount());
6
+ exports.get_client(server, (smtp_client) => {
12
7
 
13
- exports.get_client(server, (err, smtp_client) => {
14
- test.equals(null, err);
15
- test.equals(1, server.notes.pool[pool_name].getPoolSize());
16
- test.equals(0, server.notes.pool[pool_name].availableObjectsCount());
17
-
18
- const message_stream = new MessageStream(
8
+ const message_stream = new message.stream(
19
9
  { main : { spool_after : 1024 } }, "123456789"
20
10
  );
21
11
 
@@ -1,22 +1,12 @@
1
- const MessageStream = require('./messagestream');
1
+ const message = require('haraka-email-message')
2
2
 
3
- test.expect(21);
3
+ test.expect(14);
4
4
  const server = {notes: {}};
5
5
 
6
- exports.get_pool(server);
7
- const pool_name = '25:localhost:300:no_user';
8
- test.equals(1, Object.keys(server.notes.pool).length);
9
- test.equals(pool_name, Object.keys(server.notes.pool)[0]);
10
- test.equals(0, server.notes.pool[pool_name].getPoolSize());
11
- test.equals(0, server.notes.pool[pool_name].availableObjectsCount());
6
+ exports.get_client(server, (smtp_client) => {
12
7
 
13
- exports.get_client(server, (err, smtp_client) => {
14
- test.equals(null, err);
15
- test.equals(1, server.notes.pool[pool_name].getPoolSize());
16
- test.equals(0, server.notes.pool[pool_name].availableObjectsCount());
17
-
18
- const message_stream = new MessageStream(
19
- { main : { spool_after : 1024 } }, "123456789"
8
+ const message_stream = new message.stream(
9
+ { main : { spool_after : 1024 } }, '123456789'
20
10
  );
21
11
 
22
12
  const data = [];
@@ -11,6 +11,10 @@ vm_harness.add_tests(
11
11
  const smtp_client = require('../smtp_client');
12
12
  const fixtures = require('haraka-test-fixtures');
13
13
 
14
+ function getClientOpts (socket) {
15
+ return { port: 25, host: 'localhost', connect_timeout: 30, idle_timeout: 30, socket }
16
+ }
17
+
14
18
  exports.testUpgradeIsCalledOnSTARTTLS = test => {
15
19
  test.expect(1);
16
20
 
@@ -35,13 +39,13 @@ exports.testUpgradeIsCalledOnSTARTTLS = test => {
35
39
  }
36
40
  };
37
41
 
38
- const client = new smtp_client.smtp_client(25, 'localhost', 30, 30, socket);
42
+ const client = new smtp_client.smtp_client(getClientOpts(socket));
39
43
  client.load_tls_config({ key: Buffer.from('OutboundTlsKeyLoaded')});
40
44
 
41
45
  client.command = 'starttls';
42
46
  cmds.line('250 Hello client.example.com\r\n');
43
47
 
44
- const StringDecoder = require('string_decoder').StringDecoder;
48
+ const { StringDecoder } = require('string_decoder');
45
49
  const decoder = new StringDecoder('utf8');
46
50
 
47
51
  const cent = Buffer.from(upgradeArgs.key);
@@ -63,7 +67,7 @@ exports.startTLS = test => {
63
67
  write: arg => { cmd = arg; }
64
68
  };
65
69
 
66
- const client = new smtp_client.smtp_client(25, 'localhost', 30, 30, socket);
70
+ const client = new smtp_client.smtp_client(getClientOpts(socket));
67
71
  client.tls_options = {};
68
72
 
69
73
  client.secured = false;