haraka 0.0.33 → 3.3.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.
- package/.githooks/pre-commit +41 -0
- package/.prettierignore +7 -0
- package/.qlty/.gitignore +7 -0
- package/.qlty/configs/.shellcheckrc +1 -0
- package/.qlty/qlty.toml +15 -0
- package/CHANGELOG.md +1898 -0
- package/CONTRIBUTORS.md +34 -0
- package/Dockerfile +50 -0
- package/LICENSE +22 -0
- package/Plugins.md +227 -0
- package/README.md +119 -4
- package/SECURITY.md +178 -0
- package/TODO +22 -0
- package/bin/haraka +593 -0
- package/bin/haraka_grep +32 -0
- package/config/aliases +2 -0
- package/config/auth_flat_file.ini +7 -0
- package/config/auth_vpopmaild.ini +9 -0
- package/config/connection.ini +79 -0
- package/config/delay_deny.ini +7 -0
- package/config/host_list +3 -0
- package/config/host_list_regex +6 -0
- package/config/http.ini +11 -0
- package/config/lmtp.ini +7 -0
- package/config/log.ini +11 -0
- package/config/outbound.bounce_message +18 -0
- package/config/outbound.bounce_message_html +36 -0
- package/config/outbound.bounce_message_image +106 -0
- package/config/outbound.ini +24 -0
- package/config/plugins +67 -0
- package/config/smtp.ini +37 -0
- package/config/smtp_bridge.ini +4 -0
- package/config/smtp_forward.ini +31 -0
- package/config/smtp_proxy.ini +27 -0
- package/config/tarpit.timeout +1 -0
- package/config/tls.ini +83 -0
- package/config/watch.ini +12 -0
- package/config/xclient.hosts +2 -0
- package/connection.js +1865 -0
- package/contrib/Haraka.cf +6 -0
- package/contrib/Haraka.pm +35 -0
- package/contrib/bad_smtp_server.pl +25 -0
- package/contrib/bsd-rc.d/haraka +63 -0
- package/contrib/debian-init.d/haraka +87 -0
- package/contrib/haraka.init +96 -0
- package/contrib/haraka.service +23 -0
- package/contrib/plugin2npm.sh +81 -0
- package/contrib/ubuntu-upstart/haraka.conf +27 -0
- package/docs/Body.md +1 -0
- package/docs/Config.md +1 -0
- package/docs/Connection.md +153 -0
- package/docs/CoreConfig.md +96 -0
- package/docs/CustomReturnCodes.md +3 -0
- package/docs/HAProxy.md +62 -0
- package/docs/Header.md +1 -0
- package/docs/Logging.md +129 -0
- package/docs/Outbound.md +210 -0
- package/docs/Plugins.md +372 -0
- package/docs/Results.md +7 -0
- package/docs/Transaction.md +135 -0
- package/docs/Tutorial.md +183 -0
- package/docs/deprecated/access.md +3 -0
- package/docs/deprecated/backscatterer.md +9 -0
- package/docs/deprecated/connect.rdns_access.md +53 -0
- package/docs/deprecated/data.headers.md +3 -0
- package/docs/deprecated/data.nomsgid.md +7 -0
- package/docs/deprecated/data.noreceived.md +11 -0
- package/docs/deprecated/data.rfc5322_header_checks.md +11 -0
- package/docs/deprecated/dkim_sign.md +97 -0
- package/docs/deprecated/dkim_verify.md +28 -0
- package/docs/deprecated/dnsbl.md +80 -0
- package/docs/deprecated/dnswl.md +73 -0
- package/docs/deprecated/lookup_rdns.strict.md +67 -0
- package/docs/deprecated/mail_from.access.md +52 -0
- package/docs/deprecated/mail_from.blocklist.md +18 -0
- package/docs/deprecated/mail_from.nobounces.md +8 -0
- package/docs/deprecated/rcpt_to.access.md +53 -0
- package/docs/deprecated/rcpt_to.blocklist.md +18 -0
- package/docs/deprecated/rcpt_to.routes.md +3 -0
- package/docs/deprecated/rdns.regexp.md +30 -0
- package/docs/plugins/aliases.md +3 -0
- package/docs/plugins/auth/auth_bridge.md +34 -0
- package/docs/plugins/auth/auth_ldap.md +4 -0
- package/docs/plugins/auth/auth_proxy.md +36 -0
- package/docs/plugins/auth/auth_vpopmaild.md +33 -0
- package/docs/plugins/auth/flat_file.md +40 -0
- package/docs/plugins/block_me.md +18 -0
- package/docs/plugins/data.signatures.md +11 -0
- package/docs/plugins/delay_deny.md +23 -0
- package/docs/plugins/max_unrecognized_commands.md +6 -0
- package/docs/plugins/prevent_credential_leaks.md +22 -0
- package/docs/plugins/process_title.md +42 -0
- package/docs/plugins/queue/deliver.md +3 -0
- package/docs/plugins/queue/discard.md +32 -0
- package/docs/plugins/queue/lmtp.md +24 -0
- package/docs/plugins/queue/qmail-queue.md +16 -0
- package/docs/plugins/queue/quarantine.md +87 -0
- package/docs/plugins/queue/smtp_bridge.md +32 -0
- package/docs/plugins/queue/smtp_forward.md +127 -0
- package/docs/plugins/queue/smtp_proxy.md +68 -0
- package/docs/plugins/queue/test.md +7 -0
- package/docs/plugins/rcpt_to.in_host_list.md +34 -0
- package/docs/plugins/rcpt_to.max_count.md +3 -0
- package/docs/plugins/record_envelope_addresses.md +20 -0
- package/docs/plugins/relay.md +3 -0
- package/docs/plugins/reseed_rng.md +16 -0
- package/docs/plugins/status.md +41 -0
- package/docs/plugins/tarpit.md +50 -0
- package/docs/plugins/tls.md +235 -0
- package/docs/plugins/toobusy.md +27 -0
- package/docs/plugins/xclient.md +10 -0
- package/docs/tutorials/Migrating_from_v1_to_v2.md +96 -0
- package/docs/tutorials/SettingUpOutbound.md +62 -0
- package/eslint.config.mjs +2 -0
- package/haraka.js +74 -0
- package/haraka.sh +2 -0
- package/http/html/404.html +58 -0
- package/http/html/index.html +47 -0
- package/http/package.json +21 -0
- package/line_socket.js +24 -0
- package/logger.js +322 -0
- package/outbound/client_pool.js +59 -0
- package/outbound/config.js +134 -0
- package/outbound/hmail.js +1504 -0
- package/outbound/index.js +349 -0
- package/outbound/qfile.js +93 -0
- package/outbound/queue.js +399 -0
- package/outbound/tls.js +85 -0
- package/outbound/todo.js +17 -0
- package/package.json +100 -4
- package/plugins/.eslintrc.yaml +3 -0
- package/plugins/auth/auth_base.js +261 -0
- package/plugins/auth/auth_bridge.js +20 -0
- package/plugins/auth/auth_proxy.js +227 -0
- package/plugins/auth/auth_vpopmaild.js +162 -0
- package/plugins/auth/flat_file.js +44 -0
- package/plugins/block_me.js +88 -0
- package/plugins/data.signatures.js +30 -0
- package/plugins/delay_deny.js +153 -0
- package/plugins/prevent_credential_leaks.js +61 -0
- package/plugins/process_title.js +197 -0
- package/plugins/profile.js +11 -0
- package/plugins/queue/deliver.js +12 -0
- package/plugins/queue/discard.js +27 -0
- package/plugins/queue/lmtp.js +45 -0
- package/plugins/queue/qmail-queue.js +93 -0
- package/plugins/queue/quarantine.js +133 -0
- package/plugins/queue/smtp_bridge.js +45 -0
- package/plugins/queue/smtp_forward.js +371 -0
- package/plugins/queue/smtp_proxy.js +142 -0
- package/plugins/queue/test.js +15 -0
- package/plugins/rcpt_to.host_list_base.js +65 -0
- package/plugins/rcpt_to.in_host_list.js +56 -0
- package/plugins/record_envelope_addresses.js +17 -0
- package/plugins/reseed_rng.js +7 -0
- package/plugins/status.js +274 -0
- package/plugins/tarpit.js +45 -0
- package/plugins/tls.js +164 -0
- package/plugins/toobusy.js +47 -0
- package/plugins/xclient.js +124 -0
- package/plugins.js +605 -0
- package/run_tests +11 -0
- package/server.js +827 -0
- package/smtp_client.js +504 -0
- package/test/.eslintrc.yaml +11 -0
- package/test/config/auth_flat_file.ini +5 -0
- package/test/config/block_me.recipient +1 -0
- package/test/config/block_me.senders +1 -0
- package/test/config/dhparams.pem +8 -0
- package/test/config/host_list +2 -0
- package/test/config/outbound_tls_cert.pem +1 -0
- package/test/config/outbound_tls_key.pem +1 -0
- package/test/config/plugins +7 -0
- package/test/config/smtp.ini +11 -0
- package/test/config/smtp_forward.ini +30 -0
- package/test/config/tls/example.com/_.example.com.key +28 -0
- package/test/config/tls/example.com/example.com.crt +25 -0
- package/test/config/tls/haraka.local.pem +51 -0
- package/test/config/tls.ini +45 -0
- package/test/config/tls_cert.pem +21 -0
- package/test/config/tls_key.pem +28 -0
- package/test/connection.js +820 -0
- package/test/fixtures/haproxy_allowed/config/connection.ini +3 -0
- package/test/fixtures/haproxy_disabled/config/connection.ini +3 -0
- package/test/fixtures/haproxy_untrusted/config/connection.ini +3 -0
- package/test/fixtures/line_socket.js +21 -0
- package/test/fixtures/todo_qfile.txt +0 -0
- package/test/fixtures/util_hmailitem.js +156 -0
- package/test/installation/config/test-plugin-flat +1 -0
- package/test/installation/config/test-plugin.ini +10 -0
- package/test/installation/config/tls.ini +1 -0
- package/test/installation/node_modules/load_first/index.js +5 -0
- package/test/installation/node_modules/load_first/package.json +11 -0
- package/test/installation/node_modules/test-plugin/config/test-plugin-flat +1 -0
- package/test/installation/node_modules/test-plugin/config/test-plugin.ini +9 -0
- package/test/installation/node_modules/test-plugin/package.json +5 -0
- package/test/installation/node_modules/test-plugin/test-plugin.js +5 -0
- package/test/installation/plugins/base_plugin.js +3 -0
- package/test/installation/plugins/folder_plugin/index.js +3 -0
- package/test/installation/plugins/folder_plugin/package.json +11 -0
- package/test/installation/plugins/inherits.js +7 -0
- package/test/installation/plugins/load_first.js +3 -0
- package/test/installation/plugins/plugin.js +1 -0
- package/test/installation/plugins/tls.js +3 -0
- package/test/logger.js +217 -0
- package/test/loud/config/dhparams.pem +0 -0
- package/test/loud/config/tls/goobered.pem +45 -0
- package/test/loud/config/tls.ini +43 -0
- package/test/mail_specimen/base64-root-part.txt +23 -0
- package/test/mail_specimen/varied-fold-lengths-preserve-data.txt +283 -0
- package/test/outbound/bounce_net_errors.js +133 -0
- package/test/outbound/bounce_rfc3464.js +226 -0
- package/test/outbound/hmail.js +210 -0
- package/test/outbound/index.js +385 -0
- package/test/outbound/qfile.js +124 -0
- package/test/outbound/queue.js +325 -0
- package/test/plugins/auth/auth_base.js +620 -0
- package/test/plugins/auth/auth_bridge.js +80 -0
- package/test/plugins/auth/auth_vpopmaild.js +81 -0
- package/test/plugins/auth/flat_file.js +123 -0
- package/test/plugins/block_me.js +141 -0
- package/test/plugins/data.signatures.js +111 -0
- package/test/plugins/delay_deny.js +262 -0
- package/test/plugins/prevent_credential_leaks.js +174 -0
- package/test/plugins/process_title.js +141 -0
- package/test/plugins/queue/deliver.js +98 -0
- package/test/plugins/queue/discard.js +78 -0
- package/test/plugins/queue/lmtp.js +137 -0
- package/test/plugins/queue/qmail-queue.js +98 -0
- package/test/plugins/queue/quarantine.js +80 -0
- package/test/plugins/queue/smtp_bridge.js +152 -0
- package/test/plugins/queue/smtp_forward.js +1023 -0
- package/test/plugins/queue/smtp_proxy.js +138 -0
- package/test/plugins/rcpt_to.host_list_base.js +102 -0
- package/test/plugins/rcpt_to.in_host_list.js +186 -0
- package/test/plugins/record_envelope_addresses.js +66 -0
- package/test/plugins/reseed_rng.js +34 -0
- package/test/plugins/status.js +207 -0
- package/test/plugins/tarpit.js +90 -0
- package/test/plugins/tls.js +86 -0
- package/test/plugins/toobusy.js +198 -0
- package/test/plugins/xclient.js +119 -0
- package/test/plugins.js +230 -0
- package/test/queue/1507509981169_1507509981169_0_61403_e0Y0Ym_1_fixed +0 -0
- package/test/queue/1507509981169_1507509981169_0_61403_e0Y0Ym_1_haraka +0 -0
- package/test/queue/1508269674999_1508269674999_0_34002_socVUF_1_haraka +0 -0
- package/test/queue/1508455115683_1508455115683_0_90253_9Q4o4V_1_haraka +0 -0
- package/test/queue/zero-length +0 -0
- package/test/server.js +1012 -0
- package/test/smtp_client.js +1303 -0
- package/test/tls_socket.js +321 -0
- package/test/transaction.js +554 -0
- package/tls_socket.js +771 -0
- package/transaction.js +267 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const events = require('node:events')
|
|
4
|
+
const fixtures = require('haraka-test-fixtures')
|
|
5
|
+
const { stub } = fixtures.stub
|
|
6
|
+
|
|
7
|
+
class Socket extends events.EventEmitter {
|
|
8
|
+
constructor(port, host) {
|
|
9
|
+
super()
|
|
10
|
+
this.port = port
|
|
11
|
+
this.host = host
|
|
12
|
+
this.setTimeout = stub()
|
|
13
|
+
this.setKeepAlive = stub()
|
|
14
|
+
this.destroy = stub()
|
|
15
|
+
this.end = stub()
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
exports.Socket = Socket
|
|
20
|
+
|
|
21
|
+
exports.connect = (port, host) => new Socket(port, host)
|
|
Binary file
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const assert = require('node:assert')
|
|
4
|
+
|
|
5
|
+
const { Address } = require('@haraka/email-address')
|
|
6
|
+
const fixtures = require('haraka-test-fixtures')
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Creates a HMailItem instance, which is passed to callback. Reports error on test param if creation fails.
|
|
10
|
+
*
|
|
11
|
+
* @param outbound_context
|
|
12
|
+
* @param options
|
|
13
|
+
* @param callback
|
|
14
|
+
*/
|
|
15
|
+
exports.newMockHMailItem = (outbound_context, done, options, callback) => {
|
|
16
|
+
const opts = options || {}
|
|
17
|
+
exports.createHMailItem(outbound_context, opts, (err, hmail) => {
|
|
18
|
+
if (err) {
|
|
19
|
+
assert.ok(false, `Could not create HMailItem: ${err}`)
|
|
20
|
+
done()
|
|
21
|
+
return
|
|
22
|
+
}
|
|
23
|
+
if (!hmail.todo) {
|
|
24
|
+
hmail.once('ready', () => {
|
|
25
|
+
setImmediate(() => {
|
|
26
|
+
callback(hmail)
|
|
27
|
+
})
|
|
28
|
+
})
|
|
29
|
+
} else {
|
|
30
|
+
callback(hmail)
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Creates a HMailItem instance for testing purpose
|
|
37
|
+
*
|
|
38
|
+
* @param outbound_context: The context of outbound, e.g. from require('outbound/index.js')
|
|
39
|
+
* @param options
|
|
40
|
+
* @param callback(err, hmail)
|
|
41
|
+
*/
|
|
42
|
+
exports.createHMailItem = (outbound_context, options, callback) => {
|
|
43
|
+
const mail_from = options.mail_from || 'sender@domain'
|
|
44
|
+
const delivery_domain = options.delivery_domain || 'domain'
|
|
45
|
+
const mail_recipients = options.mail_recipients || [new Address('recipient@domain')]
|
|
46
|
+
|
|
47
|
+
const conn = fixtures.makeConnection({ withTxn: true })
|
|
48
|
+
conn.transaction.mail_from = new Address(mail_from)
|
|
49
|
+
|
|
50
|
+
const todo = new outbound_context.TODOItem(delivery_domain, mail_recipients, conn.transaction)
|
|
51
|
+
todo.uuid = `${todo.uuid}.1`
|
|
52
|
+
|
|
53
|
+
let contents = [
|
|
54
|
+
`From: ${mail_from}`,
|
|
55
|
+
`To: ${mail_recipients.join(', ')}`,
|
|
56
|
+
'MIME-Version: 1.0',
|
|
57
|
+
'Content-type: text/plain; charset=us-ascii',
|
|
58
|
+
'Subject: Some subject here',
|
|
59
|
+
'',
|
|
60
|
+
'Some email body here',
|
|
61
|
+
'',
|
|
62
|
+
].join('\n')
|
|
63
|
+
let match
|
|
64
|
+
const re = /^([^\n]*\n?)/
|
|
65
|
+
while ((match = re.exec(contents))) {
|
|
66
|
+
let line = match[1]
|
|
67
|
+
line = line.replace(/\r?\n?$/, '\r\n') // make sure it ends in \r\n
|
|
68
|
+
conn.transaction.add_data(Buffer.from(line))
|
|
69
|
+
contents = contents.substring(match[1].length)
|
|
70
|
+
if (contents.length === 0) {
|
|
71
|
+
break
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
conn.transaction.message_stream.add_line_end()
|
|
75
|
+
|
|
76
|
+
const hmails = []
|
|
77
|
+
const ok_paths = []
|
|
78
|
+
outbound_context.exports
|
|
79
|
+
.process_delivery(ok_paths, todo, hmails)
|
|
80
|
+
.then(() => {
|
|
81
|
+
if (hmails.length == 0) {
|
|
82
|
+
callback('No hmail producted')
|
|
83
|
+
return
|
|
84
|
+
}
|
|
85
|
+
for (const hmail of hmails) {
|
|
86
|
+
hmail.hostlist = [delivery_domain]
|
|
87
|
+
callback(null, hmail)
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
.catch((err) => {
|
|
91
|
+
callback(`process_delivery error: ${err}`)
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* runs a socket.write
|
|
97
|
+
* @param socket
|
|
98
|
+
* @param test
|
|
99
|
+
* @param playbook
|
|
100
|
+
*/
|
|
101
|
+
exports.playTestSmtpConversation = (hmail, socket, done, playbook, callback) => {
|
|
102
|
+
const testmx = {
|
|
103
|
+
bind_helo: 'haraka.test',
|
|
104
|
+
exchange: 'remote.testhost',
|
|
105
|
+
}
|
|
106
|
+
hmail.try_deliver_host_on_socket(testmx, 'testhost', 'testport', socket)
|
|
107
|
+
|
|
108
|
+
socket.write = (line) => {
|
|
109
|
+
//console.log('MockSocket.write(' + line.replace(/\n/, '\\n').replace(/\r/, '\\r') + ')');
|
|
110
|
+
if (playbook.length == 0) {
|
|
111
|
+
assert.ok(false, 'missing next playbook entry')
|
|
112
|
+
done()
|
|
113
|
+
return
|
|
114
|
+
}
|
|
115
|
+
let expected
|
|
116
|
+
while (false != (expected = getNextEntryFromPlaybook('haraka', playbook))) {
|
|
117
|
+
if (typeof expected.test === 'function') {
|
|
118
|
+
assert.ok(
|
|
119
|
+
expected.test(line),
|
|
120
|
+
expected.description || `Expected that line works with func: ${expected.test}`,
|
|
121
|
+
)
|
|
122
|
+
} else {
|
|
123
|
+
assert.equal(
|
|
124
|
+
`${expected.test}\r\n`,
|
|
125
|
+
line,
|
|
126
|
+
expected.description || `Expected that line equals: ${expected.test}`,
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
if (expected.end_test === true) {
|
|
130
|
+
setTimeout(() => {
|
|
131
|
+
callback()
|
|
132
|
+
}, 0)
|
|
133
|
+
return
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
setTimeout(() => {
|
|
137
|
+
let nextMessageFromServer
|
|
138
|
+
while (false != (nextMessageFromServer = getNextEntryFromPlaybook('remote', playbook))) {
|
|
139
|
+
socket.emit('line', `${nextMessageFromServer.line}\r\n`)
|
|
140
|
+
}
|
|
141
|
+
}, 0)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const welcome = getNextEntryFromPlaybook('remote', playbook)
|
|
145
|
+
socket.emit('line', welcome.line)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function getNextEntryFromPlaybook(ofType, playbook) {
|
|
149
|
+
if (playbook.length == 0) {
|
|
150
|
+
return false
|
|
151
|
+
}
|
|
152
|
+
if (playbook[0].from == ofType) {
|
|
153
|
+
return playbook.shift()
|
|
154
|
+
}
|
|
155
|
+
return false
|
|
156
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
flatisloaded
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ciphers=test
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
flatnotloaded
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
exports.register = () => {}
|
package/test/logger.js
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { describe, it, beforeEach } = require('node:test')
|
|
4
|
+
const assert = require('node:assert/strict')
|
|
5
|
+
const util = require('node:util')
|
|
6
|
+
|
|
7
|
+
const _set_up = () => {
|
|
8
|
+
this.logger = require('../logger')
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
describe('logger', () => {
|
|
12
|
+
beforeEach(_set_up)
|
|
13
|
+
|
|
14
|
+
describe('init', () => {
|
|
15
|
+
it('logger', () => {
|
|
16
|
+
assert.ok(this.logger)
|
|
17
|
+
})
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
describe('log', () => {
|
|
21
|
+
const formats = ['DEFAULT', 'LOGFMT', 'JSON']
|
|
22
|
+
|
|
23
|
+
for (const fmt of formats) {
|
|
24
|
+
it(`log in ${fmt} format`, () => {
|
|
25
|
+
this.logger.deferred_logs = []
|
|
26
|
+
this.logger.format = this.logger.formats[fmt]
|
|
27
|
+
assert.ok(this.logger.log('WARN', 'test warning'))
|
|
28
|
+
assert.equal(this.logger.deferred_logs.length, 1)
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it(`log in ${fmt} format w/deferred`, () => {
|
|
32
|
+
this.logger.format = this.logger.formats[fmt]
|
|
33
|
+
this.logger.plugins = { plugin_list: true }
|
|
34
|
+
this.logger.deferred_logs.push({ level: 'INFO', data: 'log test info' })
|
|
35
|
+
assert.ok(this.logger.log('INFO', 'another test info'))
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
describe('level', () => {
|
|
41
|
+
it('both INFO and LOGINFO are log levels', () => {
|
|
42
|
+
assert.equal(this.logger.levels.INFO, 6)
|
|
43
|
+
assert.equal(this.logger.levels.LOGINFO, 6)
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
describe('set_format', () => {
|
|
48
|
+
// [input, expected format key]
|
|
49
|
+
const cases = [
|
|
50
|
+
['DEFAULT', 'DEFAULT'],
|
|
51
|
+
['LOGFMT', 'LOGFMT'],
|
|
52
|
+
['JSON', 'JSON'],
|
|
53
|
+
['', 'DEFAULT'], // empty → DEFAULT
|
|
54
|
+
['default', 'DEFAULT'], // case-insensitive → DEFAULT
|
|
55
|
+
['invalid', 'DEFAULT'], // unknown → DEFAULT
|
|
56
|
+
]
|
|
57
|
+
for (const [input, expectedKey] of cases) {
|
|
58
|
+
it(`set_format(${JSON.stringify(input)}) → ${expectedKey}`, () => {
|
|
59
|
+
this.logger.format = ''
|
|
60
|
+
this.logger.set_format(input)
|
|
61
|
+
assert.equal(this.logger.format, this.logger.formats[expectedKey])
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
describe('set_loglevel', () => {
|
|
67
|
+
// [input, expected level key or null for numeric assertion]
|
|
68
|
+
const cases = [
|
|
69
|
+
['LOGINFO', 'LOGINFO'],
|
|
70
|
+
['INFO', 'INFO'],
|
|
71
|
+
['emerg', 'EMERG'], // case-insensitive
|
|
72
|
+
[6, null], // numeric passthrough
|
|
73
|
+
['invalid', 'WARN'], // unknown → WARN
|
|
74
|
+
]
|
|
75
|
+
for (const [input, expectedKey] of cases) {
|
|
76
|
+
it(`set_loglevel(${JSON.stringify(input)}) → ${expectedKey ?? input}`, () => {
|
|
77
|
+
this.logger.set_loglevel(input)
|
|
78
|
+
const expected = expectedKey ? this.logger.levels[expectedKey] : input
|
|
79
|
+
assert.equal(this.logger.loglevel, expected)
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
describe('set_timestamps', () => {
|
|
85
|
+
it('set timestamps to false', () => {
|
|
86
|
+
this.logger.timestamps = undefined
|
|
87
|
+
this.logger.set_timestamps(false)
|
|
88
|
+
assert.equal(this.logger.timestamps, false)
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
it('set timestamps to true', () => {
|
|
92
|
+
this.logger.timestamps = undefined
|
|
93
|
+
this.logger.set_timestamps(true)
|
|
94
|
+
assert.equal(this.logger.timestamps, true)
|
|
95
|
+
})
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
describe('would_log', () => {
|
|
99
|
+
it('should', () => {
|
|
100
|
+
this.logger.loglevel = 4
|
|
101
|
+
assert.equal(false, this.logger.would_log(7))
|
|
102
|
+
assert.equal(false, this.logger.would_log(6))
|
|
103
|
+
assert.equal(false, this.logger.would_log(5))
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
it('should not', () => {
|
|
107
|
+
this.logger.loglevel = 4
|
|
108
|
+
assert.equal(true, this.logger.would_log(4))
|
|
109
|
+
assert.equal(true, this.logger.would_log(3))
|
|
110
|
+
assert.equal(true, this.logger.would_log(2))
|
|
111
|
+
assert.equal(true, this.logger.would_log(1))
|
|
112
|
+
})
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
describe('log_respond', () => {
|
|
116
|
+
it('invalid retval', () => {
|
|
117
|
+
assert.equal(false, this.logger.log_respond(901))
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
it('valid retval', () => {
|
|
121
|
+
const data = { level: 'INFO', data: 'test data' }
|
|
122
|
+
assert.equal(true, this.logger.log_respond(900, 'test msg', data))
|
|
123
|
+
})
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
describe('dump_logs', () => {
|
|
127
|
+
it('empty', () => {
|
|
128
|
+
assert.ok(this.logger.dump_logs(0))
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
it('with deferred', () => {
|
|
132
|
+
this.logger.deferred_logs.push({
|
|
133
|
+
level: 'info',
|
|
134
|
+
data: 'test info',
|
|
135
|
+
})
|
|
136
|
+
this.logger.deferred_logs.push({
|
|
137
|
+
level: 'INFO',
|
|
138
|
+
data: 'test info, color',
|
|
139
|
+
})
|
|
140
|
+
this.logger.deferred_logs.push({
|
|
141
|
+
level: 'WARN',
|
|
142
|
+
data: 'test warn, color',
|
|
143
|
+
})
|
|
144
|
+
assert.ok(this.logger.dump_logs(0))
|
|
145
|
+
assert.ok(this.logger.deferred_logs.length === 0)
|
|
146
|
+
})
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
describe('colors', () => {
|
|
150
|
+
it('colors', () => {
|
|
151
|
+
assert.ok(this.logger.colors)
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
it('colorize', () => {
|
|
155
|
+
assert.ok(this.logger.colorize)
|
|
156
|
+
assert.equal('function', typeof this.logger.colorize)
|
|
157
|
+
assert.equal('error', this.logger.colorize('bad-color', 'error'))
|
|
158
|
+
const expected = util.inspect.colors ? '\u001b[34mgood\u001b[39m' : 'good'
|
|
159
|
+
assert.equal(expected, this.logger.colorize('blue', 'good'))
|
|
160
|
+
})
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
describe('log_if_level', () => {
|
|
164
|
+
it('is a function', () => {
|
|
165
|
+
assert.equal(typeof this.logger.log_if_level, 'function')
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
it('returns a logging function', () => {
|
|
169
|
+
this.logger.loglevel = 9
|
|
170
|
+
const f = this.logger.log_if_level('INFO', 'LOGINFO')
|
|
171
|
+
assert.equal(typeof f, 'function')
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
// Each of these runs independently with a fresh deferred_logs
|
|
175
|
+
for (const [label, msg] of [
|
|
176
|
+
['string', 'test info message'],
|
|
177
|
+
['null', null],
|
|
178
|
+
['false', false],
|
|
179
|
+
['0 (falsy number)', 0],
|
|
180
|
+
]) {
|
|
181
|
+
it(`logs ${label} value and appends to deferred_logs`, () => {
|
|
182
|
+
this.logger.loglevel = 9
|
|
183
|
+
this.logger.deferred_logs = []
|
|
184
|
+
const f = this.logger.log_if_level('INFO', 'LOGINFO')
|
|
185
|
+
assert.ok(f(msg))
|
|
186
|
+
assert.equal(this.logger.deferred_logs.length, 1)
|
|
187
|
+
})
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
it('records correct level in deferred log entry', () => {
|
|
191
|
+
this.logger.loglevel = 9
|
|
192
|
+
this.logger.deferred_logs = []
|
|
193
|
+
const f = this.logger.log_if_level('INFO', 'LOGINFO')
|
|
194
|
+
f('test info message')
|
|
195
|
+
assert.equal(this.logger.deferred_logs[0].level, 'INFO')
|
|
196
|
+
})
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
describe('add_log_methods', () => {
|
|
200
|
+
it('ignores non-objects', () => {
|
|
201
|
+
assert.equal(undefined, this.logger.add_log_methods(''))
|
|
202
|
+
assert.equal(
|
|
203
|
+
undefined,
|
|
204
|
+
this.logger.add_log_methods(function foo() {}),
|
|
205
|
+
)
|
|
206
|
+
})
|
|
207
|
+
|
|
208
|
+
it('adds functions to an object', () => {
|
|
209
|
+
const testObj = {}
|
|
210
|
+
this.logger.add_log_methods(testObj)
|
|
211
|
+
const levels = ['DATA', 'PROTOCOL', 'DEBUG', 'INFO', 'NOTICE', 'WARN', 'ERROR', 'CRIT', 'ALERT', 'EMERG']
|
|
212
|
+
for (const level of levels) {
|
|
213
|
+
assert.ok('function' === typeof testObj[`log${level.toLowerCase()}`])
|
|
214
|
+
}
|
|
215
|
+
})
|
|
216
|
+
})
|
|
217
|
+
})
|
|
File without changes
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
-----BEGIN PRIVATE KEY-----
|
|
2
|
+
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDcg5h5TVO1gECK
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G9jYWwxIDAeBgkqhkiG9w0BCQEWEW1hdHRAaGFyYWthLmxvY2FsMIIBIjANBgkq
|
|
34
|
+
FgAPvcmF6fNpZij8yjZCRE3xlV339JaF1keUkoxl2L46plyuiF6j3Lja4lE5spS8
|
|
35
|
+
dtePTukViT2mdmGMUzh03leTjHhB4y6QDkoQn2YuFWLwHhmUhauVHTL+UA9ZOgbn
|
|
36
|
+
ktUbn+goQi436pDHAgMPAzmPKMb86L4DP7IAXMdy9NP6XkHknoBvtwIDAQABo1Aw
|
|
37
|
+
TjAdBgNVHQ4EFgQUsfam5K8yKVyyJG7NQfKXjpr6gYEwHwYDVR0jBBgwFoAUsfam
|
|
38
|
+
5K8yKVyyJG7NQfKXjpr6gYEwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOC
|
|
39
|
+
AQEAL7vMH/sYj/rDzo+pYn8qK9eZBpTPQLsuiotNYqoH/tOJzaOBI2cMSrbGM3zG
|
|
40
|
+
aegTqKOduO6vpXun7MT4tGilOxt+1eve6RbsjKMeTkZr+A44rRRUZ4LHZe38oaGk
|
|
41
|
+
A8jB6YHiiefH1mgfSN1igcT7SkOxv8WM4jsCyOCy3wG8b4V8wvDytOtJOJo041hX
|
|
42
|
+
njmypWHaZ1IDYu1ybnb/Macnno0NMkEMx0uIlG/c3+KvJwpz2WHrKrKA5l5oGp/n
|
|
43
|
+
+F3pt6NhSJCDG0cktax07LIvxMpAoOaJ6cYSfwB/v0HiYh2733bEXEiQ2jxO5vXo
|
|
44
|
+
NS2fKRYBqs2ATDVHpzknBC1KcA==
|
|
45
|
+
-----END CERTIFICATE-----
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
|
|
2
|
+
key = tls_key.pem
|
|
3
|
+
cert = tls_cert.pem
|
|
4
|
+
dhparam = dhparams.pem
|
|
5
|
+
|
|
6
|
+
ciphers = ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384
|
|
7
|
+
minVersion = TLSv1
|
|
8
|
+
rejectUnauthorized=false
|
|
9
|
+
requestCert=true
|
|
10
|
+
honorCipherOrder=true
|
|
11
|
+
requireAuthorized[]=2465
|
|
12
|
+
requireAuthorized[]=2587
|
|
13
|
+
|
|
14
|
+
no_starttls_ports[]=2525
|
|
15
|
+
|
|
16
|
+
[redis]
|
|
17
|
+
; options in this block require redis to be available.
|
|
18
|
+
|
|
19
|
+
; remember when a remote fails STARTTLS. The next time they connect,
|
|
20
|
+
; don't offer STARTTLS option (so message gets delivered).
|
|
21
|
+
; pro: increases mail reliability
|
|
22
|
+
; con: reduces security
|
|
23
|
+
; default: false
|
|
24
|
+
; disable_for_failed_hosts=true
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
; no_tls_hosts - disable TLS for servers with broken TLS.
|
|
28
|
+
[no_tls_hosts]
|
|
29
|
+
; 127.0.0.1
|
|
30
|
+
; 192.168.1.1
|
|
31
|
+
; 172.16.0.0/16
|
|
32
|
+
|
|
33
|
+
[outbound]
|
|
34
|
+
key = outbound_tls_key.pem
|
|
35
|
+
cert = outbound_tls_cert.pem
|
|
36
|
+
dhparam = dhparams.pem
|
|
37
|
+
ciphers = ECDHE-RSA-AES256-GCM-SHA384
|
|
38
|
+
minVersion = TLSv1
|
|
39
|
+
rejectUnauthorized=false
|
|
40
|
+
requestCert=false
|
|
41
|
+
honorCipherOrder=false
|
|
42
|
+
force_tls_hosts[]=first.example.com
|
|
43
|
+
force_tls_hosts[]=second.example.net
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MIME-Version: 1.0
|
|
2
|
+
Content-Type: text/html;
|
|
3
|
+
Content-Transfer-Encoding: base64
|
|
4
|
+
|
|
5
|
+
PCFET0NUWVBFIGh0bWw+CjxodG1sPgo
|
|
6
|
+
8aGVhZD4KCTx0aXRsZT5UaGlzIGlzIG
|
|
7
|
+
EgdGVzdDwvdGl0bGU+CjwvaGVhZD4KP
|
|
8
|
+
GJvZHk+Cgk8Yj5UaGlzIGlzIG9ubHkg
|
|
9
|
+
YSB0ZXN0PC9iPgoJPHA+CglUaGlzIGR
|
|
10
|
+
vY3VtZW50IGRlc2NyaWJlcyB0aGUgY2
|
|
11
|
+
9tbW9ubHkgdXNlZCBiYXNlIDY0LCBiY
|
|
12
|
+
XNlIDMyLCBhbmQgYmFzZQoJMTYgZW5j
|
|
13
|
+
b2Rpbmcgc2NoZW1lcy4gIEl0IGFsc28
|
|
14
|
+
gZGlzY3Vzc2VzIHRoZSB1c2Ugb2YgbG
|
|
15
|
+
luZS1mZWVkcyBpbgoJZW5jb2RlZCBkY
|
|
16
|
+
XRhLCB1c2Ugb2YgcGFkZGluZyBpbiBl
|
|
17
|
+
bmNvZGVkIGRhdGEsIHVzZSBvZiBub24
|
|
18
|
+
tYWxwaGFiZXQKCWNoYXJhY3RlcnMgaW
|
|
19
|
+
4gZW5jb2RlZCBkYXRhLCB1c2Ugb2YgZ
|
|
20
|
+
GlmZmVyZW50IGVuY29kaW5nIGFscGhh
|
|
21
|
+
YmV0cywgYW5kCgljYW5vbmljYWwgZW5
|
|
22
|
+
jb2RpbmdzLgoJPC9wPgo8L2JvZHk+Cj
|
|
23
|
+
wvaHRtbD4=
|